From 33e72c57635923aa4ed85ab529cb7dd1d38ffc17 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 31 Oct 2011 13:20:39 +0000
Subject: [PATCH] Utilities: Use openssl_random_pseudo_bytes for in
 generateRandomBytes().

Fixes issue 403.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2969 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/Utilities.php | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index a9c7bfc03..2a15674e2 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -1006,6 +1006,10 @@ class SimpleSAML_Utilities {
 		static $fp = NULL;
 		assert('is_int($length)');
 
+		if (function_exists('openssl_random_pseudo_bytes')) {
+			return openssl_random_pseudo_bytes($length);
+		}
+
 		if($fp === NULL) {
 			if (@file_exists('/dev/urandom')) {
 				$fp = @fopen('/dev/urandom', 'rb');
-- 
GitLab