Development snapshot
This commit is contained in:
parent
5328aae8a8
commit
13d93fb416
|
@ -144,10 +144,6 @@ class Crypt {
|
|||
// Fetch IV from end of file
|
||||
$iv = substr( $meta, -16 );
|
||||
|
||||
// $msg = "\$content = ".var_dump($content, 1).", \$noPadding = ".var_dump($noPadding, 1).", \$meta = ".var_dump($meta, 1).", \$iv = ".var_dump($iv, 1);
|
||||
//
|
||||
// file_put_contents('/home/samtuke/newtmp.txt', $msg );
|
||||
|
||||
// Fetch identifier from start of metadata
|
||||
$identifier = substr( $meta, 0, 6 );
|
||||
|
||||
|
@ -163,6 +159,23 @@ class Crypt {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is encrypted according to database file cache
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
private static function isEncryptedMeta( $path ) {
|
||||
|
||||
# TODO: Use DI to get OC_FileCache_Cached out of here
|
||||
|
||||
// Fetch all file metadata from DB
|
||||
$metadata = \OC_FileCache_Cached::get( $path, '' );
|
||||
|
||||
// Return encryption status
|
||||
return isset( $metadata['encrypted'] ) and ( bool )$metadata['encrypted'];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if a file is encrypted via legacy system
|
||||
* @return true / false
|
||||
|
@ -625,6 +638,7 @@ class Crypt {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -89,27 +89,12 @@ class Proxy extends \OC_FileProxy {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is encrypted according to database file cache
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
private static function isEncrypted( $path ){
|
||||
|
||||
// Fetch all file metadata from DB
|
||||
$metadata = \OC_FileCache_Cached::get( $path, '' );
|
||||
|
||||
// Return encryption status
|
||||
return isset( $metadata['encrypted'] ) and ( bool )$metadata['encrypted'];
|
||||
|
||||
}
|
||||
|
||||
public function preFile_put_contents( $path, &$data ) {
|
||||
|
||||
if ( self::shouldEncrypt( $path ) ) {
|
||||
|
||||
if ( !is_resource( $data ) ) { //stream put contents should have been converter to fopen
|
||||
if ( !is_resource( $data ) ) { //stream put contents should have been converted to fopen
|
||||
|
||||
// Set the filesize for userland, before encrypting
|
||||
$size = strlen( $data );
|
||||
|
@ -176,7 +161,7 @@ class Proxy extends \OC_FileProxy {
|
|||
}
|
||||
|
||||
public function postFopen( $path, &$result ){
|
||||
|
||||
trigger_error(var_export($path));
|
||||
if ( !$result ) {
|
||||
|
||||
return $result;
|
||||
|
@ -188,7 +173,7 @@ class Proxy extends \OC_FileProxy {
|
|||
|
||||
$meta = stream_get_meta_data( $result );
|
||||
|
||||
$view = new \OC_FilesystemView();
|
||||
$view = new \OC_FilesystemView( '' );
|
||||
|
||||
$util = new Util( $view, \OCP\USER::getUser());
|
||||
|
||||
|
@ -203,30 +188,22 @@ class Proxy extends \OC_FileProxy {
|
|||
|
||||
$encrypted = $view->file_get_contents( $path );
|
||||
|
||||
//file_put_contents('/home/samtuke/newtmp.txt', "\$path = $path, \$data = $data" );
|
||||
|
||||
// Replace the contents of
|
||||
\OC_Filesystem::file_put_contents( $path, $tmp );
|
||||
|
||||
fclose( $tmp );
|
||||
|
||||
//file_put_contents('/home/samtuke/newtmp.txt', file_get_contents( 'crypt://' . $path ) );
|
||||
|
||||
$result = fopen( 'crypt://' . $path, $meta['mode'] );
|
||||
|
||||
// file_put_contents('/home/samtuke/newtmp.txt', "mode= server" );
|
||||
|
||||
// $keyFile = Keymanager::getFileKey( $filePath );
|
||||
//
|
||||
// $tmp = tmpfile();
|
||||
//
|
||||
// file_put_contents( $tmp, Crypt::keyDecryptKeyfile( $result, $keyFile, $_SESSION['enckey'] ) );
|
||||
//
|
||||
// fclose ( $result );
|
||||
//
|
||||
// $result = fopen( $tmp );
|
||||
|
||||
} /*elseif (
|
||||
} elseif (
|
||||
self::shouldEncrypt( $path )
|
||||
and $meta ['mode'] != 'r'
|
||||
and $meta['mode'] != 'rb'
|
||||
|
@ -235,8 +212,8 @@ class Proxy extends \OC_FileProxy {
|
|||
# TODO: figure out what this does
|
||||
|
||||
if (
|
||||
\OC_Filesystem::file_exists( $path )
|
||||
and \OC_Filesystem::filesize( $path ) > 0
|
||||
$view->file_exists( $path )
|
||||
and $view->filesize( $path ) > 0
|
||||
) {
|
||||
|
||||
//first encrypt the target file so we don't end up with a half encrypted file
|
||||
|
@ -244,6 +221,7 @@ class Proxy extends \OC_FileProxy {
|
|||
|
||||
$tmp = fopen( 'php://temp' );
|
||||
|
||||
// Make a temporary copy of the original file
|
||||
\OCP\Files::streamCopy( $result, $tmp );
|
||||
|
||||
// Close the original stream, we'll return another one
|
||||
|
@ -257,7 +235,7 @@ class Proxy extends \OC_FileProxy {
|
|||
|
||||
$result = fopen( 'crypt://'.$path, $meta['mode'] );
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
// Re-enable the proxy
|
||||
\OC_FileProxy::$enabled = true;
|
||||
|
|
|
@ -46,6 +46,11 @@ class Util {
|
|||
# DONE: add method to decrypt legacy encrypted data
|
||||
# DONE: fix / test the crypt stream proxy class
|
||||
# DONE: replace cryptstream wrapper new AES based system
|
||||
# DONE: Encryption works for writing new text files in web ui
|
||||
# DONE: reading unencrypted files when encryption is enabled works via webdav
|
||||
|
||||
# TODO: file uploaded via web ui get encrypted
|
||||
# TODO: new files created and uploaded via webdav get encrypted
|
||||
|
||||
# TODO: add support for optional recovery user in case of lost passphrase / keys
|
||||
# TODO: add admin optional required long passphrase for users
|
||||
|
@ -61,6 +66,8 @@ class Util {
|
|||
# TODO: test new encryption with versioning
|
||||
# TODO: test new encryption with sharing
|
||||
# TODO: test new encryption with proxies
|
||||
|
||||
# NOTE: Curretly code on line 206 onwards in lib/proxy.php needs work. This code is executed when webdav writes take place, and appears to need to convert streams into fopen resources. Currently code within the if statement on 215 is not executing. Investigate the paths (handled there (which appear to be blank), and whether oc_fsv is borking them during processing.
|
||||
|
||||
private $view; // OC_FilesystemView object for filesystem operations
|
||||
private $pwd; // User Password
|
||||
|
|
Loading…
Reference in New Issue