Added SHA3 to benchmark.

Taken from #1549, as it is closed.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2022-05-20 14:26:00 +02:00
parent 4712d4c3e6
commit ebb3640ada
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3

View file

@ -46,6 +46,7 @@ int main( void )
#include "mbedtls/sha1.h"
#include "mbedtls/sha256.h"
#include "mbedtls/sha512.h"
#include "mbedtls/sha3.h"
#include "mbedtls/des.h"
#include "mbedtls/aes.h"
@ -121,6 +122,7 @@ static void mbedtls_set_alarm( int seconds );
#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_gcm, aes_ccm, aes_xts, chachapoly,\n" \
"aes_cmac, des3_cmac, poly1305\n" \
@ -518,6 +520,7 @@ unsigned char buf[BUFSIZE];
typedef struct {
char md5, ripemd160, sha1, sha256, sha512,
sha3_224, sha3_256, sha3_384, sha3_512,
des3, des,
aes_cbc, aes_gcm, aes_ccm, aes_xts, chachapoly,
aes_cmac, des3_cmac,
@ -569,6 +572,14 @@ int main( int argc, char *argv[] )
todo.sha256 = 1;
else if( strcmp( argv[i], "sha512" ) == 0 )
todo.sha512 = 1;
else if( strcmp( argv[i], "sha3_224" ) == 0 )
todo.sha3_224 = 1;
else if( strcmp( argv[i], "sha3_256" ) == 0 )
todo.sha3_256 = 1;
else if( strcmp( argv[i], "sha3_384" ) == 0 )
todo.sha3_384 = 1;
else if( strcmp( argv[i], "sha3_512" ) == 0 )
todo.sha3_512 = 1;
else if( strcmp( argv[i], "des3" ) == 0 )
todo.des3 = 1;
else if( strcmp( argv[i], "des" ) == 0 )
@ -655,6 +666,16 @@ int main( int argc, char *argv[] )
if( todo.sha512 )
TIME_AND_TSC( "SHA-512", mbedtls_sha512( buf, BUFSIZE, tmp, 0 ) );
#endif
#if defined(MBEDTLS_SHA3_C)
if ( todo.sha3_224 )
TIME_AND_TSC( "SHA3-224", mbedtls_sha3( MBEDTLS_SHA3_224, buf, BUFSIZE, tmp, 28 ) );
if ( todo.sha3_256 )
TIME_AND_TSC( "SHA3-256", mbedtls_sha3( MBEDTLS_SHA3_256, buf, BUFSIZE, tmp, 32 ) );
if ( todo.sha3_384 )
TIME_AND_TSC( "SHA3-384", mbedtls_sha3( MBEDTLS_SHA3_384, buf, BUFSIZE, tmp, 48 ) );
if ( todo.sha3_512 )
TIME_AND_TSC( "SHA3-512", mbedtls_sha3( MBEDTLS_SHA3_512, buf, BUFSIZE, tmp, 64 ) );
#endif
#if defined(MBEDTLS_DES_C)
#if defined(MBEDTLS_CIPHER_MODE_CBC)