You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
checkasm: add tests for AES
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
committed by
James Almer
parent
a35b4e8d29
commit
779cbc2b97
@ -70,6 +70,7 @@ SWSCALEOBJS += sw_gbrp.o sw_range_convert.o sw_rgb.o
|
|||||||
CHECKASMOBJS-$(CONFIG_SWSCALE) += $(SWSCALEOBJS)
|
CHECKASMOBJS-$(CONFIG_SWSCALE) += $(SWSCALEOBJS)
|
||||||
|
|
||||||
# libavutil tests
|
# libavutil tests
|
||||||
|
AVUTILOBJS += aes.o
|
||||||
AVUTILOBJS += av_tx.o
|
AVUTILOBJS += av_tx.o
|
||||||
AVUTILOBJS += fixed_dsp.o
|
AVUTILOBJS += fixed_dsp.o
|
||||||
AVUTILOBJS += float_dsp.o
|
AVUTILOBJS += float_dsp.o
|
||||||
|
64
tests/checkasm/aes.c
Normal file
64
tests/checkasm/aes.c
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 Rodger Combs <rodger.combs@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");
|
||||||
|
}
|
||||||
|
}
|
@ -296,6 +296,7 @@ static const struct {
|
|||||||
{ "sw_yuv2yuv", checkasm_check_sw_yuv2yuv },
|
{ "sw_yuv2yuv", checkasm_check_sw_yuv2yuv },
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_AVUTIL
|
#if CONFIG_AVUTIL
|
||||||
|
{ "aes", checkasm_check_aes },
|
||||||
{ "fixed_dsp", checkasm_check_fixed_dsp },
|
{ "fixed_dsp", checkasm_check_fixed_dsp },
|
||||||
{ "float_dsp", checkasm_check_float_dsp },
|
{ "float_dsp", checkasm_check_float_dsp },
|
||||||
{ "lls", checkasm_check_lls },
|
{ "lls", checkasm_check_lls },
|
||||||
|
@ -80,6 +80,7 @@ typedef sigjmp_buf checkasm_context;
|
|||||||
void checkasm_check_aacencdsp(void);
|
void checkasm_check_aacencdsp(void);
|
||||||
void checkasm_check_aacpsdsp(void);
|
void checkasm_check_aacpsdsp(void);
|
||||||
void checkasm_check_ac3dsp(void);
|
void checkasm_check_ac3dsp(void);
|
||||||
|
void checkasm_check_aes(void);
|
||||||
void checkasm_check_afir(void);
|
void checkasm_check_afir(void);
|
||||||
void checkasm_check_alacdsp(void);
|
void checkasm_check_alacdsp(void);
|
||||||
void checkasm_check_audiodsp(void);
|
void checkasm_check_audiodsp(void);
|
||||||
|
Reference in New Issue
Block a user