Skip to content

Commit 518fb25

Browse files
author
Tero Heinonen
committed
Replaced srand & rand with randlib functions.
Functionality is same, but now it works in different platforms.
1 parent e154420 commit 518fb25

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

source/coap_security_handler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,14 @@ int entropy_poll( void *ctx, unsigned char *output, size_t len,
383383
size_t *olen )
384384
{
385385
//TODO: change to more secure random
386-
srand(time(NULL));
386+
randLIB_seed_random();
387387
char *c = (char*)ns_dyn_mem_temporary_alloc(len);
388388
if( !c ){
389389
return MBEDTLS_ERR_ENTROPY_SOURCE_FAILED;
390390
}
391391
memset(c, 0, len);
392392
for(uint16_t i=0; i < len; i++){
393-
c[i] = rand() % 256;
393+
c[i] = (char)randLIB_get_8bit;
394394
}
395395
memmove(output, c, len);
396396
*olen = len;

0 commit comments

Comments
 (0)