diff options
author | J0WI <J0WI@users.noreply.github.com> | 2021-06-24 02:58:08 +0300 |
---|---|---|
committer | J0WI <J0WI@users.noreply.github.com> | 2021-06-29 14:41:22 +0300 |
commit | c694b9d52b375158790f1c95c0804073dcab57f4 (patch) | |
tree | 82aaf17345c1a3d21afebef009fa191029ee7a87 /apps/encryption | |
parent | 556f51efb41824fd3ae25620c58f8b48d06fc36d (diff) |
Remember current cipher
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
Diffstat (limited to 'apps/encryption')
-rw-r--r-- | apps/encryption/lib/Crypto/Crypt.php | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/apps/encryption/lib/Crypto/Crypt.php b/apps/encryption/lib/Crypto/Crypt.php index a7d7c024cbb..8a6be4d3809 100644 --- a/apps/encryption/lib/Crypto/Crypt.php +++ b/apps/encryption/lib/Crypto/Crypt.php @@ -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')); } |