mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 02:25:40 +01:00
Fail the test case immediately if cipher_reset_key fails
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
a2971ea62c
commit
8a3d234859
@ -27,7 +27,7 @@
|
|||||||
* individual ciphers, and it doesn't work with the PSA wrappers. So don't do
|
* individual ciphers, and it doesn't work with the PSA wrappers. So don't do
|
||||||
* it, and instead start with a fresh context.
|
* it, and instead start with a fresh context.
|
||||||
*/
|
*/
|
||||||
static void cipher_reset_key( mbedtls_cipher_context_t *ctx, int cipher_id,
|
static int cipher_reset_key( mbedtls_cipher_context_t *ctx, int cipher_id,
|
||||||
int use_psa, size_t tag_len, const data_t *key, int direction )
|
int use_psa, size_t tag_len, const data_t *key, int direction )
|
||||||
{
|
{
|
||||||
mbedtls_cipher_free( ctx );
|
mbedtls_cipher_free( ctx );
|
||||||
@ -52,8 +52,10 @@ static void cipher_reset_key( mbedtls_cipher_context_t *ctx, int cipher_id,
|
|||||||
|
|
||||||
TEST_ASSERT( 0 == mbedtls_cipher_setkey( ctx, key->x, 8 * key->len,
|
TEST_ASSERT( 0 == mbedtls_cipher_setkey( ctx, key->x, 8 * key->len,
|
||||||
direction ) );
|
direction ) );
|
||||||
|
return( 1 );
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
;
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1195,8 +1197,9 @@ void auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
|
|||||||
/*
|
/*
|
||||||
* Prepare context for decryption
|
* Prepare context for decryption
|
||||||
*/
|
*/
|
||||||
cipher_reset_key( &ctx, cipher_id, use_psa, tag->len, key,
|
if( ! cipher_reset_key( &ctx, cipher_id, use_psa, tag->len, key,
|
||||||
MBEDTLS_DECRYPT );
|
MBEDTLS_DECRYPT ) )
|
||||||
|
goto exit;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* prepare buffer for decryption
|
* prepare buffer for decryption
|
||||||
@ -1264,8 +1267,9 @@ void auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
|
|||||||
if( strcmp( result, "FAIL" ) != 0 )
|
if( strcmp( result, "FAIL" ) != 0 )
|
||||||
{
|
{
|
||||||
/* prepare context for encryption */
|
/* prepare context for encryption */
|
||||||
cipher_reset_key( &ctx, cipher_id, use_psa, tag->len, key,
|
if( ! cipher_reset_key( &ctx, cipher_id, use_psa, tag->len, key,
|
||||||
MBEDTLS_ENCRYPT );
|
MBEDTLS_ENCRYPT ) )
|
||||||
|
goto exit;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute size of output buffer according to documentation
|
* Compute size of output buffer according to documentation
|
||||||
@ -1327,8 +1331,9 @@ void auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
|
|||||||
/*
|
/*
|
||||||
* Prepare context for decryption
|
* Prepare context for decryption
|
||||||
*/
|
*/
|
||||||
cipher_reset_key( &ctx, cipher_id, use_psa, tag->len, key,
|
if( ! cipher_reset_key( &ctx, cipher_id, use_psa, tag->len, key,
|
||||||
MBEDTLS_DECRYPT );
|
MBEDTLS_DECRYPT ) )
|
||||||
|
goto exit;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare pointers for decryption
|
* Prepare pointers for decryption
|
||||||
@ -1387,8 +1392,9 @@ void auth_crypt_tv( int cipher_id, data_t * key, data_t * iv,
|
|||||||
if( strcmp( result, "FAIL" ) != 0 )
|
if( strcmp( result, "FAIL" ) != 0 )
|
||||||
{
|
{
|
||||||
/* prepare context for encryption */
|
/* prepare context for encryption */
|
||||||
cipher_reset_key( &ctx, cipher_id, use_psa, tag->len, key,
|
if( ! cipher_reset_key( &ctx, cipher_id, use_psa, tag->len, key,
|
||||||
MBEDTLS_ENCRYPT );
|
MBEDTLS_ENCRYPT ) )
|
||||||
|
goto exit;
|
||||||
|
|
||||||
/* prepare buffers for encryption */
|
/* prepare buffers for encryption */
|
||||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
Loading…
Reference in New Issue
Block a user