@@ -64,8 +64,8 @@ class Encryption extends \OCP\AppFramework\App { | |||
*/ | |||
public function boot() { | |||
$this->registerServices(); | |||
$this->registerHooks(); | |||
$this->registerEncryptionModule(); | |||
$this->registerHooks(); | |||
$this->registerSettings(); | |||
} | |||
@@ -96,7 +96,12 @@ class Encryption extends \OCP\AppFramework\App { | |||
* | |||
*/ | |||
public function registerEncryptionModule() { | |||
$this->encryptionManager->registerEncryptionModule(new \OCA\Encryption\Crypto\Encryption()); | |||
$container = $this->getContainer(); | |||
$container->registerService('EncryptionModule', function (IAppContainer $c) { | |||
return new \OCA\Encryption\Crypto\Encryption($c->query('Crypt')); | |||
}); | |||
$module = $container->query('EncryptionModule'); | |||
$this->encryptionManager->registerEncryptionModule($module); | |||
} | |||
/** | |||
@@ -117,7 +122,8 @@ class Encryption extends \OCP\AppFramework\App { | |||
function (IAppContainer $c) { | |||
$server = $c->getServer(); | |||
return new KeyManager($server->getEncryptionKeyStorage('encryption'), | |||
$moduleId = $c->query('EncryptionModule')->getId(); | |||
return new KeyManager($server->getEncryptionKeyStorage($moduleId), | |||
$c->query('Crypt'), | |||
$server->getConfig(), | |||
$server->getUserSession(), | |||
@@ -131,13 +137,14 @@ class Encryption extends \OCP\AppFramework\App { | |||
function (IAppContainer $c) { | |||
$server = $c->getServer(); | |||
$moduleId = $c->query('EncryptionModule')->getId(); | |||
return new Recovery( | |||
$server->getUserSession(), | |||
$c->query('Crypt'), | |||
$server->getSecureRandom(), | |||
$c->query('KeyManager'), | |||
$server->getConfig(), | |||
$server->getEncryptionKeyStorage('encryption')); | |||
$server->getEncryptionKeyStorage($moduleId)); | |||
}); | |||
$container->registerService('UserSetup', | |||
@@ -149,16 +156,6 @@ class Encryption extends \OCP\AppFramework\App { | |||
$c->query('KeyManager')); | |||
}); | |||
$container->registerService('Migrator', | |||
function (IAppContainer $c) { | |||
$server = $c->getServer(); | |||
return new Migrator($server->getConfig(), | |||
$server->getUserManager(), | |||
$server->getLogger(), | |||
$c->query('Crypt')); | |||
}); | |||
$container->registerService('Util', | |||
function (IAppContainer $c) { | |||
$server = $c->getServer(); |
@@ -63,7 +63,6 @@ class UserHooks implements IHook { | |||
* @param IUserSession $user | |||
* @param OCUtil $ocUtil | |||
* @param Util $util | |||
* @internal param Migrator $migrator | |||
*/ | |||
public function __construct( | |||
KeyManager $keyManager, ILogger $logger, Setup $userSetup, IUserSession $user, OCUtil $ocUtil, Util $util) { |
@@ -1,129 +0,0 @@ | |||
<?php | |||
/** | |||
* @author Clark Tomlinson <fallen013@gmail.com> | |||
* @since 3/6/15, 2:28 PM | |||
* @link http:/www.clarkt.com | |||
* @copyright Clark Tomlinson © 2015 | |||
* | |||
*/ | |||
namespace OCA\Encryption\Crypto; | |||
use OCP\Encryption\IEncryptionModule; | |||
class Encryption extends Crypt implements IEncryptionModule { | |||
/** | |||
* @return string defining the technical unique id | |||
*/ | |||
public function getId() { | |||
return md5($this->getDisplayName()); | |||
} | |||
/** | |||
* In comparison to getKey() this function returns a human readable (maybe translated) name | |||
* | |||
* @return string | |||
*/ | |||
public function getDisplayName() { | |||
return 'ownCloud Default Encryption'; | |||
} | |||
/** | |||
* start receiving chunks from a file. This is the place where you can | |||
* perform some initial step before starting encrypting/decrypting the | |||
* chunks | |||
* | |||
* @param string $path to the file | |||
* @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' | |||
* | |||
* $return array $header contain data as key-value pairs which should be | |||
* 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, $header, $accessList) { | |||
// TODO: Implement begin() method. | |||
// return additional header information that needs to be written i.e. cypher used | |||
} | |||
/** | |||
* last chunk received. This is the place where you can perform some final | |||
* operation and return some remaining data if something is left in your | |||
* buffer. | |||
* | |||
* @param string $path to the file | |||
* @return string remained data which should be written to the file in case | |||
* of a write operation | |||
*/ | |||
public function end($path) { | |||
// TODO: Implement end() method. | |||
} | |||
/** | |||
* encrypt data | |||
* | |||
* @param string $data you want to encrypt | |||
* @return mixed encrypted data | |||
*/ | |||
public function encrypt($data) { | |||
// Todo: xxx Update Signature and usages | |||
// passphrase is file key decrypted with user private/share key | |||
$this->symmetricEncryptFileContent($data); | |||
} | |||
/** | |||
* decrypt data | |||
* | |||
* @param string $data you want to decrypt | |||
* @param string $user decrypt as user (null for public access) | |||
* @return mixed decrypted data | |||
*/ | |||
public function decrypt($data, $user) { | |||
// Todo: xxx Update Usages? | |||
$this->symmetricDecryptFileContent($data, $user); | |||
} | |||
/** | |||
* update encrypted file, e.g. give additional users access to the file | |||
* | |||
* @param string $path path to the file which should be updated | |||
* @param array $accessList who has access to the file contains the key 'users' and 'public' | |||
* @return boolean | |||
*/ | |||
public function update($path, $accessList) { | |||
// TODO: Implement update() method. | |||
} | |||
/** | |||
* should the file be encrypted or not | |||
* | |||
* @param string $path | |||
* @return boolean | |||
*/ | |||
public function shouldEncrypt($path) { | |||
// TODO: Implement shouldEncrypt() method. | |||
} | |||
/** | |||
* calculate unencrypted size | |||
* | |||
* @param string $path to file | |||
* @return integer unencrypted size | |||
*/ | |||
public function calculateUnencryptedSize($path) { | |||
// TODO: Implement calculateUnencryptedSize() method. | |||
} | |||
/** | |||
* get size of the unencrypted payload per block. | |||
* ownCloud read/write files with a block size of 8192 byte | |||
* | |||
* @return integer | |||
*/ | |||
public function getUnencryptedBlockSize() { | |||
// TODO: Implement getUnencryptedBlockSize() method. | |||
} | |||
} |
@@ -0,0 +1,138 @@ | |||
<?php | |||
/** | |||
* @author Clark Tomlinson <fallen013@gmail.com> | |||
* @since 3/6/15, 2:28 PM | |||
* @link http:/www.clarkt.com | |||
* @copyright Clark Tomlinson © 2015 | |||
* | |||
*/ | |||
namespace OCA\Encryption\Crypto; | |||
use OCP\Encryption\IEncryptionModule; | |||
class Encryption implements IEncryptionModule { | |||
/** | |||
* @var Crypt | |||
*/ | |||
private $crypt; | |||
public function __construct(Crypt $crypt) { | |||
$this->crypt = $crypt; | |||
} | |||
/** | |||
* @return string defining the technical unique id | |||
*/ | |||
public function getId() { | |||
// we need to hard code this value | |||
return md5($this->getDisplayName()); | |||
} | |||
/** | |||
* In comparison to getKey() this function returns a human readable (maybe translated) name | |||
* | |||
* @return string | |||
*/ | |||
public function getDisplayName() { | |||
return 'ownCloud Default Encryption'; | |||
} | |||
/** | |||
* start receiving chunks from a file. This is the place where you can | |||
* perform some initial step before starting encrypting/decrypting the | |||
* chunks | |||
* | |||
* @param string $path to the file | |||
* @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' | |||
* | |||
* $return array $header contain data as key-value pairs which should be | |||
* 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, $header, $accessList) { | |||
$cipher = $header['']; | |||
} | |||
/** | |||
* last chunk received. This is the place where you can perform some final | |||
* operation and return some remaining data if something is left in your | |||
* buffer. | |||
* | |||
* @param string $path to the file | |||
* @return string remained data which should be written to the file in case | |||
* of a write operation | |||
*/ | |||
public function end($path) { | |||
// TODO: Implement end() method. | |||
} | |||
/** | |||
* encrypt data | |||
* | |||
* @param string $data you want to encrypt | |||
* @return mixed encrypted data | |||
*/ | |||
public function encrypt($data) { | |||
// Todo: xxx Update Signature and usages | |||
// passphrase is file key decrypted with user private/share key | |||
$this->symmetricEncryptFileContent($data); | |||
} | |||
/** | |||
* decrypt data | |||
* | |||
* @param string $data you want to decrypt | |||
* @param string $user decrypt as user (null for public access) | |||
* @return mixed decrypted data | |||
*/ | |||
public function decrypt($data, $user) { | |||
// Todo: xxx Update Usages? | |||
$this->symmetricDecryptFileContent($data, $user); | |||
} | |||
/** | |||
* update encrypted file, e.g. give additional users access to the file | |||
* | |||
* @param string $path path to the file which should be updated | |||
* @param array $accessList who has access to the file contains the key 'users' and 'public' | |||
* @return boolean | |||
*/ | |||
public function update($path, $accessList) { | |||
// TODO: Implement update() method. | |||
} | |||
/** | |||
* should the file be encrypted or not | |||
* | |||
* @param string $path | |||
* @return boolean | |||
*/ | |||
public function shouldEncrypt($path) { | |||
// TODO: Implement shouldEncrypt() method. | |||
} | |||
/** | |||
* calculate unencrypted size | |||
* | |||
* @param string $path to file | |||
* @return integer unencrypted size | |||
*/ | |||
public function calculateUnencryptedSize($path) { | |||
// TODO: Implement calculateUnencryptedSize() method. | |||
} | |||
/** | |||
* get size of the unencrypted payload per block. | |||
* ownCloud read/write files with a block size of 8192 byte | |||
* | |||
* @return integer | |||
*/ | |||
public function getUnencryptedBlockSize() { | |||
// TODO: Implement getUnencryptedBlockSize() method. | |||
} | |||
} |