mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
ascon-aead: add benchmarking
This commit is contained in:
@@ -674,6 +674,7 @@
|
|||||||
#define BENCH_BLAKE2S 0x00010000
|
#define BENCH_BLAKE2S 0x00010000
|
||||||
#define BENCH_SM3 0x00020000
|
#define BENCH_SM3 0x00020000
|
||||||
#define BENCH_ASCON_HASH256 0x00040000
|
#define BENCH_ASCON_HASH256 0x00040000
|
||||||
|
#define BENCH_ASCON_AEAD128 0x00080000
|
||||||
|
|
||||||
/* MAC algorithms. */
|
/* MAC algorithms. */
|
||||||
#define BENCH_CMAC 0x00000001
|
#define BENCH_CMAC 0x00000001
|
||||||
@@ -887,6 +888,9 @@ static const bench_alg bench_cipher_opt[] = {
|
|||||||
#endif
|
#endif
|
||||||
#ifndef NO_DES3
|
#ifndef NO_DES3
|
||||||
{ "-des", BENCH_DES },
|
{ "-des", BENCH_DES },
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_ASCON
|
||||||
|
{ "-ascon-aead", BENCH_ASCON_AEAD128 },
|
||||||
#endif
|
#endif
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
@@ -3350,6 +3354,10 @@ static void* benchmarks_do(void* args)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_ASCON
|
||||||
|
if (bench_all || (bench_cipher_algs & BENCH_ASCON_AEAD128))
|
||||||
|
bench_ascon_aead();
|
||||||
|
#endif
|
||||||
#ifndef NO_MD5
|
#ifndef NO_MD5
|
||||||
if (bench_all || (bench_digest_algs & BENCH_MD5)) {
|
if (bench_all || (bench_digest_algs & BENCH_MD5)) {
|
||||||
#ifndef NO_SW_BENCH
|
#ifndef NO_SW_BENCH
|
||||||
@@ -6115,6 +6123,67 @@ exit:
|
|||||||
}
|
}
|
||||||
#endif /* HAVE_CHACHA && HAVE_POLY1305 */
|
#endif /* HAVE_CHACHA && HAVE_POLY1305 */
|
||||||
|
|
||||||
|
#ifdef HAVE_ASCON
|
||||||
|
|
||||||
|
void bench_ascon_aead(void)
|
||||||
|
{
|
||||||
|
#define ASCON_AD (byte*)"ADADADADAD"
|
||||||
|
#define ASCON_AD_SZ XSTR_SIZEOF(ASCON_AD)
|
||||||
|
double start;
|
||||||
|
int ret = 0, i, count;
|
||||||
|
WC_DECLARE_VAR(authTag, byte, ASCON_AEAD128_TAG_SZ, HEAP_HINT);
|
||||||
|
WC_DECLARE_VAR(enc, wc_AsconAEAD128, 1, HEAP_HINT);
|
||||||
|
DECLARE_MULTI_VALUE_STATS_VARS()
|
||||||
|
|
||||||
|
WC_ALLOC_VAR(authTag, byte, ASCON_AEAD128_TAG_SZ, HEAP_HINT);
|
||||||
|
XMEMSET(authTag, 0, ASCON_AEAD128_TAG_SZ);
|
||||||
|
|
||||||
|
WC_ALLOC_VAR(enc, wc_AsconAEAD128, 1, HEAP_HINT);
|
||||||
|
XMEMSET(enc, 0, sizeof(wc_AsconAEAD128));
|
||||||
|
|
||||||
|
bench_stats_start(&count, &start);
|
||||||
|
do {
|
||||||
|
for (i = 0; i < numBlocks; i++) {
|
||||||
|
ret = wc_AsconAEAD128_Init(enc);
|
||||||
|
if (ret == 0)
|
||||||
|
ret = wc_AsconAEAD128_SetKey(enc, bench_key);
|
||||||
|
if (ret == 0)
|
||||||
|
ret = wc_AsconAEAD128_SetNonce(enc, bench_iv);
|
||||||
|
if (ret == 0)
|
||||||
|
ret = wc_AsconAEAD128_SetAD(enc, ASCON_AD, ASCON_AD_SZ);
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = wc_AsconAEAD128_EncryptUpdate(enc, bench_cipher,
|
||||||
|
bench_plain, bench_size);
|
||||||
|
}
|
||||||
|
if (ret == 0)
|
||||||
|
ret = wc_AsconAEAD128_EncryptFinal(enc, authTag);
|
||||||
|
wc_AsconAEAD128_Deinit(enc);
|
||||||
|
|
||||||
|
if (ret != 0) {
|
||||||
|
printf("ASCON-AEAD error: %d\n", ret);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
RECORD_MULTI_VALUE_STATS();
|
||||||
|
}
|
||||||
|
count += i;
|
||||||
|
} while (bench_stats_check(start)
|
||||||
|
#ifdef MULTI_VALUE_STATISTICS
|
||||||
|
|| runs < minimum_runs
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
bench_stats_sym_finish("ASCON-AEAD", 0, count, bench_size, start, ret);
|
||||||
|
#ifdef MULTI_VALUE_STATISTICS
|
||||||
|
bench_multi_value_stats(max, min, sum, squareSum, runs);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
exit:
|
||||||
|
|
||||||
|
WC_FREE_VAR(authTag, HEAP_HINT);
|
||||||
|
WC_FREE_VAR(enc, HEAP_HINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_ASCON */
|
||||||
|
|
||||||
#ifndef NO_MD5
|
#ifndef NO_MD5
|
||||||
void bench_md5(int useDeviceID)
|
void bench_md5(int useDeviceID)
|
||||||
|
@@ -64,6 +64,7 @@ void bench_camellia(void);
|
|||||||
void bench_sm4_cbc(void);
|
void bench_sm4_cbc(void);
|
||||||
void bench_sm4_gcm(void);
|
void bench_sm4_gcm(void);
|
||||||
void bench_sm4_ccm(void);
|
void bench_sm4_ccm(void);
|
||||||
|
void bench_ascon_aead(void);
|
||||||
void bench_md5(int useDeviceID);
|
void bench_md5(int useDeviceID);
|
||||||
void bench_sha(int useDeviceID);
|
void bench_sha(int useDeviceID);
|
||||||
void bench_sha224(int useDeviceID);
|
void bench_sha224(int useDeviceID);
|
||||||
|
Reference in New Issue
Block a user