summaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2016-03-02 13:58:06 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2016-03-18 11:06:14 +0100
commit5e267589d40400223e5dce692568ab2933be14f7 (patch)
tree018f66a48dacf80ab512c3d1898359f420b173b6 /apps/encryption/lib
parenta6c921267e00d0fb5021e8bdbd4d202931d7a58a (diff)
downloadnextcloud-server-5e267589d40400223e5dce692568ab2933be14f7.tar.gz
nextcloud-server-5e267589d40400223e5dce692568ab2933be14f7.zip
only create and update user specific key if no master key is enabled
Diffstat (limited to 'apps/encryption/lib')
-rw-r--r--apps/encryption/lib/keymanager.php8
-rw-r--r--apps/encryption/lib/users/setup.php22
2 files changed, 14 insertions, 16 deletions
diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php
index 12fa5f92bd5..1b81936aed1 100644
--- a/apps/encryption/lib/keymanager.php
+++ b/apps/encryption/lib/keymanager.php
@@ -174,6 +174,11 @@ class KeyManager {
* check if a key pair for the master key exists, if not we create one
*/
public function validateMasterKey() {
+
+ if ($this->util->isMasterKeyEnabled() === false) {
+ return;
+ }
+
$masterKey = $this->getPublicMasterKey();
if (empty($masterKey)) {
$keyPair = $this->crypt->createKeyPair();
@@ -334,7 +339,7 @@ class KeyManager {
/**
* Decrypt private key and store it
*
- * @param string $uid userid
+ * @param string $uid user id
* @param string $passPhrase users password
* @return boolean
*/
@@ -342,7 +347,6 @@ class KeyManager {
$this->session->setStatus(Session::INIT_EXECUTED);
-
try {
if($this->util->isMasterKeyEnabled()) {
$uid = $this->getMasterKeyId();
diff --git a/apps/encryption/lib/users/setup.php b/apps/encryption/lib/users/setup.php
index 0b5fb351aca..e59340c4ce2 100644
--- a/apps/encryption/lib/users/setup.php
+++ b/apps/encryption/lib/users/setup.php
@@ -66,29 +66,23 @@ class Setup {
}
/**
- * @param string $uid userid
+ * @param string $uid user id
* @param string $password user password
* @return bool
*/
public function setupUser($uid, $password) {
- return $this->setupServerSide($uid, $password);
+ if (!$this->keyManager->userHasKeys($uid)) {
+ return $this->keyManager->storeKeyPair($uid, $password,
+ $this->crypt->createKeyPair());
+ }
+ return true;
}
/**
- * check if user has a key pair, if not we create one
- *
- * @param string $uid userid
- * @param string $password user password
- * @return bool
+ * make sure that all system keys exists
*/
- public function setupServerSide($uid, $password) {
+ public function setupSystem() {
$this->keyManager->validateShareKey();
$this->keyManager->validateMasterKey();
- // Check if user already has keys
- if (!$this->keyManager->userHasKeys($uid)) {
- return $this->keyManager->storeKeyPair($uid, $password,
- $this->crypt->createKeyPair());
- }
- return true;
}
}