Remove generateRandomBytes from OC_Util

This commit is contained in:
Roeland Jago Douma 2016-01-10 22:07:33 +01:00
parent 656b541899
commit e01a488b31
5 changed files with 3 additions and 20 deletions

View File

@ -106,7 +106,7 @@ class OCI extends AbstractDatabase {
//add prefix to the oracle user name to prevent collisions //add prefix to the oracle user name to prevent collisions
$this->dbUser='oc_'.$username; $this->dbUser='oc_'.$username;
//create a new password so we don't need to store the admin config in the config file //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: //oracle passwords are treated as identifiers:
// must start with alphanumeric char // must start with alphanumeric char

View File

@ -61,7 +61,7 @@ class PostgreSQL extends AbstractDatabase {
//add prefix to the postgresql user name to prevent collisions //add prefix to the postgresql user name to prevent collisions
$this->dbUser='oc_'.$username; $this->dbUser='oc_'.$username;
//create a new password so we don't need to store the admin config in the config file //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); $this->createDBUser($connection);
} }

View File

@ -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 * Checks whether the server is running on Windows
* *

View File

@ -637,7 +637,7 @@ class Util {
* @since 7.0.0 * @since 7.0.0
*/ */
public static function generateRandomBytes($length = 30) { 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);
} }
/** /**

View File

@ -138,11 +138,6 @@ class Test_Util extends \Test\TestCase {
$this->assertEquals($expected, \OC_Util::fileInfoLoaded()); $this->assertEquals($expected, \OC_Util::fileInfoLoaded());
} }
function testGenerateRandomBytes() {
$result = strlen(OC_Util::generateRandomBytes(59));
$this->assertEquals(59, $result);
}
function testGetDefaultEmailAddress() { function testGetDefaultEmailAddress() {
$email = \OCP\Util::getDefaultEmailAddress("no-reply"); $email = \OCP\Util::getDefaultEmailAddress("no-reply");
$this->assertEquals('no-reply@localhost', $email); $this->assertEquals('no-reply@localhost', $email);