Adjust verbose self-test output to match other ciphers.

This commit is contained in:
Daniel King 2016-05-18 10:07:53 -03:00 committed by Manuel Pégourié-Gonnard
parent 8fe4701abe
commit dedf4a3e7b
3 changed files with 52 additions and 7 deletions

View File

@ -428,6 +428,11 @@ int mbedtls_aead_chacha20_poly1305_self_test( int verbose )
for ( i = 0U; i < 1U; i++ )
{
if ( verbose != 0 )
{
mbedtls_printf( " ChaCha20-Poly1305 test %zi ", i );
}
result = mbedtls_aead_chacha20_poly1305_crypt_and_mac( test_key[i],
test_nonce[i],
MBEDTLS_AEAD_CHACHA20_POLY1305_ENCRYPT,
@ -441,7 +446,7 @@ int mbedtls_aead_chacha20_poly1305_self_test( int verbose )
{
if ( verbose != 0 )
{
mbedtls_printf( "ChaCha20-Poly1305 test %zi error code: %i\n", i, result );
mbedtls_printf( "error code: %i\n", result );
}
return( -1 );
}
@ -450,7 +455,7 @@ int mbedtls_aead_chacha20_poly1305_self_test( int verbose )
{
if ( verbose != 0 )
{
mbedtls_printf( "ChaCha20-Poly1305 test %zi failure (wrong output)\n", i );
mbedtls_printf( "failure (wrong output)\n" );
}
return( -1 );
}
@ -459,10 +464,20 @@ int mbedtls_aead_chacha20_poly1305_self_test( int verbose )
{
if ( verbose != 0 )
{
mbedtls_printf( "ChaCha20-Poly1305 test %zi failure (wrong MAC)\n", i );
mbedtls_printf( "failure (wrong MAC)\n" );
}
return( -1 );
}
if ( verbose != 0 )
{
mbedtls_printf( "passed\n" );
}
}
if( verbose != 0 )
{
mbedtls_printf( "\n" );
}
return( 0 );

View File

@ -559,6 +559,11 @@ int mbedtls_chacha20_self_test( int verbose )
for ( i = 0U; i < 2U; i++ )
{
if ( verbose != 0 )
{
mbedtls_printf( " ChaCha20 test %zi ", i );
}
result = mbedtls_chacha20_crypt( test_keys[i],
test_nonces[i],
test_counters[i],
@ -569,7 +574,7 @@ int mbedtls_chacha20_self_test( int verbose )
{
if ( verbose != 0 )
{
mbedtls_printf( "ChaCha20 test %zi error code: %i\n", i, result );
mbedtls_printf( "error code: %i\n", result );
}
return( -1 );
@ -579,11 +584,21 @@ int mbedtls_chacha20_self_test( int verbose )
{
if ( verbose != 0 )
{
mbedtls_printf( "ChaCha20 test %zi failed\n", i );
mbedtls_printf( "failed\n" );
}
return( -1 );
}
if ( verbose != 0 )
{
mbedtls_printf( "passed\n" );
}
}
if( verbose != 0 )
{
mbedtls_printf( "\n" );
}
return( 0 );

View File

@ -490,6 +490,11 @@ int mbedtls_poly1305_self_test( int verbose )
for ( i = 0U; i < 2U; i++ )
{
if ( verbose != 0 )
{
mbedtls_printf( " Poly1305 test %zi ", i );
}
result = mbedtls_poly1305_mac( test_keys[i],
test_data_len[i],
test_data[i],
@ -498,7 +503,7 @@ int mbedtls_poly1305_self_test( int verbose )
{
if ( verbose != 0 )
{
mbedtls_printf( "Poly1305 test %zi error code: %i\n", i, result );
mbedtls_printf( "error code: %i\n", result );
}
return( -1 );
@ -508,11 +513,21 @@ int mbedtls_poly1305_self_test( int verbose )
{
if ( verbose != 0 )
{
mbedtls_printf( "Poly1305 test %zi failed\n", i );
mbedtls_printf( "failed\n" );
}
return( -1 );
}
if ( verbose != 0 )
{
mbedtls_printf( "passed\n" );
}
}
if( verbose != 0 )
{
mbedtls_printf( "\n" );
}
return( 0 );