Skip to content

Commit

Permalink
Merge pull request #4553 from gilles-peskine-arm/aria_alt-3.0
Browse files Browse the repository at this point in the history
Fix ARIA_ALT header and self-test and CAMELLIA_ALT self-test
  • Loading branch information
gilles-peskine-arm authored May 25, 2021
2 parents 86d1d74 + 0e1f05d commit 8a5304d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.d/aria-alt.txt
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 4 additions & 4 deletions include/mbedtls/aria.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@

#define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E /**< Invalid data input length. */

#if !defined(MBEDTLS_ARIA_ALT)
// Regular implementation
//

#ifdef __cplusplus
extern "C" {
#endif

#if !defined(MBEDTLS_ARIA_ALT)
// Regular implementation
//

/**
* \brief The ARIA context-type definition.
*/
Expand Down
11 changes: 9 additions & 2 deletions library/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ static const uint8_t aria_test2_ctr_ct[3][48] = // CTR ciphertext
{ \
if( verbose ) \
mbedtls_printf( "failed\n" ); \
return( 1 ); \
goto exit; \
} else { \
if( verbose ) \
mbedtls_printf( "passed\n" ); \
Expand All @@ -935,6 +935,7 @@ int mbedtls_aria_self_test( int verbose )
int i;
uint8_t blk[MBEDTLS_ARIA_BLOCKSIZE];
mbedtls_aria_context ctx;
int ret = 1;

#if (defined(MBEDTLS_CIPHER_MODE_CFB) || defined(MBEDTLS_CIPHER_MODE_CTR))
size_t j;
Expand All @@ -946,6 +947,8 @@ int mbedtls_aria_self_test( int verbose )
uint8_t buf[48], iv[MBEDTLS_ARIA_BLOCKSIZE];
#endif

mbedtls_aria_init( &ctx );

/*
* Test set 1
*/
Expand Down Expand Up @@ -1065,7 +1068,11 @@ int mbedtls_aria_self_test( int verbose )
mbedtls_printf( "\n" );
#endif /* MBEDTLS_CIPHER_MODE_CTR */

return( 0 );
ret = 0;

exit:
mbedtls_aria_free( &ctx );
return( ret );
}

#endif /* MBEDTLS_SELF_TEST */
Expand Down
20 changes: 11 additions & 9 deletions library/camellia.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,11 @@ int mbedtls_camellia_self_test( int verbose )
unsigned char nonce_counter[16];
unsigned char stream_block[16];
#endif
int ret = 1;

mbedtls_camellia_context ctx;

mbedtls_camellia_init( &ctx );
memset( key, 0, 32 );

for( j = 0; j < 6; j++ ) {
Expand Down Expand Up @@ -974,8 +976,7 @@ int mbedtls_camellia_self_test( int verbose )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );

return( 1 );
goto exit;
}
}

Expand Down Expand Up @@ -1027,8 +1028,7 @@ int mbedtls_camellia_self_test( int verbose )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );

return( 1 );
goto exit;
}
}

Expand Down Expand Up @@ -1071,8 +1071,7 @@ int mbedtls_camellia_self_test( int verbose )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );

return( 1 );
goto exit;
}
}
else
Expand All @@ -1087,8 +1086,7 @@ int mbedtls_camellia_self_test( int verbose )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );

return( 1 );
goto exit;
}
}

Expand All @@ -1100,7 +1098,11 @@ int mbedtls_camellia_self_test( int verbose )
mbedtls_printf( "\n" );
#endif /* MBEDTLS_CIPHER_MODE_CTR */

return( 0 );
ret = 0;

exit:
mbedtls_camellia_free( &ctx );
return( ret );
}

#endif /* MBEDTLS_SELF_TEST */
Expand Down

0 comments on commit 8a5304d

Please sign in to comment.