| From 6a2f9ac84d44e2644056322efbc108f2973152eb Mon Sep 17 00:00:00 2001 |
| From: Antonio de Angelis <Antonio.deAngelis@arm.com> |
| Date: Fri, 6 Oct 2023 10:20:44 +0100 |
| Subject: [PATCH 1/6] Add TF-M Builtin Key Loader driver entry points |
| |
| TF-M requires a mechanism to leverage the drivers and builtin keys |
| at the same time to allow for "transparent builtin keys". More details |
| are in the TF-M design doc. Provide directly the wrappers instead of |
| modifying the autogen scripts, for the time being. |
| |
| Signed-off-by: Raef Coles <raef.coles@arm.com> |
| Co-authored-by: Antonio de Angelis <antonio.deangelis@arm.com> |
| --- |
| library/psa_crypto.c | 10 +- |
| library/psa_crypto_driver_wrappers.h | 102 +++++++++++++++++- |
| .../psa_crypto_driver_wrappers_no_static.c | 40 ++++++- |
| 3 files changed, 143 insertions(+), 9 deletions(-) |
| |
| diff --git a/library/psa_crypto.c b/library/psa_crypto.c |
| index 1faf1dd6..52f34497 100644 |
| --- a/library/psa_crypto.c |
| +++ b/library/psa_crypto.c |
| @@ -85,6 +85,10 @@ |
| #include "mbedtls/sha512.h" |
| #include "md_psa.h" |
| |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| +#include "tfm_builtin_key_loader.h" |
| +#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */ |
| + |
| #if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF) || \ |
| defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXTRACT) || \ |
| defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXPAND) |
| @@ -1144,7 +1148,11 @@ static psa_status_t psa_get_and_lock_transparent_key_slot_with_policy( |
| return status; |
| } |
| |
| - if (psa_key_lifetime_is_external((*p_slot)->attr.lifetime)) { |
| + if (psa_key_lifetime_is_external((*p_slot)->attr.lifetime) |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + && PSA_KEY_LIFETIME_GET_LOCATION((*p_slot)->attr.lifetime) != TFM_BUILTIN_KEY_LOADER_KEY_LOCATION |
| +#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */ |
| + ) { |
| psa_unlock_key_slot(*p_slot); |
| *p_slot = NULL; |
| return PSA_ERROR_NOT_SUPPORTED; |
| diff --git a/library/psa_crypto_driver_wrappers.h b/library/psa_crypto_driver_wrappers.h |
| index 6ab95976..8b468b46 100644 |
| --- a/library/psa_crypto_driver_wrappers.h |
| +++ b/library/psa_crypto_driver_wrappers.h |
| @@ -54,16 +54,32 @@ |
| |
| #endif |
| |
| +/* Include TF-M builtin key driver */ |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| +#ifndef PSA_CRYPTO_DRIVER_PRESENT |
| +#define PSA_CRYPTO_DRIVER_PRESENT |
| +#endif |
| +#ifndef PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT |
| +#define PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT |
| +#endif |
| +#include "tfm_builtin_key_loader.h" |
| +#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */ |
| + |
| /* END-driver headers */ |
| |
| /* Auto-generated values depending on which drivers are registered. |
| * ID 0 is reserved for unallocated operations. |
| * ID 1 is reserved for the Mbed TLS software driver. */ |
| /* BEGIN-driver id definition */ |
| -#define PSA_CRYPTO_MBED_TLS_DRIVER_ID (1) |
| -#define MBEDTLS_TEST_OPAQUE_DRIVER_ID (2) |
| -#define MBEDTLS_TEST_TRANSPARENT_DRIVER_ID (3) |
| -#define P256_TRANSPARENT_DRIVER_ID (4) |
| +enum { |
| + PSA_CRYPTO_MBED_TLS_DRIVER_ID = 1, |
| + MBEDTLS_TEST_OPAQUE_DRIVER_ID, |
| + MBEDTLS_TEST_TRANSPARENT_DRIVER_ID, |
| + P256_TRANSPARENT_DRIVER_ID, |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + PSA_CRYPTO_TFM_BUILTIN_KEY_LOADER_DRIVER_ID, |
| +#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */ |
| +}; |
| |
| /* END-driver id */ |
| |
| @@ -85,6 +101,12 @@ static inline psa_status_t psa_driver_wrapper_init( void ) |
| { |
| psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; |
| |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + status = tfm_builtin_key_loader_init(); |
| + if (status != PSA_SUCCESS) |
| + return ( status ); |
| +#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */ |
| + |
| #if defined(MBEDTLS_PSA_CRYPTO_SE_C) |
| status = psa_init_all_se_drivers( ); |
| if( status != PSA_SUCCESS ) |
| @@ -138,6 +160,9 @@ static inline psa_status_t psa_driver_wrapper_sign_message( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -212,6 +237,9 @@ static inline psa_status_t psa_driver_wrapper_verify_message( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -299,6 +327,9 @@ static inline psa_status_t psa_driver_wrapper_sign_hash( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -403,6 +434,9 @@ static inline psa_status_t psa_driver_wrapper_verify_hash( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -532,6 +566,9 @@ static inline psa_status_t psa_driver_wrapper_sign_hash_start( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| |
| @@ -620,6 +657,9 @@ static inline psa_status_t psa_driver_wrapper_verify_hash_start( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| |
| @@ -765,6 +805,9 @@ static inline psa_status_t psa_driver_wrapper_generate_key( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| /* Transparent drivers are limited to generating asymmetric keys */ |
| if( PSA_KEY_TYPE_IS_ASYMMETRIC( attributes->core.type ) ) |
| @@ -865,6 +908,9 @@ static inline psa_status_t psa_driver_wrapper_import_key( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -966,6 +1012,9 @@ static inline psa_status_t psa_driver_wrapper_export_key( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| return( psa_export_key_internal( attributes, |
| key_buffer, |
| key_buffer_size, |
| @@ -1072,6 +1121,9 @@ static inline psa_status_t psa_driver_wrapper_cipher_encrypt( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -1162,6 +1214,9 @@ static inline psa_status_t psa_driver_wrapper_cipher_decrypt( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -1239,6 +1294,9 @@ static inline psa_status_t psa_driver_wrapper_cipher_encrypt_setup( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -1312,6 +1370,9 @@ static inline psa_status_t psa_driver_wrapper_cipher_decrypt_setup( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -1712,6 +1773,9 @@ static inline psa_status_t psa_driver_wrapper_aead_encrypt( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| |
| @@ -1764,6 +1828,9 @@ static inline psa_status_t psa_driver_wrapper_aead_decrypt( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| |
| @@ -1813,6 +1880,9 @@ static inline psa_status_t psa_driver_wrapper_aead_encrypt_setup( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| |
| @@ -1861,6 +1931,9 @@ static inline psa_status_t psa_driver_wrapper_aead_decrypt_setup( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| |
| @@ -2197,6 +2270,9 @@ static inline psa_status_t psa_driver_wrapper_mac_compute( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -2261,6 +2337,9 @@ static inline psa_status_t psa_driver_wrapper_mac_sign_setup( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -2333,6 +2412,9 @@ static inline psa_status_t psa_driver_wrapper_mac_verify_setup( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -2533,6 +2615,9 @@ static inline psa_status_t psa_driver_wrapper_asymmetric_encrypt( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -2591,6 +2676,9 @@ static inline psa_status_t psa_driver_wrapper_asymmetric_decrypt( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -2655,6 +2743,9 @@ static inline psa_status_t psa_driver_wrapper_key_agreement( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -2735,6 +2826,9 @@ static inline psa_status_t psa_driver_wrapper_pake_setup( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| status = PSA_ERROR_NOT_SUPPORTED; |
| diff --git a/library/psa_crypto_driver_wrappers_no_static.c b/library/psa_crypto_driver_wrappers_no_static.c |
| index de1511ba..af677746 100644 |
| --- a/library/psa_crypto_driver_wrappers_no_static.c |
| +++ b/library/psa_crypto_driver_wrappers_no_static.c |
| @@ -53,16 +53,32 @@ |
| |
| #endif |
| |
| +/* Include TF-M builtin key driver */ |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| +#ifndef PSA_CRYPTO_DRIVER_PRESENT |
| +#define PSA_CRYPTO_DRIVER_PRESENT |
| +#endif |
| +#ifndef PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT |
| +#define PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT |
| +#endif |
| +#include "tfm_builtin_key_loader.h" |
| +#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */ |
| + |
| /* END-driver headers */ |
| |
| /* Auto-generated values depending on which drivers are registered. |
| * ID 0 is reserved for unallocated operations. |
| * ID 1 is reserved for the Mbed TLS software driver. */ |
| /* BEGIN-driver id definition */ |
| -#define PSA_CRYPTO_MBED_TLS_DRIVER_ID (1) |
| -#define MBEDTLS_TEST_OPAQUE_DRIVER_ID (2) |
| -#define MBEDTLS_TEST_TRANSPARENT_DRIVER_ID (3) |
| -#define P256_TRANSPARENT_DRIVER_ID (4) |
| +enum { |
| + PSA_CRYPTO_MBED_TLS_DRIVER_ID = 1, |
| + MBEDTLS_TEST_OPAQUE_DRIVER_ID, |
| + MBEDTLS_TEST_TRANSPARENT_DRIVER_ID, |
| + P256_TRANSPARENT_DRIVER_ID, |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + PSA_CRYPTO_TFM_BUILTIN_KEY_LOADER_DRIVER_ID, |
| +#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */ |
| +}; |
| |
| /* END-driver id */ |
| |
| @@ -124,6 +140,12 @@ psa_status_t psa_driver_wrapper_get_key_buffer_size( |
| PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED ); |
| #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| + return tfm_builtin_key_loader_get_key_buffer_size(psa_get_key_id(attributes), |
| + key_buffer_size); |
| +#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */ |
| + |
| default: |
| (void)key_type; |
| (void)key_bits; |
| @@ -165,6 +187,9 @@ psa_status_t psa_driver_wrapper_export_public_key( |
| switch( location ) |
| { |
| case PSA_KEY_LOCATION_LOCAL_STORAGE: |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| +#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */ |
| /* Key is stored in the slot in export representation, so |
| * cycle through all known transparent accelerators */ |
| #if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT) |
| @@ -255,6 +280,13 @@ psa_status_t psa_driver_wrapper_get_builtin_key( |
| |
| |
| #endif /* PSA_CRYPTO_DRIVER_TEST */ |
| +#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) |
| + case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION: |
| + return( tfm_builtin_key_loader_get_builtin_key( |
| + slot_number, |
| + attributes, |
| + key_buffer, key_buffer_size, key_buffer_length ) ); |
| +#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */ |
| default: |
| (void) slot_number; |
| (void) key_buffer; |
| -- |
| 2.25.1 |
| |