[FFmpeg-devel] [PATCH 07/10] checkasm: add tests for AES
Rodger Combs
rodger.combs at gmail.com
Tue Oct 13 02:33:30 CEST 2015
---
tests/checkasm/Makefile | 2 +-
tests/checkasm/aes.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++
tests/checkasm/checkasm.c | 1 +
tests/checkasm/checkasm.h | 1 +
4 files changed, 60 insertions(+), 1 deletion(-)
create mode 100644 tests/checkasm/aes.c
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index c29ceef..5529e98 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -13,7 +13,7 @@ CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes)
-include $(SRC_PATH)/tests/checkasm/$(ARCH)/Makefile
-CHECKASMOBJS += $(CHECKASMOBJS-yes) checkasm.o
+CHECKASMOBJS += $(CHECKASMOBJS-yes) aes.o checkasm.o
CHECKASMOBJS := $(sort $(CHECKASMOBJS:%=tests/checkasm/%))
-include $(CHECKASMOBJS:.o=.d)
diff --git a/tests/checkasm/aes.c b/tests/checkasm/aes.c
new file mode 100644
index 0000000..67b6666
--- /dev/null
+++ b/tests/checkasm/aes.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2015 Rodger Combs <rodger.combs at gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "checkasm.h"
+#include "libavutil/aes.h"
+#include "libavutil/aes_internal.h"
+#include "libavutil/internal.h"
+
+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)) {
+ 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++)
+ 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])))
+ 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])))
+ fail();
+ bench_new(&b, temp[1], pt, 1, NULL, b.rounds);
+ }
+ report("%scrypt_%i", d ? "de" : "en", i);
+ }
+ }
+}
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index e875120..f5b28dc 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -57,6 +57,7 @@ static const struct {
const char *name;
void (*func)(void);
} tests[] = {
+ { "aes", checkasm_check_aes },
#if CONFIG_AVCODEC
#if CONFIG_ALAC_DECODER
{ "alacdsp", checkasm_check_alacdsp },
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 1775a25..3b39e16 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -29,6 +29,7 @@
#include "libavutil/lfg.h"
#include "libavutil/timer.h"
+void checkasm_check_aes(void);
void checkasm_check_alacdsp(void);
void checkasm_check_bswapdsp(void);
void checkasm_check_flacdsp(void);
--
2.6.1
More information about the ffmpeg-devel
mailing list