diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-03-26 13:37:14 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-07 13:30:27 +0200 |
commit | 6c9251d9f8bd105ed5e3a99e124f0bab997fb477 (patch) | |
tree | 55e148c2fa032e871c84e902b528520ffc4e9ad8 | |
parent | cb9980823d62ab1ed843779bcac65152ed5379fe (diff) | |
download | nextcloud-server-6c9251d9f8bd105ed5e3a99e124f0bab997fb477.tar.gz nextcloud-server-6c9251d9f8bd105ed5e3a99e124f0bab997fb477.zip |
make sure that all file keys are written to the key storage
-rw-r--r-- | apps/encryption/lib/crypto/encryption.php | 11 | ||||
-rw-r--r-- | apps/encryption/lib/keymanager.php | 24 |
2 files changed, 32 insertions, 3 deletions
diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php index 66cb1dc434b..516d7b1304a 100644 --- a/apps/encryption/lib/crypto/encryption.php +++ b/apps/encryption/lib/crypto/encryption.php @@ -117,11 +117,16 @@ class Encryption implements IEncryptionModule { $this->writeCache = ''; } $publicKeys = array(); - foreach ($this->accessList['users'] as $user) { - $publicKeys[] = $this->keymanager->getPublicKey($user); + foreach ($this->accessList['users'] as $uid) { + $publicKeys[$uid] = $this->keymanager->getPublicKey($uid); } - $result = $this->crypt->multiKeyEncrypt($this->fileKey, $publicKeys); + $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); + } } return $result; } diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php index 120254defdd..59f904ecf17 100644 --- a/apps/encryption/lib/keymanager.php +++ b/apps/encryption/lib/keymanager.php @@ -174,6 +174,30 @@ class KeyManager { } /** + * write file key to key storage + * + * @param string $path + * @param string $key + * @return boolean + */ + public function setFileKey($path, $key) { + return $this->keyStorage->setFileKey($path, $this->fileKeyId, $key); + } + + /** + * write share key to the key storage + * + * @param string $path + * @param string $uid + * @param string $key + * @return boolean + */ + public function setShareKey($path, $uid, $key) { + $keyId = $uid . '.' . $this->shareKeyId; + return $this->keyStorage->setFileKey($path, $keyId, $key); + } + + /** * Decrypt private key and store it * * @param string $uid userid |