diff --git a/lib/private/setup/oci.php b/lib/private/setup/oci.php index e5634572d90243063d6751d90f28b869aacdb23d..d335df850cfbea801b0c397769dccda93cb39b50 100644 --- a/lib/private/setup/oci.php +++ b/lib/private/setup/oci.php @@ -106,7 +106,7 @@ class OCI extends AbstractDatabase { //add prefix to the oracle user name to prevent collisions $this->dbUser='oc_'.$username; //create a new password so we don't need to store the admin config in the config file - $this->dbPassword=\OC_Util::generateRandomBytes(30); + $this->dbPassword = \OC::$server->getSecureRandom()->generate(30, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS); //oracle passwords are treated as identifiers: // must start with alphanumeric char diff --git a/lib/private/setup/postgresql.php b/lib/private/setup/postgresql.php index 59762209d086766dc7f69f04ba0885c6ecfc6f20..850551e794fb00746a94272db10e8bc5cb2e858c 100644 --- a/lib/private/setup/postgresql.php +++ b/lib/private/setup/postgresql.php @@ -61,7 +61,7 @@ class PostgreSQL extends AbstractDatabase { //add prefix to the postgresql user name to prevent collisions $this->dbUser='oc_'.$username; //create a new password so we don't need to store the admin config in the config file - $this->dbPassword=\OC_Util::generateRandomBytes(30); + $this->dbPassword = \OC::$server->getSecureRandom()->generate(30, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS); $this->createDBUser($connection); } diff --git a/lib/private/util.php b/lib/private/util.php index ecb18946f124bf076d1c105d0a7800991a735486..ed62f1afb4a7857fdb283c9503e82c11add7580a 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -1278,18 +1278,6 @@ class OC_Util { } } - - /** - * Generates a cryptographic secure pseudo-random string - * - * @param int $length of the random string - * @return string - * @deprecated Use \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate($length); instead - */ - public static function generateRandomBytes($length = 30) { - return \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate($length, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS); - } - /** * Checks whether the server is running on Windows * diff --git a/lib/public/util.php b/lib/public/util.php index 493aa0000a52d28ffa72192594e1e794f3d7ad20..55bbd01eeaf48591b9d5cf4475ab67affaef3ce6 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -637,7 +637,7 @@ class Util { * @since 7.0.0 */ public static function generateRandomBytes($length = 30) { - return \OC_Util::generateRandomBytes($length); + return \OC::$server->getSecureRandom()->generate($length, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS); } /** diff --git a/tests/lib/util.php b/tests/lib/util.php index cb5d28b48a7d039fd9810e7a85493849b618e8a8..f05a33766b78efd4c351760695cd55f5dc55c6d7 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -138,11 +138,6 @@ class Test_Util extends \Test\TestCase { $this->assertEquals($expected, \OC_Util::fileInfoLoaded()); } - function testGenerateRandomBytes() { - $result = strlen(OC_Util::generateRandomBytes(59)); - $this->assertEquals(59, $result); - } - function testGetDefaultEmailAddress() { $email = \OCP\Util::getDefaultEmailAddress("no-reply"); $this->assertEquals('no-reply@localhost', $email);