mirror of
https://github.com/espressif/mbedtls.git
synced 2026-06-05 21:14:47 +00:00
feat(psa): Add generic secure element PSA driver dispatch
Add dispatch wrappers for secure element opaque sign, transparent verify, import key, and export public key operations.
This commit is contained in:
committed by
Ashish Sharma
parent
6097a0e6d3
commit
0e4c264731
@@ -85,9 +85,9 @@
|
||||
|
||||
#endif
|
||||
|
||||
/* Headers for atca_ecdsa opaque driver */
|
||||
#if defined(ATCA_ECDSA_DRIVER_ENABLED)
|
||||
#include "../../../port/psa_driver/include/psa_crypto_driver_atca_ecdsa.h"
|
||||
/* Headers for secure element opaque driver */
|
||||
#if defined(SECURE_ELEMENT_DRIVER_ENABLED)
|
||||
#include "../../../port/psa_driver/include/psa_crypto_driver_secure_element.h"
|
||||
#endif
|
||||
/* END-driver headers */
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
#define ESP_CMAC_TRANSPARENT_DRIVER_ID (11)
|
||||
#define ESP_HMAC_TRANSPARENT_DRIVER_ID (12)
|
||||
#define ESP_HMAC_OPAQUE_DRIVER_ID (13)
|
||||
#define ATCA_ECDSA_OPAQUE_DRIVER_ID (14)
|
||||
#define SECURE_ELEMENT_OPAQUE_DRIVER_ID (14)
|
||||
|
||||
/* END-driver id */
|
||||
|
||||
@@ -399,15 +399,15 @@ static inline psa_status_t psa_driver_wrapper_sign_hash(
|
||||
}
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
#endif /* ESP_RSA_DS_DRIVER_ENABLED */
|
||||
#if defined(ATCA_ECDSA_DRIVER_ENABLED) && defined(ATCA_ECDSA_SIGN_DRIVER_ENABLED)
|
||||
case PSA_KEY_LOCATION_ATCA_ECDSA:
|
||||
return( atca_ecdsa_opaque_sign_hash(
|
||||
#if defined(SECURE_ELEMENT_DRIVER_ENABLED)
|
||||
case PSA_KEY_LOCATION_SECURE_ELEMENT:
|
||||
return( secure_element_opaque_sign_hash(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
alg, hash, hash_length,
|
||||
signature, signature_size,
|
||||
signature_length ) );
|
||||
#endif /* ATCA_ECDSA_DRIVER_ENABLED && ATCA_ECDSA_SIGN_DRIVER_ENABLED */
|
||||
#endif /* SECURE_ELEMENT_DRIVER_ENABLED */
|
||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||
default:
|
||||
/* Key is declared with a lifetime not known to us */
|
||||
@@ -482,8 +482,8 @@ static inline psa_status_t psa_driver_wrapper_verify_hash(
|
||||
return( status );
|
||||
}
|
||||
#endif /* MBEDTLS_PSA_P256M_DRIVER_ENABLED */
|
||||
#if defined(ATCA_ECDSA_DRIVER_ENABLED) && defined(ATCA_ECDSA_VERIFY_DRIVER_ENABLED)
|
||||
status = atca_ecdsa_transparent_verify_hash(
|
||||
#if defined(SECURE_ELEMENT_DRIVER_ENABLED)
|
||||
status = secure_element_transparent_verify_hash(
|
||||
attributes,
|
||||
key_buffer,
|
||||
key_buffer_size,
|
||||
@@ -494,7 +494,7 @@ static inline psa_status_t psa_driver_wrapper_verify_hash(
|
||||
signature_length );
|
||||
if( status != PSA_ERROR_NOT_SUPPORTED )
|
||||
return( status );
|
||||
#endif /* ATCA_ECDSA_DRIVER_ENABLED && ATCA_ECDSA_VERIFY_DRIVER_ENABLED */
|
||||
#endif /* SECURE_ELEMENT_DRIVER_ENABLED */
|
||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||
|
||||
return( psa_verify_hash_builtin( attributes,
|
||||
@@ -930,13 +930,13 @@ static inline psa_status_t psa_driver_wrapper_get_key_buffer_size_from_key_data(
|
||||
PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED );
|
||||
#endif /* defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED) */
|
||||
|
||||
#if defined(ATCA_ECDSA_DRIVER_ENABLED) && defined(ATCA_ECDSA_SIGN_DRIVER_ENABLED)
|
||||
case PSA_KEY_LOCATION_ATCA_ECDSA:
|
||||
*key_buffer_size = atca_ecdsa_opaque_size_function( key_type,
|
||||
#if defined(SECURE_ELEMENT_DRIVER_ENABLED)
|
||||
case PSA_KEY_LOCATION_SECURE_ELEMENT:
|
||||
*key_buffer_size = secure_element_opaque_size_function( key_type,
|
||||
PSA_BYTES_TO_BITS( data_length ) );
|
||||
return( ( *key_buffer_size != 0 ) ?
|
||||
PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED );
|
||||
#endif /* ATCA_ECDSA_DRIVER_ENABLED && ATCA_ECDSA_SIGN_DRIVER_ENABLED */
|
||||
#endif /* SECURE_ELEMENT_DRIVER_ENABLED */
|
||||
|
||||
default:
|
||||
(void)key_type;
|
||||
@@ -1138,14 +1138,14 @@ static inline psa_status_t psa_driver_wrapper_import_key(
|
||||
));
|
||||
#endif /* ESP_RSA_DS_DRIVER_ENABLED */
|
||||
|
||||
#if defined(ATCA_ECDSA_DRIVER_ENABLED) && defined(ATCA_ECDSA_SIGN_DRIVER_ENABLED)
|
||||
case PSA_KEY_LOCATION_ATCA_ECDSA:
|
||||
return( atca_ecdsa_opaque_import_key(
|
||||
#if defined(SECURE_ELEMENT_DRIVER_ENABLED)
|
||||
case PSA_KEY_LOCATION_SECURE_ELEMENT:
|
||||
return( secure_element_opaque_import_key(
|
||||
attributes,
|
||||
data, data_length,
|
||||
key_buffer, key_buffer_size,
|
||||
key_buffer_length, bits ) );
|
||||
#endif /* ATCA_ECDSA_DRIVER_ENABLED && ATCA_ECDSA_SIGN_DRIVER_ENABLED */
|
||||
#endif /* SECURE_ELEMENT_DRIVER_ENABLED */
|
||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||
default:
|
||||
(void)status;
|
||||
|
||||
@@ -46,9 +46,9 @@
|
||||
|
||||
#endif
|
||||
|
||||
/* Headers for atca_ecdsa opaque driver */
|
||||
#if defined(ATCA_ECDSA_DRIVER_ENABLED)
|
||||
#include "../../../port/psa_driver/include/psa_crypto_driver_atca_ecdsa.h"
|
||||
/* Headers for secure element opaque driver */
|
||||
#if defined(SECURE_ELEMENT_DRIVER_ENABLED)
|
||||
#include "../../../port/psa_driver/include/psa_crypto_driver_secure_element.h"
|
||||
#endif
|
||||
|
||||
/* END-driver headers */
|
||||
@@ -112,13 +112,13 @@ psa_status_t psa_driver_wrapper_get_key_buffer_size(
|
||||
PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED );
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
#if defined(ATCA_ECDSA_DRIVER_ENABLED) && defined(ATCA_ECDSA_SIGN_DRIVER_ENABLED)
|
||||
case PSA_KEY_LOCATION_ATCA_ECDSA:
|
||||
*key_buffer_size = atca_ecdsa_opaque_size_function( key_type,
|
||||
key_bits );
|
||||
#if defined(SECURE_ELEMENT_DRIVER_ENABLED)
|
||||
case PSA_KEY_LOCATION_SECURE_ELEMENT:
|
||||
*key_buffer_size = secure_element_opaque_size_function( key_type,
|
||||
key_bits );
|
||||
return( ( *key_buffer_size != 0 ) ?
|
||||
PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED );
|
||||
#endif /* ATCA_ECDSA_DRIVER_ENABLED && ATCA_ECDSA_SIGN_DRIVER_ENABLED */
|
||||
#endif /* SECURE_ELEMENT_DRIVER_ENABLED */
|
||||
|
||||
default:
|
||||
(void)key_type;
|
||||
@@ -215,19 +215,13 @@ psa_status_t psa_driver_wrapper_export_public_key(
|
||||
}
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
#endif /* defined(ESP_ECDSA_DRIVER_ENABLED) && defined(ESP_ECDSA_SIGN_DRIVER_ENABLED) */
|
||||
#if defined(ATCA_ECDSA_DRIVER_ENABLED) && defined(ATCA_ECDSA_SIGN_DRIVER_ENABLED)
|
||||
case PSA_KEY_LOCATION_ATCA_ECDSA:
|
||||
if( PSA_KEY_TYPE_IS_ECC( psa_get_key_type(attributes) ) &&
|
||||
PSA_ALG_IS_ECDSA( psa_get_key_algorithm(attributes) ) &&
|
||||
PSA_KEY_TYPE_ECC_GET_FAMILY(psa_get_key_type(attributes)) == PSA_ECC_FAMILY_SECP_R1)
|
||||
{
|
||||
return( atca_ecdsa_opaque_export_public_key(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
data, data_size, data_length ) );
|
||||
}
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
#endif /* ATCA_ECDSA_DRIVER_ENABLED && ATCA_ECDSA_SIGN_DRIVER_ENABLED */
|
||||
#if defined(SECURE_ELEMENT_DRIVER_ENABLED)
|
||||
case PSA_KEY_LOCATION_SECURE_ELEMENT:
|
||||
return( secure_element_opaque_export_public_key(
|
||||
attributes,
|
||||
key_buffer, key_buffer_size,
|
||||
data, data_size, data_length ) );
|
||||
#endif /* SECURE_ELEMENT_DRIVER_ENABLED */
|
||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||
default:
|
||||
/* Key is declared with a lifetime not known to us */
|
||||
|
||||
Reference in New Issue
Block a user