36
36
37
37
MBED_STATIC_ASSERT (sizeof (psa_key_id_t ) == CLIENT_PSA_KEY_ID_SIZE_IN_BYTES , "Unexpected psa_key_id_t size" );
38
38
39
+ /****************************************************************/
40
+ /* INTERNAL HELPER FUNCTIONS */
41
+ /****************************************************************/
39
42
static psa_status_t ipc_connect (uint32_t sid , psa_handle_t * handle )
40
43
{
41
44
* handle = psa_connect (sid , MINOR_VER );
@@ -78,16 +81,24 @@ static psa_status_t ipc_oneshot(uint32_t sid, psa_invec *in_vec, size_t in_vec_s
78
81
return (status );
79
82
}
80
83
84
+ /****************************************************************/
85
+ /* MODULE SETUP/TEARDOWN */
86
+ /****************************************************************/
81
87
psa_status_t psa_crypto_init (void )
82
88
{
83
89
psa_status_t status = ipc_oneshot (PSA_CRYPTO_INIT_ID , NULL , 0 , NULL , 0 );
84
90
return (status );
85
91
}
86
92
93
+ void mbedtls_psa_crypto_free (void )
94
+ {
95
+ //TODO: add retry mechanism to make sure resources were deallocated.
96
+ ipc_oneshot (PSA_CRYPTO_FREE_ID , NULL , 0 , NULL , 0 );
97
+ }
98
+
87
99
/****************************************************************/
88
- /* PSA_MAC */
100
+ /* MAC */
89
101
/****************************************************************/
90
-
91
102
psa_status_t psa_mac_abort (psa_mac_operation_t * operation )
92
103
{
93
104
if (operation -> handle <= PSA_NULL_HANDLE ) {
@@ -186,9 +197,8 @@ psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation,
186
197
}
187
198
188
199
/****************************************************************/
189
- /* PSA_HASH */
200
+ /* HASH */
190
201
/****************************************************************/
191
-
192
202
psa_status_t psa_hash_abort (psa_hash_operation_t * operation )
193
203
{
194
204
if (operation -> handle <= PSA_NULL_HANDLE ) {
@@ -312,7 +322,6 @@ psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation,
312
322
/****************************************************************/
313
323
/* AEAD */
314
324
/****************************************************************/
315
-
316
325
psa_status_t psa_aead_encrypt (psa_key_handle_t key_handle ,
317
326
psa_algorithm_t alg ,
318
327
const uint8_t * nonce ,
@@ -434,9 +443,8 @@ psa_status_t psa_aead_decrypt(psa_key_handle_t key_handle,
434
443
}
435
444
436
445
/****************************************************************/
437
- /* PSA_ASYMMETRIC */
446
+ /* ASYMMETRIC */
438
447
/****************************************************************/
439
-
440
448
psa_status_t psa_asymmetric_sign (psa_key_handle_t key_handle ,
441
449
psa_algorithm_t alg ,
442
450
const uint8_t * hash ,
@@ -590,9 +598,8 @@ psa_status_t psa_asymmetric_decrypt(psa_key_handle_t key_handle,
590
598
}
591
599
592
600
/****************************************************************/
593
- /* PSA_KEY_MANAGMENT */
601
+ /* KEY MANAGMENT */
594
602
/****************************************************************/
595
-
596
603
psa_status_t psa_allocate_key (psa_key_handle_t * key_handle )
597
604
{
598
605
psa_key_mng_ipc_t psa_key_mng_ipc = { 0 , 0 , 0 , 0 };
@@ -861,9 +868,8 @@ psa_status_t psa_generate_key(psa_key_handle_t key_handle,
861
868
}
862
869
863
870
/****************************************************************/
864
- /* PSA_RNG */
871
+ /* RNG */
865
872
/****************************************************************/
866
-
867
873
psa_status_t psa_generate_random (uint8_t * output ,
868
874
size_t output_size )
869
875
{
@@ -876,9 +882,8 @@ psa_status_t psa_generate_random(uint8_t *output,
876
882
}
877
883
878
884
/****************************************************************/
879
- /* PSA_ENTROPY_INJECT */
885
+ /* ENTROPY INJECT */
880
886
/****************************************************************/
881
-
882
887
psa_status_t mbedtls_psa_inject_entropy (const unsigned char * seed ,
883
888
size_t seed_size )
884
889
{
@@ -891,9 +896,8 @@ psa_status_t mbedtls_psa_inject_entropy(const unsigned char *seed,
891
896
}
892
897
893
898
/****************************************************************/
894
- /* PSA Generator */
899
+ /* GENERATOR */
895
900
/****************************************************************/
896
-
897
901
psa_status_t psa_get_generator_capacity (const psa_crypto_generator_t * generator ,
898
902
size_t * capacity )
899
903
{
@@ -1024,9 +1028,8 @@ psa_status_t psa_generator_abort(psa_crypto_generator_t *generator)
1024
1028
}
1025
1029
1026
1030
/****************************************************************/
1027
- /* PSA_SYMMETRIC */
1031
+ /* SYMMETRIC */
1028
1032
/****************************************************************/
1029
-
1030
1033
psa_status_t psa_cipher_encrypt_setup (psa_cipher_operation_t * operation ,
1031
1034
psa_key_handle_t key_handle ,
1032
1035
psa_algorithm_t alg )
@@ -1168,10 +1171,4 @@ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation)
1168
1171
return (status );
1169
1172
}
1170
1173
1171
- void mbedtls_psa_crypto_free (void )
1172
- {
1173
- //TODO: add retry mechanism to make sure resourecs were deallocated.
1174
- ipc_oneshot (PSA_CRYPTO_FREE_ID , NULL , 0 , NULL , 0 );
1175
- }
1176
-
1177
1174
#endif /* MBEDTLS_PSA_CRYPTO_C */
0 commit comments