AES-CBC: IV vector update

View: New views
2 Messages — Rating Filter:   Alert me  

AES-CBC: IV vector update

by Paul Subramanian :: Rate this Message:

| View Threaded | Show Only this Message

Hi,
I am new to cryptography and I inherited the code from someone else.
We are doing AES-CBC encryption in pieces and after each piece I was
told that IV vector needs to change.

Initially the code was
e_CBC.SetKeyWithIV( m_crypto_encryption_packet_h.encr_key, key_size /
8, m_crypto_encryption_packet_h.encr_cntr_iv );

 
StringSource( m_crypto_encryption_packet_h.encr_data_in,
crypto_encr_seg_size, true, new StreamTransformationFilter( e_CBC, new
ArraySink( m_crypto_encryption_packet_h.encr_data_out,
crypto_encr_seg_size), StreamTransformationFilter::NO_PADDING));

I tried to the add  the following lines for IV vector update
e_CBC.GetNextIV(NullRNG(), m_crypto_encryption_packet_h.encr_cntr_iv);
This doesn't change the IV vector

e_CBC.GetNextIV(RandomPool(),
m_crypto_encryption_packet_h.encr_cntr_iv);
This changes the vector but the encryption output is not what I expect

Can someone provide me a sample code on what I should be doing.

Thanks a lot
Paul

--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.

Re: AES-CBC: IV vector update

by Jeffrey Walton-3 :: Rate this Message:

| View Threaded | Show Only this Message



On Jun 1, 1:52 am, Paul Subramanian <spalan...@...> wrote:

> Hi,
> I am new to cryptography and I inherited the code from someone else.
> We are doing AES-CBC encryption in pieces and after each piece I was
> told that IV vector needs to change.
>
> Initially the code was
> e_CBC.SetKeyWithIV( m_crypto_encryption_packet_h.encr_key, key_size /
> 8, m_crypto_encryption_packet_h.encr_cntr_iv );
>
> StringSource( m_crypto_encryption_packet_h.encr_data_in,
> crypto_encr_seg_size, true, new StreamTransformationFilter( e_CBC, new
> ArraySink( m_crypto_encryption_packet_h.encr_data_out,
> crypto_encr_seg_size), StreamTransformationFilter::NO_PADDING));
>
> I tried to the add  the following lines for IV vector update
> e_CBC.GetNextIV(NullRNG(), m_crypto_encryption_packet_h.encr_cntr_iv);
> This doesn't change the IV vector
>
> e_CBC.GetNextIV(RandomPool(),
> m_crypto_encryption_packet_h.encr_cntr_iv);
> This changes the vector but the encryption output is not what I expect
>
> Can someone provide me a sample code on what I should be doing.
The library handles IV updates internally. There is no need to do it
yourself. See http://www.cryptopp.com/wiki/Cbc for a couple of
examples.

To see how to put in a few bytes at a time (and extract bytes in block
size chunks), see the paragraph that starts with "To manually insert
bytes into the filter...". Be sure to call MessageEnd() so the
encryptor will add padding and finish encrypting the data.

Jeff

--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.