Thank you for your answer,

For the moment I will do something like the following:

*// Create vector to store result*
*std::vector<CryptoPP::byte> decoded(data_len);*

*// Set counter before decoding*

*decryptor_.Resynchronize(counter, 16);// Decrypt data*
*decryptor_.ProcessData(decoded.data(), data, data_len);*

*// For the moment we compute ourself the value of IV after decrypting*
*// But maybe we could optimize by retrieving it from decryptor object?*
*for(std::size_t i = 0; i < data_len / 16; ++i)*
*{*
*    for(int j = 15; j >= 0; --j)*
*    {*
*        if (++counter[j] != 0)*
*            break;*
*    }*
*}*

Note that *data_len* is a multiple of block size (i.e 16).

Do you think it is possible to me to patch your library to get back the 
current IV in order to optimize the code a bit?
I haven't take a look in the underling code, but is the current IV 
available in private member at one moment?
Or maybe it is not available because you are using some Hardware function 
which do not return the IV?

Regards

Le samedi 9 janvier 2021 à 02:14:52 UTC+1, Jeffrey Walton a écrit :

> On Fri, Jan 8, 2021 at 8:05 PM Jeffrey Walton <nolo...@gmail.com> wrote:
> >
> > On Fri, Jan 8, 2021 at 10:44 AM Xamix <gma...@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/74d359df-42b0-4861-883e-7d72c480bb7dn%40googlegroups.com.

Reply via email to