From 90cc1e033915780aa3b9728da5998080dfcc8ba9 Mon Sep 17 00:00:00 2001 From: Alex Lanzano Date: Tue, 26 May 2026 10:03:49 -0400 Subject: [PATCH] Fix mcxn build by providing the RNG for TZ_PSA builds --- test-app/Makefile | 4 +++- test-app/wcs/user_settings.h | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/test-app/Makefile b/test-app/Makefile index cddbb99a66..72e51085be 100644 --- a/test-app/Makefile +++ b/test-app/Makefile @@ -16,7 +16,9 @@ TARGET?=none ARCH?=ARM MCUXPRESSO_CMSIS?=$(MCUXPRESSO)/CMSIS ifneq (,$(filter $(TARGET),mcxa mcxw mcxn)) - TEST_APP_NO_RNG?=1 + ifneq ($(WOLFCRYPT_TZ_PSA),1) + TEST_APP_NO_RNG?=1 + endif endif ifeq ($(TZEN),1) # wcs directory contains a user_settings.h, which will conflict with diff --git a/test-app/wcs/user_settings.h b/test-app/wcs/user_settings.h index 1f71ff86a8..5870eeece2 100644 --- a/test-app/wcs/user_settings.h +++ b/test-app/wcs/user_settings.h @@ -166,6 +166,24 @@ static inline int wcs_cmse_get_random(unsigned char* output, int sz) #define CUSTOM_RAND_GENERATE_BLOCK wcs_cmse_get_random #endif +#ifdef WOLFCRYPT_TZ_PSA + +extern int hal_trng_get_entropy(unsigned char *out, unsigned int len); + +static inline int wcs_psa_rand_block(unsigned char *output, int sz) +{ + if (sz <= 0 || output == (unsigned char*)0) + return -1; + + if (hal_trng_get_entropy(output, (unsigned int)sz) != 0) + return -1; + + return 0; +} + +#define CUSTOM_RAND_GENERATE_BLOCK wcs_psa_rand_block +#endif + /* Disable VLAs */ #define WOLFSSL_SP_NO_DYN_STACK