Skip to content

Commit 745e9cb

Browse files
committed
Add hook for signing using secure element
1 parent 91fb162 commit 745e9cb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

library/psa_crypto.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2997,6 +2997,7 @@ psa_status_t psa_asymmetric_sign( psa_key_handle_t handle,
29972997
{
29982998
psa_key_slot_t *slot;
29992999
psa_status_t status;
3000+
const psa_se_drv_table_entry_t *driver = NULL;
30003001

30013002
*signature_length = signature_size;
30023003

@@ -3009,6 +3010,24 @@ psa_status_t psa_asymmetric_sign( psa_key_handle_t handle,
30093010
goto exit;
30103011
}
30113012

3013+
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
3014+
driver = psa_get_se_driver_entry( slot->lifetime );
3015+
if( driver != NULL )
3016+
{
3017+
const psa_drv_se_t *drv = psa_get_se_driver_methods( driver );
3018+
if( drv->asymmetric == NULL ||
3019+
drv->asymmetric->p_sign == NULL )
3020+
{
3021+
status = PSA_ERROR_NOT_SUPPORTED;
3022+
goto exit;
3023+
}
3024+
status = drv->asymmetric->p_sign(
3025+
slot->data.se.slot_number, alg, hash, hash_length, signature,
3026+
signature_size, signature_length );
3027+
goto exit;
3028+
}
3029+
else
3030+
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
30123031
#if defined(MBEDTLS_RSA_C)
30133032
if( slot->type == PSA_KEY_TYPE_RSA_KEY_PAIR )
30143033
{

0 commit comments

Comments
 (0)