mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Remember current cipher
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
This commit is contained in:
parent
556f51efb4
commit
c694b9d52b
1 changed files with 23 additions and 4 deletions
|
|
@ -89,6 +89,9 @@ class Crypt {
|
|||
/** @var IL10N */
|
||||
private $l;
|
||||
|
||||
/** @var string|null */
|
||||
private $currentCipher;
|
||||
|
||||
/** @var bool */
|
||||
private $supportLegacy;
|
||||
|
||||
|
|
@ -248,12 +251,17 @@ class Crypt {
|
|||
}
|
||||
|
||||
/**
|
||||
* return Cipher either from config.php or the default cipher defined in
|
||||
* return cipher either from config.php or the default cipher defined in
|
||||
* this class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCipher() {
|
||||
private function getCachedCipher() {
|
||||
if (isset($this->currentCipher)) {
|
||||
return $this->currentCipher;
|
||||
}
|
||||
|
||||
// Get cipher either from config.php or the default cipher defined in this class
|
||||
$cipher = $this->config->getSystemValue('cipher', self::DEFAULT_CIPHER);
|
||||
if (!isset(self::SUPPORTED_CIPHERS_AND_KEY_SIZE[$cipher])) {
|
||||
$this->logger->warning(
|
||||
|
|
@ -267,7 +275,18 @@ class Crypt {
|
|||
$cipher = self::DEFAULT_CIPHER;
|
||||
}
|
||||
|
||||
return $cipher;
|
||||
// Remember current cipher to avoid frequent lookups
|
||||
$this->currentCipher = $cipher;
|
||||
return $this->currentCipher;
|
||||
}
|
||||
|
||||
/**
|
||||
* return current encryption cipher
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCipher() {
|
||||
return $this->getCachedCipher();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -577,7 +596,7 @@ class Crypt {
|
|||
throw new GenericEncryptionException('Missing Signature', $this->l->t('Missing Signature'));
|
||||
}
|
||||
|
||||
// enforce signature for the new 'CTR' ciphers
|
||||
// Enforce signature for the new 'CTR' ciphers
|
||||
if (!$skipSignatureCheck && $signaturePosition === false && stripos($cipher, 'ctr') !== false) {
|
||||
throw new GenericEncryptionException('Missing Signature', $this->l->t('Missing Signature'));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue