42
42
43
43
#endif
44
44
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
+
45
56
/* END-driver headers */
46
57
47
58
/* Auto-generated values depending on which drivers are registered.
48
59
* ID 0 is reserved for unallocated operations.
49
60
* ID 1 is reserved for the Mbed TLS software driver. */
50
61
/* 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
+ };
55
71
56
72
/* END-driver id */
57
73
@@ -73,6 +89,12 @@ static inline psa_status_t psa_driver_wrapper_init( void )
73
89
{
74
90
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED ;
75
91
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
+
76
98
#if defined(MBEDTLS_PSA_CRYPTO_SE_C )
77
99
status = psa_init_all_se_drivers ( );
78
100
if ( status != PSA_SUCCESS )
@@ -126,6 +148,9 @@ static inline psa_status_t psa_driver_wrapper_sign_message(
126
148
switch ( location )
127
149
{
128
150
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 */
129
154
/* Key is stored in the slot in export representation, so
130
155
* cycle through all known transparent accelerators */
131
156
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -200,6 +225,9 @@ static inline psa_status_t psa_driver_wrapper_verify_message(
200
225
switch ( location )
201
226
{
202
227
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 */
203
231
/* Key is stored in the slot in export representation, so
204
232
* cycle through all known transparent accelerators */
205
233
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -287,6 +315,9 @@ static inline psa_status_t psa_driver_wrapper_sign_hash(
287
315
switch ( location )
288
316
{
289
317
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 */
290
321
/* Key is stored in the slot in export representation, so
291
322
* cycle through all known transparent accelerators */
292
323
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -391,6 +422,9 @@ static inline psa_status_t psa_driver_wrapper_verify_hash(
391
422
switch ( location )
392
423
{
393
424
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 */
394
428
/* Key is stored in the slot in export representation, so
395
429
* cycle through all known transparent accelerators */
396
430
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -521,6 +555,9 @@ static inline psa_status_t psa_driver_wrapper_sign_hash_start(
521
555
switch ( location )
522
556
{
523
557
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 */
524
561
/* Key is stored in the slot in export representation, so
525
562
* cycle through all known transparent accelerators */
526
563
@@ -613,6 +650,9 @@ static inline psa_status_t psa_driver_wrapper_verify_hash_start(
613
650
switch ( location )
614
651
{
615
652
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 */
616
656
/* Key is stored in the slot in export representation, so
617
657
* cycle through all known transparent accelerators */
618
658
@@ -775,6 +815,9 @@ static inline psa_status_t psa_driver_wrapper_generate_key(
775
815
switch ( location )
776
816
{
777
817
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 */
778
821
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
779
822
/* Transparent drivers are limited to generating asymmetric keys. */
780
823
/* We don't support passing custom production parameters
@@ -879,6 +922,9 @@ static inline psa_status_t psa_driver_wrapper_import_key(
879
922
switch ( location )
880
923
{
881
924
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 */
882
928
/* Key is stored in the slot in export representation, so
883
929
* cycle through all known transparent accelerators */
884
930
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -980,6 +1026,9 @@ static inline psa_status_t psa_driver_wrapper_export_key(
980
1026
switch ( location )
981
1027
{
982
1028
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 */
983
1032
return ( psa_export_key_internal ( attributes ,
984
1033
key_buffer ,
985
1034
key_buffer_size ,
@@ -1086,6 +1135,9 @@ static inline psa_status_t psa_driver_wrapper_cipher_encrypt(
1086
1135
switch ( location )
1087
1136
{
1088
1137
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 */
1089
1141
/* Key is stored in the slot in export representation, so
1090
1142
* cycle through all known transparent accelerators */
1091
1143
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -1176,6 +1228,9 @@ static inline psa_status_t psa_driver_wrapper_cipher_decrypt(
1176
1228
switch ( location )
1177
1229
{
1178
1230
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 */
1179
1234
/* Key is stored in the slot in export representation, so
1180
1235
* cycle through all known transparent accelerators */
1181
1236
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -1253,6 +1308,9 @@ static inline psa_status_t psa_driver_wrapper_cipher_encrypt_setup(
1253
1308
switch ( location )
1254
1309
{
1255
1310
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 */
1256
1314
/* Key is stored in the slot in export representation, so
1257
1315
* cycle through all known transparent accelerators */
1258
1316
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -1326,6 +1384,9 @@ static inline psa_status_t psa_driver_wrapper_cipher_decrypt_setup(
1326
1384
switch ( location )
1327
1385
{
1328
1386
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 */
1329
1390
/* Key is stored in the slot in export representation, so
1330
1391
* cycle through all known transparent accelerators */
1331
1392
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -1726,6 +1787,9 @@ static inline psa_status_t psa_driver_wrapper_aead_encrypt(
1726
1787
switch ( location )
1727
1788
{
1728
1789
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 */
1729
1793
/* Key is stored in the slot in export representation, so
1730
1794
* cycle through all known transparent accelerators */
1731
1795
@@ -1778,6 +1842,9 @@ static inline psa_status_t psa_driver_wrapper_aead_decrypt(
1778
1842
switch ( location )
1779
1843
{
1780
1844
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 */
1781
1848
/* Key is stored in the slot in export representation, so
1782
1849
* cycle through all known transparent accelerators */
1783
1850
@@ -1827,6 +1894,9 @@ static inline psa_status_t psa_driver_wrapper_aead_encrypt_setup(
1827
1894
switch ( location )
1828
1895
{
1829
1896
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 */
1830
1900
/* Key is stored in the slot in export representation, so
1831
1901
* cycle through all known transparent accelerators */
1832
1902
@@ -1875,6 +1945,9 @@ static inline psa_status_t psa_driver_wrapper_aead_decrypt_setup(
1875
1945
switch ( location )
1876
1946
{
1877
1947
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 */
1878
1951
/* Key is stored in the slot in export representation, so
1879
1952
* cycle through all known transparent accelerators */
1880
1953
@@ -2211,6 +2284,9 @@ static inline psa_status_t psa_driver_wrapper_mac_compute(
2211
2284
switch ( location )
2212
2285
{
2213
2286
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 */
2214
2290
/* Key is stored in the slot in export representation, so
2215
2291
* cycle through all known transparent accelerators */
2216
2292
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -2275,6 +2351,9 @@ static inline psa_status_t psa_driver_wrapper_mac_sign_setup(
2275
2351
switch ( location )
2276
2352
{
2277
2353
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 */
2278
2357
/* Key is stored in the slot in export representation, so
2279
2358
* cycle through all known transparent accelerators */
2280
2359
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -2347,6 +2426,9 @@ static inline psa_status_t psa_driver_wrapper_mac_verify_setup(
2347
2426
switch ( location )
2348
2427
{
2349
2428
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 */
2350
2432
/* Key is stored in the slot in export representation, so
2351
2433
* cycle through all known transparent accelerators */
2352
2434
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -2547,6 +2629,9 @@ static inline psa_status_t psa_driver_wrapper_asymmetric_encrypt(
2547
2629
switch ( location )
2548
2630
{
2549
2631
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 */
2550
2635
/* Key is stored in the slot in export representation, so
2551
2636
* cycle through all known transparent accelerators */
2552
2637
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -2605,6 +2690,9 @@ static inline psa_status_t psa_driver_wrapper_asymmetric_decrypt(
2605
2690
switch ( location )
2606
2691
{
2607
2692
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 */
2608
2696
/* Key is stored in the slot in export representation, so
2609
2697
* cycle through all known transparent accelerators */
2610
2698
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -2669,6 +2757,9 @@ static inline psa_status_t psa_driver_wrapper_key_agreement(
2669
2757
switch ( location )
2670
2758
{
2671
2759
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 */
2672
2763
/* Key is stored in the slot in export representation, so
2673
2764
* cycle through all known transparent accelerators */
2674
2765
#if defined(PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT )
@@ -2749,6 +2840,9 @@ static inline psa_status_t psa_driver_wrapper_pake_setup(
2749
2840
switch ( location )
2750
2841
{
2751
2842
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 */
2752
2846
/* Key is stored in the slot in export representation, so
2753
2847
* cycle through all known transparent accelerators */
2754
2848
status = PSA_ERROR_NOT_SUPPORTED ;
0 commit comments