Skip to content

Commit d3ab3c6

Browse files
committed
crypto: Ensure PSA crypto is called on CryptoCell enabled devices
-This added SYS_INIT will ensure that psa_crypto_init is called in kernel *after* Hw_CC3XX is executed to ensure that mutexes are ready to be used. Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
1 parent 78cb045 commit d3ab3c6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/hw_cc3xx/hw_cc3xx.c

+22
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,26 @@ SYS_INIT(hw_cc3xx_init_internal, PRE_KERNEL_1,
5959
SYS_INIT(hw_cc3xx_init, POST_KERNEL,
6060
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
6161

62+
63+
#if defined(CONFIG_MBEDTLS_PSA_CRYPTO_CLIENT)
64+
65+
#include "psa/crypto.h"
66+
67+
/* Ensuring psa_crypto_init is run on CryptoCell enabled HW */
68+
static int _psa_crypto_init(void)
69+
{
70+
psa_status_t err = psa_crypto_init();
71+
if(err != PSA_SUCCESS) {
72+
return -EIO;
73+
}
74+
75+
return 0;
76+
}
77+
78+
/* Ensure PSA crypto is initalized after nrf_cc3xx mutex initialization */
79+
SYS_INIT(_psa_crypto_init, POST_KERNEL,
80+
CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
81+
82+
#endif /* CONFIG_MBEDTLS_PSA_CRYPTO_CLIENT */
83+
6284
#endif /* CONFIG_HW_CC3XX */

0 commit comments

Comments
 (0)