Skip to content

Commit

Permalink
Merge pull request #176 from paragonie/issue-175
Browse files Browse the repository at this point in the history
Issue 175
  • Loading branch information
paragonie-security committed Feb 16, 2022
2 parents 9174875 + 4958521 commit 96c132c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"php": ">=5.2.0"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*"
"phpunit/phpunit": "*"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
Expand Down
2 changes: 1 addition & 1 deletion lib/random.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class_exists('COM')
try {
$RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
/** @psalm-suppress TypeDoesNotContainType */
if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
if (is_callable(array($RandomCompatCOMtest, 'GetRandom'))) {
// See random_bytes_com_dotnet.php
require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_com_dotnet.php';
}
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/RandomBytesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public function testOutput()
random_bytes(12),
random_bytes(64),
random_bytes(64),
random_bytes(1.5)
PHP_VERSION_ID < 80100
? random_bytes(1.5)
: random_bytes(1)
);

$this->assertTrue(
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/RandomIntTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ public function testOutput()
random_int(-1000, 1000),
random_int(~PHP_INT_MAX, PHP_INT_MAX),
random_int("0", "1"),
random_int(0.11111, 0.99999),
PHP_VERSION_ID < 80100
? random_int(0.11111, 0.99999)
: 0,
random_int($half_neg_max, PHP_INT_MAX),
random_int(0.0, 255.0),
random_int(-4.5, -4.5),
PHP_VERSION_ID < 80100
? random_int(-4.5, -4.5)
: -4,
random_int("1337e3","1337e3")
);

Expand Down

0 comments on commit 96c132c

Please sign in to comment.