EVP Padding size

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

EVP Padding size

coderl
Hi,

How can I set the EVP padding size to 32byte instead of 16?

I currently have the problem, using aes 256bit, that if I encrypt a 20 or 30 size block it will only encrypt 16bytes instead of the whole part.


Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: EVP Padding size

Jakob Bohm-7
On 11/20/2012 11:38 AM, coderl wrote:
> Hi,
>
> How can I set the EVP padding size to 32byte instead of 16?
>
> I currently have the problem, using aes 256bit, that if I encrypt a 20
> or 30
> size block it will only encrypt 16bytes instead of the whole part.
>
>
That is not what the padding does.

Padding *increases* the encrypted size by 1 to P bytes so it is
a multiple of P bytes total.  A padding of 16 would cause encryption
of 20 or 30 bytes to result in an encrypted value of 32 bytes.

What you need to check is:

- Did you pass the right input data size to the encrypt function?

- Did you use a function that actually does padding?

- Did you use a function that encrypts only onedata block (16 bytes
  for AES 256)?

- Did you use the correct functions but forget the call that said
  that there are no more bytes after your 20 or 30 bytes (until you
  do, the code will hold back the 4 or 14 extra bytes until it knows
  if it should be followed by more data or padding).

Enjoy

Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S. http://www.wisemo.com
Transformervej 29, 2730 Herlev, Denmark. Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded
______________________________________________________________________
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: EVP Padding size

coderl
Yes I passed the correct size into the functions.

For encryption functions I use "EVP_EncryptUpdate" and "EVP_EncryptFinal_ex".
Reply | Threaded
Open this post in threaded view
|

Re: EVP Padding size

coderl
So how do I fix this?
Reply | Threaded
Open this post in threaded view
|

RE: EVP Padding size

J. J. Farrell-2
> From: coderl [mailto:[hidden email]]
> Sent: Wednesday, November 21, 2012 2:34 PM
>
> So how do I fix this?
> --
> View this message in context: http://openssl.6102.n7.nabble.com/EVP-
> Padding-size-tp42413p42447.html

You change whatever you're doing wrong and do it right instead.

As always, if you were to present the minimal subset of your code showing exactly what you are doing someone might be able to help you find what you are doing wrong - or perhaps even to nail a bug in OpenSSL and advise on a fix or workaround.

You'd likely benefit from absorbing http://www.catb.org/~esr/faqs/smart-questions.html

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