Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2023-02-08 00:50:04 +01:00
parent a391a9e472
commit a6779287e8
No known key found for this signature in database
GPG Key ID: C0095B7870A4CCD3
4 changed files with 233 additions and 231 deletions

View File

@ -46,8 +46,7 @@ extern "C" {
* It identifies the family (SHA3-256, SHA3-512, etc.) * It identifies the family (SHA3-256, SHA3-512, etc.)
*/ */
typedef enum typedef enum {
{
MBEDTLS_SHA3_NONE = 0, /*!< Operation not defined. */ MBEDTLS_SHA3_NONE = 0, /*!< Operation not defined. */
MBEDTLS_SHA3_224, /*!< SHA3-224 */ MBEDTLS_SHA3_224, /*!< SHA3-224 */
MBEDTLS_SHA3_256, /*!< SHA3-256 */ MBEDTLS_SHA3_256, /*!< SHA3-256 */
@ -56,8 +55,7 @@ typedef enum
} mbedtls_sha3_id; } mbedtls_sha3_id;
struct mbedtls_sha3_context; struct mbedtls_sha3_context;
typedef struct mbedtls_sha3_family_functions typedef struct mbedtls_sha3_family_functions {
{
mbedtls_sha3_id id; mbedtls_sha3_id id;
uint16_t r; uint16_t r;
@ -199,4 +197,3 @@ int mbedtls_sha3_self_test( int verbose );
#endif #endif
#endif /* mbedtls_sha3.h */ #endif /* mbedtls_sha3.h */

View File

@ -277,13 +277,13 @@ const mbedtls_md_info_t *mbedtls_md_info_from_type(mbedtls_md_type_t md_type)
#endif #endif
#if defined(MBEDTLS_SHA3_C) #if defined(MBEDTLS_SHA3_C)
case MBEDTLS_MD_SHA3_224: case MBEDTLS_MD_SHA3_224:
return( &mbedtls_sha3_224_info ); return &mbedtls_sha3_224_info;
case MBEDTLS_MD_SHA3_256: case MBEDTLS_MD_SHA3_256:
return( &mbedtls_sha3_256_info ); return &mbedtls_sha3_256_info;
case MBEDTLS_MD_SHA3_384: case MBEDTLS_MD_SHA3_384:
return( &mbedtls_sha3_384_info ); return &mbedtls_sha3_384_info;
case MBEDTLS_MD_SHA3_512: case MBEDTLS_MD_SHA3_512:
return( &mbedtls_sha3_512_info ); return &mbedtls_sha3_512_info;
#endif #endif
default: default:
return NULL; return NULL;
@ -548,13 +548,13 @@ int mbedtls_md_starts(mbedtls_md_context_t *ctx)
#endif #endif
#if defined(MBEDTLS_SHA3_C) #if defined(MBEDTLS_SHA3_C)
case MBEDTLS_MD_SHA3_224: case MBEDTLS_MD_SHA3_224:
return( mbedtls_sha3_starts( ctx->md_ctx, MBEDTLS_SHA3_224 ) ); return mbedtls_sha3_starts(ctx->md_ctx, MBEDTLS_SHA3_224);
case MBEDTLS_MD_SHA3_256: case MBEDTLS_MD_SHA3_256:
return( mbedtls_sha3_starts( ctx->md_ctx, MBEDTLS_SHA3_256 ) ); return mbedtls_sha3_starts(ctx->md_ctx, MBEDTLS_SHA3_256);
case MBEDTLS_MD_SHA3_384: case MBEDTLS_MD_SHA3_384:
return( mbedtls_sha3_starts( ctx->md_ctx, MBEDTLS_SHA3_384 ) ); return mbedtls_sha3_starts(ctx->md_ctx, MBEDTLS_SHA3_384);
case MBEDTLS_MD_SHA3_512: case MBEDTLS_MD_SHA3_512:
return( mbedtls_sha3_starts( ctx->md_ctx, MBEDTLS_SHA3_512 ) ); return mbedtls_sha3_starts(ctx->md_ctx, MBEDTLS_SHA3_512);
#endif #endif
default: default:
return MBEDTLS_ERR_MD_BAD_INPUT_DATA; return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
@ -601,7 +601,7 @@ int mbedtls_md_update(mbedtls_md_context_t *ctx, const unsigned char *input, siz
case MBEDTLS_MD_SHA3_256: case MBEDTLS_MD_SHA3_256:
case MBEDTLS_MD_SHA3_384: case MBEDTLS_MD_SHA3_384:
case MBEDTLS_MD_SHA3_512: case MBEDTLS_MD_SHA3_512:
return( mbedtls_sha3_update( ctx->md_ctx, input, ilen ) ); return mbedtls_sha3_update(ctx->md_ctx, input, ilen);
#endif #endif
default: default:
return MBEDTLS_ERR_MD_BAD_INPUT_DATA; return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
@ -648,7 +648,7 @@ int mbedtls_md_finish(mbedtls_md_context_t *ctx, unsigned char *output)
case MBEDTLS_MD_SHA3_256: case MBEDTLS_MD_SHA3_256:
case MBEDTLS_MD_SHA3_384: case MBEDTLS_MD_SHA3_384:
case MBEDTLS_MD_SHA3_512: case MBEDTLS_MD_SHA3_512:
return( mbedtls_sha3_finish( ctx->md_ctx, output, ctx->md_info->size ) ); return mbedtls_sha3_finish(ctx->md_ctx, output, ctx->md_info->size);
#endif #endif
default: default:
return MBEDTLS_ERR_MD_BAD_INPUT_DATA; return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
@ -693,13 +693,13 @@ int mbedtls_md(const mbedtls_md_info_t *md_info, const unsigned char *input, siz
#endif #endif
#if defined(MBEDTLS_SHA3_C) #if defined(MBEDTLS_SHA3_C)
case MBEDTLS_MD_SHA3_224: case MBEDTLS_MD_SHA3_224:
return( mbedtls_sha3( MBEDTLS_SHA3_224, input, ilen, output, md_info->size ) ); return mbedtls_sha3(MBEDTLS_SHA3_224, input, ilen, output, md_info->size);
case MBEDTLS_MD_SHA3_256: case MBEDTLS_MD_SHA3_256:
return( mbedtls_sha3( MBEDTLS_SHA3_256, input, ilen, output, md_info->size ) ); return mbedtls_sha3(MBEDTLS_SHA3_256, input, ilen, output, md_info->size);
case MBEDTLS_MD_SHA3_384: case MBEDTLS_MD_SHA3_384:
return( mbedtls_sha3( MBEDTLS_SHA3_384, input, ilen, output, md_info->size ) ); return mbedtls_sha3(MBEDTLS_SHA3_384, input, ilen, output, md_info->size);
case MBEDTLS_MD_SHA3_512: case MBEDTLS_MD_SHA3_512:
return( mbedtls_sha3( MBEDTLS_SHA3_512, input, ilen, output, md_info->size ) ); return mbedtls_sha3(MBEDTLS_SHA3_512, input, ilen, output, md_info->size);
#endif #endif
default: default:
return MBEDTLS_ERR_MD_BAD_INPUT_DATA; return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
@ -936,7 +936,7 @@ int mbedtls_md_process(mbedtls_md_context_t *ctx, const unsigned char *data)
case MBEDTLS_MD_SHA3_256: case MBEDTLS_MD_SHA3_256:
case MBEDTLS_MD_SHA3_384: case MBEDTLS_MD_SHA3_384:
case MBEDTLS_MD_SHA3_512: case MBEDTLS_MD_SHA3_512:
return( 0 ); return 0;
#endif #endif
default: default:
return MBEDTLS_ERR_MD_BAD_INPUT_DATA; return MBEDTLS_ERR_MD_BAD_INPUT_DATA;

View File

@ -68,7 +68,8 @@ static const uint8_t pi[24] = {
}; };
#define ROT64(x, y) (((x) << (y)) | ((x) >> (64U - (y)))) #define ROT64(x, y) (((x) << (y)) | ((x) >> (64U - (y))))
#define ABSORB( ctx, idx, v ) do { ctx->state[( idx ) >> 3] ^= ( ( uint64_t ) ( v ) ) << ( ( ( idx ) & 0x7 ) << 3 ); } while( 0 ) #define ABSORB(ctx, idx, v) do { ctx->state[(idx) >> 3] ^= ((uint64_t) (v)) << (((idx) & 0x7) << 3); \
} while (0)
#define SQUEEZE(ctx, idx) ((uint8_t) (ctx->state[(idx) >> 3] >> (((idx) & 0x7) << 3))) #define SQUEEZE(ctx, idx) ((uint8_t) (ctx->state[(idx) >> 3] >> (((idx) & 0x7) << 3)))
#define SWAP(x, y) do { uint64_t tmp = (x); (x) = (y); (y) = tmp; } while (0) #define SWAP(x, y) do { uint64_t tmp = (x); (x) = (y); (y) = tmp; } while (0)
@ -79,8 +80,7 @@ static void keccak_f1600(mbedtls_sha3_context *ctx)
uint64_t *s = ctx->state; uint64_t *s = ctx->state;
int i; int i;
for( int round = 0; round < 24; round++ ) for (int round = 0; round < 24; round++) {
{
uint64_t t; uint64_t t;
/* Theta */ /* Theta */
@ -106,13 +106,15 @@ static void keccak_f1600(mbedtls_sha3_context *ctx)
s[4] ^= t; s[9] ^= t; s[14] ^= t; s[19] ^= t; s[24] ^= t; s[4] ^= t; s[9] ^= t; s[14] ^= t; s[19] ^= t; s[24] ^= t;
/* Rho */ /* Rho */
for( i = 1; i < 25; i++ ) for (i = 1; i < 25; i++) {
s[i] = ROT64(s[i], rho[i-1]); s[i] = ROT64(s[i], rho[i-1]);
}
/* Pi */ /* Pi */
t = s[1]; t = s[1];
for( i = 0; i < 24; i++ ) for (i = 0; i < 24; i++) {
SWAP(s[pi[i]], t); SWAP(s[pi[i]], t);
}
/* Chi */ /* Chi */
lane[0] = s[0]; lane[1] = s[1]; lane[2] = s[2]; lane[3] = s[3]; lane[4] = s[4]; lane[0] = s[0]; lane[1] = s[1]; lane[2] = s[2]; lane[3] = s[3]; lane[4] = s[4];
@ -157,16 +159,18 @@ static void keccak_f1600(mbedtls_sha3_context *ctx)
void mbedtls_sha3_init(mbedtls_sha3_context *ctx) void mbedtls_sha3_init(mbedtls_sha3_context *ctx)
{ {
if( ctx == NULL ) if (ctx == NULL) {
return; return;
}
memset(ctx, 0, sizeof(mbedtls_sha3_context)); memset(ctx, 0, sizeof(mbedtls_sha3_context));
} }
void mbedtls_sha3_free(mbedtls_sha3_context *ctx) void mbedtls_sha3_free(mbedtls_sha3_context *ctx)
{ {
if( ctx == NULL ) if (ctx == NULL) {
return; return;
}
mbedtls_platform_zeroize(ctx, sizeof(mbedtls_sha3_context)); mbedtls_platform_zeroize(ctx, sizeof(mbedtls_sha3_context));
} }
@ -174,8 +178,9 @@ void mbedtls_sha3_free( mbedtls_sha3_context *ctx )
void mbedtls_sha3_clone(mbedtls_sha3_context *dst, void mbedtls_sha3_clone(mbedtls_sha3_context *dst,
const mbedtls_sha3_context *src) const mbedtls_sha3_context *src)
{ {
if ( dst == NULL || src == NULL ) if (dst == NULL || src == NULL) {
return; return;
}
*dst = *src; *dst = *src;
} }
@ -186,17 +191,19 @@ void mbedtls_sha3_clone( mbedtls_sha3_context *dst,
int mbedtls_sha3_starts(mbedtls_sha3_context *ctx, mbedtls_sha3_id id) int mbedtls_sha3_starts(mbedtls_sha3_context *ctx, mbedtls_sha3_id id)
{ {
mbedtls_sha3_family_functions *p = NULL; mbedtls_sha3_family_functions *p = NULL;
if( ctx == NULL ) if (ctx == NULL) {
return( MBEDTLS_ERR_SHA3_BAD_INPUT_DATA ); return MBEDTLS_ERR_SHA3_BAD_INPUT_DATA;
for( p = sha3_families; p->id != MBEDTLS_SHA3_NONE; p++ )
{
if( p->id == id )
break;
} }
if( p == NULL || p->id == MBEDTLS_SHA3_NONE ) for (p = sha3_families; p->id != MBEDTLS_SHA3_NONE; p++) {
return( MBEDTLS_ERR_SHA3_BAD_INPUT_DATA ); if (p->id == id) {
break;
}
}
if (p == NULL || p->id == MBEDTLS_SHA3_NONE) {
return MBEDTLS_ERR_SHA3_BAD_INPUT_DATA;
}
ctx->id = id; ctx->id = id;
ctx->r = p->r; ctx->r = p->r;
@ -207,7 +214,7 @@ int mbedtls_sha3_starts( mbedtls_sha3_context *ctx, mbedtls_sha3_id id )
memset(ctx->state, 0, sizeof(ctx->state)); memset(ctx->state, 0, sizeof(ctx->state));
ctx->index = 0; ctx->index = 0;
return( 0 ); return 0;
} }
/* /*
@ -217,33 +224,36 @@ int mbedtls_sha3_update( mbedtls_sha3_context *ctx,
const uint8_t *input, const uint8_t *input,
size_t ilen) size_t ilen)
{ {
if( ctx == NULL ) if (ctx == NULL) {
return( MBEDTLS_ERR_SHA3_BAD_INPUT_DATA ); return MBEDTLS_ERR_SHA3_BAD_INPUT_DATA;
if( ilen == 0 || input == NULL )
return( 0 );
while( ilen-- > 0 )
{
ABSORB( ctx, ctx->index, *input++ );
if( ( ctx->index = ( ctx->index + 1) % ctx->max_block_size ) == 0 )
keccak_f1600( ctx );
} }
return( 0 ); if (ilen == 0 || input == NULL) {
return 0;
}
while (ilen-- > 0) {
ABSORB(ctx, ctx->index, *input++);
if ((ctx->index = (ctx->index + 1) % ctx->max_block_size) == 0) {
keccak_f1600(ctx);
}
}
return 0;
} }
int mbedtls_sha3_finish(mbedtls_sha3_context *ctx, int mbedtls_sha3_finish(mbedtls_sha3_context *ctx,
uint8_t *output, size_t olen) uint8_t *output, size_t olen)
{ {
if( ctx == NULL || output == NULL ) if (ctx == NULL || output == NULL) {
return( MBEDTLS_ERR_SHA3_BAD_INPUT_DATA ); return MBEDTLS_ERR_SHA3_BAD_INPUT_DATA;
}
/* Catch SHA-3 families, with fixed output length */ /* Catch SHA-3 families, with fixed output length */
if( ctx->olen > 0 ) if (ctx->olen > 0) {
{ if (ctx->olen > olen) {
if ( ctx->olen > olen ) return MBEDTLS_ERR_SHA3_BAD_INPUT_DATA;
return( MBEDTLS_ERR_SHA3_BAD_INPUT_DATA ); }
olen = ctx->olen; olen = ctx->olen;
} }
@ -252,15 +262,15 @@ int mbedtls_sha3_finish( mbedtls_sha3_context *ctx,
keccak_f1600(ctx); keccak_f1600(ctx);
ctx->index = 0; ctx->index = 0;
while( olen-- > 0 ) while (olen-- > 0) {
{
*output++ = SQUEEZE(ctx, ctx->index); *output++ = SQUEEZE(ctx, ctx->index);
if( ( ctx->index = ( ctx->index + 1) % ctx->max_block_size ) == 0 ) if ((ctx->index = (ctx->index + 1) % ctx->max_block_size) == 0) {
keccak_f1600(ctx); keccak_f1600(ctx);
} }
}
return( 0 ); return 0;
} }
/* /*
@ -275,19 +285,22 @@ int mbedtls_sha3( mbedtls_sha3_id id, const uint8_t *input,
mbedtls_sha3_init(&ctx); mbedtls_sha3_init(&ctx);
/* Sanity checks are performed in every mbedtls_sha3_xxx() */ /* Sanity checks are performed in every mbedtls_sha3_xxx() */
if( ( ret = mbedtls_sha3_starts( &ctx, id ) ) != 0 ) if ((ret = mbedtls_sha3_starts(&ctx, id)) != 0) {
goto exit; goto exit;
}
if( ( ret = mbedtls_sha3_update( &ctx, input, ilen ) ) != 0 ) if ((ret = mbedtls_sha3_update(&ctx, input, ilen)) != 0) {
goto exit; goto exit;
}
if( ( ret = mbedtls_sha3_finish( &ctx, output, olen ) ) != 0 ) if ((ret = mbedtls_sha3_finish(&ctx, output, olen)) != 0) {
goto exit; goto exit;
}
exit: exit:
mbedtls_sha3_free(&ctx); mbedtls_sha3_free(&ctx);
return( ret ); return ret;
} }
/**************** Self-tests ****************/ /**************** Self-tests ****************/
@ -431,19 +444,16 @@ static int mbedtls_sha3_kat_test( int verbose,
result = mbedtls_sha3(id, result = mbedtls_sha3(id,
test_data[test_num], test_data_len[test_num], test_data[test_num], test_data_len[test_num],
hash, sizeof(hash)); hash, sizeof(hash));
if( result != 0 ) if (result != 0) {
{ if (verbose != 0) {
if( verbose != 0 )
{
mbedtls_printf(" %s test %d error code: %d\n", mbedtls_printf(" %s test %d error code: %d\n",
type_name, test_num, result); type_name, test_num, result);
} }
return( result ); return result;
} }
switch( id ) switch (id) {
{
case MBEDTLS_SHA3_224: case MBEDTLS_SHA3_224:
result = memcmp(hash, test_hash_sha3_224[test_num], 28); result = memcmp(hash, test_hash_sha3_224[test_num], 28);
break; break;
@ -460,22 +470,19 @@ static int mbedtls_sha3_kat_test( int verbose,
break; break;
} }
if( 0 != result ) if (0 != result) {
{ if (verbose != 0) {
if( verbose != 0 )
{
mbedtls_printf(" %s test %d failed\n", type_name, test_num); mbedtls_printf(" %s test %d failed\n", type_name, test_num);
} }
return( -1 ); return -1;
} }
if( verbose != 0 ) if (verbose != 0) {
{
mbedtls_printf(" %s test %d passed\n", type_name, test_num); mbedtls_printf(" %s test %d passed\n", type_name, test_num);
} }
return( 0 ); return 0;
} }
static int mbedtls_sha3_long_kat_test(int verbose, static int mbedtls_sha3_long_kat_test(int verbose,
@ -490,30 +497,24 @@ static int mbedtls_sha3_long_kat_test( int verbose,
memset(buffer, 'a', 1000); memset(buffer, 'a', 1000);
if( verbose != 0 ) if (verbose != 0) {
{
mbedtls_printf(" %s long KAT test ", type_name); mbedtls_printf(" %s long KAT test ", type_name);
} }
mbedtls_sha3_init(&ctx); mbedtls_sha3_init(&ctx);
result = mbedtls_sha3_starts(&ctx, id); result = mbedtls_sha3_starts(&ctx, id);
if( result != 0 ) if (result != 0) {
{ if (verbose != 0) {
if( verbose != 0 )
{
mbedtls_printf("setup failed\n "); mbedtls_printf("setup failed\n ");
} }
} }
/* Process 1,000,000 (one million) 'a' characters */ /* Process 1,000,000 (one million) 'a' characters */
for( i = 0; i < 1000; i++ ) for (i = 0; i < 1000; i++) {
{
result = mbedtls_sha3_update(&ctx, buffer, 1000); result = mbedtls_sha3_update(&ctx, buffer, 1000);
if( result != 0 ) if (result != 0) {
{ if (verbose != 0) {
if( verbose != 0 )
{
mbedtls_printf("update error code: %i\n", result); mbedtls_printf("update error code: %i\n", result);
} }
@ -522,18 +523,15 @@ static int mbedtls_sha3_long_kat_test( int verbose,
} }
result = mbedtls_sha3_finish(&ctx, hash, sizeof(hash)); result = mbedtls_sha3_finish(&ctx, hash, sizeof(hash));
if( result != 0 ) if (result != 0) {
{ if (verbose != 0) {
if( verbose != 0 )
{
mbedtls_printf("finish error code: %d\n", result); mbedtls_printf("finish error code: %d\n", result);
} }
goto cleanup; goto cleanup;
} }
switch( id ) switch (id) {
{
case MBEDTLS_SHA3_224: case MBEDTLS_SHA3_224:
result = memcmp(hash, long_kat_hash_sha3_224, 28); result = memcmp(hash, long_kat_hash_sha3_224, 28);
break; break;
@ -550,22 +548,19 @@ static int mbedtls_sha3_long_kat_test( int verbose,
break; break;
} }
if( result != 0 ) if (result != 0) {
{ if (verbose != 0) {
if( verbose != 0 )
{
mbedtls_printf("failed\n"); mbedtls_printf("failed\n");
} }
} }
if( verbose != 0 ) if (verbose != 0) {
{
mbedtls_printf("passed\n"); mbedtls_printf("passed\n");
} }
cleanup: cleanup:
mbedtls_sha3_free(&ctx); mbedtls_sha3_free(&ctx);
return( result ); return result;
} }
int mbedtls_sha3_self_test(int verbose) int mbedtls_sha3_self_test(int verbose)
@ -573,48 +568,54 @@ int mbedtls_sha3_self_test( int verbose )
int i; int i;
/* SHA3 Known Answer Tests (KAT) */ /* SHA3 Known Answer Tests (KAT) */
for( i = 0; i < 2; i++ ) for (i = 0; i < 2; i++) {
{
if (0 != mbedtls_sha3_kat_test(verbose, if (0 != mbedtls_sha3_kat_test(verbose,
"SHA3-224", MBEDTLS_SHA3_224, i ) ) "SHA3-224", MBEDTLS_SHA3_224, i)) {
return( 1 ); return 1;
}
if (0 != mbedtls_sha3_kat_test(verbose, if (0 != mbedtls_sha3_kat_test(verbose,
"SHA3-256", MBEDTLS_SHA3_256, i ) ) "SHA3-256", MBEDTLS_SHA3_256, i)) {
return( 1 ); return 1;
}
if (0 != mbedtls_sha3_kat_test(verbose, if (0 != mbedtls_sha3_kat_test(verbose,
"SHA3-384", MBEDTLS_SHA3_384, i ) ) "SHA3-384", MBEDTLS_SHA3_384, i)) {
return( 1 ); return 1;
}
if (0 != mbedtls_sha3_kat_test(verbose, if (0 != mbedtls_sha3_kat_test(verbose,
"SHA3-512", MBEDTLS_SHA3_512, i ) ) "SHA3-512", MBEDTLS_SHA3_512, i)) {
return( 1 ); return 1;
}
} }
/* SHA3 long KAT tests */ /* SHA3 long KAT tests */
if (0 != mbedtls_sha3_long_kat_test(verbose, if (0 != mbedtls_sha3_long_kat_test(verbose,
"SHA3-224", MBEDTLS_SHA3_224 ) ) "SHA3-224", MBEDTLS_SHA3_224)) {
return( 1 ); return 1;
}
if (0 != mbedtls_sha3_long_kat_test(verbose, if (0 != mbedtls_sha3_long_kat_test(verbose,
"SHA3-256", MBEDTLS_SHA3_256 ) ) "SHA3-256", MBEDTLS_SHA3_256)) {
return( 1 ); return 1;
}
if (0 != mbedtls_sha3_long_kat_test(verbose, if (0 != mbedtls_sha3_long_kat_test(verbose,
"SHA3-384", MBEDTLS_SHA3_384 ) ) "SHA3-384", MBEDTLS_SHA3_384)) {
return( 1 ); return 1;
}
if (0 != mbedtls_sha3_long_kat_test(verbose, if (0 != mbedtls_sha3_long_kat_test(verbose,
"SHA3-512", MBEDTLS_SHA3_512 ) ) "SHA3-512", MBEDTLS_SHA3_512)) {
return( 1 ); return 1;
}
if( verbose != 0 ) if (verbose != 0) {
{
mbedtls_printf("\n"); mbedtls_printf("\n");
} }
return( 0 ); return 0;
} }
#endif /* MBEDTLS_SELF_TEST */ #endif /* MBEDTLS_SELF_TEST */

View File

@ -657,14 +657,18 @@ int main(int argc, char *argv[])
} }
#endif #endif
#if defined(MBEDTLS_SHA3_C) #if defined(MBEDTLS_SHA3_C)
if ( todo.sha3_224 ) if (todo.sha3_224) {
TIME_AND_TSC("SHA3-224", mbedtls_sha3(MBEDTLS_SHA3_224, buf, BUFSIZE, tmp, 28)); TIME_AND_TSC("SHA3-224", mbedtls_sha3(MBEDTLS_SHA3_224, buf, BUFSIZE, tmp, 28));
if ( todo.sha3_256 ) }
if (todo.sha3_256) {
TIME_AND_TSC("SHA3-256", mbedtls_sha3(MBEDTLS_SHA3_256, buf, BUFSIZE, tmp, 32)); TIME_AND_TSC("SHA3-256", mbedtls_sha3(MBEDTLS_SHA3_256, buf, BUFSIZE, tmp, 32));
if ( todo.sha3_384 ) }
if (todo.sha3_384) {
TIME_AND_TSC("SHA3-384", mbedtls_sha3(MBEDTLS_SHA3_384, buf, BUFSIZE, tmp, 48)); TIME_AND_TSC("SHA3-384", mbedtls_sha3(MBEDTLS_SHA3_384, buf, BUFSIZE, tmp, 48));
if ( todo.sha3_512 ) }
if (todo.sha3_512) {
TIME_AND_TSC("SHA3-512", mbedtls_sha3(MBEDTLS_SHA3_512, buf, BUFSIZE, tmp, 64)); TIME_AND_TSC("SHA3-512", mbedtls_sha3(MBEDTLS_SHA3_512, buf, BUFSIZE, tmp, 64));
}
#endif #endif
#if defined(MBEDTLS_DES_C) #if defined(MBEDTLS_DES_C)