diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index b7e8df9eac..a9b3b2bcd8 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -63,7 +63,7 @@ class Hooks { * @brief update the encryption key of the file uploaded by the client */ public static function updateKeyfile( $params ) { - if (Crypt::mode(\OCP\User::getUser()) == 'client') + if (Crypt::mode() == 'client') if (isset($params['properties']['key'])) { Keymanager::setFileKey($params['path'], $params['properties']['key']); } else { diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php index 0705205682..42aaf9b60b 100644 --- a/apps/files_encryption/lib/keymanager.php +++ b/apps/files_encryption/lib/keymanager.php @@ -38,9 +38,8 @@ class Keymanager { $user = \OCP\User::getUser(); $view = new \OC_FilesystemView( '/' . $user . '/' . 'files_encryption' ); - $result = $view->file_get_contents( '/' . $user.'.private.key' ); - - return $result; + return $view->file_get_contents( '/' . $user.'.private.key' ); + } /** @@ -110,9 +109,8 @@ class Keymanager { } $view = new \OC_FilesystemView('/'.$user.'/files_encryption/keyfiles/'); - $result = $view->file_get_contents($keypath.'.key'); - - return $result; + return $view->file_get_contents($keypath.'.key'); + } /** @@ -126,9 +124,8 @@ class Keymanager { $user = \OCP\User::getUser(); $view = new \OC_FilesystemView('/'.$user.'/files_encryption'); if (!$view->file_exists('')) $view->mkdir(''); - $result = $view->file_put_contents($user.'.private.key', $key); + return $view->file_put_contents($user.'.private.key', $key); - return $result; } @@ -142,9 +139,8 @@ class Keymanager { $view = new \OC_FilesystemView('/public-keys'); if (!$view->file_exists('')) $view->mkdir(''); - $result = $view->file_put_contents(\OCP\User::getUser().'.public.key', $key); + return $view->file_put_contents(\OCP\User::getUser().'.public.key', $key); - return $result; } /** @@ -186,9 +182,8 @@ class Keymanager { if ( !$view->file_exists( $path_parts['dirname'] ) ) $view->mkdir( $path_parts['dirname'] ); - $result = $view->file_put_contents( '/' . $targetpath . '.key', $key ); + return $view->file_put_contents( '/' . $targetpath . '.key', $key ); - return $result; } /** @@ -199,6 +194,7 @@ class Keymanager { * @return bool true/false */ public static function changePasswd($oldpasswd, $newpasswd) { + if ( \OCP\User::checkPassword(\OCP\User::getUser(), $newpasswd) ) { $key = Keymanager::getPrivateKey(); if ( ($key = Crypt::symmetricDecryptFileContent($key,$oldpasswd)) ) { @@ -209,6 +205,7 @@ class Keymanager { } } return false; + } } \ No newline at end of file diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 32b7a67e65..85b5c868f3 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -40,7 +40,7 @@ class Proxy extends \OC_FileProxy { * @param string $path * @return bool * - * Tests if encryption is enabled, and file is allowed by blacklists + * Tests if server side encryption is enabled, and file is allowed by blacklists */ private static function shouldEncrypt( $path ) { @@ -130,7 +130,7 @@ class Proxy extends \OC_FileProxy { public function postFile_get_contents( $path, $data ) { - if ( Crypt::isEncryptedContent( $data ) ) { + if ( Crypt::mode() == 'server' && Crypt::isEncryptedContent( $data ) ) { $filePath = explode( '/', $path ); @@ -164,7 +164,7 @@ class Proxy extends \OC_FileProxy { $meta = stream_get_meta_data( $result ); // If file is encrypted, decrypt using crypto protocol - if ( Crypt::isEncryptedContent( $path ) ) { + if ( Crypt::mode() == 'server' && Crypt::isEncryptedContent( $path ) ) { fclose ( $result ); @@ -208,14 +208,14 @@ class Proxy extends \OC_FileProxy { } public function postGetMimeType($path,$mime){ - if(Crypt::isEncryptedContent($path)){ + if( Crypt::isEncryptedContent($path)){ $mime = \OCP\Files::getMimeType('crypt://'.$path,'w'); } return $mime; } public function postStat($path,$data){ - if(Crypt::isEncryptedContent($path)){ + if( Crypt::isEncryptedContent($path)){ $cached= \OC_FileCache_Cached::get($path,''); $data['size']=$cached['size']; } @@ -223,7 +223,7 @@ class Proxy extends \OC_FileProxy { } public function postFileSize($path,$size){ - if(Crypt::isEncryptedContent($path)){ + if( Crypt::isEncryptedContent($path)){ $cached = \OC_FileCache_Cached::get($path,''); return $cached['size']; }else{