summaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-04-21 11:48:26 +0200
committerVincent Petry <pvince81@owncloud.com>2016-04-21 11:48:26 +0200
commitb50d3255fb512c1b4f1186a5874c9528d9b407a3 (patch)
tree8874e8f1d00f1b3694951ada7234622bb21fb291 /apps/encryption/lib
parent6f5d3adfa405d41dd0e803d44bd54efcaa35769b (diff)
parent89223379ad155ae0896d1481089e3751257aa76f (diff)
downloadnextcloud-server-b50d3255fb512c1b4f1186a5874c9528d9b407a3.tar.gz
nextcloud-server-b50d3255fb512c1b4f1186a5874c9528d9b407a3.zip
Merge pull request #22791 from owncloud/enc_master_key_improvements
Enc master key improvements
Diffstat (limited to 'apps/encryption/lib')
-rw-r--r--apps/encryption/lib/keymanager.php12
-rw-r--r--apps/encryption/lib/users/setup.php22
2 files changed, 17 insertions, 17 deletions
diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php
index 0accfb7900a..5cce760fa59 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();
@@ -554,9 +558,11 @@ class KeyManager {
}
/**
+ * creat a backup of the users private and public key and then delete it
+ *
* @param string $uid
*/
- public function replaceUserKeys($uid) {
+ public function deleteUserKeys($uid) {
$this->backupAllKeys('password_reset');
$this->deletePublicKey($uid);
$this->deletePrivateKey($uid);
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;
}
}