Skip to content

Commit 0b12f32

Browse files
author
Andrzej Kurek
committed
Change the is_public_key_slot function to return a boolean value
1 parent a885a15 commit 0b12f32

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

atecc608a_se.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ static void pubkey_for_psa(uint8_t *data)
136136
data[0] = 0x4;
137137
}
138138

139-
static psa_status_t is_public_key_slot(uint16_t key_slot)
139+
static bool is_public_key_slot(uint16_t key_slot)
140140
{
141141
/* 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);
143143
}
144144

145145
psa_status_t atecc608a_init()
@@ -202,7 +202,9 @@ static psa_status_t atecc608a_import_public_key(
202202
psa_algorithm_t alg = psa_get_key_algorithm(attributes);
203203

204204
(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+
}
206208

207209
/* Check if the key has a size of 65 {0x04, X, Y}. */
208210
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,
333335
bool is_verified = false;
334336

335337
(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+
}
337341

338342
/* The driver can only do randomized ECDSA on SHA-256 */
339343
if (alg != PSA_ALG_ECDSA(PSA_ALG_SHA_256) && alg != PSA_ALG_ECDSA_ANY) {

0 commit comments

Comments
 (0)