diff --git a/crypto/random_pool.c b/crypto/random_pool.c index bdae9d506f..ace8ca7442 100644 --- a/crypto/random_pool.c +++ b/crypto/random_pool.c @@ -111,7 +111,8 @@ static struct rng_s g_rng; #ifdef CONFIG_BOARD_ENTROPY_POOL /* Entropy pool structure can be provided by board source. Use for this is, * for example, allocate entropy pool from special area of RAM which content - * is kept over system reset. */ + * is kept over system reset. + */ # define entropy_pool board_entropy_pool #else diff --git a/drivers/crypto/dev_urandom.c b/drivers/crypto/dev_urandom.c index 77778e70d5..6ac260a3d4 100644 --- a/drivers/crypto/dev_urandom.c +++ b/drivers/crypto/dev_urandom.c @@ -162,14 +162,15 @@ static inline uint32_t do_congruential(void) static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer, size_t len) { + size_t n; + uint32_t rnd; + #ifdef CONFIG_DEV_URANDOM_RANDOM_POOL - if (len) + if (len > 0) { getrandom(buffer, len); } #else - size_t n; - uint32_t rnd; n = len; @@ -239,6 +240,7 @@ static ssize_t devurand_write(FAR struct file *filep, FAR const char *buffer, memcpy(&seed, buffer, len); srand(seed); return len; + #elif defined(CONFIG_DEV_URANDOM_RANDOM_POOL) const unsigned int alignmask = sizeof(uint32_t) - 1; const size_t initlen = len;