Use ASSERT_ALLOC in key agreement tests

This commit is contained in:
Gilles Peskine 2018-10-25 22:34:48 +02:00
parent 211a436f2e
commit fc411f1ac1

View file

@ -11,6 +11,8 @@
#include "psa/crypto.h" #include "psa/crypto.h"
#define MAX( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
#define ARRAY_LENGTH( array ) ( sizeof( array ) / sizeof( *( array ) ) ) #define ARRAY_LENGTH( array ) ( sizeof( array ) / sizeof( *( array ) ) )
#if(UINT32_MAX > SIZE_MAX) #if(UINT32_MAX > SIZE_MAX)
@ -415,7 +417,7 @@ static int exercise_key_agreement_key( psa_key_slot_t key,
public_key_type = PSA_KEY_TYPE_PUBLIC_KEY_OF_KEYPAIR( key_type ); public_key_type = PSA_KEY_TYPE_PUBLIC_KEY_OF_KEYPAIR( key_type );
public_key_length = PSA_KEY_EXPORT_MAX_SIZE( public_key_type, public_key_length = PSA_KEY_EXPORT_MAX_SIZE( public_key_type,
key_bits ); key_bits );
public_key = mbedtls_calloc( 1, public_key_length ); ASSERT_ALLOC( public_key, public_key_length );
TEST_ASSERT( public_key != NULL ); TEST_ASSERT( public_key != NULL );
TEST_ASSERT( TEST_ASSERT(
psa_export_public_key( key, psa_export_public_key( key,
@ -1724,7 +1726,7 @@ void agreement_key_policy( int policy_usage,
&key_bits ) == PSA_SUCCESS ); &key_bits ) == PSA_SUCCESS );
public_key_type = PSA_KEY_TYPE_PUBLIC_KEY_OF_KEYPAIR( key_type ); public_key_type = PSA_KEY_TYPE_PUBLIC_KEY_OF_KEYPAIR( key_type );
public_key_length = PSA_KEY_EXPORT_MAX_SIZE( public_key_type, key_bits ); public_key_length = PSA_KEY_EXPORT_MAX_SIZE( public_key_type, key_bits );
public_key = mbedtls_calloc( 1, public_key_length ); ASSERT_ALLOC( public_key, public_key_length );
TEST_ASSERT( public_key != NULL ); TEST_ASSERT( public_key != NULL );
TEST_ASSERT( psa_export_public_key( key_slot, TEST_ASSERT( psa_export_public_key( key_slot,
public_key, public_key_length, public_key, public_key_length,