Skip to content

Commit d918d0e

Browse files
committed
bootutil: ed25519 PSA: Remove unneeded psa_crypto_inits
Now there is single point of initialization. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 83983ff commit d918d0e

File tree

2 files changed

+0
-40
lines changed

2 files changed

+0
-40
lines changed

boot/bootutil/src/ed25519_psa.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ int ED25519_verify(const uint8_t *message, size_t message_len,
4141

4242
BOOT_LOG_DBG("ED25519_verify: PSA implementation");
4343

44-
/* Initialize PSA Crypto */
45-
status = psa_crypto_init();
46-
if (status != PSA_SUCCESS) {
47-
BOOT_LOG_ERR("PSA crypto init failed %d\n", status);
48-
return 0;
49-
}
50-
5144
status = PSA_ERROR_BAD_STATE;
5245

5346
psa_set_key_type(&key_attr,

boot/bootutil/src/encrypted_psa.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,6 @@ parse_priv_enckey(uint8_t **p, uint8_t *end, uint8_t *private_key)
188188

189189
void bootutil_aes_ctr_init(bootutil_aes_ctr_context *ctx)
190190
{
191-
psa_status_t psa_ret = psa_crypto_init();
192-
193-
if (psa_ret != PSA_SUCCESS) {
194-
BOOT_LOG_ERR("AES init PSA crypto init failed %d", psa_ret);
195-
assert(0);
196-
}
197-
198191
ctx->key = PSA_KEY_ID_NULL;
199192
}
200193

@@ -266,12 +259,6 @@ boot_decrypt_key(const uint8_t *buf, uint8_t *enckey)
266259

267260
BOOT_LOG_DBG("boot_decrypt_key: PSA ED25519");
268261

269-
psa_ret = psa_crypto_init();
270-
if (psa_ret != PSA_SUCCESS) {
271-
BOOT_LOG_ERR("PSA crypto init failed %d", psa_ret);
272-
return -1;
273-
}
274-
275262
/*
276263
* * Load the stored decryption private key
277264
*/
@@ -431,16 +418,6 @@ int bootutil_aes_ctr_encrypt(bootutil_aes_ctr_context *ctx, uint8_t *counter,
431418
psa_cipher_operation_t psa_op;
432419
size_t elen = 0; /* Decrypted length */
433420

434-
/* Fixme: calling psa_crypto_init multiple times is not a problem,
435-
* yet the code here is only present because there is not general
436-
* crypto init. */
437-
psa_ret = psa_crypto_init();
438-
if (psa_ret != PSA_SUCCESS) {
439-
BOOT_LOG_ERR("PSA crypto init failed %d", psa_ret);
440-
ret = -1;
441-
goto gone;
442-
}
443-
444421
psa_op = psa_cipher_operation_init();
445422

446423
/* This could be done with psa_cipher_decrypt one-shot operation, but
@@ -488,16 +465,6 @@ int bootutil_aes_ctr_decrypt(bootutil_aes_ctr_context *ctx, uint8_t *counter,
488465
psa_cipher_operation_t psa_op;
489466
size_t dlen = 0; /* Decrypted length */
490467

491-
/* Fixme: the init should already happen before calling the function, but
492-
* somehow it does not, for example when recovering in swap.
493-
*/
494-
psa_ret = psa_crypto_init();
495-
if (psa_ret != PSA_SUCCESS) {
496-
BOOT_LOG_ERR("PSA crypto init failed %d", psa_ret);
497-
ret = -1;
498-
goto gone;
499-
}
500-
501468
psa_op = psa_cipher_operation_init();
502469

503470
/* This could be done with psa_cipher_decrypt one-shot operation, but

0 commit comments

Comments
 (0)