mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00

Fix to_read, throw exception if syscall fails Fixes thanks to feedback from sarnold at ##crypto on freenode Correction on error conditions Remove dead code (thanks @defuse) It turns out getrandom can take >256, getentropy refuses. Better semantics Thanks @defuse for catching my silly mistake here Cast to size_t to be explicit Let's simplify the logic a bit Let's be consistent; define everything before we do any logic Continuously check that the file descriptor is still a valid one Add device type check on fd initialization
17 lines
246 B
PHP
17 lines
246 B
PHP
--TEST--
|
|
Test normal operation of random_bytes()
|
|
--FILE--
|
|
<?php
|
|
//-=-=-=-
|
|
|
|
var_dump(strlen(bin2hex(random_bytes(16))));
|
|
|
|
var_dump(is_string(random_bytes(10)));
|
|
|
|
var_dump(is_string(random_bytes(257)));
|
|
|
|
?>
|
|
--EXPECT--
|
|
int(32)
|
|
bool(true)
|
|
bool(true)
|