From edcf99e3d1729610acbfc9cbb55bf814aa1c5636 Mon Sep 17 00:00:00 2001 From: Ilja Neumann Date: Fri, 22 Jul 2022 13:07:50 +0200 Subject: [PATCH 1/2] Disable signature-check on decrypt --- lib/Crypto/Crypt.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Crypto/Crypt.php b/lib/Crypto/Crypt.php index cd4e176..6900db0 100644 --- a/lib/Crypto/Crypt.php +++ b/lib/Crypto/Crypt.php @@ -496,6 +496,7 @@ protected function isValidPrivateKey($plainKey) { public function symmetricDecryptFileContent($keyFileContents, $passPhrase, $cipher = self::DEFAULT_CIPHER, $version = 0, $position = 0, $binaryEncode = false) { $catFile = $this->splitMetaData($keyFileContents, $cipher); + /* if ($catFile['signature'] !== false) { try { $this->checkSignature($catFile['encrypted'], $passPhrase . $version . "-" . $position, $catFile['signature']); @@ -504,6 +505,7 @@ public function symmetricDecryptFileContent($keyFileContents, $passPhrase, $ciph $this->checkSignature($catFile['encrypted'], $passPhrase . $version . $position, $catFile['signature']); } } + */ return $this->decrypt( $catFile['encrypted'], @@ -601,10 +603,12 @@ private function hasSignature($catFile, $cipher) { $meta = \substr($catFile, -93); $signaturePosition = \strpos($meta, '00sig00'); + /* // enforce signature for the new 'CTR' ciphers if ($signaturePosition === false && \strpos(\strtolower($cipher), 'ctr') !== false) { throw new HintException('Missing Signature', $this->l->t('Missing Signature')); } + */ return ($signaturePosition !== false); } @@ -628,7 +632,7 @@ private function decrypt($encryptedContent, $iv, $passPhrase = '', $cipher = sel $iv ); - if ($plainContent) { + if ($plainContent === false) { return $plainContent; } else { throw new DecryptionFailedException('Encryption library: Decryption (symmetric) of content failed: ' . \openssl_error_string()); From d91d40ff2c4eb1f0af83431bfdb5ba09e77ec9e7 Mon Sep 17 00:00:00 2001 From: Ilja Neumann Date: Mon, 25 Jul 2022 15:37:58 +0200 Subject: [PATCH 2/2] Update Crypt.php Wrong condition --- lib/Crypto/Crypt.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Crypto/Crypt.php b/lib/Crypto/Crypt.php index 6900db0..521ea18 100644 --- a/lib/Crypto/Crypt.php +++ b/lib/Crypto/Crypt.php @@ -633,9 +633,9 @@ private function decrypt($encryptedContent, $iv, $passPhrase = '', $cipher = sel ); if ($plainContent === false) { - return $plainContent; - } else { throw new DecryptionFailedException('Encryption library: Decryption (symmetric) of content failed: ' . \openssl_error_string()); + } else { + return $plainContent; } }