php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #71365 random_bytes(): missing Error causes; may return PRNG
Submitted: 2016-01-14 05:37 UTC Modified: 2017-01-28 13:14 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:0 of 1 (0.0%)
From: salsi at icosaedro dot it Assigned:
Status: Open Package: Unknown/Other Function
PHP Version: 7.0.2 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
45 - 12 = ?
Subscribe to this entry?

 
 [2016-01-14 05:37 UTC] salsi at icosaedro dot it
Description:
------------
---
From manual page: http://www.php.net/function.random-bytes
---

Examining the C source code, appears that the Error exception might be thrown also on failed reading from the source of randomness, or no enough entropy is available (whenever an estimation of the available entropy is available).

It might worth to mention also that if not enough entropy data is available, some implementations (notably when reading from /dev/urandom as a last resort) may return values from a PRNG rather than from a CSPRNG, so partially defeating the purpose of this function for CS applications.

The same holds for the companion random_int() function, which relies on the same base function as random_bytes().

Programmers should be advised that abusing of the entropy source may then compromise security, and those entropy sources should be used sparingly.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-17 16:01 UTC] public+php dot net at bastelstu dot be
http://www.2uo.de/myths-about-urandom/
 [2017-01-28 13:14 UTC] cmb@php.net
-Package: Documentation problem +Package: Unknown/Other Function
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Apr 12 17:01:24 2021 UTC