ARIA: add missing context init/free

This fixes the self-test with alternative implementations.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2021-05-25 09:17:22 +02:00
parent a8d0718b1c
commit ccbbb2c501

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 */