From 7acb5ae3a021f832e96cb64bcfbb6408f7e94938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Audun=20Kvamtr=C3=B8?= Date: Thu, 26 Sep 2024 12:13:23 +0200 Subject: [PATCH] fixup! crypto: nrf_cc3xx: Update mutex support for Mbed TLS 3.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Don't reuse RNG mutex for the PSA rng mutex type Signed-off-by: Frank Audun Kvamtrø --- .../src/nrf_cc3xx_platform_mutex_zephyr.c | 17 ++++++++++++++--- .../src/nrf_cc3xx_platform_mutex_zephyr.c | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/crypto/nrf_cc310_platform/src/nrf_cc3xx_platform_mutex_zephyr.c b/crypto/nrf_cc310_platform/src/nrf_cc3xx_platform_mutex_zephyr.c index 60d73dbbed..5f5fa32c51 100644 --- a/crypto/nrf_cc310_platform/src/nrf_cc3xx_platform_mutex_zephyr.c +++ b/crypto/nrf_cc310_platform/src/nrf_cc3xx_platform_mutex_zephyr.c @@ -53,6 +53,10 @@ K_MUTEX_DEFINE(key_slot_mutex_int); */ K_MUTEX_DEFINE(psa_globaldata_mutex_int); +/** @brief Definition of mutex for PSA global access + */ +K_MUTEX_DEFINE(psa_rng_mutex_int); + #elif CONFIG_CC3XX_ATOMIC_LOCK /** @brief Definition of mutex for symmetric cryptography @@ -79,6 +83,10 @@ static atomic_t key_slot_mutex_int; */ static atomic_t psa_globaldata_mutex_int; +/** @brief Definition of mutex for PSA global access + */ +static atomic_t psa_rng_mutex_int; + #elif defined(NRF5340_XXAA_APPLICATION) && NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_HW_MUTEX typedef enum { @@ -88,6 +96,7 @@ typedef enum { HW_MUTEX_HEAP_ALLOC = 12, HW_MUTEX_KEY_SLOT = 11, HW_MUTEX_PSA_GLOBALDATA = 10, + HW_MUTEX_PSA_RNG = 9, } hw_mutex_t; /** @brief Definition of mutex for symmetric cryptography @@ -114,6 +123,10 @@ static hw_mutex_t key_slot_mutex_int = HW_MUTEX_KEY_SLOT; */ static hw_mutex_t psa_globaldata_mutex_int = HW_MUTEX_PSA_GLOBALDATA; +/** @brief Definition of mutex for PSA global access + */ +static hw_mutex_t psa_rng_mutex_int = HW_MUTEX_PSA_RNG; + #else #error "Improper configuration of the lock variant!" #endif @@ -233,11 +246,9 @@ nrf_cc3xx_platform_mutex_t mbedtls_threading_psa_globaldata_mutex = { * allocation is unneccesary * * @note This symbol can't be static as it is referenced from Mbed TLS - * - * @note Reusing the RNG mutex used for CryptoCell. */ nrf_cc3xx_platform_mutex_t mbedtls_threading_psa_rngdata_mutex = { - .mutex = &rng_mutex_int, + .mutex = &psa_rng_mutex_int, .flags = IS_ENABLED(CONFIG_CC3XX_ATOMIC_LOCK) ? NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_ATOMIC : IS_ENABLED(CONFIG_CC3XX_HW_MUTEX_LOCK) ? diff --git a/crypto/nrf_cc312_platform/src/nrf_cc3xx_platform_mutex_zephyr.c b/crypto/nrf_cc312_platform/src/nrf_cc3xx_platform_mutex_zephyr.c index 60d73dbbed..5f5fa32c51 100644 --- a/crypto/nrf_cc312_platform/src/nrf_cc3xx_platform_mutex_zephyr.c +++ b/crypto/nrf_cc312_platform/src/nrf_cc3xx_platform_mutex_zephyr.c @@ -53,6 +53,10 @@ K_MUTEX_DEFINE(key_slot_mutex_int); */ K_MUTEX_DEFINE(psa_globaldata_mutex_int); +/** @brief Definition of mutex for PSA global access + */ +K_MUTEX_DEFINE(psa_rng_mutex_int); + #elif CONFIG_CC3XX_ATOMIC_LOCK /** @brief Definition of mutex for symmetric cryptography @@ -79,6 +83,10 @@ static atomic_t key_slot_mutex_int; */ static atomic_t psa_globaldata_mutex_int; +/** @brief Definition of mutex for PSA global access + */ +static atomic_t psa_rng_mutex_int; + #elif defined(NRF5340_XXAA_APPLICATION) && NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_HW_MUTEX typedef enum { @@ -88,6 +96,7 @@ typedef enum { HW_MUTEX_HEAP_ALLOC = 12, HW_MUTEX_KEY_SLOT = 11, HW_MUTEX_PSA_GLOBALDATA = 10, + HW_MUTEX_PSA_RNG = 9, } hw_mutex_t; /** @brief Definition of mutex for symmetric cryptography @@ -114,6 +123,10 @@ static hw_mutex_t key_slot_mutex_int = HW_MUTEX_KEY_SLOT; */ static hw_mutex_t psa_globaldata_mutex_int = HW_MUTEX_PSA_GLOBALDATA; +/** @brief Definition of mutex for PSA global access + */ +static hw_mutex_t psa_rng_mutex_int = HW_MUTEX_PSA_RNG; + #else #error "Improper configuration of the lock variant!" #endif @@ -233,11 +246,9 @@ nrf_cc3xx_platform_mutex_t mbedtls_threading_psa_globaldata_mutex = { * allocation is unneccesary * * @note This symbol can't be static as it is referenced from Mbed TLS - * - * @note Reusing the RNG mutex used for CryptoCell. */ nrf_cc3xx_platform_mutex_t mbedtls_threading_psa_rngdata_mutex = { - .mutex = &rng_mutex_int, + .mutex = &psa_rng_mutex_int, .flags = IS_ENABLED(CONFIG_CC3XX_ATOMIC_LOCK) ? NRF_CC3XX_PLATFORM_MUTEX_MASK_IS_ATOMIC : IS_ENABLED(CONFIG_CC3XX_HW_MUTEX_LOCK) ?