On Fri, Jan 8, 2021 at 8:05 PM Jeffrey Walton <noloa...@gmail.com> wrote: > > On Fri, Jan 8, 2021 at 10:44 AM Xamix <gmax...@gmail.com> wrote: > > > > I'm using the library with the templated AES CTR decryptor: > > > > CryptoPP::CTR_Mode<CryptoPP::AES>::Decryption decryptor_ctr_; > > > > I decrypt input data which is previouslly encoded data blocks by using the > > following function: > > > > decryptor_ecb_.ProcessData(output, input, input_len); > > > > Now I want to get get the IV value after encoding, in order to save it. > > I haven't found any function to retrieve the current IV value which is > > normally incremented by 1 after each block encoding. > > I can compute it myself but the decryptor should have the value currently > > after encoding. > > > > Is there a solution to get back the current IV value after encoding? > > No, there is no function to retrieve the IV. > > There is a function to retrieve the next IV, which only generates a > random block with size of IVsize().
By the way, for CTR mode, it is pretty easy to calculate the next IV. Something like: // AES block size byte iv[AES::BLOCKSIZE] = ...; // i-th block size_t i = ...; for (size_t b=0; b < i; ++i) IncrementCounterByOne(iv, 1); // The mask is AES_enc(iv) byte mask[16]; AES::Encryption enc(key, key.size()); enc.ProcessBlock(mask, iv); Then XOR mask with the plaintext or ciphertext. AES::Encryption is used for both the forward and reverse directions. Jeff -- You received this message because you are subscribed to "Crypto++ Users". More information about Crypto++ and this group is available at http://www.cryptopp.com and http://groups.google.com/forum/#!forum/cryptopp-users. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8%3D24_Bfyb54yUW2nOrCN7g7rHizDwjWdCdzTw7aqXhfjA%40mail.gmail.com.