Skip to content

Commit

Permalink
Made SEC_randomBytes a bit safer
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Aug 18, 2019
1 parent 3018541 commit 6a68441
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion system/lib-security.php
Expand Up @@ -2127,9 +2127,14 @@ function SEC_randomBytes($length)
$retval = random_bytes($length);
} catch (Exception $e) {
$retval = false;
$isStrong = true;

if (is_callable('openssl_random_pseudo_bytes ')) {
$retval = openssl_random_pseudo_bytes($length);
$retval = openssl_random_pseudo_bytes($length, $isStrong);

if ($isStrong === false) {
$retval = false;
}
}

if ($retval === false) {
Expand Down

0 comments on commit 6a68441

Please sign in to comment.