]> source.dussan.org Git - nextcloud-server.git/commitdiff
SSE enhancement 22212/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Tue, 11 Aug 2020 17:26:41 +0000 (19:26 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Wed, 12 Aug 2020 07:13:43 +0000 (07:13 +0000)
Do not blind concatenate ints. Lets add a _ between them. So that we can
distrinquis them properly

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
apps/encryption/lib/Crypto/Crypt.php

index 45319302bbfb4f2b9cd54224dd3d062cae9fe591..eaa77954d46dfced4079143cc89bdb142d3d7d27 100644 (file)
@@ -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'],