Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ if(NOT ZEPHYR_BASE)
check_function_exists(getifaddrs HAVE_GETIFADDRS)
check_function_exists(strnlen HAVE_STRNLEN)
check_function_exists(strrchr HAVE_STRRCHR)
check_function_exists(getentropy HAVE_GETENTROPY)
check_function_exists(getrandom HAVE_GETRANDOM)
check_function_exists(random HAVE_RANDOM)
check_function_exists(if_nametoindex HAVE_IF_NAMETOINDEX)
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ AC_TYPE_SSIZE_T

# Checks for library functions.
AC_CHECK_FUNCS([memset select socket strcasecmp strrchr getaddrinfo getifaddrs \
strnlen malloc pthread_mutex_lock getrandom random if_nametoindex])
strnlen malloc pthread_mutex_lock getentropy getrandom random if_nametoindex])

# Check if -lsocket -lnsl is required (specifically Solaris)
AC_SEARCH_LIBS([socket], [socket])
Expand Down
3 changes: 3 additions & 0 deletions src/coap_prng.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ coap_prng_default(void *buf, size_t len) {
#elif defined(HAVE_GETRANDOM)
return (getrandom(buf, len, 0) > 0) ? 1 : 0;

#elif defined(HAVE_GETENTROPY)
return (getentropy(buf, len) == 0) ? 1 : 0;

#elif defined(HAVE_RANDOM)
#define RAND_BYTES (RAND_MAX >= 0xffffff ? 3 : (RAND_MAX >= 0xffff ? 2 : 1))
unsigned char *dst = (unsigned char *)buf;
Expand Down
Loading