Skip to content

Commit 8c6d6e2

Browse files
twcook86danielinux
authored andcommitted
Better hook rng into wolfCrypt
1 parent f40b01d commit 8c6d6e2

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

arch.mk

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,15 +1244,16 @@ ifeq ($(TARGET),lpc55s69)
12441244
$(MCUXPRESSO)/drivers/flexcomm/usart/fsl_usart.o
12451245
endif
12461246
ifeq ($(PKA),1)
1247-
CFLAGS+=-DWOLFSSL_NXP_CASPER -DWOLFSSL_NXP_HASHCRYPT
1247+
CFLAGS+=-DWOLFSSL_NXP_LPC55S69
12481248
OBJS+=\
12491249
$(MCUXPRESSO)/drivers/casper/fsl_casper.o \
12501250
$(MCUXPRESSO)/drivers/hashcrypt/fsl_hashcrypt.o \
1251+
$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o \
12511252
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/casper_port.o \
1252-
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/hashcrypt_port.o
1253-
endif
1254-
ifeq ($(WOLFCRYPT_TZ),1)
1255-
OBJS+=$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o
1253+
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/hashcrypt_port.o \
1254+
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/rng_port.o
1255+
else
1256+
CFLAGS+=-DWOLFSSL_NXP_LPC55S69_NO_HWACCEL
12561257
endif
12571258
endif
12581259

hal/lpc55s69.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ static void hal_sau_init(void)
7171

7272
static void periph_unsecure(void)
7373
{
74+
#ifdef WOLFSSL_NXP_RNG_1
75+
CLOCK_EnableClock(kCLOCK_Rng);
76+
RESET_PeripheralReset(kRNG_RST_SHIFT_RSTn);
77+
#endif
7478
CLOCK_EnableClock(kCLOCK_Iocon);
7579
CLOCK_EnableClock(kCLOCK_Gpio1);
7680
}
@@ -225,11 +229,13 @@ int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
225229
#ifdef WOLFCRYPT_SECURE_MODE
226230
void hal_trng_init(void)
227231
{
228-
#ifdef __WOLFBOOT
232+
#ifdef WOLFSSL_NXP_RNG_1
233+
# ifdef __WOLFBOOT
229234
CLOCK_EnableClock(kCLOCK_Rng);
230235
RESET_PeripheralReset(kRNG_RST_SHIFT_RSTn);
231-
#endif
236+
# endif
232237
RNG_Init(RNG);
238+
#endif
233239
}
234240

235241
void hal_trng_fini(void)
@@ -238,8 +244,10 @@ void hal_trng_fini(void)
238244

239245
int hal_trng_get_entropy(unsigned char *out, unsigned int len)
240246
{
247+
#ifdef WOLFSSL_NXP_RNG_1
241248
if (RNG_GetRandomData(RNG, out, len) == kStatus_Success)
242249
return 0;
250+
#endif
243251

244252
return -1;
245253
}

test-app/Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,17 @@ ifeq ($(TARGET),lpc55s69)
725725
$(MCUXPRESSO)/drivers/flexcomm/usart/fsl_usart.o \
726726
$(MCUXPRESSO)/drivers/iap1/fsl_iap.o \
727727
$(MCUXPRESSO)/drivers/lpc_gpio/fsl_gpio.o
728-
ifeq ($(WOLFCRYPT_TZ),1)
729-
APP_OBJS+=$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o
728+
ifeq ($(PKA),1)
729+
CFLAGS+=-DWOLFSSL_NXP_LPC55S69
730+
APP_OBJS+=\
731+
$(MCUXPRESSO)/drivers/casper/fsl_casper.o \
732+
$(MCUXPRESSO)/drivers/hashcrypt/fsl_hashcrypt.o \
733+
$(MCUXPRESSO)/drivers/rng_1/fsl_rng.o \
734+
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/casper_port.o \
735+
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/hashcrypt_port.o \
736+
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/nxp/rng_port.o
737+
else
738+
CFLAGS+=-DWOLFSSL_NXP_LPC55S69_NO_HWACCEL
730739
endif
731740
ifeq (,$(findstring nosys.specs,$(LDFLAGS)))
732741
LDFLAGS+=--specs=nosys.specs

0 commit comments

Comments
 (0)