[Pkg-owncloud-commits] [owncloud] 139/215: make sure that we create a header for the encrypted private key
David Prévot
taffit at moszumanska.debian.org
Tue May 5 01:01:39 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit 7d05f387fb01c1b72ab6a21951f6d86d2bb99003
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date: Tue Apr 28 12:57:30 2015 +0200
make sure that we create a header for the encrypted private key
---
apps/encryption/hooks/userhooks.php | 4 ++--
apps/encryption/tests/hooks/UserHooksTest.php | 13 ++++++++++++-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/apps/encryption/hooks/userhooks.php b/apps/encryption/hooks/userhooks.php
index b09b8e7..a86b866 100644
--- a/apps/encryption/hooks/userhooks.php
+++ b/apps/encryption/hooks/userhooks.php
@@ -226,7 +226,7 @@ class UserHooks implements IHook {
// Save private key
if ($encryptedPrivateKey) {
$this->keyManager->setPrivateKey($this->user->getUser()->getUID(),
- $encryptedPrivateKey);
+ $this->crypt->generateHeader() . $encryptedPrivateKey);
} else {
$this->logger->error('Encryption could not update users encryption password');
}
@@ -263,7 +263,7 @@ class UserHooks implements IHook {
$newUserPassword);
if ($encryptedKey) {
- $this->keyManager->setPrivateKey($user, $encryptedKey);
+ $this->keyManager->setPrivateKey($user, $this->crypt->generateHeader() . $encryptedKey);
if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files
$this->recovery->recoverUsersFiles($recoveryPassword, $user);
diff --git a/apps/encryption/tests/hooks/UserHooksTest.php b/apps/encryption/tests/hooks/UserHooksTest.php
index bcfb33e..b0cc9cc 100644
--- a/apps/encryption/tests/hooks/UserHooksTest.php
+++ b/apps/encryption/tests/hooks/UserHooksTest.php
@@ -11,6 +11,7 @@
namespace OCA\Encryption\Tests\Hooks;
+use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Hooks\UserHooks;
use Test\TestCase;
@@ -101,8 +102,18 @@ class UserHooksTest extends TestCase {
->method('symmetricEncryptFileContent')
->willReturn(true);
+ $this->cryptMock->expects($this->any())
+ ->method('generateHeader')
+ ->willReturn(Crypt::HEADER_START . ':Cipher:test:' . Crypt::HEADER_END);
+
$this->keyManagerMock->expects($this->exactly(4))
- ->method('setPrivateKey');
+ ->method('setPrivateKey')
+ ->willReturnCallback(function ($user, $key) {
+ $header = substr($key, 0, strlen(Crypt::HEADER_START));
+ $this->assertSame(
+ Crypt::HEADER_START,
+ $header, 'every encrypted file should start with a header');
+ });
$this->assertNull($this->instance->setPassphrase($this->params));
$this->params['recoveryPassword'] = 'password';
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list