Skip to content

Commit

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

Expand Down Expand Up @@ -147,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 getentropy(output, n_bytes);
return arc4random_buf(output, n_bytes);
}
}

Expand All @@ -158,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;
getentropy(seed, length);
arc4random_buf(seed, length);
EVP_RAND_reseed(generator->context, params->prediction_resistance, seed, length, params->additional_data, params->additional_data_length);
}

Expand Down

0 comments on commit 877214c

Please sign in to comment.