Skip to content

Commit

Permalink
Using arc4random_buf instead of getentropy. Thanks to Leont for GH#16
Browse files Browse the repository at this point in the history
  • Loading branch information
david-dick committed Jan 13, 2025
1 parent be528e2 commit d07eae1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions URandom.xs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ crypt_urandom_getrandom(length)
result = syscall(SYS_getrandom, data, length, GRND_NONBLOCK);
#else
#ifdef HAVE_CRYPT_URANDOM_NATIVE_GETENTROPY
result = getentropy(data, length);
arc4random_buf(data, length);
result = length;
#else
#ifdef HAVE_CRYPT_URANDOM_UNISTD_GETENTROPY
result = getentropy(data, length);
arc4random_buf(data, length);
result = length;
#else
croak("Unable to find getrandom or an alternative");
#endif
Expand Down
8 changes: 4 additions & 4 deletions check_random.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ int main(void)
{
char buf[5];
int l = 5;
int r = getentropy(buf, l);
return 0;
arc4random_buf(buf, l);
return l;
}
_OUT_
close FOO or die "Failed to close $test_file_name:$!";
Expand All @@ -83,8 +83,8 @@ int main(void)
{
char buf[5];
int l = 5;
int r = getentropy(buf, l);
return 0;
arc4random_buf(buf, l);
return l;
}
_OUT_
close FOO or die "Failed to close $test_file_name:$!";
Expand Down

0 comments on commit d07eae1

Please sign in to comment.