88
99#include <stddef.h>
1010#include <stdint.h>
11+ #include <psa/error.h>
12+ #include <psa/crypto.h>
1113#include "tfm_attest_hal.h"
1214#include "tfm_plat_boot_seed.h"
1315#include "tfm_plat_device_id.h"
14- #include <nrf_cc3xx_platform.h>
1516#include "tfm_strnlen.h"
1617#include "nrf_provisioning.h"
17- #include <nrfx_nvmc.h>
1818#include <bl_storage.h>
1919
20+ #ifdef CONFIG_NRFX_NVMC
21+ #include <nrfx_nvmc.h>
22+ #endif
23+ #ifdef CONFIG_HAS_HW_NRF_CC3XX
24+ #include <nrf_cc3xx_platform.h>
25+ #endif
26+
27+ #if defined(CONFIG_CRACEN_HW_PRESENT )
28+ static bool boot_seed_set ;
29+ static uint8_t boot_seed [BOOT_SEED_SIZE ];
30+ #endif
31+
2032static enum tfm_security_lifecycle_t map_bl_storage_lcs_to_tfm_slc (enum lcs lcs )
2133{
2234 switch (lcs ) {
@@ -101,8 +113,11 @@ enum tfm_plat_err_t tfm_attest_hal_get_profile_definition(uint32_t *size, uint8_
101113
102114enum tfm_plat_err_t tfm_plat_get_boot_seed (uint32_t size , uint8_t * buf )
103115{
116+ #if defined(CONFIG_HAS_HW_NRF_CC3XX )
104117 int nrf_err ;
105118
119+ _Static_assert (NRF_CC3XX_PLATFORM_TFM_BOOT_SEED_SIZE == BOOT_SEED_SIZE ,
120+ "NRF_CC3XX_PLATFORM_TFM_BOOT_SEED_SIZE must match BOOT_SEED_SIZE" );
106121 if (size != NRF_CC3XX_PLATFORM_TFM_BOOT_SEED_SIZE ) {
107122 return TFM_PLAT_ERR_INVALID_INPUT ;
108123 }
@@ -111,6 +126,24 @@ enum tfm_plat_err_t tfm_plat_get_boot_seed(uint32_t size, uint8_t *buf)
111126 if (nrf_err != NRF_CC3XX_PLATFORM_SUCCESS ) {
112127 return TFM_PLAT_ERR_SYSTEM_ERR ;
113128 }
129+ #elif defined(CONFIG_CRACEN_HW_PRESENT )
130+ if (!boot_seed_set ) {
131+ psa_status_t psa_err = psa_generate_random (boot_seed , sizeof (boot_seed ));
132+
133+ if (psa_err != PSA_SUCCESS ) {
134+ return TFM_PLAT_ERR_SYSTEM_ERR ;
135+ }
136+
137+ boot_seed_set = true;
138+ }
139+
140+ if (size != BOOT_SEED_SIZE ) {
141+ return TFM_PLAT_ERR_INVALID_INPUT ;
142+ }
143+ memcpy (buf , boot_seed , size );
144+ #else
145+ #error "No crypto hardware to generate boot seed available."
146+ #endif
114147
115148 return TFM_PLAT_ERR_SUCCESS ;
116149}
0 commit comments