Andy Polyakov told me that:
>>>>> In my opinion aligning code abuses malloc.
> 
> 
> Hope it's not much trouble, but why not do following?
> 
> struct padlock_aes_key
> {
>     union    {
>         uint32_t align[4];
>         struct    {
>             int rounds:4;
>             int algo:3;
>             int keygen:1;
>             int interm:1;
>             int encdec:1;
>             int ksize:2;
>             } b;
>         } cword;
>     uint8_t  iv[IV_SIZE];
>     AES_KEY  aes_key;
> };
> 
> static const EVP_CIPHER padlock_aes_##ksize##_##lmode = {    \
>     ...                            \
>     sizeof(struct padlock_aes_key)+15,            \
>     ...
> 
> Then every time you want to refer to the structure you do:
> 
>     char *p=ctx->cipher_data;
>     struct padlock_aes_key *aes_key;
>     p += (16 - ((size_t)p)&0x0F)&0x0F;
>     aes_key=(struct padlock_aes_key *)p;

Yeah, I was thinking about something very similar few whiles ago while
reworking the aligner code ;-)

> Also note that I kind of suggest to make byte
> swaping in place. There is no reason to leak the key material on the
> stack. 

OK, I'll take care of this.

I'll send the updated patch later today or tomorrow...

Michal Ludvig
-- 
* A mouse is a device used to point at the xterm you want to type in.
* Personal homepage - http://www.logix.cz/michal
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to