diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-08-12 10:44:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-12 10:44:15 +0200 |
commit | 7ffd98d91aea99eba17c6469090c728d7371acb5 (patch) | |
tree | da20c014dbd0dd899cb99b095606ddd7b5279551 | |
parent | 5431a110756941014c966155440e0c424ca5fbba (diff) | |
parent | bcf66f57eede2cf78c4f98b1fc296b052c9ea30a (diff) | |
download | nextcloud-server-7ffd98d91aea99eba17c6469090c728d7371acb5.tar.gz nextcloud-server-7ffd98d91aea99eba17c6469090c728d7371acb5.zip |
Merge pull request #22212 from nextcloud/backport/22196/stable18
[stable18] SSE enhancement of file signature
-rw-r--r-- | apps/encryption/lib/Crypto/Crypt.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/apps/encryption/lib/Crypto/Crypt.php b/apps/encryption/lib/Crypto/Crypt.php index 45319302bbf..eaa77954d46 100644 --- a/apps/encryption/lib/Crypto/Crypt.php +++ b/apps/encryption/lib/Crypto/Crypt.php @@ -192,7 +192,7 @@ class Crypt { $this->getCipher()); // Create a signature based on the key as well as the current version - $sig = $this->createSignature($encryptedContent, $passPhrase.$version.$position); + $sig = $this->createSignature($encryptedContent, $passPhrase.'_'.$version.'_'.$position); // combine content to encrypt the IV identifier and actual IV $catFile = $this->concatIV($encryptedContent, $iv); @@ -465,7 +465,13 @@ class Crypt { $catFile = $this->splitMetaData($keyFileContents, $cipher); if ($catFile['signature'] !== false) { - $this->checkSignature($catFile['encrypted'], $passPhrase.$version.$position, $catFile['signature']); + try { + // First try the new format + $this->checkSignature($catFile['encrypted'], $passPhrase . '_' . $version . '_' . $position, $catFile['signature']); + } catch (GenericEncryptionException $e) { + // For compatibility with old files check the version without _ + $this->checkSignature($catFile['encrypted'], $passPhrase . $version . $position, $catFile['signature']); + } } return $this->decrypt($catFile['encrypted'], |