From a401a2aea0bb77c42a444e3dcde5d36a37276a72 Mon Sep 17 00:00:00 2001 From: kkrentz Date: Fri, 4 Aug 2023 21:41:56 +0200 Subject: [PATCH] Contiki-NG: Switch to secure PRNG --- src/coap_prng.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/coap_prng.c b/src/coap_prng.c index a983e165..62c1ef26 100644 --- a/src/coap_prng.c +++ b/src/coap_prng.c @@ -19,7 +19,7 @@ #ifdef HAVE_GETRANDOM #include #elif defined(WITH_CONTIKI) -#include "lib/random.h" +#include "lib/csprng.h" #else /* !WITH_CONTIKI */ #include #endif /* !WITH_CONTIKI */ @@ -96,18 +96,7 @@ coap_prng_default(void *buf, size_t len) { return 1; #elif defined(WITH_CONTIKI) - size_t i; - uint_fast8_t j; - unsigned short r; - - for (i = 0; i < len;) { - r = random_rand(); - for (j = 0; (i < len) && (j < sizeof(r)); i++, j++) { - ((uint8_t *)buf)[i] = r & 0xFF; - r >>= 8; - } - } - return 1; + return csprng_rand(buf, len); #elif defined(_WIN32) return coap_prng_impl(buf,len);