diff options
author | Vincent Petry <pvince81@owncloud.com> | 2017-03-02 16:11:01 +0100 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2017-03-24 14:55:42 +0100 |
commit | 6b9ef15803d16de4f227f4176056c030bbed9ebf (patch) | |
tree | 2ad1dda10e405dcc0c06a76b2a7680e6edb98338 /apps/encryption/lib | |
parent | 305718370a0a202dbb1848683876ff236ec9f441 (diff) | |
download | nextcloud-server-6b9ef15803d16de4f227f4176056c030bbed9ebf.tar.gz nextcloud-server-6b9ef15803d16de4f227f4176056c030bbed9ebf.zip |
Use master key for public links as well
Diffstat (limited to 'apps/encryption/lib')
-rw-r--r-- | apps/encryption/lib/KeyManager.php | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/apps/encryption/lib/KeyManager.php b/apps/encryption/lib/KeyManager.php index a6708df9a1c..32872ae99b3 100644 --- a/apps/encryption/lib/KeyManager.php +++ b/apps/encryption/lib/KeyManager.php @@ -399,17 +399,28 @@ class KeyManager { * @return string */ public function getFileKey($path, $uid) { + if ($uid === '') { + $uid = null; + } + $publicAccess = is_null($uid); $encryptedFileKey = $this->keyStorage->getFileKey($path, $this->fileKeyId, Encryption::ID); if (empty($encryptedFileKey)) { return ''; } - if (!is_null($uid) && $this->util->isMasterKeyEnabled()) { + if ($this->util->isMasterKeyEnabled()) { $uid = $this->getMasterKeyId(); - } - - if (is_null($uid)) { + $shareKey = $this->getShareKey($path, $uid); + if ($publicAccess) { + $privateKey = $this->getSystemPrivateKey($uid); + $privateKey = $this->crypt->decryptPrivateKey($privateKey, $this->getMasterKeyPassword(), $uid); + } else { + // when logged in, the master key is already decrypted in the session + $privateKey = $this->session->getPrivateKey(); + } + } else if ($publicAccess) { + // use public share key for public links $uid = $this->getPublicShareKeyId(); $shareKey = $this->getShareKey($path, $uid); $privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.privateKey', Encryption::ID); |