@@ -136,10 +136,10 @@ static void pubkey_for_psa(uint8_t *data)
136
136
data [0 ] = 0x4 ;
137
137
}
138
138
139
- static psa_status_t is_public_key_slot (uint16_t key_slot )
139
+ static bool is_public_key_slot (uint16_t key_slot )
140
140
{
141
141
/* Keys 8 to 15 can store public keys. Slots 1-7 are too small. */
142
- return (( key_slot >= 8 && key_slot <= 15 ) ? PSA_SUCCESS : PSA_ERROR_INVALID_ARGUMENT );
142
+ return (key_slot >= 8 && key_slot <= 15 );
143
143
}
144
144
145
145
psa_status_t atecc608a_init ()
@@ -202,7 +202,9 @@ static psa_status_t atecc608a_import_public_key(
202
202
psa_algorithm_t alg = psa_get_key_algorithm (attributes );
203
203
204
204
(void ) drv_context ;
205
- ASSERT_SUCCESS_PSA (is_public_key_slot (key_id ));
205
+ if (!is_public_key_slot (key_id )) {
206
+ return PSA_ERROR_INVALID_ARGUMENT ;
207
+ }
206
208
207
209
/* Check if the key has a size of 65 {0x04, X, Y}. */
208
210
if (data_length != PSA_KEY_EXPORT_MAX_SIZE (PSA_KEY_TYPE_ECC_PUBLIC_KEY (
@@ -333,7 +335,9 @@ psa_status_t atecc608a_asymmetric_verify(psa_drv_se_context_t *drv_context,
333
335
bool is_verified = false;
334
336
335
337
(void ) drv_context ;
336
- ASSERT_SUCCESS_PSA (is_public_key_slot (key_id ));
338
+ if (!is_public_key_slot (key_id )) {
339
+ return PSA_ERROR_INVALID_ARGUMENT ;
340
+ }
337
341
338
342
/* The driver can only do randomized ECDSA on SHA-256 */
339
343
if (alg != PSA_ALG_ECDSA (PSA_ALG_SHA_256 ) && alg != PSA_ALG_ECDSA_ANY ) {
0 commit comments