1. multi thread verify bignum AES and SHA

This commit is contained in:
liuhan
2016-08-15 21:04:57 +08:00
committed by Wu Jian Gang
parent 98021903a2
commit 0f83831c74
11 changed files with 238 additions and 150 deletions
+21 -3
View File
@@ -1237,9 +1237,8 @@ int mbedtls_aes_self_test( int verbose )
unsigned char stream_block[16];
#endif
mbedtls_aes_context ctx;
memset( key, 0, 32 );
mbedtls_aes_init( &ctx );
memset( key, 0, 32 );
/*
* ECB mode
@@ -1255,6 +1254,8 @@ int mbedtls_aes_self_test( int verbose )
memset( buf, 0, 16 );
mbedtls_aes_init( &ctx );
if( v == MBEDTLS_AES_DECRYPT )
{
mbedtls_aes_setkey_dec( &ctx, key, 128 + u * 64 );
@@ -1267,6 +1268,7 @@ int mbedtls_aes_self_test( int verbose )
if( verbose != 0 )
mbedtls_printf( "failed\n" );
mbedtls_aes_free( &ctx );
ret = 1;
goto exit;
}
@@ -1283,6 +1285,8 @@ int mbedtls_aes_self_test( int verbose )
if( verbose != 0 )
mbedtls_printf( "failed\n" );
mbedtls_aes_free( &ctx );
ret = 1;
goto exit;
}
@@ -1290,6 +1294,8 @@ int mbedtls_aes_self_test( int verbose )
if( verbose != 0 )
mbedtls_printf( "passed\n" );
mbedtls_aes_free( &ctx );
}
if( verbose != 0 )
@@ -1312,6 +1318,8 @@ int mbedtls_aes_self_test( int verbose )
memset( prv, 0, 16 );
memset( buf, 0, 16 );
mbedtls_aes_init( &ctx );
if( v == MBEDTLS_AES_DECRYPT )
{
mbedtls_aes_setkey_dec( &ctx, key, 128 + u * 64 );
@@ -1324,6 +1332,8 @@ int mbedtls_aes_self_test( int verbose )
if( verbose != 0 )
mbedtls_printf( "failed\n" );
mbedtls_aes_free( &ctx );
ret = 1;
goto exit;
}
@@ -1348,6 +1358,8 @@ int mbedtls_aes_self_test( int verbose )
if( verbose != 0 )
mbedtls_printf( "failed\n" );
mbedtls_aes_free( &ctx );
ret = 1;
goto exit;
}
@@ -1355,6 +1367,8 @@ int mbedtls_aes_self_test( int verbose )
if( verbose != 0 )
mbedtls_printf( "passed\n" );
mbedtls_aes_free( &ctx );
}
if( verbose != 0 )
@@ -1377,6 +1391,8 @@ int mbedtls_aes_self_test( int verbose )
memcpy( iv, aes_test_cfb128_iv, 16 );
memcpy( key, aes_test_cfb128_key[u], 16 + u * 8 );
mbedtls_aes_init( &ctx );
offset = 0;
mbedtls_aes_setkey_enc( &ctx, key, 128 + u * 64 );
@@ -1433,6 +1449,8 @@ int mbedtls_aes_self_test( int verbose )
memcpy( nonce_counter, aes_test_ctr_nonce_counter[u], 16 );
memcpy( key, aes_test_ctr_key[u], 16 );
mbedtls_aes_init( &ctx );
offset = 0;
mbedtls_aes_setkey_enc( &ctx, key, 128 );
+6 -3
View File
@@ -396,13 +396,13 @@ int mbedtls_sha1_self_test( int verbose )
unsigned char sha1sum[20];
mbedtls_sha1_context ctx;
mbedtls_sha1_init( &ctx );
/*
* SHA-1
*/
for( i = 0; i < 3; i++ )
{
mbedtls_sha1_init( &ctx );
if( verbose != 0 )
mbedtls_printf( " SHA-1 test #%d: ", i + 1 );
@@ -426,19 +426,22 @@ int mbedtls_sha1_self_test( int verbose )
if( verbose != 0 )
mbedtls_printf( "failed\n" );
mbedtls_sha1_free( &ctx );
ret = 1;
goto exit;
}
if( verbose != 0 )
mbedtls_printf( "passed\n" );
mbedtls_sha1_free( &ctx );
}
if( verbose != 0 )
mbedtls_printf( "\n" );
exit:
mbedtls_sha1_free( &ctx );
return( ret );
}
+6 -3
View File
@@ -393,13 +393,13 @@ int mbedtls_sha256_self_test( int verbose )
unsigned char sha256sum[32];
mbedtls_sha256_context ctx;
mbedtls_sha256_init( &ctx );
for( i = 0; i < 6; i++ )
{
j = i % 3;
k = i < 3;
mbedtls_sha256_init( &ctx );
if( verbose != 0 )
mbedtls_printf( " SHA-%d test #%d: ", 256 - k * 32, j + 1 );
@@ -423,19 +423,22 @@ int mbedtls_sha256_self_test( int verbose )
if( verbose != 0 )
mbedtls_printf( "failed\n" );
mbedtls_sha256_free( &ctx );
ret = 1;
goto exit;
}
if( verbose != 0 )
mbedtls_printf( "passed\n" );
mbedtls_sha256_free( &ctx );
}
if( verbose != 0 )
mbedtls_printf( "\n" );
exit:
mbedtls_sha256_free( &ctx );
return( ret );
}
+7 -3
View File
@@ -449,13 +449,13 @@ int mbedtls_sha512_self_test( int verbose )
unsigned char sha512sum[64];
mbedtls_sha512_context ctx;
mbedtls_sha512_init( &ctx );
for( i = 0; i < 6; i++ )
{
j = i % 3;
k = i < 3;
mbedtls_sha512_init( &ctx );
if( verbose != 0 )
mbedtls_printf( " SHA-%d test #%d: ", 512 - k * 128, j + 1 );
@@ -479,19 +479,23 @@ int mbedtls_sha512_self_test( int verbose )
if( verbose != 0 )
mbedtls_printf( "failed\n" );
mbedtls_sha512_free( &ctx );
ret = 1;
goto exit;
}
if( verbose != 0 )
mbedtls_printf( "passed\n" );
mbedtls_sha512_free( &ctx );
}
if( verbose != 0 )
mbedtls_printf( "\n" );
exit:
mbedtls_sha512_free( &ctx );
return( ret );
}