Skip to content

Commit 47b6730

Browse files
adeaarmtomi-font
authored andcommitted
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> applied using: git am modules/tee/tf-m/trusted-firmware-m/lib/ext/mbedcrypto/\ 0001-Add-TF-M-Builtin-Key-Loader-driver-entry-points.patch Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
1 parent b5ac64f commit 47b6730

3 files changed

+143
-9
lines changed

library/psa_crypto.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
#include "mbedtls/psa_util.h"
7474
#include "mbedtls/threading.h"
7575

76+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
77+
#include "tfm_builtin_key_loader.h"
78+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
79+
7680
#if defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF) || \
7781
defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXTRACT) || \
7882
defined(MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXPAND)
@@ -1166,7 +1170,11 @@ static psa_status_t psa_get_and_lock_transparent_key_slot_with_policy(
11661170
return status;
11671171
}
11681172

1169-
if (psa_key_lifetime_is_external((*p_slot)->attr.lifetime)) {
1173+
if (psa_key_lifetime_is_external((*p_slot)->attr.lifetime)
1174+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
1175+
&& PSA_KEY_LIFETIME_GET_LOCATION((*p_slot)->attr.lifetime) != TFM_BUILTIN_KEY_LOADER_KEY_LOCATION
1176+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
1177+
) {
11701178
psa_unregister_read_under_mutex(*p_slot);
11711179
*p_slot = NULL;
11721180
return PSA_ERROR_NOT_SUPPORTED;

library/psa_crypto_driver_wrappers.h

+98-4
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,32 @@
4242

4343
#endif
4444

45+
/* Include TF-M builtin key driver */
46+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
47+
#ifndef PSA_CRYPTO_DRIVER_PRESENT
48+
#define PSA_CRYPTO_DRIVER_PRESENT
49+
#endif
50+
#ifndef PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT
51+
#define PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT
52+
#endif
53+
#include "tfm_builtin_key_loader.h"
54+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
55+
4556
/* END-driver headers */
4657

4758
/* Auto-generated values depending on which drivers are registered.
4859
* ID 0 is reserved for unallocated operations.
4960
* ID 1 is reserved for the Mbed TLS software driver. */
5061
/* BEGIN-driver id definition */
51-
#define PSA_CRYPTO_MBED_TLS_DRIVER_ID (1)
52-
#define MBEDTLS_TEST_OPAQUE_DRIVER_ID (2)
53-
#define MBEDTLS_TEST_TRANSPARENT_DRIVER_ID (3)
54-
#define P256_TRANSPARENT_DRIVER_ID (4)
62+
enum {
63+
PSA_CRYPTO_MBED_TLS_DRIVER_ID = 1,
64+
MBEDTLS_TEST_OPAQUE_DRIVER_ID,
65+
MBEDTLS_TEST_TRANSPARENT_DRIVER_ID,
66+
P256_TRANSPARENT_DRIVER_ID,
67+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
68+
PSA_CRYPTO_TFM_BUILTIN_KEY_LOADER_DRIVER_ID,
69+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
70+
};
5571

5672
/* END-driver id */
5773

@@ -73,6 +89,12 @@ static inline psa_status_t psa_driver_wrapper_init( void )
7389
{
7490
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
7591

92+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
93+
status = tfm_builtin_key_loader_init();
94+
if (status != PSA_SUCCESS)
95+
return ( status );
96+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
97+
7698
#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
7799
status = psa_init_all_se_drivers( );
78100
if( status != PSA_SUCCESS )
@@ -126,6 +148,9 @@ static inline psa_status_t psa_driver_wrapper_sign_message(
126148
switch( location )
127149
{
128150
case PSA_KEY_LOCATION_LOCAL_STORAGE:
151+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
152+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
153+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
129154
/* Key is stored in the slot in export representation, so
130155
* cycle through all known transparent accelerators */
131156
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -200,6 +225,9 @@ static inline psa_status_t psa_driver_wrapper_verify_message(
200225
switch( location )
201226
{
202227
case PSA_KEY_LOCATION_LOCAL_STORAGE:
228+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
229+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
230+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
203231
/* Key is stored in the slot in export representation, so
204232
* cycle through all known transparent accelerators */
205233
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -287,6 +315,9 @@ static inline psa_status_t psa_driver_wrapper_sign_hash(
287315
switch( location )
288316
{
289317
case PSA_KEY_LOCATION_LOCAL_STORAGE:
318+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
319+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
320+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
290321
/* Key is stored in the slot in export representation, so
291322
* cycle through all known transparent accelerators */
292323
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -391,6 +422,9 @@ static inline psa_status_t psa_driver_wrapper_verify_hash(
391422
switch( location )
392423
{
393424
case PSA_KEY_LOCATION_LOCAL_STORAGE:
425+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
426+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
427+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
394428
/* Key is stored in the slot in export representation, so
395429
* cycle through all known transparent accelerators */
396430
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -521,6 +555,9 @@ static inline psa_status_t psa_driver_wrapper_sign_hash_start(
521555
switch( location )
522556
{
523557
case PSA_KEY_LOCATION_LOCAL_STORAGE:
558+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
559+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
560+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
524561
/* Key is stored in the slot in export representation, so
525562
* cycle through all known transparent accelerators */
526563

@@ -613,6 +650,9 @@ static inline psa_status_t psa_driver_wrapper_verify_hash_start(
613650
switch( location )
614651
{
615652
case PSA_KEY_LOCATION_LOCAL_STORAGE:
653+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
654+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
655+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
616656
/* Key is stored in the slot in export representation, so
617657
* cycle through all known transparent accelerators */
618658

@@ -775,6 +815,9 @@ static inline psa_status_t psa_driver_wrapper_generate_key(
775815
switch( location )
776816
{
777817
case PSA_KEY_LOCATION_LOCAL_STORAGE:
818+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
819+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
820+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
778821
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
779822
/* Transparent drivers are limited to generating asymmetric keys. */
780823
/* We don't support passing custom production parameters
@@ -879,6 +922,9 @@ static inline psa_status_t psa_driver_wrapper_import_key(
879922
switch( location )
880923
{
881924
case PSA_KEY_LOCATION_LOCAL_STORAGE:
925+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
926+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
927+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
882928
/* Key is stored in the slot in export representation, so
883929
* cycle through all known transparent accelerators */
884930
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -980,6 +1026,9 @@ static inline psa_status_t psa_driver_wrapper_export_key(
9801026
switch( location )
9811027
{
9821028
case PSA_KEY_LOCATION_LOCAL_STORAGE:
1029+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
1030+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
1031+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
9831032
return( psa_export_key_internal( attributes,
9841033
key_buffer,
9851034
key_buffer_size,
@@ -1086,6 +1135,9 @@ static inline psa_status_t psa_driver_wrapper_cipher_encrypt(
10861135
switch( location )
10871136
{
10881137
case PSA_KEY_LOCATION_LOCAL_STORAGE:
1138+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
1139+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
1140+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
10891141
/* Key is stored in the slot in export representation, so
10901142
* cycle through all known transparent accelerators */
10911143
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -1176,6 +1228,9 @@ static inline psa_status_t psa_driver_wrapper_cipher_decrypt(
11761228
switch( location )
11771229
{
11781230
case PSA_KEY_LOCATION_LOCAL_STORAGE:
1231+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
1232+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
1233+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
11791234
/* Key is stored in the slot in export representation, so
11801235
* cycle through all known transparent accelerators */
11811236
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -1253,6 +1308,9 @@ static inline psa_status_t psa_driver_wrapper_cipher_encrypt_setup(
12531308
switch( location )
12541309
{
12551310
case PSA_KEY_LOCATION_LOCAL_STORAGE:
1311+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
1312+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
1313+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
12561314
/* Key is stored in the slot in export representation, so
12571315
* cycle through all known transparent accelerators */
12581316
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -1326,6 +1384,9 @@ static inline psa_status_t psa_driver_wrapper_cipher_decrypt_setup(
13261384
switch( location )
13271385
{
13281386
case PSA_KEY_LOCATION_LOCAL_STORAGE:
1387+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
1388+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
1389+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
13291390
/* Key is stored in the slot in export representation, so
13301391
* cycle through all known transparent accelerators */
13311392
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -1726,6 +1787,9 @@ static inline psa_status_t psa_driver_wrapper_aead_encrypt(
17261787
switch( location )
17271788
{
17281789
case PSA_KEY_LOCATION_LOCAL_STORAGE:
1790+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
1791+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
1792+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
17291793
/* Key is stored in the slot in export representation, so
17301794
* cycle through all known transparent accelerators */
17311795

@@ -1778,6 +1842,9 @@ static inline psa_status_t psa_driver_wrapper_aead_decrypt(
17781842
switch( location )
17791843
{
17801844
case PSA_KEY_LOCATION_LOCAL_STORAGE:
1845+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
1846+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
1847+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
17811848
/* Key is stored in the slot in export representation, so
17821849
* cycle through all known transparent accelerators */
17831850

@@ -1827,6 +1894,9 @@ static inline psa_status_t psa_driver_wrapper_aead_encrypt_setup(
18271894
switch( location )
18281895
{
18291896
case PSA_KEY_LOCATION_LOCAL_STORAGE:
1897+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
1898+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
1899+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
18301900
/* Key is stored in the slot in export representation, so
18311901
* cycle through all known transparent accelerators */
18321902

@@ -1875,6 +1945,9 @@ static inline psa_status_t psa_driver_wrapper_aead_decrypt_setup(
18751945
switch( location )
18761946
{
18771947
case PSA_KEY_LOCATION_LOCAL_STORAGE:
1948+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
1949+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
1950+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
18781951
/* Key is stored in the slot in export representation, so
18791952
* cycle through all known transparent accelerators */
18801953

@@ -2211,6 +2284,9 @@ static inline psa_status_t psa_driver_wrapper_mac_compute(
22112284
switch( location )
22122285
{
22132286
case PSA_KEY_LOCATION_LOCAL_STORAGE:
2287+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
2288+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
2289+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
22142290
/* Key is stored in the slot in export representation, so
22152291
* cycle through all known transparent accelerators */
22162292
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -2275,6 +2351,9 @@ static inline psa_status_t psa_driver_wrapper_mac_sign_setup(
22752351
switch( location )
22762352
{
22772353
case PSA_KEY_LOCATION_LOCAL_STORAGE:
2354+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
2355+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
2356+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
22782357
/* Key is stored in the slot in export representation, so
22792358
* cycle through all known transparent accelerators */
22802359
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -2347,6 +2426,9 @@ static inline psa_status_t psa_driver_wrapper_mac_verify_setup(
23472426
switch( location )
23482427
{
23492428
case PSA_KEY_LOCATION_LOCAL_STORAGE:
2429+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
2430+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
2431+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
23502432
/* Key is stored in the slot in export representation, so
23512433
* cycle through all known transparent accelerators */
23522434
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -2547,6 +2629,9 @@ static inline psa_status_t psa_driver_wrapper_asymmetric_encrypt(
25472629
switch( location )
25482630
{
25492631
case PSA_KEY_LOCATION_LOCAL_STORAGE:
2632+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
2633+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
2634+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
25502635
/* Key is stored in the slot in export representation, so
25512636
* cycle through all known transparent accelerators */
25522637
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -2605,6 +2690,9 @@ static inline psa_status_t psa_driver_wrapper_asymmetric_decrypt(
26052690
switch( location )
26062691
{
26072692
case PSA_KEY_LOCATION_LOCAL_STORAGE:
2693+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
2694+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
2695+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
26082696
/* Key is stored in the slot in export representation, so
26092697
* cycle through all known transparent accelerators */
26102698
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -2669,6 +2757,9 @@ static inline psa_status_t psa_driver_wrapper_key_agreement(
26692757
switch( location )
26702758
{
26712759
case PSA_KEY_LOCATION_LOCAL_STORAGE:
2760+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
2761+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
2762+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
26722763
/* Key is stored in the slot in export representation, so
26732764
* cycle through all known transparent accelerators */
26742765
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -2749,6 +2840,9 @@ static inline psa_status_t psa_driver_wrapper_pake_setup(
27492840
switch( location )
27502841
{
27512842
case PSA_KEY_LOCATION_LOCAL_STORAGE:
2843+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
2844+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
2845+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
27522846
/* Key is stored in the slot in export representation, so
27532847
* cycle through all known transparent accelerators */
27542848
status = PSA_ERROR_NOT_SUPPORTED;

library/psa_crypto_driver_wrappers_no_static.c

+36-4
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,32 @@
4141

4242
#endif
4343

44+
/* Include TF-M builtin key driver */
45+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
46+
#ifndef PSA_CRYPTO_DRIVER_PRESENT
47+
#define PSA_CRYPTO_DRIVER_PRESENT
48+
#endif
49+
#ifndef PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT
50+
#define PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT
51+
#endif
52+
#include "tfm_builtin_key_loader.h"
53+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
54+
4455
/* END-driver headers */
4556

4657
/* Auto-generated values depending on which drivers are registered.
4758
* ID 0 is reserved for unallocated operations.
4859
* ID 1 is reserved for the Mbed TLS software driver. */
4960
/* BEGIN-driver id definition */
50-
#define PSA_CRYPTO_MBED_TLS_DRIVER_ID (1)
51-
#define MBEDTLS_TEST_OPAQUE_DRIVER_ID (2)
52-
#define MBEDTLS_TEST_TRANSPARENT_DRIVER_ID (3)
53-
#define P256_TRANSPARENT_DRIVER_ID (4)
61+
enum {
62+
PSA_CRYPTO_MBED_TLS_DRIVER_ID = 1,
63+
MBEDTLS_TEST_OPAQUE_DRIVER_ID,
64+
MBEDTLS_TEST_TRANSPARENT_DRIVER_ID,
65+
P256_TRANSPARENT_DRIVER_ID,
66+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
67+
PSA_CRYPTO_TFM_BUILTIN_KEY_LOADER_DRIVER_ID,
68+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
69+
};
5470

5571
/* END-driver id */
5672

@@ -112,6 +128,12 @@ psa_status_t psa_driver_wrapper_get_key_buffer_size(
112128
PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED );
113129
#endif /* PSA_CRYPTO_DRIVER_TEST */
114130

131+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
132+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
133+
return tfm_builtin_key_loader_get_key_buffer_size(psa_get_key_id(attributes),
134+
key_buffer_size);
135+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
136+
115137
default:
116138
(void)key_type;
117139
(void)key_bits;
@@ -153,6 +175,9 @@ psa_status_t psa_driver_wrapper_export_public_key(
153175
switch( location )
154176
{
155177
case PSA_KEY_LOCATION_LOCAL_STORAGE:
178+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
179+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
180+
#endif /* defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER) */
156181
/* Key is stored in the slot in export representation, so
157182
* cycle through all known transparent accelerators */
158183
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT)
@@ -241,6 +266,13 @@ psa_status_t psa_driver_wrapper_get_builtin_key(
241266
));
242267
#endif
243268

269+
#if defined(PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER)
270+
case TFM_BUILTIN_KEY_LOADER_KEY_LOCATION:
271+
return( tfm_builtin_key_loader_get_builtin_key(
272+
slot_number,
273+
attributes,
274+
key_buffer, key_buffer_size, key_buffer_length ) );
275+
#endif /* PSA_CRYPTO_DRIVER_TFM_BUILTIN_KEY_LOADER */
244276

245277
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
246278
default:

0 commit comments

Comments
 (0)