Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/classes/Plugins/Auth/AuthenticationCookie.php')
-rw-r--r--libraries/classes/Plugins/Auth/AuthenticationCookie.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/libraries/classes/Plugins/Auth/AuthenticationCookie.php b/libraries/classes/Plugins/Auth/AuthenticationCookie.php
index b4a0b0bfde..c468223232 100644
--- a/libraries/classes/Plugins/Auth/AuthenticationCookie.php
+++ b/libraries/classes/Plugins/Auth/AuthenticationCookie.php
@@ -592,11 +592,21 @@ class AuthenticationCookie extends AuthenticationPlugin
*/
private function getEncryptionSecret(): string
{
+ /** @var mixed $key */
$key = $GLOBALS['cfg']['blowfish_secret'] ?? null;
- if (is_string($key) && mb_strlen($key, '8bit') === SODIUM_CRYPTO_SECRETBOX_KEYBYTES) {
+ if (! is_string($key)) {
+ return $this->getSessionEncryptionSecret();
+ }
+
+ $length = mb_strlen($key, '8bit');
+ if ($length === SODIUM_CRYPTO_SECRETBOX_KEYBYTES) {
return $key;
}
+ if ($length > SODIUM_CRYPTO_SECRETBOX_KEYBYTES) {
+ return mb_substr($key, 0, SODIUM_CRYPTO_SECRETBOX_KEYBYTES, '8bit');
+ }
+
return $this->getSessionEncryptionSecret();
}
@@ -605,6 +615,7 @@ class AuthenticationCookie extends AuthenticationPlugin
*/
private function getSessionEncryptionSecret(): string
{
+ /** @var mixed $key */
$key = $_SESSION['encryption_key'] ?? null;
if (is_string($key) && mb_strlen($key, '8bit') === SODIUM_CRYPTO_SECRETBOX_KEYBYTES) {
return $key;