[FFmpeg-devel] [PATCH 2/2] checkasm: add tests for AES

Henrik Gramner henrik at gramner.com
Mon Oct 12 20:59:44 CEST 2015


On Mon, Oct 12, 2015 at 9:54 AM, Rodger Combs <rodger.combs at gmail.com> wrote:
> +void checkasm_check_aes(void)
> +{
> +    int i, j, d;
> +    AVAES b;
> +    uint8_t pt[32];
> +    uint8_t temp[2][32];
> +    uint8_t iv[2][16];
> +
> +    for (d = 0; d <= 1; d++) {
> +        for (i = 128; i <= 256; i += 64) {
> +            av_aes_init(&b, (const uint8_t*)"PI=3.1415926535897932384626433..", i, d);
> +            if (check_func(b.crypt, "aes_%scrypt_%i", d ? "de" : "en", i)) {

This will only run for i == 128. check_func() only returns non-NULL
once for each unique pointer.

> +                declare_func(void, AVAES *a, uint8_t *dst, const uint8_t *src,
> +                               int count, uint8_t *iv, int rounds);

Weird indentation in the last row.

> +                for (j = 0; j < 32; j++)
> +                    pt[j] = rnd() & 0xFF;
> +                for (j = 0; j < 16; j++)
> +                    iv[0][j] = iv[1][j] = rnd() & 0xFF;

& 0xFF isn't nesseccary since those arrays are uint8_t anyway.

> +                call_ref(&b, temp[0], pt, 2, iv[0], b.rounds);
> +                call_new(&b, temp[1], pt, 2, iv[1], b.rounds);
> +                for (j = 0; j < 32; j++) {
> +                    if (temp[0][j] != temp[1][j]) {
> +                        fail();

memcmp()


More information about the ffmpeg-devel mailing list