summaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib/KeyManager.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/encryption/lib/KeyManager.php')
-rw-r--r--apps/encryption/lib/KeyManager.php26
1 files changed, 17 insertions, 9 deletions
diff --git a/apps/encryption/lib/KeyManager.php b/apps/encryption/lib/KeyManager.php
index 2c6487d062a..5f35f7a8422 100644
--- a/apps/encryption/lib/KeyManager.php
+++ b/apps/encryption/lib/KeyManager.php
@@ -44,7 +44,6 @@ use OCP\IUserSession;
use OCP\Lock\ILockingProvider;
class KeyManager {
-
/**
* @var Session
*/
@@ -443,15 +442,18 @@ class KeyManager {
* @param $uid
* @return string
*/
- public function getFileKey($path, $uid) {
+ public function getFileKey(string $path, ?string $uid, bool $useLegacyFileKey): string {
if ($uid === '') {
$uid = null;
}
$publicAccess = is_null($uid);
- $encryptedFileKey = $this->keyStorage->getFileKey($path, $this->fileKeyId, Encryption::ID);
- if (empty($encryptedFileKey)) {
- return '';
+ if ($useLegacyFileKey) {
+ $encryptedFileKey = $this->keyStorage->getFileKey($path, $this->fileKeyId, Encryption::ID);
+
+ if (empty($encryptedFileKey)) {
+ return '';
+ }
}
if ($this->util->isMasterKeyEnabled()) {
@@ -475,10 +477,16 @@ class KeyManager {
$privateKey = $this->session->getPrivateKey();
}
- if ($encryptedFileKey && $shareKey && $privateKey) {
- return $this->crypt->multiKeyDecrypt($encryptedFileKey,
- $shareKey,
- $privateKey);
+ if ($useLegacyFileKey) {
+ if ($encryptedFileKey && $shareKey && $privateKey) {
+ return $this->crypt->multiKeyDecryptLegacy($encryptedFileKey,
+ $shareKey,
+ $privateKey);
+ }
+ } else {
+ if ($shareKey && $privateKey) {
+ return $this->crypt->multiKeyDecrypt($shareKey, $privateKey);
+ }
}
return '';