Fix parity tests to actually fail the test on error

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2020-08-25 22:30:31 +02:00
parent ed19762a22
commit 14613bcd75

View File

@ -58,7 +58,7 @@
/* Check the parity of value. /* Check the parity of value.
* Return 0 if value has even parity and a nonzero value otherwise. */ * Return 0 if value has even parity and a nonzero value otherwise. */
int test_parity( uint32_t value ) int check_parity( uint32_t value )
{ {
value ^= value >> 16; value ^= value >> 16;
value ^= value >> 8; value ^= value >> 8;
@ -66,7 +66,7 @@ int test_parity( uint32_t value )
return( 0x9669 & 1 << ( value & 0xf ) ); return( 0x9669 & 1 << ( value & 0xf ) );
} }
#define TEST_PARITY( value ) \ #define TEST_PARITY( value ) \
TEST_ASSERT( test_parity( value ) ) TEST_ASSERT( check_parity( value ) )
void algorithm_classification( psa_algorithm_t alg, unsigned flags ) void algorithm_classification( psa_algorithm_t alg, unsigned flags )
{ {
@ -497,7 +497,7 @@ void ecc_key_family( int curve_arg )
psa_key_type_t public_type = PSA_KEY_TYPE_ECC_PUBLIC_KEY( curve ); psa_key_type_t public_type = PSA_KEY_TYPE_ECC_PUBLIC_KEY( curve );
psa_key_type_t pair_type = PSA_KEY_TYPE_ECC_KEY_PAIR( curve ); psa_key_type_t pair_type = PSA_KEY_TYPE_ECC_KEY_PAIR( curve );
test_parity( curve ); TEST_PARITY( curve );
test_key_type( public_type, KEY_TYPE_IS_ECC | KEY_TYPE_IS_PUBLIC_KEY ); test_key_type( public_type, KEY_TYPE_IS_ECC | KEY_TYPE_IS_PUBLIC_KEY );
test_key_type( pair_type, KEY_TYPE_IS_ECC | KEY_TYPE_IS_KEY_PAIR ); test_key_type( pair_type, KEY_TYPE_IS_ECC | KEY_TYPE_IS_KEY_PAIR );
@ -514,7 +514,7 @@ void dh_key_family( int group_arg )
psa_key_type_t public_type = PSA_KEY_TYPE_DH_PUBLIC_KEY( group ); psa_key_type_t public_type = PSA_KEY_TYPE_DH_PUBLIC_KEY( group );
psa_key_type_t pair_type = PSA_KEY_TYPE_DH_KEY_PAIR( group ); psa_key_type_t pair_type = PSA_KEY_TYPE_DH_KEY_PAIR( group );
test_parity( group ); TEST_PARITY( group );
test_key_type( public_type, KEY_TYPE_IS_DH | KEY_TYPE_IS_PUBLIC_KEY ); test_key_type( public_type, KEY_TYPE_IS_DH | KEY_TYPE_IS_PUBLIC_KEY );
test_key_type( pair_type, KEY_TYPE_IS_DH | KEY_TYPE_IS_KEY_PAIR ); test_key_type( pair_type, KEY_TYPE_IS_DH | KEY_TYPE_IS_KEY_PAIR );