aboutsummaryrefslogtreecommitdiffstats
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.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php
index a280ea9bde3..b451b5c25a9 100644
--- a/apps/encryption/lib/keymanager.php
+++ b/apps/encryption/lib/keymanager.php
@@ -140,7 +140,8 @@ class KeyManager {
// Encrypt private key empty passphrase
$encryptedKey = $this->crypt->symmetricEncryptFileContent($keyPair['privateKey'], '');
- $this->keyStorage->setSystemUserKey($this->publicShareKeyId . '.privateKey', $encryptedKey);
+ $header = $this->crypt->generateHeader();
+ $this->setSystemPrivateKey($this->publicShareKeyId, $header . $encryptedKey);
}
$this->keyId = $userSession && $userSession->isLoggedIn() ? $userSession->getUser()->getUID() : false;
@@ -294,6 +295,9 @@ class KeyManager {
* @return boolean
*/
public function init($uid, $passPhrase) {
+
+ $this->session->setStatus(Session::INIT_EXECUTED);
+
try {
$privateKey = $this->getPrivateKey($uid);
$privateKey = $this->crypt->decryptPrivateKey($privateKey,
@@ -304,10 +308,13 @@ class KeyManager {
return false;
}
- $this->session->setPrivateKey($privateKey);
- $this->session->setStatus(Session::INIT_SUCCESSFUL);
+ if ($privateKey) {
+ $this->session->setPrivateKey($privateKey);
+ $this->session->setStatus(Session::INIT_SUCCESSFUL);
+ return true;
+ }
- return true;
+ return false;
}
/**
@@ -337,7 +344,7 @@ class KeyManager {
$uid = $this->getPublicShareKeyId();
$shareKey = $this->getShareKey($path, $uid);
$privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.privateKey');
- $privateKey = $this->crypt->symmetricDecryptFileContent($privateKey);
+ $privateKey = $this->crypt->decryptPrivateKey($privateKey);
} else {
$shareKey = $this->getShareKey($path, $uid);
$privateKey = $this->session->getPrivateKey();