Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
[nrf noup] zephyr: Fix the CSRNG define
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
krish2718 committed Jul 9, 2024
1 parent 6311fde commit 3b64b3b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/utils/os_zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3b64b3b

Please sign in to comment.