summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-03-27 11:43:02 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-07 13:30:27 +0200
commit37e8268447b93f6a74c69b0b489c9c3a95ed1fa5 (patch)
tree1f36d1efc71d15fe9b163a0450abb6b5de29e49b
parent8dde93254680bfb481e8c737fd3696ee5a9e74da (diff)
downloadnextcloud-server-37e8268447b93f6a74c69b0b489c9c3a95ed1fa5.tar.gz
nextcloud-server-37e8268447b93f6a74c69b0b489c9c3a95ed1fa5.zip
make sharing and unsharing work
-rw-r--r--apps/encryption/lib/crypto/encryption.php21
-rw-r--r--apps/encryption/lib/keymanager.php17
2 files changed, 31 insertions, 7 deletions
diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php
index f036ea42cb9..beb922afe72 100644
--- a/apps/encryption/lib/crypto/encryption.php
+++ b/apps/encryption/lib/crypto/encryption.php
@@ -122,11 +122,7 @@ class Encryption implements IEncryptionModule {
}
$encryptedKeyfiles = $this->crypt->multiKeyEncrypt($this->fileKey, $publicKeys);
-
- $this->keymanager->setFileKey($path, $encryptedKeyfiles['data']);
- foreach ($encryptedKeyfiles['keys'] as $uid => $keyFile) {
- $this->keymanager->setShareKey($path, $uid, $keyFile);
- }
+ $this->keymanager->setAllFileKeys($path, $encryptedKeyfiles);
}
return $result;
}
@@ -218,11 +214,22 @@ class Encryption implements IEncryptionModule {
* update encrypted file, e.g. give additional users access to the file
*
* @param string $path path to the file which should be updated
+ * @param string $uid of the user who performs the operation
* @param array $accessList who has access to the file contains the key 'users' and 'public'
* @return boolean
*/
- public function update($path, $accessList) {
- // TODO: Implement update() method.
+ public function update($path, $uid, $accessList) {
+ $fileKey = $this->keymanager->getFileKey($path, $uid);
+ foreach ($accessList['users'] as $user) {
+ $publicKeys[$user] = $this->keymanager->getPublicKey($user);
+ }
+ $encryptedFileKey = $this->crypt->multiKeyEncrypt($fileKey, $publicKeys);
+
+ $this->keymanager->deleteAllFileKeys($path);
+
+ $this->keymanager->setAllFileKeys($path, $encryptedFileKey);
+
+ return true;
}
/**
diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php
index e03852c1f6b..fe7fe08d277 100644
--- a/apps/encryption/lib/keymanager.php
+++ b/apps/encryption/lib/keymanager.php
@@ -184,6 +184,19 @@ class KeyManager {
}
/**
+ * set all file keys (the file key and the corresponding share keys)
+ *
+ * @param string $path
+ * @param array $keys
+ */
+ public function setAllFileKeys($path, $keys) {
+ $this->setFileKey($path, $keys['data']);
+ foreach ($keys['keys'] as $uid => $keyFile) {
+ $this->setShareKey($path, $uid, $keyFile);
+ }
+ }
+
+ /**
* write share key to the key storage
*
* @param string $path
@@ -405,6 +418,10 @@ class KeyManager {
return $this->keyStorage->deleteUserKey($uid, $this->privateKeyId);
}
+ public function deleteAllFileKeys($path) {
+ return $this->keyStorage->deleteAllFileKeys($path);
+ }
+
/**
* @param array $userIds
* @return array