ffmpeg | branch: master | Rodger Combs <rodger.co...@gmail.com> | Wed Oct 28 05:39:34 2015 -0500| [779cbc2b97015a0e0e70aa222c50b27959c4c372] | committer: James Almer
checkasm: add tests for AES Signed-off-by: James Almer <jamr...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=779cbc2b97015a0e0e70aa222c50b27959c4c372 --- tests/checkasm/Makefile | 1 + tests/checkasm/aes.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++ tests/checkasm/checkasm.c | 1 + tests/checkasm/checkasm.h | 1 + 4 files changed, 67 insertions(+) diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index c7268d836e..d5c50e5599 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -70,6 +70,7 @@ SWSCALEOBJS += sw_gbrp.o sw_range_convert.o sw_rgb.o CHECKASMOBJS-$(CONFIG_SWSCALE) += $(SWSCALEOBJS) # libavutil tests +AVUTILOBJS += aes.o AVUTILOBJS += av_tx.o AVUTILOBJS += fixed_dsp.o AVUTILOBJS += float_dsp.o diff --git a/tests/checkasm/aes.c b/tests/checkasm/aes.c new file mode 100644 index 0000000000..c5502118fa --- /dev/null +++ b/tests/checkasm/aes.c @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015 Rodger Combs <rodger.co...@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" + +#define MAX_COUNT 16 + +void checkasm_check_aes(void) +{ + int i, j, d; + AVAES b; + uint8_t pt[MAX_COUNT * 16]; + uint8_t temp[2][MAX_COUNT * 16]; + 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); + 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, count, iv[0], b.rounds); + call_new(&b, temp[1], pt, count, iv[1], b.rounds); + if (memcmp(temp[0], temp[1], sizeof(16 * count))) + fail(); + if (memcmp(iv[0], iv[1], sizeof(iv[0]))) + fail(); + 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], sizeof(16 * count))) + fail(); + if (memcmp(iv[0], iv[1], sizeof(iv[0]))) + fail(); + bench_new(&b, temp[1], pt, MAX_COUNT, NULL, b.rounds); + } + } + report("%scrypt", d ? "de" : "en"); + } +} diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 1cfc4feb48..412b8b2cd1 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -296,6 +296,7 @@ static const struct { { "sw_yuv2yuv", checkasm_check_sw_yuv2yuv }, #endif #if CONFIG_AVUTIL + { "aes", checkasm_check_aes }, { "fixed_dsp", checkasm_check_fixed_dsp }, { "float_dsp", checkasm_check_float_dsp }, { "lls", checkasm_check_lls }, diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 67b7df42d2..ad239fb2a4 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -80,6 +80,7 @@ typedef sigjmp_buf checkasm_context; void checkasm_check_aacencdsp(void); void checkasm_check_aacpsdsp(void); void checkasm_check_ac3dsp(void); +void checkasm_check_aes(void); void checkasm_check_afir(void); void checkasm_check_alacdsp(void); void checkasm_check_audiodsp(void); _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".