aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib/util.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption/lib/util.php')
-rw-r--r--apps/files_encryption/lib/util.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 19c9cd72a19..6cb4ccb8085 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -1282,4 +1282,32 @@ class Util {
return $this->userFilesDir;
}
+ public function checkRecoveryPassword($password) {
+
+ $pathKey = '/owncloud_private_key/' . $this->recoveryKeyId . ".private.key";
+ $pathControlData = '/control-file/controlfile.enc';
+
+ $proxyStatus = \OC_FileProxy::$enabled;
+ \OC_FileProxy::$enabled = false;
+
+ $recoveryKey = $this->view->file_get_contents($pathKey);
+
+ $decryptedRecoveryKey = Crypt::symmetricDecryptFileContent($recoveryKey, $password);
+
+ $controlData = $this->view->file_get_contents($pathControlData);
+ $decryptedControlData = Crypt::keyDecrypt($controlData, $decryptedRecoveryKey);
+
+ \OC_FileProxy::$enabled = $proxyStatus;
+
+ if ($decryptedControlData === 'ownCloud') {
+ return true;
+ }
+
+ return false;
+ }
+
+ public function getRecoveryKeyId() {
+ return $this->recoveryKeyId;
+ }
+
}