Skip to content
Snippets Groups Projects
Commit e43f85a5 authored by Jakob Olsson's avatar Jakob Olsson
Browse files

refactor random seed generation

parent 2dedcf16
No related branches found
No related tags found
No related merge requests found
Pipeline #35458 passed
......@@ -91,9 +91,14 @@ int timeradd_msecs(struct timeval *a, unsigned long msecs, struct timeval *res)
void get_random_bytes(int num, uint8_t *buf)
{
unsigned int seed = (unsigned int)time(NULL);
unsigned int seed;
struct timespec res = {0};
int i;
clock_gettime(CLOCK_REALTIME, &res);
seed = res.tv_nsec;
srand(seed);
for (i = 0; i < num; i++)
buf[i] = rand_r(&seed) & 0xff;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment