diff options
author | Björn Schießle <schiessle@owncloud.com> | 2013-05-17 17:29:32 +0200 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2013-05-17 17:29:32 +0200 |
commit | eaa61b8539bcd1f428d8fad1d67894e8cb4f271a (patch) | |
tree | d7724a0ebdbb720da73c393b4adbf870cef80528 /apps/files_encryption/lib/crypt.php | |
parent | bdf74090fc073a9968a14ff53e7d70954f5920e8 (diff) | |
download | nextcloud-server-eaa61b8539bcd1f428d8fad1d67894e8cb4f271a.tar.gz nextcloud-server-eaa61b8539bcd1f428d8fad1d67894e8cb4f271a.zip |
fix migration to new encryption
Diffstat (limited to 'apps/files_encryption/lib/crypt.php')
-rwxr-xr-x | apps/files_encryption/lib/crypt.php | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php index 708d1719d73..56dacc94b0c 100755 --- a/apps/files_encryption/lib/crypt.php +++ b/apps/files_encryption/lib/crypt.php @@ -169,7 +169,7 @@ class Crypt { * @return true / false
*/
public static function isLegacyEncryptedContent( $data, $relPath ) {
-
+
// Fetch all file metadata from DB
$metadata = \OC\Files\Filesystem::getFileInfo( $relPath, '' );
@@ -683,15 +683,26 @@ class Crypt { $decrypted = $bf->decrypt( $content );
- $trimmed = rtrim( $decrypted, "\0" );
-
- return $trimmed;
+ return $decrypted;
}
+
+ private static function legacyBlockDecrypt($data, $key='',$maxLength=0) {
+ $result = '';
+ while (strlen($data)) {
+ $result.=self::legacyDecrypt(substr($data, 0, 8192), $key);
+ $data = substr($data, 8192);
+ }
+ if ($maxLength > 0) {
+ return substr($result, 0, $maxLength);
+ } else {
+ return rtrim($result, "\0");
+ }
+ }
public static function legacyKeyRecryptKeyfile( $legacyEncryptedContent, $legacyPassphrase, $publicKeys, $newPassphrase, $path ) {
- $decrypted = self::legacyDecrypt( $legacyEncryptedContent, $legacyPassphrase );
+ $decrypted = self::legacyBlockDecrypt( $legacyEncryptedContent, $legacyPassphrase );
// Encrypt plain data, generate keyfile & encrypted file
$cryptedData = self::symmetricEncryptFileContentKeyfile( $decrypted );
|