Reduce indentation need by checking negative case first

Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
Steven Cooreman 2021-04-06 15:09:19 +02:00
parent 43e4a406d9
commit 054bf7f2a0

View File

@ -173,8 +173,12 @@ psa_status_t test_opaque_export_key(
const uint8_t *key, size_t key_length,
uint8_t *data, size_t data_size, size_t *data_length )
{
if( key_length == sizeof( psa_drv_slot_number_t ) )
if( key_length != sizeof( psa_drv_slot_number_t ) )
{
/* Test driver does not support generic opaque key handling yet. */
return( PSA_ERROR_NOT_SUPPORTED );
}
/* Assume this is a builtin key based on the key material length. */
psa_drv_slot_number_t slot_number = *( ( psa_drv_slot_number_t* ) key );
@ -227,12 +231,6 @@ psa_status_t test_opaque_export_key(
default:
return( PSA_ERROR_DOES_NOT_EXIST );
}
}
else
{
/* Test driver does not support generic opaque key handling yet. */
return( PSA_ERROR_NOT_SUPPORTED );
}
}
psa_status_t test_transparent_export_public_key(
@ -295,8 +293,12 @@ psa_status_t test_opaque_export_public_key(
const uint8_t *key, size_t key_length,
uint8_t *data, size_t data_size, size_t *data_length )
{
if( key_length == sizeof( psa_drv_slot_number_t ) )
if( key_length != sizeof( psa_drv_slot_number_t ) )
{
/* Test driver does not support generic opaque key handling yet. */
return( PSA_ERROR_NOT_SUPPORTED );
}
/* Assume this is a builtin key based on the key material length. */
psa_drv_slot_number_t slot_number = *( ( psa_drv_slot_number_t* ) key );
switch( slot_number )
@ -324,12 +326,6 @@ psa_status_t test_opaque_export_public_key(
default:
return( PSA_ERROR_DOES_NOT_EXIST );
}
}
else
{
/* Test driver does not support generic opaque key handling yet. */
return( PSA_ERROR_NOT_SUPPORTED );
}
}
/* The opaque test driver exposes two built-in keys when builtin key support is