Improve secret generation
Strip highest bit so that we can use more generated bytes in the ASCII password. See #13308 Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
parent
a07ee72499
commit
6b18dfa588
@ -223,10 +223,12 @@ class ServerConfigChecks
|
||||
$random_func = 'openssl_random_pseudo_bytes';
|
||||
}
|
||||
while (strlen($blowfishSecret) < 32) {
|
||||
$byte = $random_func(1);
|
||||
// Get random byte and strip highest bit
|
||||
// to get ASCII only range
|
||||
$byte = ord($random_func(1)) & 0x7f;
|
||||
// We want only ASCII chars
|
||||
if (ord($byte) > 32 && ord($byte) < 127) {
|
||||
$blowfishSecret .= $byte;
|
||||
if ($byte > 32) {
|
||||
$blowfishSecret .= chr($byte);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user