]> source.dussan.org Git - nextcloud-server.git/commitdiff
make sure that all file keys are written to the key storage
authorBjoern Schiessle <schiessle@owncloud.com>
Thu, 26 Mar 2015 12:37:14 +0000 (13:37 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 7 Apr 2015 11:30:27 +0000 (13:30 +0200)
apps/encryption/lib/crypto/encryption.php
apps/encryption/lib/keymanager.php

index 66cb1dc434b1e9774451db830d6140844d6b9512..516d7b1304a41ee9a63c27ec3d22783b714c7df5 100644 (file)
@@ -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;
        }
index 120254defdd18070daaff844fb1841e83cdd49cc..59f904ecf17f5af198ed177c8f3e95811a4f3706 100644 (file)
@@ -173,6 +173,30 @@ class KeyManager {
                        $key);
        }
 
+       /**
+        * 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
         *