diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-03-28 11:02:26 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-07 13:30:28 +0200 |
commit | c64e0af4fb44b1464ca3433e99b12b729a2084b2 (patch) | |
tree | d2528e9e4e375cddc665adeb4aa84fa27e62c989 /apps/encryption/lib/crypto | |
parent | 24c6604388c0c3a32517e1aa18ebd851e1f7a6a1 (diff) | |
download | nextcloud-server-c64e0af4fb44b1464ca3433e99b12b729a2084b2.tar.gz nextcloud-server-c64e0af4fb44b1464ca3433e99b12b729a2084b2.zip |
check if recovery key exists and encrypt the file with the recovery key if needed
Diffstat (limited to 'apps/encryption/lib/crypto')
-rw-r--r-- | apps/encryption/lib/crypto/encryption.php | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php index da805892eaf..8c00077729e 100644 --- a/apps/encryption/lib/crypto/encryption.php +++ b/apps/encryption/lib/crypto/encryption.php @@ -46,9 +46,19 @@ class Encryption implements IEncryptionModule { /** @var boolean */ private $isWriteOperation; - public function __construct(Crypt $crypt, KeyManager $keymanager) { + /** @var \OC\Encryption\Util */ + private $util; + + /** + * + * @param \OCA\Encryption\Crypto\Crypt $crypt + * @param KeyManager $keymanager + * @param \OC\Encryption\Util $util + */ + public function __construct(Crypt $crypt, KeyManager $keymanager, \OC\Encryption\Util $util) { $this->crypt = $crypt; $this->keymanager = $keymanager; + $this->util = $util; } /** @@ -225,9 +235,7 @@ class Encryption implements IEncryptionModule { $publicKeys[$user] = $this->keymanager->getPublicKey($user); } - if (!empty($accessList['public'])) { - $publicKeys[$this->keymanager->getPublicShareKeyId()] = $this->keymanager->getPublicShareKey(); - } + $publicKeys = $this->addSystemKeys($accessList, $publicKeys); $encryptedFileKey = $this->crypt->multiKeyEncrypt($fileKey, $publicKeys); @@ -239,6 +247,29 @@ class Encryption implements IEncryptionModule { } /** + * add system keys such as the public share key and the recovery key + * + * @param array $accessList + * @param array $publicKeys + * @return array + */ + public function addSystemKeys(array $accessList, array $publicKeys) { + if (!empty($accessList['public'])) { + $publicKeys[$this->keymanager->getPublicShareKeyId()] = $this->keymanager->getPublicShareKey(); + } + + if ($this->keymanager->recoveryKeyExists() && + $this->util->recoveryEnabled($this->user)) { + + $publicKeys[$this->keymanager->getRecoveryKeyId()] = $this->keymanager->getRecoveryKey(); + } + + + return $publicKeys; + } + + + /** * should the file be encrypted or not * * @param string $path |