Skip to content

Commit

Permalink
use getrandom instead of getentropy
Browse files Browse the repository at this point in the history
  • Loading branch information
pushkarnk committed Sep 18, 2024
1 parent 877214c commit 112f37c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/native/c/drbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*
*/
#include <drbg.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/random.h>
#include <unistd.h>

DRBGParams NO_PARAMS = { DEFAULT_STRENGTH, 0, 0, NULL, 0, NULL, 0 };
Expand Down Expand Up @@ -148,7 +148,7 @@ int generate_seed(DRBG* generator, byte output[], int n_bytes) {
if (parent != NULL) {
return next_rand(parent, output, n_bytes);
} else {
return arc4random_buf(output, n_bytes);
return getrandom(output, n_bytes, 0);
}
}

Expand All @@ -159,7 +159,7 @@ void reseed(DRBG* generator) {
void reseed_with_params(DRBG *generator, DRBGParams *params) {
byte seed[128]; // TODO: what should the default seed size be?
size_t length = 128;
arc4random_buf(seed, length);
getrandom(seed, length, 0);
EVP_RAND_reseed(generator->context, params->prediction_resistance, seed, length, params->additional_data, params->additional_data_length);
}

Expand Down

0 comments on commit 112f37c

Please sign in to comment.