From 0f5a17d896fd81b6ab7246e4e8496e8778f65aa7 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Tue, 2 Jul 2024 21:26:42 +0530 Subject: [PATCH] [nrf noup] zephyr: Fix the CSRNG define CSRNG availability relies on having an entropy driver, so, protect the API and fallback to non-CSRNG in case of unavailability of such driver. Signed-off-by: Chaitanya Tata --- src/utils/os_zephyr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/os_zephyr.c b/src/utils/os_zephyr.c index b1f733d0a..ad65ac4dd 100644 --- a/src/utils/os_zephyr.c +++ b/src/utils/os_zephyr.c @@ -144,9 +144,13 @@ void os_daemonize_terminate(const char *pid_file) int os_get_random(unsigned char *buf, size_t len) { +#if defined(CONFIG_ENTROPY_HAS_DRIVER) + return sys_csrand_get(buf, len); +#else sys_rand_get(buf, len); return 0; +#endif } unsigned long os_random(void)