summaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib/crypto/encryption.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/encryption/lib/crypto/encryption.php')
-rw-r--r--apps/encryption/lib/crypto/encryption.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php
index 8498b4223e1..3f298481680 100644
--- a/apps/encryption/lib/crypto/encryption.php
+++ b/apps/encryption/lib/crypto/encryption.php
@@ -101,6 +101,7 @@ class Encryption implements IEncryptionModule {
*
* @param string $path to the file
* @param string $user who read/write the file
+ * @param string $mode php stream open mode
* @param array $header contains the header data read from the file
* @param array $accessList who has access to the file contains the key 'users' and 'public'
*
@@ -108,12 +109,19 @@ class Encryption implements IEncryptionModule {
* written to the header, in case of a write operation
* or if no additional data is needed return a empty array
*/
- public function begin($path, $user, array $header, array $accessList) {
+ public function begin($path, $user, $mode, array $header, array $accessList) {
if (isset($header['cipher'])) {
$this->cipher = $header['cipher'];
- } else {
+ } else if (
+ $mode === 'w'
+ || $mode === 'w+'
+ || $mode === 'wb'
+ || $mode === 'wb+'
+ ) {
$this->cipher = $this->crypt->getCipher();
+ } else {
+ $this->cipher = $this->crypt->getLegacyCipher();
}
$this->path = $this->getPathToRealFile($path);
@@ -234,7 +242,7 @@ class Encryption implements IEncryptionModule {
public function decrypt($data) {
$result = '';
if (!empty($data)) {
- $result = $this->crypt->symmetricDecryptFileContent($data, $this->fileKey);
+ $result = $this->crypt->symmetricDecryptFileContent($data, $this->fileKey, $this->cipher);
}
return $result;
}