[FFmpeg-devel] [RFC] AES init

Måns Rullgård mans
Sun May 13 17:55:34 CEST 2007


Alex Beregszaszi <alex at rtfs.hu> writes:

> Hi,
>
> Current AES tables init looks as follows:
>
> if(!enc_multbl[4][1023]){
>
> While the tables are defined as:
>
> #ifdef CONFIG_SMALL
> static uint32_t enc_multbl[1][256];
> static uint32_t dec_multbl[1][256];
> #else
> static uint32_t enc_multbl[4][256];
> static uint32_t dec_multbl[4][256];
> #endif
>
> That means [4][1023] is pointing to an invalid area in both case.
>
> For my case, this caused AES to malfunction, the AES struct was not
> inited (only the key's were there). This happened to me in GCC 4.0.3.
>
> My change is as follows, introducing a bad static variable. Other
> solution would be checking for enc_multbl[0][0] ? But than again, this
> probably breaks with compilers not zeroing those variables (like VisualC
> which sets them to 0xCC). I know some will shout that "broken compilers
> are not supported".

The C standard *requires* data without an explicit initialiser to be
initialised to zero.  A lot of code depends on this happening, so I
somehow doubt that even microsoft would be able to get away with
anything else.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list