@@ -45,6 +45,14 @@ K_MUTEX_DEFINE(power_mutex_int);
4545 */
4646K_MUTEX_DEFINE (heap_mutex_int );
4747
48+ /** @brief Definition of mutex for PSA storage key slot operations
49+ */
50+ K_MUTEX_DEFINE (key_slot_mutex_int );
51+
52+ /** @brief Definition of mutex for PSA global access
53+ */
54+ K_MUTEX_DEFINE (psa_globaldata_mutex_int );
55+
4856#elif CONFIG_CC3XX_ATOMIC_LOCK
4957
5058/** @brief Definition of mutex for symmetric cryptography
@@ -63,13 +71,23 @@ static atomic_t power_mutex_int;
6371 */
6472static atomic_t heap_mutex_int ;
6573
74+ /** @brief Definition of mutex for PSA storage key slot operations
75+ */
76+ static atomic_t key_slot_mutex_int ;
77+
78+ /** @brief Definition of mutex for PSA global access
79+ */
80+ static atomic_t psa_globaldata_mutex_int ;
81+
6682#elif defined(NRF5340_XXAA_APPLICATION ) && NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_HW_MUTEX
6783
6884typedef enum {
6985 HW_MUTEX_SYM_CRYPTO = 15 ,
7086 HW_MUTEX_ASYM_CRYPTO = 14 ,
7187 HW_MUTEX_POWER_MODE = 13 ,
7288 HW_MUTEX_HEAP_ALLOC = 12 ,
89+ HW_MUTEX_KEY_SLOT = 11 ,
90+ HW_MUTEX_PSA_GLOBALDATA = 10 ,
7391} hw_mutex_t ;
7492
7593/** @brief Definition of mutex for symmetric cryptography
@@ -88,6 +106,14 @@ static hw_mutex_t power_mutex_int = HW_MUTEX_POWER_MODE;
88106 */
89107static hw_mutex_t heap_mutex_int = HW_MUTEX_HEAP_ALLOC ;
90108
109+ /** @brief Definition of mutex for PSA storage key slot operations
110+ */
111+ static hw_mutex_t key_slot_mutex_int = HW_MUTEX_KEY_SLOT ;
112+
113+ /** @brief Definition of mutex for PSA global access
114+ */
115+ static hw_mutex_t psa_globaldata_mutex_int = HW_MUTEX_PSA_GLOBALDATA ;
116+
91117#else
92118#error "Improper configuration of the lock variant!"
93119#endif
@@ -161,7 +187,7 @@ static nrf_cc3xx_platform_mutex_t power_mutex = {
161187 * allocation is unneccesary
162188 *
163189 * @note This symbol can't be static as it is referenced in the replacement
164- * file mbemory_buffer_alloc .c inside the heap structure.
190+ * file memory_buffer_alloc .c inside the heap structure.
165191 */
166192nrf_cc3xx_platform_mutex_t heap_mutex = {
167193 .mutex = & heap_mutex_int ,
@@ -172,6 +198,53 @@ nrf_cc3xx_platform_mutex_t heap_mutex = {
172198 NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_VALID
173199};
174200
201+ /** @brief Definition of RTOS-independent key slot mutex
202+ * with NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_VALID set to indicate that
203+ * allocation is unneccesary
204+ *
205+ * @note This symbol can't be static as it is referenced from Mbed TLS
206+ */
207+ nrf_cc3xx_platform_mutex_t mbedtls_threading_key_slot_mutex = {
208+ .mutex = & key_slot_mutex_int ,
209+ .flags = IS_ENABLED (CONFIG_CC3XX_ATOMIC_LOCK ) ?
210+ NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_ATOMIC :
211+ IS_ENABLED (CONFIG_CC3XX_HW_MUTEX_LOCK ) ?
212+ NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_HW_MUTEX :
213+ NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_VALID
214+ };
215+
216+ /** @brief Definition of RTOS-independent PSA global data mutex
217+ * with NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_VALID set to indicate that
218+ * allocation is unneccesary
219+ *
220+ * @note This symbol can't be static as it is referenced from Mbed TLS
221+ */
222+ nrf_cc3xx_platform_mutex_t mbedtls_threading_psa_globaldata_mutex = {
223+ .mutex = & psa_globaldata_mutex_int ,
224+ .flags = IS_ENABLED (CONFIG_CC3XX_ATOMIC_LOCK ) ?
225+ NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_ATOMIC :
226+ IS_ENABLED (CONFIG_CC3XX_HW_MUTEX_LOCK ) ?
227+ NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_HW_MUTEX :
228+ NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_VALID
229+ };
230+
231+ /** @brief Definition of RTOS-independent psa global data mutex
232+ * with NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_VALID set to indicate that
233+ * allocation is unneccesary
234+ *
235+ * @note This symbol can't be static as it is referenced from Mbed TLS
236+ *
237+ * @note Reusing the RNG mutex used for CryptoCell.
238+ */
239+ nrf_cc3xx_platform_mutex_t mbedtls_threading_psa_rngdata_mutex = {
240+ .mutex = & rng_mutex_int ,
241+ .flags = IS_ENABLED (CONFIG_CC3XX_ATOMIC_LOCK ) ?
242+ NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_ATOMIC :
243+ IS_ENABLED (CONFIG_CC3XX_HW_MUTEX_LOCK ) ?
244+ NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_HW_MUTEX :
245+ NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_VALID
246+ };
247+
175248static bool mutex_flags_unknown (uint32_t flags ){
176249 switch (flags ){
177250 case (NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_VALID | NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_INTERNAL_MUTEX ):
0 commit comments