diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-08-13 12:34:21 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-08-13 12:34:21 +0200 |
commit | f282a5cff00d2e7ecbfaa0d93d7ab0bf30921701 (patch) | |
tree | e5d23e0cac3374fac043f04151cc4dabe33920eb /apps/files_encryption/hooks/hooks.php | |
parent | fc46fbd1541bda8eb094bd8ee64827fa1cbf1fd0 (diff) | |
parent | ffa6b330477193dd5f438980bd2736555aa738e6 (diff) | |
download | nextcloud-server-f282a5cff00d2e7ecbfaa0d93d7ab0bf30921701.tar.gz nextcloud-server-f282a5cff00d2e7ecbfaa0d93d7ab0bf30921701.zip |
Merge pull request #9754 from owncloud/enc_support_aes_256
[encryption] support aes 256
Diffstat (limited to 'apps/files_encryption/hooks/hooks.php')
-rw-r--r-- | apps/files_encryption/hooks/hooks.php | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index bd2268aa048..b1e7e8c52a5 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -200,10 +200,14 @@ class Hooks { $privateKey = $session->getPrivateKey();
// Encrypt private key with new user pwd as passphrase
- $encryptedPrivateKey = Crypt::symmetricEncryptFileContent($privateKey, $params['password']);
+ $encryptedPrivateKey = Crypt::symmetricEncryptFileContent($privateKey, $params['password'], Helper::getCipher());
// Save private key
- Keymanager::setPrivateKey($encryptedPrivateKey);
+ if ($encryptedPrivateKey) {
+ Keymanager::setPrivateKey($encryptedPrivateKey, \OCP\User::getUser());
+ } else {
+ \OCP\Util::writeLog('files_encryption', 'Could not update users encryption password', \OCP\Util::ERROR);
+ }
// NOTE: Session does not need to be updated as the
// private key has not changed, only the passphrase
@@ -238,16 +242,17 @@ class Hooks { // Save public key
$view->file_put_contents('/public-keys/' . $user . '.public.key', $keypair['publicKey']);
- // Encrypt private key empty passphrase
- $encryptedPrivateKey = Crypt::symmetricEncryptFileContent($keypair['privateKey'], $newUserPassword);
-
- // Save private key
- $view->file_put_contents(
- '/' . $user . '/files_encryption/' . $user . '.private.key', $encryptedPrivateKey);
-
- if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files
- $util = new Util($view, $user);
- $util->recoverUsersFiles($recoveryPassword);
+ // Encrypt private key with new password
+ $encryptedKey = \OCA\Encryption\Crypt::symmetricEncryptFileContent($keypair['privateKey'], $newUserPassword, Helper::getCipher());
+ if ($encryptedKey) {
+ Keymanager::setPrivateKey($encryptedKey, $user);
+
+ if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files
+ $util = new Util($view, $user);
+ $util->recoverUsersFiles($recoveryPassword);
+ }
+ } else {
+ \OCP\Util::writeLog('files_encryption', 'Could not update users encryption password', \OCP\Util::ERROR);
}
\OC_FileProxy::$enabled = $proxyStatus;
|