1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-01 10:06:53 +03:00

Merge pull request #4553 from gilles-peskine-arm/aria_alt-3.0

Fix ARIA_ALT header and self-test and CAMELLIA_ALT self-test
This commit is contained in:
Gilles Peskine
2021-05-25 20:32:40 +02:00
committed by GitHub
4 changed files with 29 additions and 15 deletions

5
ChangeLog.d/aria-alt.txt Normal file
View File

@ -0,0 +1,5 @@
Bugfix
* Fix some issues affecting MBEDTLS_ARIA_ALT implementations: a misplaced
directive in a header and a missing initialization in the self-test.
* Fix a missing initialization in the Camellia self-test, affecting
MBEDTLS_CAMELLIA_ALT implementations.

View File

@ -51,14 +51,14 @@
#define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E /**< Invalid data input length. */ #define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E /**< Invalid data input length. */
#if !defined(MBEDTLS_ARIA_ALT)
// Regular implementation
//
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#if !defined(MBEDTLS_ARIA_ALT)
// Regular implementation
//
/** /**
* \brief The ARIA context-type definition. * \brief The ARIA context-type definition.
*/ */

View File

@ -921,7 +921,7 @@ static const uint8_t aria_test2_ctr_ct[3][48] = // CTR ciphertext
{ \ { \
if( verbose ) \ if( verbose ) \
mbedtls_printf( "failed\n" ); \ mbedtls_printf( "failed\n" ); \
return( 1 ); \ goto exit; \
} else { \ } else { \
if( verbose ) \ if( verbose ) \
mbedtls_printf( "passed\n" ); \ mbedtls_printf( "passed\n" ); \
@ -935,6 +935,7 @@ int mbedtls_aria_self_test( int verbose )
int i; int i;
uint8_t blk[MBEDTLS_ARIA_BLOCKSIZE]; uint8_t blk[MBEDTLS_ARIA_BLOCKSIZE];
mbedtls_aria_context ctx; mbedtls_aria_context ctx;
int ret = 1;
#if (defined(MBEDTLS_CIPHER_MODE_CFB) || defined(MBEDTLS_CIPHER_MODE_CTR)) #if (defined(MBEDTLS_CIPHER_MODE_CFB) || defined(MBEDTLS_CIPHER_MODE_CTR))
size_t j; size_t j;
@ -946,6 +947,8 @@ int mbedtls_aria_self_test( int verbose )
uint8_t buf[48], iv[MBEDTLS_ARIA_BLOCKSIZE]; uint8_t buf[48], iv[MBEDTLS_ARIA_BLOCKSIZE];
#endif #endif
mbedtls_aria_init( &ctx );
/* /*
* Test set 1 * Test set 1
*/ */
@ -1065,7 +1068,11 @@ int mbedtls_aria_self_test( int verbose )
mbedtls_printf( "\n" ); mbedtls_printf( "\n" );
#endif /* MBEDTLS_CIPHER_MODE_CTR */ #endif /* MBEDTLS_CIPHER_MODE_CTR */
return( 0 ); ret = 0;
exit:
mbedtls_aria_free( &ctx );
return( ret );
} }
#endif /* MBEDTLS_SELF_TEST */ #endif /* MBEDTLS_SELF_TEST */

View File

@ -942,9 +942,11 @@ int mbedtls_camellia_self_test( int verbose )
unsigned char nonce_counter[16]; unsigned char nonce_counter[16];
unsigned char stream_block[16]; unsigned char stream_block[16];
#endif #endif
int ret = 1;
mbedtls_camellia_context ctx; mbedtls_camellia_context ctx;
mbedtls_camellia_init( &ctx );
memset( key, 0, 32 ); memset( key, 0, 32 );
for( j = 0; j < 6; j++ ) { for( j = 0; j < 6; j++ ) {
@ -974,8 +976,7 @@ int mbedtls_camellia_self_test( int verbose )
{ {
if( verbose != 0 ) if( verbose != 0 )
mbedtls_printf( "failed\n" ); mbedtls_printf( "failed\n" );
goto exit;
return( 1 );
} }
} }
@ -1027,8 +1028,7 @@ int mbedtls_camellia_self_test( int verbose )
{ {
if( verbose != 0 ) if( verbose != 0 )
mbedtls_printf( "failed\n" ); mbedtls_printf( "failed\n" );
goto exit;
return( 1 );
} }
} }
@ -1071,8 +1071,7 @@ int mbedtls_camellia_self_test( int verbose )
{ {
if( verbose != 0 ) if( verbose != 0 )
mbedtls_printf( "failed\n" ); mbedtls_printf( "failed\n" );
goto exit;
return( 1 );
} }
} }
else else
@ -1087,8 +1086,7 @@ int mbedtls_camellia_self_test( int verbose )
{ {
if( verbose != 0 ) if( verbose != 0 )
mbedtls_printf( "failed\n" ); mbedtls_printf( "failed\n" );
goto exit;
return( 1 );
} }
} }
@ -1100,7 +1098,11 @@ int mbedtls_camellia_self_test( int verbose )
mbedtls_printf( "\n" ); mbedtls_printf( "\n" );
#endif /* MBEDTLS_CIPHER_MODE_CTR */ #endif /* MBEDTLS_CIPHER_MODE_CTR */
return( 0 ); ret = 0;
exit:
mbedtls_camellia_free( &ctx );
return( ret );
} }
#endif /* MBEDTLS_SELF_TEST */ #endif /* MBEDTLS_SELF_TEST */