Skip to content

Commit

Permalink
Disconnect knowing about a PSA key type from knowing the mbedTLS API
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
  • Loading branch information
stevew817 committed Jul 24, 2020
1 parent 560c28a commit c92b0e2
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions library/psa_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,22 +951,33 @@ psa_status_t psa_import_key_into_slot( psa_key_slot_t *slot,
* caller, which may be 0 (meaning unspecified) or wrong. */
slot->attr.bits = (psa_key_bits_t) bit_size;
}
else
else if( PSA_KEY_TYPE_IS_ECC( slot->attr.type ) )
{
#if defined(MBEDTLS_ECP_C)
if( PSA_KEY_TYPE_IS_ECC( slot->attr.type ) )
status = psa_import_ecp_key( slot,
data, data_length );
#else
/* No drivers have been implemented yet, so without mbed TLS backing
* there's no way to do ECP with the current library. */
return( PSA_ERROR_NOT_SUPPORTED );
#endif /* defined(MBEDTLS_ECP_C) */
}
else if( PSA_KEY_TYPE_IS_RSA( slot->attr.type ) )
{
status = psa_import_ecp_key( slot, data, data_length );
#if defined(MBEDTLS_RSA_C)
status = psa_import_rsa_key( slot,
data, data_length );
#else
/* No drivers have been implemented yet, so without mbed TLS backing
* there's no way to do RSA with the current library. */
status = PSA_ERROR_NOT_SUPPORTED;
#endif /* defined(MBEDTLS_RSA_C) */
}
else
#endif /* MBEDTLS_ECP_C */
#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_PK_PARSE_C)
if( PSA_KEY_TYPE_IS_RSA( slot->attr.type ) )
{
status = psa_import_rsa_key( slot, data, data_length );
}
else
#endif /* defined(MBEDTLS_RSA_C) && defined(MBEDTLS_PK_PARSE_C) */
{
/* Unknown key type */
return( PSA_ERROR_NOT_SUPPORTED );
}

Expand Down

0 comments on commit c92b0e2

Please sign in to comment.