benchmark: Add AES-XTS benchmark

This commit is contained in:
Jaeden Amero 2018-05-02 17:38:00 +01:00
parent e4daf77c2e
commit c00cac79be

View file

@ -94,7 +94,7 @@ int main( void )
#define OPTIONS \
"md4, md5, ripemd160, sha1, sha256, sha512,\n" \
"arc4, des3, des, camellia, blowfish,\n" \
"aes_cbc, aes_gcm, aes_ccm, aes_cmac, des3_cmac,\n" \
"aes_cbc, aes_gcm, aes_ccm, aes_cmac, aes_xts, des3_cmac,\n" \
"havege, ctr_drbg, hmac_drbg\n" \
"rsa, dhm, ecdsa, ecdh.\n"
@ -228,7 +228,7 @@ unsigned char buf[BUFSIZE];
typedef struct {
char md4, md5, ripemd160, sha1, sha256, sha512,
arc4, des3, des,
aes_cbc, aes_gcm, aes_ccm, aes_cmac, des3_cmac,
aes_cbc, aes_gcm, aes_ccm, aes_cmac, aes_xts, des3_cmac,
camellia, blowfish,
havege, ctr_drbg, hmac_drbg,
rsa, dhm, ecdsa, ecdh;
@ -280,6 +280,8 @@ int main( int argc, char *argv[] )
todo.aes_ccm = 1;
else if( strcmp( argv[i], "aes_cmac" ) == 0 )
todo.aes_cmac = 1;
else if( strcmp( argv[i], "aes_xts" ) == 0 )
todo.aes_xts = 1;
else if( strcmp( argv[i], "des3_cmac" ) == 0 )
todo.des3_cmac = 1;
else if( strcmp( argv[i], "camellia" ) == 0 )
@ -496,6 +498,29 @@ int main( int argc, char *argv[] )
output ) );
}
#endif /* MBEDTLS_CMAC_C */
#if defined(MBEDTLS_CIPHER_MODE_XTS)
if( todo.aes_xts )
{
int keysize;
mbedtls_aes_xts_context ctx;
mbedtls_aes_xts_init( &ctx );
for( keysize = 128; keysize <= 256; keysize += 64 )
{
mbedtls_snprintf( title, sizeof( title ), "AES-XTS-%d", keysize );
memset( buf, 0, sizeof( buf ) );
memset( tmp, 0, sizeof( tmp ) );
mbedtls_aes_xts_setkey_enc( &ctx, tmp, keysize * 2);
TIME_AND_TSC( title,
mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, BUFSIZE,
tmp, buf, buf ) );
mbedtls_aes_xts_free( &ctx );
}
}
#endif /* MBEDTLS_CIPHER_MODE_XTS */
#endif /* MBEDTLS_AES_C */
#if defined(MBEDTLS_CAMELLIA_C) && defined(MBEDTLS_CIPHER_MODE_CBC)