summaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-12-08 09:28:49 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-01-07 21:30:44 +0100
commit00a01a8de29614e95575a2e1689508e0871948e8 (patch)
tree96ef0c9dd1e932762057b5b9243cac998e73ee67 /apps/encryption/lib
parent1cc6fddead3f71d170557e99ef8676724cb58a6e (diff)
downloadnextcloud-server-00a01a8de29614e95575a2e1689508e0871948e8.tar.gz
nextcloud-server-00a01a8de29614e95575a2e1689508e0871948e8.zip
Fix PHPDoc + Add handling for error cases
Makes static code analyzers happier.
Diffstat (limited to 'apps/encryption/lib')
-rw-r--r--apps/encryption/lib/keymanager.php2
-rw-r--r--apps/encryption/lib/recovery.php12
2 files changed, 10 insertions, 4 deletions
diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php
index 0c8418c67a8..8fa42be27fc 100644
--- a/apps/encryption/lib/keymanager.php
+++ b/apps/encryption/lib/keymanager.php
@@ -213,7 +213,7 @@ class KeyManager {
}
/**
- * @param $password
+ * @param string $password
* @return bool
*/
public function checkRecoveryPassword($password) {
diff --git a/apps/encryption/lib/recovery.php b/apps/encryption/lib/recovery.php
index cffa641f517..32e3ec16dee 100644
--- a/apps/encryption/lib/recovery.php
+++ b/apps/encryption/lib/recovery.php
@@ -102,7 +102,6 @@ class Recovery {
}
/**
- * @param $recoveryKeyId
* @param string $password
* @return bool
*/
@@ -112,6 +111,9 @@ class Recovery {
if (!$keyManager->recoveryKeyExists()) {
$keyPair = $this->crypt->createKeyPair();
+ if(!is_array($keyPair)) {
+ return false;
+ }
$this->keyManager->setRecoveryKey($password, $keyPair);
}
@@ -134,6 +136,9 @@ class Recovery {
public function changeRecoveryKeyPassword($newPassword, $oldPassword) {
$recoveryKey = $this->keyManager->getSystemPrivateKey($this->keyManager->getRecoveryKeyId());
$decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $oldPassword);
+ if($decryptedRecoveryKey === false) {
+ return false;
+ }
$encryptedRecoveryKey = $this->crypt->encryptPrivateKey($decryptedRecoveryKey, $newPassword);
$header = $this->crypt->generateHeader();
if ($encryptedRecoveryKey) {
@@ -264,8 +269,9 @@ class Recovery {
$encryptedKey = $this->keyManager->getSystemPrivateKey($this->keyManager->getRecoveryKeyId());
$privateKey = $this->crypt->decryptPrivateKey($encryptedKey, $recoveryPassword);
-
- $this->recoverAllFiles('/' . $user . '/files/', $privateKey, $user);
+ if($privateKey !== false) {
+ $this->recoverAllFiles('/' . $user . '/files/', $privateKey, $user);
+ }
}
/**