Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/files_encryption/hooks/hooks.php12
-rwxr-xr-xapps/files_encryption/lib/crypt.php8
-rw-r--r--apps/files_encryption/lib/proxy.php2
-rwxr-xr-xapps/files_encryption/tests/crypt.php6
4 files changed, 13 insertions, 15 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index f0d0856d6e1..c3371061356 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -75,15 +75,13 @@ class Hooks {
$userView->file_exists('encryption.key')
&& $encLegacyKey = $userView->file_get_contents('encryption.key')
) {
-
- $plainLegacyKey = Crypt::legacyDecrypt($encLegacyKey, $params['password']);
-
+
+ $plainLegacyKey = Crypt::legacyBlockDecrypt($encLegacyKey, $params['password']);
+
$session->setLegacyKey($plainLegacyKey);
-
+
}
-
- $publicKey = Keymanager::getPublicKey($view, $params['uid']);
-
+
// Encrypt existing user files:
// This serves to upgrade old versions of the encryption
// app (see appinfo/spec.txt)
diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php
index 11b9298b447..ef50dc0cd7a 100755
--- a/apps/files_encryption/lib/crypt.php
+++ b/apps/files_encryption/lib/crypt.php
@@ -610,14 +610,13 @@ class Crypt {
*
* This function decrypts an content
*/
- public static function legacyDecrypt($content, $passphrase = '') {
+ private static function legacyDecrypt($content, $passphrase = '') {
$bf = self::getBlowfish($passphrase);
$decrypted = $bf->decrypt($content);
- return rtrim($decrypted, "\0");;
-
+ return $decrypted;
}
/**
@@ -626,7 +625,8 @@ class Crypt {
* @param int $maxLength
* @return string
*/
- private static function legacyBlockDecrypt($data, $key = '', $maxLength = 0) {
+ public static function legacyBlockDecrypt($data, $key = '', $maxLength = 0) {
+
$result = '';
while (strlen($data)) {
$result .= self::legacyDecrypt(substr($data, 0, 8192), $key);
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 0efe0a79118..ae64e852aef 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -226,7 +226,7 @@ class Proxy extends \OC_FileProxy {
&& isset($_SESSION['legacyenckey'])
&& Crypt::isEncryptedMeta($path)
) {
- $plainData = Crypt::legacyDecrypt($data, $session->getLegacyKey());
+ $plainData = Crypt::legacyBlockDecrypt($data, $session->getLegacyKey());
}
\OC_FileProxy::$enabled = $proxyStatus;
diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php
index fa2a2984d58..f5407deef0e 100755
--- a/apps/files_encryption/tests/crypt.php
+++ b/apps/files_encryption/tests/crypt.php
@@ -515,7 +515,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testLegacyDecryptShort($crypted) {
- $decrypted = Encryption\Crypt::legacyDecrypt($crypted, $this->pass);
+ $decrypted = Encryption\Crypt::legacyBlockDecrypt($crypted, $this->pass);
$this->assertEquals($this->dataShort, $decrypted);
@@ -543,7 +543,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testLegacyDecryptLong($crypted) {
- $decrypted = Encryption\Crypt::legacyDecrypt($crypted, $this->pass);
+ $decrypted = Encryption\Crypt::legacyBlockDecrypt($crypted, $this->pass);
$this->assertEquals($this->dataLong, $decrypted);
@@ -560,7 +560,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$encKey = Encryption\Crypt::legacyCreateKey($this->pass);
// Decrypt key
- $key = Encryption\Crypt::legacyDecrypt($encKey, $this->pass);
+ $key = Encryption\Crypt::legacyBlockDecrypt($encKey, $this->pass);
$this->assertTrue(is_numeric($key));