From 022b9a1ca0bc14a29c10a423962f03e209a78298 Mon Sep 17 00:00:00 2001 From: Yanray Wang Date: Tue, 12 Sep 2023 09:45:37 +0800 Subject: [PATCH] benchmark: add AES_CFB8 Signed-off-by: Yanray Wang --- programs/test/benchmark.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c index 1a8baee9a..06b739a7f 100644 --- a/programs/test/benchmark.c +++ b/programs/test/benchmark.c @@ -113,13 +113,13 @@ static void mbedtls_set_alarm(int seconds); #define HEADER_FORMAT " %-24s : " #define TITLE_LEN 25 -#define OPTIONS \ - "md5, ripemd160, sha1, sha256, sha512,\n" \ - "sha3_224, sha3_256, sha3_384, sha3_512,\n" \ - "des3, des, camellia, chacha20,\n" \ - "aes_cbc, aes_cfb128, aes_gcm, aes_ccm, aes_xts, chachapoly,\n" \ - "aes_cmac, des3_cmac, poly1305\n" \ - "ctr_drbg, hmac_drbg\n" \ +#define OPTIONS \ + "md5, ripemd160, sha1, sha256, sha512,\n" \ + "sha3_224, sha3_256, sha3_384, sha3_512,\n" \ + "des3, des, camellia, chacha20,\n" \ + "aes_cbc, aes_cfb128, aes_cfb8, aes_gcm, aes_ccm, aes_xts, chachapoly\n" \ + "aes_cmac, des3_cmac, poly1305\n" \ + "ctr_drbg, hmac_drbg\n" \ "rsa, dhm, ecdsa, ecdh.\n" #if defined(MBEDTLS_ERROR_C) @@ -510,7 +510,7 @@ typedef struct { char md5, ripemd160, sha1, sha256, sha512, sha3_224, sha3_256, sha3_384, sha3_512, des3, des, - aes_cbc, aes_cfb128, aes_gcm, aes_ccm, aes_xts, chachapoly, + aes_cbc, aes_cfb128, aes_cfb8, aes_gcm, aes_ccm, aes_xts, chachapoly, aes_cmac, des3_cmac, aria, camellia, chacha20, poly1305, @@ -572,6 +572,8 @@ int main(int argc, char *argv[]) todo.aes_cbc = 1; } else if (strcmp(argv[i], "aes_cfb128") == 0) { todo.aes_cfb128 = 1; + } else if (strcmp(argv[i], "aes_cfb8") == 0) { + todo.aes_cfb8 = 1; } else if (strcmp(argv[i], "aes_xts") == 0) { todo.aes_xts = 1; } else if (strcmp(argv[i], "aes_gcm") == 0) { @@ -753,6 +755,22 @@ int main(int argc, char *argv[]) } mbedtls_aes_free(&aes); } + if (todo.aes_cfb8) { + int keysize; + mbedtls_aes_context aes; + mbedtls_aes_init(&aes); + for (keysize = 128; keysize <= 256; keysize += 64) { + mbedtls_snprintf(title, sizeof(title), "AES-CFB8-%d", keysize); + + memset(buf, 0, sizeof(buf)); + memset(tmp, 0, sizeof(tmp)); + CHECK_AND_CONTINUE(mbedtls_aes_setkey_enc(&aes, tmp, keysize)); + + TIME_AND_TSC(title, + mbedtls_aes_crypt_cfb8(&aes, MBEDTLS_AES_ENCRYPT, BUFSIZE, tmp, buf, buf)); + } + mbedtls_aes_free(&aes); + } #endif #if defined(MBEDTLS_CIPHER_MODE_XTS) if (todo.aes_xts) {