Problem with AES_cbc_encrypt

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with AES_cbc_encrypt

Bhupendra K Joshi
Hello,
 
Can anyone help me with finding the length of encrypted and decrypted data via AES_cbc_encrypt? or else send me some test programs which have used AES_cbc_encrypt.
 
Bhupendra


Sell on Yahoo! Auctions - No fees. Bid on great items.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with AES_cbc_encrypt

Bhupendra K Joshi
Hi,
 
I am a novice user of OpenSSL using openssl 0.9.7.
 
The problem is when I give say 10 bytes of data to AES_cbc_encrypt(with AES_ENCRYPT), I get 16 bytes of encrypted data and when I pass the same 16 bytes of encrypted data to AES_cbc_encrypt(with AES_DECRYPT) I get 16 bytes of decrypted data.
 
How can I determine the actual data decryption length.
 
Please Help

Bhupendra K Joshi <[hidden email]> wrote:
Hello,
 
Can anyone help me with finding the length of encrypted and decrypted data via AES_cbc_encrypt? or else send me some test programs which have used AES_cbc_encrypt.
 
Bhupendra


Sell on Yahoo! Auctions - No fees. Bid on great items.


Sell on Yahoo! Auctions - No fees. Bid on great items.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with AES_cbc_encrypt

Richard Levitte - VMS Whacker
Bhupendra K Joshi writes:

> The problem is when I give say 10 bytes of data to AES_cbc_encrypt(with AES_ENCRYPT), I get 16 bytes of encrypted data and when I pass the same 16 bytes of encrypted data to AES_cbc_encrypt(with AES_DECRYPT) I get 16 bytes of decrypted data.
>  
> How can I determine the actual data decryption length.

You have to encode the length into the data you encrypt, and after
decryption, you have to use that encoded length to determine the length of
the decrypted plain text.

It might be easier for you to use the EVP API.  It will add som padding
which also contains length information, so you will get decryped plain text
with the length you expect.

Cheers,
Richard

 -----
Please consider sponsoring my work on free software.
See http://www.free.lp.se/sponsoring.html for details.

--
Richard Levitte                         [hidden email]
                                       http://richard.levitte.org/ 

"When I became a man I put away childish things, including
the fear of childishness and the desire to be very grown up."
                                               -- C.S. Lewis

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Problem with AES_cbc_encrypt

Bhupendra K Joshi
Thank You Richard

What I was thinking was to append the length at the start to the plain text and then send it for encryption and while after decryption read the length and only send that much data.



Richard Levitte <[hidden email]> wrote:
Bhupendra K Joshi writes:

> The problem is when I give say 10 bytes of data to AES_cbc_encrypt(with AES_ENCRYPT), I get 16 bytes of encrypted data and when I pass the same 16 bytes of encrypted data to AES_cbc_encrypt(with AES_DECRYPT) I get 16 bytes of decrypted data.
>
> How can I determine the actual data decryption length.

You have to encode the length into the data you encrypt, and after
decryption, you have to use that encoded length to determine the length of
the decrypted plain text.

It might be easier for you to use the EVP API. It will add som padding
which also contains length information, so you will get decryped plain text
with the length you expect.

Cheers,
Richard

-----
Please consider sponsoring my work on free software.
See http://www.free.lp.se/sponsoring.html for details.
--
Richard Levitte [hidden email]
http://richard.levitte.org/

"When I became a man I put away childish things, including
the fear of childishness and the desire to be very grown up."
-- C.S. Lewis

______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [hidden email]
Automated List Manager [hidden email]


Discover Yahoo!
Use Yahoo! to plan a weekend, have fun online & more. Check it out!