Skip to content

Commit 9bc8bcf

Browse files
author
itayzafrir
committed
Unify sections titles/comments & fix typo in comment
1 parent 5c48d58 commit 9bc8bcf

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636

3737
MBED_STATIC_ASSERT(sizeof(psa_key_id_t) == CLIENT_PSA_KEY_ID_SIZE_IN_BYTES, "Unexpected psa_key_id_t size");
3838

39+
/****************************************************************/
40+
/* INTERNAL HELPER FUNCTIONS */
41+
/****************************************************************/
3942
static psa_status_t ipc_connect(uint32_t sid, psa_handle_t *handle)
4043
{
4144
*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
7881
return (status);
7982
}
8083

84+
/****************************************************************/
85+
/* MODULE SETUP/TEARDOWN */
86+
/****************************************************************/
8187
psa_status_t psa_crypto_init(void)
8288
{
8389
psa_status_t status = ipc_oneshot(PSA_CRYPTO_INIT_ID, NULL, 0, NULL, 0);
8490
return (status);
8591
}
8692

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+
8799
/****************************************************************/
88-
/* PSA_MAC */
100+
/* MAC */
89101
/****************************************************************/
90-
91102
psa_status_t psa_mac_abort(psa_mac_operation_t *operation)
92103
{
93104
if (operation->handle <= PSA_NULL_HANDLE) {
@@ -186,9 +197,8 @@ psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation,
186197
}
187198

188199
/****************************************************************/
189-
/* PSA_HASH */
200+
/* HASH */
190201
/****************************************************************/
191-
192202
psa_status_t psa_hash_abort(psa_hash_operation_t *operation)
193203
{
194204
if (operation->handle <= PSA_NULL_HANDLE) {
@@ -312,7 +322,6 @@ psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation,
312322
/****************************************************************/
313323
/* AEAD */
314324
/****************************************************************/
315-
316325
psa_status_t psa_aead_encrypt(psa_key_handle_t key_handle,
317326
psa_algorithm_t alg,
318327
const uint8_t *nonce,
@@ -434,9 +443,8 @@ psa_status_t psa_aead_decrypt(psa_key_handle_t key_handle,
434443
}
435444

436445
/****************************************************************/
437-
/* PSA_ASYMMETRIC */
446+
/* ASYMMETRIC */
438447
/****************************************************************/
439-
440448
psa_status_t psa_asymmetric_sign(psa_key_handle_t key_handle,
441449
psa_algorithm_t alg,
442450
const uint8_t *hash,
@@ -590,9 +598,8 @@ psa_status_t psa_asymmetric_decrypt(psa_key_handle_t key_handle,
590598
}
591599

592600
/****************************************************************/
593-
/* PSA_KEY_MANAGMENT */
601+
/* KEY MANAGMENT */
594602
/****************************************************************/
595-
596603
psa_status_t psa_allocate_key(psa_key_handle_t *key_handle)
597604
{
598605
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,
861868
}
862869

863870
/****************************************************************/
864-
/* PSA_RNG */
871+
/* RNG */
865872
/****************************************************************/
866-
867873
psa_status_t psa_generate_random(uint8_t *output,
868874
size_t output_size)
869875
{
@@ -876,9 +882,8 @@ psa_status_t psa_generate_random(uint8_t *output,
876882
}
877883

878884
/****************************************************************/
879-
/* PSA_ENTROPY_INJECT */
885+
/* ENTROPY INJECT */
880886
/****************************************************************/
881-
882887
psa_status_t mbedtls_psa_inject_entropy(const unsigned char *seed,
883888
size_t seed_size)
884889
{
@@ -891,9 +896,8 @@ psa_status_t mbedtls_psa_inject_entropy(const unsigned char *seed,
891896
}
892897

893898
/****************************************************************/
894-
/* PSA Generator */
899+
/* GENERATOR */
895900
/****************************************************************/
896-
897901
psa_status_t psa_get_generator_capacity(const psa_crypto_generator_t *generator,
898902
size_t *capacity)
899903
{
@@ -1024,9 +1028,8 @@ psa_status_t psa_generator_abort(psa_crypto_generator_t *generator)
10241028
}
10251029

10261030
/****************************************************************/
1027-
/* PSA_SYMMETRIC */
1031+
/* SYMMETRIC */
10281032
/****************************************************************/
1029-
10301033
psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation,
10311034
psa_key_handle_t key_handle,
10321035
psa_algorithm_t alg)
@@ -1168,10 +1171,4 @@ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation)
11681171
return (status);
11691172
}
11701173

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-
11771174
#endif /* MBEDTLS_PSA_CRYPTO_C */

0 commit comments

Comments
 (0)