Skip to content
Snippets Groups Projects
Commit e6de086f authored by Sam Tuke's avatar Sam Tuke
Browse files

Fixed various bugs in hooks class

Fixed documentation syntax in keymanager
parent 66b46162
No related branches found
No related tags found
No related merge requests found
<?php <?php
OC::$CLASSPATH['OC_Crypt'] = 'apps/files_encryption/lib/crypt.php'; OC::$CLASSPATH['OCA_Encryption\Crypt'] = 'apps/files_encryption/lib/crypt.php';
OC::$CLASSPATH['OCA_Encryption\Hooks'] = 'apps/files_encryption/hooks/hooks.php';
OC::$CLASSPATH['OCA_Encryption\Util'] = 'apps/files_encryption/lib/util.php';
OC::$CLASSPATH['OCA_Encryption\Keymanager'] = 'apps/files_encryption/lib/keymanager.php';
OC::$CLASSPATH['OC_CryptStream'] = 'apps/files_encryption/lib/cryptstream.php'; OC::$CLASSPATH['OC_CryptStream'] = 'apps/files_encryption/lib/cryptstream.php';
OC::$CLASSPATH['OC_FileProxy_Encryption'] = 'apps/files_encryption/lib/proxy.php'; OC::$CLASSPATH['OC_FileProxy_Encryption'] = 'apps/files_encryption/lib/proxy.php';
OC_FileProxy::register(new OC_FileProxy_Encryption()); //OC_FileProxy::register(new OC_FileProxy_Encryption());
OCP\Util::connectHook('OC_User','post_login','OC_Crypt','loginListener'); OCP\Util::connectHook('OC_User','post_login','OCA_Encryption\Hooks','login');
stream_wrapper_register('crypt','OC_CryptStream'); stream_wrapper_register('crypt','OC_CryptStream');
......
...@@ -28,19 +28,27 @@ namespace OCA_Encryption; ...@@ -28,19 +28,27 @@ namespace OCA_Encryption;
class Hooks { class Hooks {
# TODO: use passphrase for encrypting private key that is separate to the login password
/**
* @brief Startup encryption backend upon user login
* @note This method should never be called for users using client side encryption
*/
public static function login( $params ){ public static function login( $params ){
$view = new \OC_FilesystemView( '/' ); $view = new \OC_FilesystemView( '/' );
$storage = new Storage( $view, $params['uid'] ); $util = new Util( $view, $params['uid'] );
if ( !$storage->ready() ) { if ( !$util->ready() ) {
return $storage->setup( $params['password'] ); return $util->setup( $params['password'] );
} }
$_SESSION['enckey'] = OC_Crypt::decrypt($key, $password); $encryptedKey = Keymanager::getPrivateKey( $params['uid'] );
$_SESSION['enckey'] = Crypt::symmetricEncryptFileContent( $encryptedKey, $params['password'] );
return true; return true;
......
<?php <?php
/** /***
* ownCloud * ownCloud
* *
* @author Bjoern Schiessle * @author Bjoern Schiessle
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
namespace OCA_Encryption; namespace OCA_Encryption;
/* /**
* This class provides basic operations to read/write encryption keys from/to the filesystem * This class provides basic operations to read/write encryption keys from/to the filesystem
*/ */
class Keymanager { class Keymanager {
/* /**
* @brief retrieve private key from a user * @brief retrieve private key from a user
* *
* @param string user name * @param string user name
...@@ -40,7 +40,7 @@ class Keymanager { ...@@ -40,7 +40,7 @@ class Keymanager {
return $view->file_get_contents($user.'.private.key'); return $view->file_get_contents($user.'.private.key');
} }
/* /**
* @brief retrieve public key from a user * @brief retrieve public key from a user
* *
* @param string user name * @param string user name
...@@ -52,7 +52,7 @@ class Keymanager { ...@@ -52,7 +52,7 @@ class Keymanager {
return $view->file_get_contents($user.'.public.key'); return $view->file_get_contents($user.'.public.key');
} }
/* /**
* @brief retrieve file encryption key * @brief retrieve file encryption key
* *
* @param string file name * @param string file name
...@@ -65,7 +65,7 @@ class Keymanager { ...@@ -65,7 +65,7 @@ class Keymanager {
return $view->file_get_contents($file.'.key'); return $view->file_get_contents($file.'.key');
} }
/* /**
* @brief store private key from a user * @brief store private key from a user
* *
* @param string user name * @param string user name
...@@ -79,7 +79,7 @@ class Keymanager { ...@@ -79,7 +79,7 @@ class Keymanager {
} }
/* /**
* @brief store public key from a user * @brief store public key from a user
* *
* @param string user name * @param string user name
...@@ -92,7 +92,7 @@ class Keymanager { ...@@ -92,7 +92,7 @@ class Keymanager {
return $view->file_put_contents($user.'.public.key', $key); return $view->file_put_contents($user.'.public.key', $key);
} }
/* /**
* @brief store file encryption key * @brief store file encryption key
* *
* @param string user name of the file owner * @param string user name of the file owner
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment