@@ -82,42 +82,42 @@ static int cracen_signature_set_hashalgo_from_digestsz(const struct sxhashalg **
82
82
}
83
83
#endif /* PSA_MAX_RSA_KEY_BITS > 0 */
84
84
85
- static int cracen_signature_prepare_ec_pubkey (const char * key_buffer , size_t key_buffer_size ,
86
- const struct sx_pk_ecurve * * sicurve ,
87
- psa_algorithm_t alg ,
88
- const psa_key_attributes_t * attributes ,
89
- char * pubkey_buffer )
85
+ static psa_status_t
86
+ cracen_signature_prepare_ec_pubkey (const char * key_buffer , size_t key_buffer_size ,
87
+ const struct sx_pk_ecurve * * sicurve , psa_algorithm_t alg ,
88
+ const psa_key_attributes_t * attributes , char * pubkey_buffer )
90
89
{
91
90
size_t curvesz = PSA_BITS_TO_BYTES (psa_get_key_bits (attributes ));
92
- int status ;
91
+ psa_status_t psa_status ;
92
+ int sx_status ;
93
93
94
- status = cracen_ecc_get_ecurve_from_psa (
94
+ psa_status = cracen_ecc_get_ecurve_from_psa (
95
95
PSA_KEY_TYPE_ECC_GET_FAMILY (psa_get_key_type (attributes )),
96
96
psa_get_key_bits (attributes ), sicurve );
97
- if (status ) {
98
- return status ;
97
+ if (psa_status != PSA_SUCCESS ) {
98
+ return psa_status ;
99
99
}
100
100
101
- status = SX_ERR_INCOMPATIBLE_HW ;
101
+ sx_status = SX_ERR_INCOMPATIBLE_HW ;
102
102
if (PSA_KEY_LIFETIME_GET_LOCATION (psa_get_key_lifetime (attributes )) ==
103
103
PSA_KEY_LOCATION_CRACEN ) {
104
104
if (IS_ENABLED (CONFIG_CRACEN_IKG )) {
105
105
if (key_buffer_size != sizeof (ikg_opaque_key )) {
106
106
return PSA_ERROR_INVALID_ARGUMENT ;
107
107
}
108
- status = cracen_ikg_create_pub_key (key_buffer [0 ], pubkey_buffer );
108
+ sx_status = cracen_ikg_create_pub_key (key_buffer [0 ], pubkey_buffer );
109
109
}
110
- return status ;
110
+ return silex_statuscodes_to_psa ( sx_status ) ;
111
111
}
112
112
113
113
if (IS_ENABLED (PSA_NEED_CRACEN_PURE_EDDSA_TWISTED_EDWARDS_255 )) {
114
114
if (alg == PSA_ALG_PURE_EDDSA || alg == PSA_ALG_ED25519PH ) {
115
115
if (PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY (psa_get_key_type (attributes ))) {
116
116
memcpy (pubkey_buffer , key_buffer , key_buffer_size );
117
- return SX_OK ;
117
+ return PSA_SUCCESS ;
118
118
}
119
- status = cracen_ed25519_create_pubkey (key_buffer , pubkey_buffer );
120
- return status ;
119
+ sx_status = cracen_ed25519_create_pubkey (key_buffer , pubkey_buffer );
120
+ return silex_statuscodes_to_psa ( sx_status ) ;
121
121
}
122
122
}
123
123
@@ -132,19 +132,19 @@ static int cracen_signature_prepare_ec_pubkey(const char *key_buffer, size_t key
132
132
*/
133
133
if ((key_buffer [0 ] != CRACEN_ECC_PUBKEY_UNCOMPRESSED ) ||
134
134
((2 * curvesz + 1 ) != key_buffer_size )) {
135
- return SX_ERR_INVALID_KEY_SZ ;
135
+ return PSA_ERROR_INVALID_ARGUMENT ;
136
136
}
137
137
138
138
/* key_buffer + 1 to skip the 0x4 flag in the first byte */
139
139
memcpy (pubkey_buffer , key_buffer + 1 , key_buffer_size - 1 );
140
- return SX_OK ;
140
+ return PSA_SUCCESS ;
141
141
142
142
} else {
143
- status = ecc_genpubkey (key_buffer , pubkey_buffer , * sicurve );
143
+ sx_status = ecc_genpubkey (key_buffer , pubkey_buffer , * sicurve );
144
144
}
145
145
}
146
146
}
147
- return status ;
147
+ return silex_statuscodes_to_psa ( sx_status ) ;
148
148
}
149
149
150
150
static psa_status_t validate_key_attributes (const psa_key_attributes_t * attributes ,
@@ -359,12 +359,13 @@ static psa_status_t cracen_signature_ecc_verify(bool is_message,
359
359
size_t input_length , const uint8_t * signature ,
360
360
size_t signature_length )
361
361
{
362
+ int sx_status ;
363
+ psa_status_t psa_status ;
362
364
psa_key_type_t key_type = psa_get_key_type (attributes );
363
365
364
- psa_status_t status = validate_ec_signature_inputs (is_message , attributes , key_type , alg );
365
-
366
- if (status != PSA_SUCCESS ) {
367
- return status ;
366
+ psa_status = validate_ec_signature_inputs (is_message , attributes , key_type , alg );
367
+ if (psa_status != PSA_SUCCESS ) {
368
+ return psa_status ;
368
369
}
369
370
370
371
const size_t public_key_size =
@@ -376,10 +377,10 @@ static psa_status_t cracen_signature_ecc_verify(bool is_message,
376
377
uint8_t pubkey_buffer [public_key_size ];
377
378
const struct sx_pk_ecurve * curve = NULL ;
378
379
379
- int sx_status = cracen_signature_prepare_ec_pubkey (key_buffer , key_buffer_size , & curve , alg ,
380
+ psa_status = cracen_signature_prepare_ec_pubkey (key_buffer , key_buffer_size , & curve , alg ,
380
381
attributes , pubkey_buffer );
381
- if (sx_status != SX_OK ) {
382
- return silex_statuscodes_to_psa ( sx_status ) ;
382
+ if (psa_status != PSA_SUCCESS ) {
383
+ return psa_status ;
383
384
}
384
385
if (signature_length != 2 * curve -> sz ) {
385
386
return PSA_ERROR_INVALID_SIGNATURE ;
@@ -400,14 +401,14 @@ static psa_status_t cracen_signature_ecc_verify(bool is_message,
400
401
struct sxhashalg hashalg = {0 };
401
402
const struct sxhashalg * hash_algorithm_ptr = & hashalg ;
402
403
403
- status = cracen_ecc_get_ecurve_from_psa (PSA_KEY_TYPE_ECC_GET_FAMILY (key_type ),
404
+ psa_status = cracen_ecc_get_ecurve_from_psa (PSA_KEY_TYPE_ECC_GET_FAMILY (key_type ),
404
405
psa_get_key_bits (attributes ), & curve );
405
- if (status != PSA_SUCCESS ) {
406
- return status ;
406
+ if (psa_status != PSA_SUCCESS ) {
407
+ return psa_status ;
407
408
}
408
- status = hash_get_algo (alg , & hash_algorithm_ptr );
409
- if (status != PSA_SUCCESS ) {
410
- return status ;
409
+ psa_status = hash_get_algo (alg , & hash_algorithm_ptr );
410
+ if (psa_status != PSA_SUCCESS ) {
411
+ return psa_status ;
411
412
}
412
413
sx_status = is_message ? cracen_ecdsa_verify_message (pubkey_buffer ,
413
414
hash_algorithm_ptr , input ,
0 commit comments