mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 02:37:28 +02:00
add aesofb benchmark
This commit is contained in:
committed by
Eric Blankenhorn
parent
df0d5f3b08
commit
ab49120652
@ -223,6 +223,7 @@
|
||||
#define BENCH_DES 0x00004000
|
||||
#define BENCH_IDEA 0x00008000
|
||||
#define BENCH_AES_CFB 0x00010000
|
||||
#define BENCH_AES_OFB 0x00020000
|
||||
/* Digest algorithms. */
|
||||
#define BENCH_MD5 0x00000001
|
||||
#define BENCH_POLY1305 0x00000002
|
||||
@ -320,6 +321,9 @@ static const bench_alg bench_cipher_opt[] = {
|
||||
#ifdef WOLFSSL_AES_CFB
|
||||
{ "-aes-cfb", BENCH_AES_CFB },
|
||||
#endif
|
||||
#ifdef WOLFSSL_AES_OFB
|
||||
{ "-aes-ofb", BENCH_AES_OFB },
|
||||
#endif
|
||||
#ifdef WOLFSSL_AES_COUNTER
|
||||
{ "-aes-ctr", BENCH_AES_CTR },
|
||||
#endif
|
||||
@ -1443,6 +1447,10 @@ static void* benchmarks_do(void* args)
|
||||
if (bench_all || (bench_cipher_algs & BENCH_AES_CFB))
|
||||
bench_aescfb();
|
||||
#endif
|
||||
#ifdef WOLFSSL_AES_OFB
|
||||
if (bench_all || (bench_cipher_algs & BENCH_AES_OFB))
|
||||
bench_aesofb();
|
||||
#endif
|
||||
#ifdef WOLFSSL_AES_COUNTER
|
||||
if (bench_all || (bench_cipher_algs & BENCH_AES_CTR))
|
||||
bench_aesctr();
|
||||
@ -2457,6 +2465,49 @@ void bench_aescfb(void)
|
||||
#endif /* WOLFSSL_AES_CFB */
|
||||
|
||||
|
||||
#ifdef WOLFSSL_AES_OFB
|
||||
static void bench_aesofb_internal(const byte* key, word32 keySz, const byte* iv,
|
||||
const char* label)
|
||||
{
|
||||
Aes enc;
|
||||
double start;
|
||||
int i, ret, count;
|
||||
|
||||
ret = wc_AesSetKey(&enc, key, keySz, iv, AES_ENCRYPTION);
|
||||
if (ret != 0) {
|
||||
printf("AesSetKey failed, ret = %d\n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
bench_stats_start(&count, &start);
|
||||
do {
|
||||
for (i = 0; i < numBlocks; i++) {
|
||||
if((ret = wc_AesOfbEncrypt(&enc, bench_plain, bench_cipher,
|
||||
BENCH_SIZE)) != 0) {
|
||||
printf("wc_AesCfbEncrypt failed, ret = %d\n", ret);
|
||||
return;
|
||||
}
|
||||
}
|
||||
count += i;
|
||||
} while (bench_stats_sym_check(start));
|
||||
bench_stats_sym_finish(label, 0, count, bench_size, start, ret);
|
||||
}
|
||||
|
||||
void bench_aesofb(void)
|
||||
{
|
||||
#ifdef WOLFSSL_AES_128
|
||||
bench_aesofb_internal(bench_key, 16, bench_iv, "AES-128-OFB");
|
||||
#endif
|
||||
#ifdef WOLFSSL_AES_192
|
||||
bench_aesofb_internal(bench_key, 24, bench_iv, "AES-192-OFB");
|
||||
#endif
|
||||
#ifdef WOLFSSL_AES_256
|
||||
bench_aesofb_internal(bench_key, 32, bench_iv, "AES-256-OFB");
|
||||
#endif
|
||||
}
|
||||
#endif /* WOLFSSL_AES_CFB */
|
||||
|
||||
|
||||
#ifdef WOLFSSL_AES_XTS
|
||||
void bench_aesxts(void)
|
||||
{
|
||||
|
@ -54,6 +54,7 @@ void bench_aesecb(int);
|
||||
void bench_aesxts(void);
|
||||
void bench_aesctr(void);
|
||||
void bench_aescfb(void);
|
||||
void bench_aesofb(void);
|
||||
void bench_poly1305(void);
|
||||
void bench_camellia(void);
|
||||
void bench_md5(int);
|
||||
|
Reference in New Issue
Block a user