benchmark: add AES_CFB8

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
Yanray Wang 2023-09-12 09:45:37 +08:00
parent 55aba195de
commit 022b9a1ca0

View file

@ -113,13 +113,13 @@ static void mbedtls_set_alarm(int seconds);
#define HEADER_FORMAT " %-24s : " #define HEADER_FORMAT " %-24s : "
#define TITLE_LEN 25 #define TITLE_LEN 25
#define OPTIONS \ #define OPTIONS \
"md5, ripemd160, sha1, sha256, sha512,\n" \ "md5, ripemd160, sha1, sha256, sha512,\n" \
"sha3_224, sha3_256, sha3_384, sha3_512,\n" \ "sha3_224, sha3_256, sha3_384, sha3_512,\n" \
"des3, des, camellia, chacha20,\n" \ "des3, des, camellia, chacha20,\n" \
"aes_cbc, aes_cfb128, aes_gcm, aes_ccm, aes_xts, chachapoly,\n" \ "aes_cbc, aes_cfb128, aes_cfb8, aes_gcm, aes_ccm, aes_xts, chachapoly\n" \
"aes_cmac, des3_cmac, poly1305\n" \ "aes_cmac, des3_cmac, poly1305\n" \
"ctr_drbg, hmac_drbg\n" \ "ctr_drbg, hmac_drbg\n" \
"rsa, dhm, ecdsa, ecdh.\n" "rsa, dhm, ecdsa, ecdh.\n"
#if defined(MBEDTLS_ERROR_C) #if defined(MBEDTLS_ERROR_C)
@ -510,7 +510,7 @@ typedef struct {
char md5, ripemd160, sha1, sha256, sha512, char md5, ripemd160, sha1, sha256, sha512,
sha3_224, sha3_256, sha3_384, sha3_512, sha3_224, sha3_256, sha3_384, sha3_512,
des3, des, 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, aes_cmac, des3_cmac,
aria, camellia, chacha20, aria, camellia, chacha20,
poly1305, poly1305,
@ -572,6 +572,8 @@ int main(int argc, char *argv[])
todo.aes_cbc = 1; todo.aes_cbc = 1;
} else if (strcmp(argv[i], "aes_cfb128") == 0) { } else if (strcmp(argv[i], "aes_cfb128") == 0) {
todo.aes_cfb128 = 1; todo.aes_cfb128 = 1;
} else if (strcmp(argv[i], "aes_cfb8") == 0) {
todo.aes_cfb8 = 1;
} else if (strcmp(argv[i], "aes_xts") == 0) { } else if (strcmp(argv[i], "aes_xts") == 0) {
todo.aes_xts = 1; todo.aes_xts = 1;
} else if (strcmp(argv[i], "aes_gcm") == 0) { } else if (strcmp(argv[i], "aes_gcm") == 0) {
@ -753,6 +755,22 @@ int main(int argc, char *argv[])
} }
mbedtls_aes_free(&aes); 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 #endif
#if defined(MBEDTLS_CIPHER_MODE_XTS) #if defined(MBEDTLS_CIPHER_MODE_XTS)
if (todo.aes_xts) { if (todo.aes_xts) {