summaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2016-11-23 12:07:04 +0100
committerBjoern Schiessle <bjoern@schiessle.org>2016-11-23 12:20:43 +0100
commit8a401ee15687059836c93dda62ee5ea3fbf800cf (patch)
tree8326dc5b2df8660f47946926af30d330c234e6f3 /apps/encryption/lib
parent558a934842a9f66a873f24b8107fca1fc68fb791 (diff)
downloadnextcloud-server-8a401ee15687059836c93dda62ee5ea3fbf800cf.tar.gz
nextcloud-server-8a401ee15687059836c93dda62ee5ea3fbf800cf.zip
check if session is initialized
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/encryption/lib')
-rw-r--r--apps/encryption/lib/Crypto/Encryption.php8
-rw-r--r--apps/encryption/lib/KeyManager.php3
-rw-r--r--apps/encryption/lib/Session.php10
3 files changed, 18 insertions, 3 deletions
diff --git a/apps/encryption/lib/Crypto/Encryption.php b/apps/encryption/lib/Crypto/Encryption.php
index c71e25b6442..fdcbd41a09c 100644
--- a/apps/encryption/lib/Crypto/Encryption.php
+++ b/apps/encryption/lib/Crypto/Encryption.php
@@ -177,6 +177,14 @@ class Encryption implements IEncryptionModule {
$this->isWriteOperation = false;
$this->writeCache = '';
+ if($this->session->isReady() === false) {
+ // if the master key is enabled we can initialize encryption
+ // with a empty password and user name
+ if ($this->util->isMasterKeyEnabled()) {
+ $this->keyManager->init('', '');
+ }
+ }
+
if ($this->session->decryptAllModeActivated()) {
$encryptedFileKey = $this->keyManager->getEncryptedFileKey($this->path);
$shareKey = $this->keyManager->getShareKey($this->path, $this->session->getDecryptAllUid());
diff --git a/apps/encryption/lib/KeyManager.php b/apps/encryption/lib/KeyManager.php
index 96264d01363..26f023ed8f9 100644
--- a/apps/encryption/lib/KeyManager.php
+++ b/apps/encryption/lib/KeyManager.php
@@ -406,9 +406,6 @@ class KeyManager {
}
if ($this->util->isMasterKeyEnabled()) {
- if ($this->session->getStatus() === Session::NOT_INITIALIZED)
- $this->init('', '');
-
$uid = $this->getMasterKeyId();
}
diff --git a/apps/encryption/lib/Session.php b/apps/encryption/lib/Session.php
index 92132d6080c..a61ee25fadb 100644
--- a/apps/encryption/lib/Session.php
+++ b/apps/encryption/lib/Session.php
@@ -68,6 +68,16 @@ class Session {
}
/**
+ * check if encryption was initialized successfully
+ *
+ * @return bool
+ */
+ public function isReady() {
+ $status = $this->getStatus();
+ return $status === self::INIT_SUCCESSFUL;
+ }
+
+ /**
* Gets user or public share private key from session
*
* @return string $privateKey The user's plaintext private key