Merge branch 'master' into remove_unused_vars

Conflicts:
	apps/files_encryption/hooks/hooks.php
	apps/files_encryption/lib/crypt.php
	apps/files_encryption/lib/proxy.php
This commit is contained in:
Björn Schießle 2013-05-27 18:09:35 +02:00
commit 2c3c60c1af
4 changed files with 13 additions and 15 deletions

View File

@ -75,15 +75,13 @@ class Hooks {
$userView->file_exists('encryption.key') $userView->file_exists('encryption.key')
&& $encLegacyKey = $userView->file_get_contents('encryption.key') && $encLegacyKey = $userView->file_get_contents('encryption.key')
) { ) {
$plainLegacyKey = Crypt::legacyDecrypt($encLegacyKey, $params['password']); $plainLegacyKey = Crypt::legacyBlockDecrypt($encLegacyKey, $params['password']);
$session->setLegacyKey($plainLegacyKey); $session->setLegacyKey($plainLegacyKey);
} }
$publicKey = Keymanager::getPublicKey($view, $params['uid']);
// Encrypt existing user files: // Encrypt existing user files:
// This serves to upgrade old versions of the encryption // This serves to upgrade old versions of the encryption
// app (see appinfo/spec.txt) // app (see appinfo/spec.txt)

View File

@ -610,14 +610,13 @@ class Crypt {
* *
* This function decrypts an content * This function decrypts an content
*/ */
public static function legacyDecrypt($content, $passphrase = '') { private static function legacyDecrypt($content, $passphrase = '') {
$bf = self::getBlowfish($passphrase); $bf = self::getBlowfish($passphrase);
$decrypted = $bf->decrypt($content); $decrypted = $bf->decrypt($content);
return rtrim($decrypted, "\0");; return $decrypted;
} }
/** /**
@ -626,7 +625,8 @@ class Crypt {
* @param int $maxLength * @param int $maxLength
* @return string * @return string
*/ */
private static function legacyBlockDecrypt($data, $key = '', $maxLength = 0) { public static function legacyBlockDecrypt($data, $key = '', $maxLength = 0) {
$result = ''; $result = '';
while (strlen($data)) { while (strlen($data)) {
$result .= self::legacyDecrypt(substr($data, 0, 8192), $key); $result .= self::legacyDecrypt(substr($data, 0, 8192), $key);

View File

@ -226,7 +226,7 @@ class Proxy extends \OC_FileProxy {
&& isset($_SESSION['legacyenckey']) && isset($_SESSION['legacyenckey'])
&& Crypt::isEncryptedMeta($path) && Crypt::isEncryptedMeta($path)
) { ) {
$plainData = Crypt::legacyDecrypt($data, $session->getLegacyKey()); $plainData = Crypt::legacyBlockDecrypt($data, $session->getLegacyKey());
} }
\OC_FileProxy::$enabled = $proxyStatus; \OC_FileProxy::$enabled = $proxyStatus;

View File

@ -515,7 +515,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/ */
function testLegacyDecryptShort($crypted) { function testLegacyDecryptShort($crypted) {
$decrypted = Encryption\Crypt::legacyDecrypt($crypted, $this->pass); $decrypted = Encryption\Crypt::legacyBlockDecrypt($crypted, $this->pass);
$this->assertEquals($this->dataShort, $decrypted); $this->assertEquals($this->dataShort, $decrypted);
@ -543,7 +543,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/ */
function testLegacyDecryptLong($crypted) { function testLegacyDecryptLong($crypted) {
$decrypted = Encryption\Crypt::legacyDecrypt($crypted, $this->pass); $decrypted = Encryption\Crypt::legacyBlockDecrypt($crypted, $this->pass);
$this->assertEquals($this->dataLong, $decrypted); $this->assertEquals($this->dataLong, $decrypted);
@ -560,7 +560,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$encKey = Encryption\Crypt::legacyCreateKey($this->pass); $encKey = Encryption\Crypt::legacyCreateKey($this->pass);
// Decrypt key // Decrypt key
$key = Encryption\Crypt::legacyDecrypt($encKey, $this->pass); $key = Encryption\Crypt::legacyBlockDecrypt($encKey, $this->pass);
$this->assertTrue(is_numeric($key)); $this->assertTrue(is_numeric($key));