summaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-04-28 17:29:10 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2015-04-28 20:21:53 +0200
commitdf428b76ac498110bde0bfec1ad726cf24c21cfa (patch)
tree36675bbc0c99deee2c11fb996fb8396b90266818 /apps/encryption/lib
parent557b4a2cb0ae0367e5facb1e4be136de07ab8cff (diff)
downloadnextcloud-server-df428b76ac498110bde0bfec1ad726cf24c21cfa.tar.gz
nextcloud-server-df428b76ac498110bde0bfec1ad726cf24c21cfa.zip
skip update of encryption keys if file is not encrypted
Diffstat (limited to 'apps/encryption/lib')
-rw-r--r--apps/encryption/lib/crypto/encryption.php39
1 files changed, 29 insertions, 10 deletions
diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php
index 3f298481680..cc61f04ef02 100644
--- a/apps/encryption/lib/crypto/encryption.php
+++ b/apps/encryption/lib/crypto/encryption.php
@@ -28,6 +28,7 @@ namespace OCA\Encryption\Crypto;
use OCA\Encryption\Util;
use OCP\Encryption\IEncryptionModule;
use OCA\Encryption\KeyManager;
+use OCP\ILogger;
class Encryption implements IEncryptionModule {
@@ -66,16 +67,24 @@ class Encryption implements IEncryptionModule {
/** @var Util */
private $util;
+ /** @var ILogger */
+ private $logger;
+
/**
*
- * @param \OCA\Encryption\Crypto\Crypt $crypt
+ * @param Crypt $crypt
* @param KeyManager $keyManager
* @param Util $util
+ * @param ILogger $logger
*/
- public function __construct(Crypt $crypt, KeyManager $keyManager, Util $util) {
+ public function __construct(Crypt $crypt,
+ KeyManager $keyManager,
+ Util $util,
+ ILogger $logger) {
$this->crypt = $crypt;
$this->keyManager = $keyManager;
$this->util = $util;
+ $this->logger = $logger;
}
/**
@@ -257,18 +266,28 @@ class Encryption implements IEncryptionModule {
*/
public function update($path, $uid, array $accessList) {
$fileKey = $this->keyManager->getFileKey($path, $uid);
- $publicKeys = array();
- foreach ($accessList['users'] as $user) {
- $publicKeys[$user] = $this->keyManager->getPublicKey($user);
- }
- $publicKeys = $this->keyManager->addSystemKeys($accessList, $publicKeys);
+ if (!empty($fileKey)) {
+
+ $publicKeys = array();
+ foreach ($accessList['users'] as $user) {
+ $publicKeys[$user] = $this->keyManager->getPublicKey($user);
+ }
+
+ $publicKeys = $this->keyManager->addSystemKeys($accessList, $publicKeys);
- $encryptedFileKey = $this->crypt->multiKeyEncrypt($fileKey, $publicKeys);
+ $encryptedFileKey = $this->crypt->multiKeyEncrypt($fileKey, $publicKeys);
- $this->keyManager->deleteAllFileKeys($path);
+ $this->keyManager->deleteAllFileKeys($path);
- $this->keyManager->setAllFileKeys($path, $encryptedFileKey);
+ $this->keyManager->setAllFileKeys($path, $encryptedFileKey);
+
+ } else {
+ $this->logger->debug('no file key found, we assume that the file "{file}" is not encrypted',
+ array('file' => $path, 'app' => 'encryption'));
+
+ return false;
+ }
return true;
}