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

Henrik Gramner henrik at gramner.com
Tue Oct 13 23:06:59 CEST 2015


Added some randomization to count and made report() less verbose:

diff --git a/tests/checkasm/aes.c b/tests/checkasm/aes.c
index 67b6666..4549a3d 100644
--- a/tests/checkasm/aes.c
+++ b/tests/checkasm/aes.c
@@ -23,12 +23,14 @@
 #include "libavutil/aes_internal.h"
 #include "libavutil/internal.h"

+#define MAX_COUNT 16
+
 void checkasm_check_aes(void)
 {
     int i, j, d;
     AVAES b;
-    uint8_t pt[32];
-    uint8_t temp[2][32];
+    uint8_t pt[MAX_COUNT*16];
+    uint8_t temp[2][MAX_COUNT*16];
     uint8_t iv[2][16];

     for (d = 0; d <= 1; d++) {
@@ -37,21 +39,22 @@ void checkasm_check_aes(void)
             if (check_func(b.crypt, "aes_%scrypt_%i", d ? "de" : "en", i)) {
                 declare_func(void, AVAES *a, uint8_t *dst, const uint8_t *src,
                              int count, uint8_t *iv, int rounds);
-                for (j = 0; j < 32; j++)
+                int count = (rnd() & (MAX_COUNT-1)) + 1;
+                for (j = 0; j < 16*MAX_COUNT; j++)
                     pt[j] = rnd();
                 for (j = 0; j < 16; j++)
                     iv[0][j] = iv[1][j] = rnd();
-                call_ref(&b, temp[0], pt, 2, iv[0], b.rounds);
-                call_new(&b, temp[1], pt, 2, iv[1], b.rounds);
-                if (memcmp(temp[0], temp[1], sizeof(temp[0])))
+                call_ref(&b, temp[0], pt, count, iv[0], b.rounds);
+                call_new(&b, temp[1], pt, count, iv[1], b.rounds);
+                if (memcmp(temp[0], temp[1], 16*count))
                     fail();
-                call_ref(&b, temp[0], pt, 2, NULL, b.rounds);
-                call_new(&b, temp[1], pt, 2, NULL, b.rounds);
-                if (memcmp(temp[0], temp[1], sizeof(temp[0])))
+                call_ref(&b, temp[0], pt, count, NULL, b.rounds);
+                call_new(&b, temp[1], pt, count, NULL, b.rounds);
+                if (memcmp(temp[0], temp[1], 16*count))
                     fail();
-                bench_new(&b, temp[1], pt, 1, NULL, b.rounds);
+                bench_new(&b, temp[1], pt, MAX_COUNT, NULL, b.rounds);
             }
-            report("%scrypt_%i", d ? "de" : "en", i);
         }
     }
+    report("crypt");


More information about the ffmpeg-devel mailing list