summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib/proxy.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption/lib/proxy.php')
-rw-r--r--apps/files_encryption/lib/proxy.php27
1 files changed, 20 insertions, 7 deletions
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 914632d3387..85664734d7a 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -131,6 +131,10 @@ class Proxy extends \OC_FileProxy {
}
+ /**
+ * @param string $path Path of file from which has been read
+ * @param string $data Data that has been read from file
+ */
public function postFile_get_contents( $path, $data ) {
# TODO: Use dependency injection to add required args for view and user etc. to this method
@@ -138,24 +142,27 @@ class Proxy extends \OC_FileProxy {
// Disable encryption proxy to prevent recursive calls
\OC_FileProxy::$enabled = false;
+ // If data is a catfile
if (
Crypt::mode() == 'server'
&& Crypt::isEncryptedContent( $data )
) {
- //trigger_error("bong");
+// trigger_error("bong");
- $filePath = explode( '/', $path );
+ $split = explode( '/', $path );
- $filePath = array_slice( $filePath, 3 );
+ $filePath = array_slice( $split, 3 );
$filePath = '/' . implode( '/', $filePath );
//$cached = \OC_FileCache_Cached::get( $path, '' );
$keyFile = Keymanager::getFileKey( $filePath );
+
+ $session = new Session();
+
+ $decrypted = Crypt::keyDecryptKeyfile( $data, $keyFile, $session->getPrivateKey( $split[1] ) );
- $data = Crypt::keyDecryptKeyfile( $data, $keyFile, $_SESSION['enckey'] );
-
} elseif (
Crypt::mode() == 'server'
&& isset( $_SESSION['legacyenckey'] )
@@ -163,14 +170,20 @@ class Proxy extends \OC_FileProxy {
) {
trigger_error("mong");
- $data = Crypt::legacyDecrypt( $data, $_SESSION['legacyenckey'] );
+ $decrypted = Crypt::legacyDecrypt( $data, $_SESSION['legacyenckey'] );
//trigger_error($data);
}
\OC_FileProxy::$enabled = true;
- return $data;
+ if ( ! isset( $decrypted ) ) {
+
+ $decrypted = $data;
+
+ }
+
+ return $decrypted;
}