diff options
author | Björn Schießle <schiessle@owncloud.com> | 2013-05-15 16:12:20 +0200 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2013-05-15 16:12:20 +0200 |
commit | 64d94c540aeaba67e2f779b2551c72a80334aa3e (patch) | |
tree | 19387991014feffc016e4f1919f214b5400b8d12 /apps/files_encryption/lib/util.php | |
parent | 5b160edebba2a10de83b09a8010a811321dd6370 (diff) | |
download | nextcloud-server-64d94c540aeaba67e2f779b2551c72a80334aa3e.tar.gz nextcloud-server-64d94c540aeaba67e2f779b2551c72a80334aa3e.zip |
enable admin to change the recovery password
Diffstat (limited to 'apps/files_encryption/lib/util.php')
-rw-r--r-- | apps/files_encryption/lib/util.php | 28 |
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; + } + } |