summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/setup.php2
-rwxr-xr-xlib/util.php24
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/setup.php b/lib/setup.php
index 16b9ec68df6..be4101fd7b0 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -5,12 +5,14 @@ $hasMySQL = is_callable('mysql_connect');
$hasPostgreSQL = is_callable('pg_connect');
$hasOracle = is_callable('oci_connect');
$datadir = OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data');
+
$opts = array(
'hasSQLite' => $hasSQLite,
'hasMySQL' => $hasMySQL,
'hasPostgreSQL' => $hasPostgreSQL,
'hasOracle' => $hasOracle,
'directory' => $datadir,
+ 'secureRNG' => OC_Util::secureRNG_available(),
'errors' => array(),
);
diff --git a/lib/util.php b/lib/util.php
index 748886083dd..9fde98c1972 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -559,6 +559,7 @@ class OC_Util {
* @brief Generates a cryptographical secure pseudorandom string
* @param Int with the length of the random string
* @return String
+ * Please also update secureRNG_available if you change something here
*/
public static function generate_random_bytes($length = 30) {
@@ -589,4 +590,27 @@ class OC_Util {
}
return $pseudo_byte;
}
+
+ /*
+ * @brief Checks if a secure random number generator is available
+ * @return bool
+ */
+ public static function secureRNG_available() {
+
+ // Check openssl_random_pseudo_bytes
+ if(function_exists('openssl_random_pseudo_bytes')) {
+ openssl_random_pseudo_bytes(1, $strong);
+ if($strong == TRUE) {
+ return true;
+ }
+ }
+
+ // Check /dev/random
+ $fp = @file_get_contents('/dev/random', false, null, 0, 1);
+ if ($fp !== FALSE) {
+ return true;
+ }
+
+ return false;
+ }
}