mirror of
https://github.com/espressif/mbedtls.git
synced 2025-05-10 12:02:28 +08:00
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:
parent
4712d4c3e6
commit
ebb3640ada
@ -46,6 +46,7 @@ int main( void )
|
|||||||
#include "mbedtls/sha1.h"
|
#include "mbedtls/sha1.h"
|
||||||
#include "mbedtls/sha256.h"
|
#include "mbedtls/sha256.h"
|
||||||
#include "mbedtls/sha512.h"
|
#include "mbedtls/sha512.h"
|
||||||
|
#include "mbedtls/sha3.h"
|
||||||
|
|
||||||
#include "mbedtls/des.h"
|
#include "mbedtls/des.h"
|
||||||
#include "mbedtls/aes.h"
|
#include "mbedtls/aes.h"
|
||||||
@ -120,11 +121,12 @@ static void mbedtls_set_alarm( int seconds );
|
|||||||
#define TITLE_LEN 25
|
#define TITLE_LEN 25
|
||||||
|
|
||||||
#define OPTIONS \
|
#define OPTIONS \
|
||||||
"md5, ripemd160, sha1, sha256, sha512,\n" \
|
"md5, ripemd160, sha1, sha256, sha512,\n" \
|
||||||
"des3, des, camellia, chacha20,\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_cbc, 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)
|
||||||
@ -518,6 +520,7 @@ unsigned char buf[BUFSIZE];
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char md5, ripemd160, sha1, sha256, sha512,
|
char md5, ripemd160, sha1, sha256, sha512,
|
||||||
|
sha3_224, sha3_256, sha3_384, sha3_512,
|
||||||
des3, des,
|
des3, des,
|
||||||
aes_cbc, aes_gcm, aes_ccm, aes_xts, chachapoly,
|
aes_cbc, aes_gcm, aes_ccm, aes_xts, chachapoly,
|
||||||
aes_cmac, des3_cmac,
|
aes_cmac, des3_cmac,
|
||||||
@ -569,6 +572,14 @@ int main( int argc, char *argv[] )
|
|||||||
todo.sha256 = 1;
|
todo.sha256 = 1;
|
||||||
else if( strcmp( argv[i], "sha512" ) == 0 )
|
else if( strcmp( argv[i], "sha512" ) == 0 )
|
||||||
todo.sha512 = 1;
|
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 )
|
else if( strcmp( argv[i], "des3" ) == 0 )
|
||||||
todo.des3 = 1;
|
todo.des3 = 1;
|
||||||
else if( strcmp( argv[i], "des" ) == 0 )
|
else if( strcmp( argv[i], "des" ) == 0 )
|
||||||
@ -655,6 +666,16 @@ int main( int argc, char *argv[] )
|
|||||||
if( todo.sha512 )
|
if( todo.sha512 )
|
||||||
TIME_AND_TSC( "SHA-512", mbedtls_sha512( buf, BUFSIZE, tmp, 0 ) );
|
TIME_AND_TSC( "SHA-512", mbedtls_sha512( buf, BUFSIZE, tmp, 0 ) );
|
||||||
#endif
|
#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_DES_C)
|
||||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user