Skip to content

Commit

Permalink
benchmark: add AES_CFB8
Browse files Browse the repository at this point in the history
Signed-off-by: Yanray Wang <[email protected]>
  • Loading branch information
Yanray Wang committed Oct 10, 2023
1 parent b382c2b commit c96db3b
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions programs/test/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ int main(void)
#define HEADER_FORMAT " %-24s : "
#define TITLE_LEN 25

#define OPTIONS \
"md4, md5, ripemd160, sha1, sha256, sha512,\n" \
"arc4, des3, des, camellia, blowfish, chacha20,\n" \
"aes_cbc, aes_cfb128, aes_gcm, aes_ccm, aes_xts, chachapoly,\n" \
"aes_cmac, des3_cmac, poly1305\n" \
"havege, ctr_drbg, hmac_drbg\n" \
#define OPTIONS \
"md4, md5, ripemd160, sha1, sha256, sha512,\n" \
"arc4, des3, des, camellia, blowfish, chacha20,\n" \
"aes_cbc, aes_cfb128, aes_cfb8, aes_gcm, aes_ccm, aes_xts, chachapoly,\n" \
"aes_cmac, des3_cmac, poly1305\n" \
"havege, ctr_drbg, hmac_drbg\n" \
"rsa, dhm, ecdsa, ecdh.\n"

#if defined(MBEDTLS_ERROR_C)
Expand Down Expand Up @@ -280,7 +280,7 @@ unsigned char buf[BUFSIZE];
typedef struct {
char md4, md5, ripemd160, sha1, sha256, sha512,
arc4, 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, blowfish, chacha20,
poly1305,
Expand Down Expand Up @@ -338,6 +338,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) {
Expand Down Expand Up @@ -521,6 +523,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) {
Expand Down

0 comments on commit c96db3b

Please sign in to comment.