Update OCA\Encryption to OCA\Files_Encryption in the encryption app itself
This commit is contained in:
parent
78a307995c
commit
efac8ced90
|
@ -7,7 +7,8 @@
|
||||||
*
|
*
|
||||||
* Script to handle admin settings for encrypted key recovery
|
* Script to handle admin settings for encrypted key recovery
|
||||||
*/
|
*/
|
||||||
use OCA\Encryption;
|
|
||||||
|
use OCA\Files_Encryption\Helper;
|
||||||
|
|
||||||
\OCP\JSON::checkAdminUser();
|
\OCP\JSON::checkAdminUser();
|
||||||
\OCP\JSON::checkAppEnabled('files_encryption');
|
\OCP\JSON::checkAppEnabled('files_encryption');
|
||||||
|
@ -42,7 +43,7 @@ $recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'rec
|
||||||
|
|
||||||
if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] === '1') {
|
if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] === '1') {
|
||||||
|
|
||||||
$return = \OCA\Encryption\Helper::adminEnableRecovery($recoveryKeyId, $_POST['recoveryPassword']);
|
$return = Helper::adminEnableRecovery($recoveryKeyId, $_POST['recoveryPassword']);
|
||||||
|
|
||||||
// Return success or failure
|
// Return success or failure
|
||||||
if ($return) {
|
if ($return) {
|
||||||
|
@ -56,7 +57,7 @@ if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] === '1
|
||||||
isset($_POST['adminEnableRecovery'])
|
isset($_POST['adminEnableRecovery'])
|
||||||
&& '0' === $_POST['adminEnableRecovery']
|
&& '0' === $_POST['adminEnableRecovery']
|
||||||
) {
|
) {
|
||||||
$return = \OCA\Encryption\Helper::adminDisableRecovery($_POST['recoveryPassword']);
|
$return = Helper::adminDisableRecovery($_POST['recoveryPassword']);
|
||||||
|
|
||||||
if ($return) {
|
if ($return) {
|
||||||
$successMessage = $l->t('Recovery key successfully disabled');
|
$successMessage = $l->t('Recovery key successfully disabled');
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
|
||||||
|
|
||||||
\OCP\JSON::checkAdminUser();
|
\OCP\JSON::checkAdminUser();
|
||||||
\OCP\JSON::checkAppEnabled('files_encryption');
|
\OCP\JSON::checkAppEnabled('files_encryption');
|
||||||
\OCP\JSON::callCheck();
|
\OCP\JSON::callCheck();
|
||||||
|
@ -49,21 +47,21 @@ if ($_POST['newPassword'] !== $_POST['confirmPassword']) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = new \OC\Files\View('/');
|
$view = new \OC\Files\View('/');
|
||||||
$util = new \OCA\Encryption\Util(new \OC\Files\View('/'), \OCP\User::getUser());
|
$util = new \OCA\Files_Encryption\Util(new \OC\Files\View('/'), \OCP\User::getUser());
|
||||||
|
|
||||||
$proxyStatus = \OC_FileProxy::$enabled;
|
$proxyStatus = \OC_FileProxy::$enabled;
|
||||||
\OC_FileProxy::$enabled = false;
|
\OC_FileProxy::$enabled = false;
|
||||||
|
|
||||||
$keyId = $util->getRecoveryKeyId();
|
$keyId = $util->getRecoveryKeyId();
|
||||||
|
|
||||||
$encryptedRecoveryKey = Encryption\Keymanager::getPrivateSystemKey($keyId);
|
$encryptedRecoveryKey = \OCA\Files_Encryption\Keymanager::getPrivateSystemKey($keyId);
|
||||||
$decryptedRecoveryKey = $encryptedRecoveryKey ? \OCA\Encryption\Crypt::decryptPrivateKey($encryptedRecoveryKey, $oldPassword) : false;
|
$decryptedRecoveryKey = $encryptedRecoveryKey ? \OCA\Files_Encryption\Crypt::decryptPrivateKey($encryptedRecoveryKey, $oldPassword) : false;
|
||||||
|
|
||||||
if ($decryptedRecoveryKey) {
|
if ($decryptedRecoveryKey) {
|
||||||
$cipher = \OCA\Encryption\Helper::getCipher();
|
$cipher = \OCA\Files_Encryption\Helper::getCipher();
|
||||||
$encryptedKey = \OCA\Encryption\Crypt::symmetricEncryptFileContent($decryptedRecoveryKey, $newPassword, $cipher);
|
$encryptedKey = \OCA\Files_Encryption\Crypt::symmetricEncryptFileContent($decryptedRecoveryKey, $newPassword, $cipher);
|
||||||
if ($encryptedKey) {
|
if ($encryptedKey) {
|
||||||
\OCA\Encryption\Keymanager::setPrivateSystemKey($encryptedKey, $keyId);
|
\OCA\Files_Encryption\Keymanager::setPrivateSystemKey($encryptedKey, $keyId);
|
||||||
$return = true;
|
$return = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
*
|
*
|
||||||
* check migration status
|
* check migration status
|
||||||
*/
|
*/
|
||||||
use OCA\Encryption\Util;
|
|
||||||
|
use OCA\Files_Encryption\Util;
|
||||||
|
|
||||||
\OCP\JSON::checkAppEnabled('files_encryption');
|
\OCP\JSON::checkAppEnabled('files_encryption');
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
|
||||||
|
|
||||||
\OCP\JSON::checkLoggedIn();
|
\OCP\JSON::checkLoggedIn();
|
||||||
\OCP\JSON::checkAppEnabled('files_encryption');
|
\OCP\JSON::checkAppEnabled('files_encryption');
|
||||||
\OCP\JSON::callCheck();
|
\OCP\JSON::callCheck();
|
||||||
|
@ -24,7 +22,7 @@ $oldPassword = $_POST['oldPassword'];
|
||||||
$newPassword = $_POST['newPassword'];
|
$newPassword = $_POST['newPassword'];
|
||||||
|
|
||||||
$view = new \OC\Files\View('/');
|
$view = new \OC\Files\View('/');
|
||||||
$session = new \OCA\Encryption\Session($view);
|
$session = new \OCA\Files_Encryption\Session($view);
|
||||||
$user = \OCP\User::getUser();
|
$user = \OCP\User::getUser();
|
||||||
$loginName = \OC::$server->getUserSession()->getLoginName();
|
$loginName = \OC::$server->getUserSession()->getLoginName();
|
||||||
|
|
||||||
|
@ -36,14 +34,14 @@ if ($passwordCorrect !== false) {
|
||||||
$proxyStatus = \OC_FileProxy::$enabled;
|
$proxyStatus = \OC_FileProxy::$enabled;
|
||||||
\OC_FileProxy::$enabled = false;
|
\OC_FileProxy::$enabled = false;
|
||||||
|
|
||||||
$encryptedKey = Encryption\Keymanager::getPrivateKey($view, $user);
|
$encryptedKey = \OCA\Files_Encryption\Keymanager::getPrivateKey($view, $user);
|
||||||
$decryptedKey = $encryptedKey ? \OCA\Encryption\Crypt::decryptPrivateKey($encryptedKey, $oldPassword) : false;
|
$decryptedKey = $encryptedKey ? \OCA\Files_Encryption\Crypt::decryptPrivateKey($encryptedKey, $oldPassword) : false;
|
||||||
|
|
||||||
if ($decryptedKey) {
|
if ($decryptedKey) {
|
||||||
$cipher = \OCA\Encryption\Helper::getCipher();
|
$cipher = \OCA\Files_Encryption\Helper::getCipher();
|
||||||
$encryptedKey = \OCA\Encryption\Crypt::symmetricEncryptFileContent($decryptedKey, $newPassword, $cipher);
|
$encryptedKey = \OCA\Files_Encryption\Crypt::symmetricEncryptFileContent($decryptedKey, $newPassword, $cipher);
|
||||||
if ($encryptedKey) {
|
if ($encryptedKey) {
|
||||||
\OCA\Encryption\Keymanager::setPrivateKey($encryptedKey, $user);
|
\OCA\Files_Encryption\Keymanager::setPrivateKey($encryptedKey, $user);
|
||||||
$session->setPrivateKey($decryptedKey);
|
$session->setPrivateKey($decryptedKey);
|
||||||
$return = true;
|
$return = true;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +59,7 @@ if ($decryptedKey) {
|
||||||
|
|
||||||
// success or failure
|
// success or failure
|
||||||
if ($return) {
|
if ($return) {
|
||||||
$session->setInitialized(\OCA\Encryption\Session::INIT_SUCCESSFUL);
|
$session->setInitialized(\OCA\Files_Encryption\Session::INIT_SUCCESSFUL);
|
||||||
\OCP\JSON::success(array('data' => array('message' => $l->t('Private key password successfully updated.'))));
|
\OCP\JSON::success(array('data' => array('message' => $l->t('Private key password successfully updated.'))));
|
||||||
} else {
|
} else {
|
||||||
\OCP\JSON::error(array('data' => array('message' => $errorMessage)));
|
\OCP\JSON::error(array('data' => array('message' => $errorMessage)));
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
* Script to handle admin settings for encrypted key recovery
|
* Script to handle admin settings for encrypted key recovery
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
|
||||||
|
|
||||||
\OCP\JSON::checkLoggedIn();
|
\OCP\JSON::checkLoggedIn();
|
||||||
\OCP\JSON::checkAppEnabled('files_encryption');
|
\OCP\JSON::checkAppEnabled('files_encryption');
|
||||||
\OCP\JSON::callCheck();
|
\OCP\JSON::callCheck();
|
||||||
|
@ -22,7 +20,7 @@ if (
|
||||||
|
|
||||||
$userId = \OCP\USER::getUser();
|
$userId = \OCP\USER::getUser();
|
||||||
$view = new \OC\Files\View('/');
|
$view = new \OC\Files\View('/');
|
||||||
$util = new \OCA\Encryption\Util($view, $userId);
|
$util = new \OCA\Files_Encryption\Util($view, $userId);
|
||||||
|
|
||||||
// Save recovery preference to DB
|
// Save recovery preference to DB
|
||||||
$return = $util->setRecoveryForUser($_POST['userEnableRecovery']);
|
$return = $util->setRecoveryForUser($_POST['userEnableRecovery']);
|
||||||
|
|
|
@ -5,22 +5,22 @@
|
||||||
\OCP\Util::addscript('files_encryption', 'detect-migration');
|
\OCP\Util::addscript('files_encryption', 'detect-migration');
|
||||||
|
|
||||||
if (!OC_Config::getValue('maintenance', false)) {
|
if (!OC_Config::getValue('maintenance', false)) {
|
||||||
OC_FileProxy::register(new OCA\Encryption\Proxy());
|
OC_FileProxy::register(new OCA\Files_Encryption\Proxy());
|
||||||
|
|
||||||
// User related hooks
|
// User related hooks
|
||||||
OCA\Encryption\Helper::registerUserHooks();
|
OCA\Files_Encryption\Helper::registerUserHooks();
|
||||||
|
|
||||||
// Sharing related hooks
|
// Sharing related hooks
|
||||||
OCA\Encryption\Helper::registerShareHooks();
|
OCA\Files_Encryption\Helper::registerShareHooks();
|
||||||
|
|
||||||
// Filesystem related hooks
|
// Filesystem related hooks
|
||||||
OCA\Encryption\Helper::registerFilesystemHooks();
|
OCA\Files_Encryption\Helper::registerFilesystemHooks();
|
||||||
|
|
||||||
// App manager related hooks
|
// App manager related hooks
|
||||||
OCA\Encryption\Helper::registerAppHooks();
|
OCA\Files_Encryption\Helper::registerAppHooks();
|
||||||
|
|
||||||
if(!in_array('crypt', stream_get_wrappers())) {
|
if(!in_array('crypt', stream_get_wrappers())) {
|
||||||
stream_wrapper_register('crypt', 'OCA\Encryption\Stream');
|
stream_wrapper_register('crypt', 'OCA\Files_Encryption\Stream');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// logout user if we are in maintenance to force re-login
|
// logout user if we are in maintenance to force re-login
|
||||||
|
|
|
@ -19,4 +19,4 @@ $this->create('files_encryption_ajax_userrecovery', 'ajax/userrecovery.php')
|
||||||
->actionInclude('files_encryption/ajax/userrecovery.php');
|
->actionInclude('files_encryption/ajax/userrecovery.php');
|
||||||
|
|
||||||
// Register with the capabilities API
|
// Register with the capabilities API
|
||||||
OC_API::register('get', '/cloud/capabilities', array('OCA\Encryption\Capabilities', 'getCapabilities'), 'files_encryption', OC_API::USER_AUTH);
|
OC_API::register('get', '/cloud/capabilities', array('OCA\Files_Encryption\Capabilities', 'getCapabilities'), 'files_encryption', OC_API::USER_AUTH);
|
||||||
|
|
|
@ -12,14 +12,14 @@ if (!isset($_)) { //also provide standalone error page
|
||||||
if (isset($_GET['errorCode'])) {
|
if (isset($_GET['errorCode'])) {
|
||||||
$errorCode = $_GET['errorCode'];
|
$errorCode = $_GET['errorCode'];
|
||||||
switch ($errorCode) {
|
switch ($errorCode) {
|
||||||
case \OCA\Encryption\Crypt::ENCRYPTION_NOT_INITIALIZED_ERROR:
|
case \OCA\Files_Encryption\Crypt::ENCRYPTION_NOT_INITIALIZED_ERROR:
|
||||||
$errorMsg = $l->t('Encryption app not initialized! Maybe the encryption app was re-enabled during your session. Please try to log out and log back in to initialize the encryption app.');
|
$errorMsg = $l->t('Encryption app not initialized! Maybe the encryption app was re-enabled during your session. Please try to log out and log back in to initialize the encryption app.');
|
||||||
break;
|
break;
|
||||||
case \OCA\Encryption\Crypt::ENCRYPTION_PRIVATE_KEY_NOT_VALID_ERROR:
|
case \OCA\Files_Encryption\Crypt::ENCRYPTION_PRIVATE_KEY_NOT_VALID_ERROR:
|
||||||
$theme = new OC_Defaults();
|
$theme = new OC_Defaults();
|
||||||
$errorMsg = $l->t('Your private key is not valid! Likely your password was changed outside of %s (e.g. your corporate directory). You can update your private key password in your personal settings to recover access to your encrypted files.', array($theme->getName()));
|
$errorMsg = $l->t('Your private key is not valid! Likely your password was changed outside of %s (e.g. your corporate directory). You can update your private key password in your personal settings to recover access to your encrypted files.', array($theme->getName()));
|
||||||
break;
|
break;
|
||||||
case \OCA\Encryption\Crypt::ENCRYPTION_NO_SHARE_KEY_FOUND:
|
case \OCA\Files_Encryption\Crypt::ENCRYPTION_NO_SHARE_KEY_FOUND:
|
||||||
$errorMsg = $l->t('Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.');
|
$errorMsg = $l->t('Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -27,7 +27,7 @@ if (!isset($_)) { //also provide standalone error page
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$errorCode = \OCA\Encryption\Crypt::ENCRYPTION_UNKNOWN_ERROR;
|
$errorCode = \OCA\Files_Encryption\Crypt::ENCRYPTION_UNKNOWN_ERROR;
|
||||||
$errorMsg = $l->t("Unknown error. Please check your system settings or contact your administrator");
|
$errorMsg = $l->t("Unknown error. Please check your system settings or contact your administrator");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ class Crypt {
|
||||||
* Check if a file's contents contains an IV and is symmetrically encrypted
|
* Check if a file's contents contains an IV and is symmetrically encrypted
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @note see also OCA\Encryption\Util->isEncryptedPath()
|
* @note see also \OCA\Files_Encryption\Util->isEncryptedPath()
|
||||||
*/
|
*/
|
||||||
public static function isCatfileContent($content) {
|
public static function isCatfileContent($content) {
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ class Crypt {
|
||||||
* @param string $passphrase
|
* @param string $passphrase
|
||||||
* @param string $cypher used for encryption, currently we support AES-128-CFB and AES-256-CFB
|
* @param string $cypher used for encryption, currently we support AES-128-CFB and AES-256-CFB
|
||||||
* @return string encrypted file content
|
* @return string encrypted file content
|
||||||
* @throws \OCA\Encryption\Exception\EncryptionException
|
* @throws \OCA\Files_Encryption\Exception\EncryptionException
|
||||||
*/
|
*/
|
||||||
private static function encrypt($plainContent, $iv, $passphrase = '', $cipher = Crypt::DEFAULT_CIPHER) {
|
private static function encrypt($plainContent, $iv, $passphrase = '', $cipher = Crypt::DEFAULT_CIPHER) {
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ class Crypt {
|
||||||
* @param string $plainContent content to be encrypted
|
* @param string $plainContent content to be encrypted
|
||||||
* @param array $publicKeys array keys must be the userId of corresponding user
|
* @param array $publicKeys array keys must be the userId of corresponding user
|
||||||
* @return array keys: keys (array, key = userId), data
|
* @return array keys: keys (array, key = userId), data
|
||||||
* @throws \OCA\Encryption\Exception\MultiKeyEncryptException if encryption failed
|
* @throws \OCA\Files_Encryption\Exception\MultiKeyEncryptException if encryption failed
|
||||||
* @note symmetricDecryptFileContent() can decrypt files created using this method
|
* @note symmetricDecryptFileContent() can decrypt files created using this method
|
||||||
*/
|
*/
|
||||||
public static function multiKeyEncrypt($plainContent, array $publicKeys) {
|
public static function multiKeyEncrypt($plainContent, array $publicKeys) {
|
||||||
|
@ -425,7 +425,7 @@ class Crypt {
|
||||||
* @param string $encryptedContent
|
* @param string $encryptedContent
|
||||||
* @param string $shareKey
|
* @param string $shareKey
|
||||||
* @param mixed $privateKey
|
* @param mixed $privateKey
|
||||||
* @throws \OCA\Encryption\Exception\MultiKeyDecryptException if decryption failed
|
* @throws \OCA\Files_Encryption\Exception\MultiKeyDecryptException if decryption failed
|
||||||
* @internal param string $plainContent contains decrypted content
|
* @internal param string $plainContent contains decrypted content
|
||||||
* @return string $plainContent decrypted string
|
* @return string $plainContent decrypted string
|
||||||
* @note symmetricDecryptFileContent() can be used to decrypt files created using this method
|
* @note symmetricDecryptFileContent() can be used to decrypt files created using this method
|
||||||
|
@ -554,7 +554,7 @@ class Crypt {
|
||||||
* get chiper from header
|
* get chiper from header
|
||||||
*
|
*
|
||||||
* @param array $header
|
* @param array $header
|
||||||
* @throws \OCA\Encryption\Exception\EncryptionException
|
* @throws \OCA\Files_Encryption\Exception\EncryptionException
|
||||||
*/
|
*/
|
||||||
public static function getCipher($header) {
|
public static function getCipher($header) {
|
||||||
$cipher = isset($header['cipher']) ? $header['cipher'] : 'AES-128-CFB';
|
$cipher = isset($header['cipher']) ? $header['cipher'] : 'AES-128-CFB';
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace OCA\Files_Encryption;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to manage registration of hooks an various helper methods
|
* Class to manage registration of hooks an various helper methods
|
||||||
* @package OCA\Encryption
|
* @package OCA\Files_Encryption
|
||||||
*/
|
*/
|
||||||
class Helper {
|
class Helper {
|
||||||
|
|
||||||
|
@ -39,9 +39,9 @@ class Helper {
|
||||||
*/
|
*/
|
||||||
public static function registerShareHooks() {
|
public static function registerShareHooks() {
|
||||||
|
|
||||||
\OCP\Util::connectHook('OCP\Share', 'pre_shared', 'OCA\Encryption\Hooks', 'preShared');
|
\OCP\Util::connectHook('OCP\Share', 'pre_shared', 'OCA\Files_Encryption\Hooks', 'preShared');
|
||||||
\OCP\Util::connectHook('OCP\Share', 'post_shared', 'OCA\Encryption\Hooks', 'postShared');
|
\OCP\Util::connectHook('OCP\Share', 'post_shared', 'OCA\Files_Encryption\Hooks', 'postShared');
|
||||||
\OCP\Util::connectHook('OCP\Share', 'post_unshare', 'OCA\Encryption\Hooks', 'postUnshare');
|
\OCP\Util::connectHook('OCP\Share', 'post_unshare', 'OCA\Files_Encryption\Hooks', 'postUnshare');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,12 +50,12 @@ class Helper {
|
||||||
*/
|
*/
|
||||||
public static function registerUserHooks() {
|
public static function registerUserHooks() {
|
||||||
|
|
||||||
\OCP\Util::connectHook('OC_User', 'post_login', 'OCA\Encryption\Hooks', 'login');
|
\OCP\Util::connectHook('OC_User', 'post_login', 'OCA\Files_Encryption\Hooks', 'login');
|
||||||
\OCP\Util::connectHook('OC_User', 'logout', 'OCA\Encryption\Hooks', 'logout');
|
\OCP\Util::connectHook('OC_User', 'logout', 'OCA\Files_Encryption\Hooks', 'logout');
|
||||||
\OCP\Util::connectHook('OC_User', 'post_setPassword', 'OCA\Encryption\Hooks', 'setPassphrase');
|
\OCP\Util::connectHook('OC_User', 'post_setPassword', 'OCA\Files_Encryption\Hooks', 'setPassphrase');
|
||||||
\OCP\Util::connectHook('OC_User', 'pre_setPassword', 'OCA\Encryption\Hooks', 'preSetPassphrase');
|
\OCP\Util::connectHook('OC_User', 'pre_setPassword', 'OCA\Files_Encryption\Hooks', 'preSetPassphrase');
|
||||||
\OCP\Util::connectHook('OC_User', 'post_createUser', 'OCA\Encryption\Hooks', 'postCreateUser');
|
\OCP\Util::connectHook('OC_User', 'post_createUser', 'OCA\Files_Encryption\Hooks', 'postCreateUser');
|
||||||
\OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OCA\Encryption\Hooks', 'postDeleteUser');
|
\OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OCA\Files_Encryption\Hooks', 'postDeleteUser');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,15 +64,15 @@ class Helper {
|
||||||
*/
|
*/
|
||||||
public static function registerFilesystemHooks() {
|
public static function registerFilesystemHooks() {
|
||||||
|
|
||||||
\OCP\Util::connectHook('OC_Filesystem', 'rename', 'OCA\Encryption\Hooks', 'preRename');
|
\OCP\Util::connectHook('OC_Filesystem', 'rename', 'OCA\Files_Encryption\Hooks', 'preRename');
|
||||||
\OCP\Util::connectHook('OC_Filesystem', 'post_rename', 'OCA\Encryption\Hooks', 'postRenameOrCopy');
|
\OCP\Util::connectHook('OC_Filesystem', 'post_rename', 'OCA\Files_Encryption\Hooks', 'postRenameOrCopy');
|
||||||
\OCP\Util::connectHook('OC_Filesystem', 'copy', 'OCA\Encryption\Hooks', 'preCopy');
|
\OCP\Util::connectHook('OC_Filesystem', 'copy', 'OCA\Files_Encryption\Hooks', 'preCopy');
|
||||||
\OCP\Util::connectHook('OC_Filesystem', 'post_copy', 'OCA\Encryption\Hooks', 'postRenameOrCopy');
|
\OCP\Util::connectHook('OC_Filesystem', 'post_copy', 'OCA\Files_Encryption\Hooks', 'postRenameOrCopy');
|
||||||
\OCP\Util::connectHook('OC_Filesystem', 'post_delete', 'OCA\Encryption\Hooks', 'postDelete');
|
\OCP\Util::connectHook('OC_Filesystem', 'post_delete', 'OCA\Files_Encryption\Hooks', 'postDelete');
|
||||||
\OCP\Util::connectHook('OC_Filesystem', 'delete', 'OCA\Encryption\Hooks', 'preDelete');
|
\OCP\Util::connectHook('OC_Filesystem', 'delete', 'OCA\Files_Encryption\Hooks', 'preDelete');
|
||||||
\OCP\Util::connectHook('\OC\Core\LostPassword\Controller\LostController', 'post_passwordReset', 'OCA\Encryption\Hooks', 'postPasswordReset');
|
\OCP\Util::connectHook('\OC\Core\LostPassword\Controller\LostController', 'post_passwordReset', 'OCA\Files_Encryption\Hooks', 'postPasswordReset');
|
||||||
\OCP\Util::connectHook('OC_Filesystem', 'post_umount', 'OCA\Encryption\Hooks', 'postUnmount');
|
\OCP\Util::connectHook('OC_Filesystem', 'post_umount', 'OCA\Files_Encryption\Hooks', 'postUnmount');
|
||||||
\OCP\Util::connectHook('OC_Filesystem', 'umount', 'OCA\Encryption\Hooks', 'preUnmount');
|
\OCP\Util::connectHook('OC_Filesystem', 'umount', 'OCA\Files_Encryption\Hooks', 'preUnmount');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,8 +81,8 @@ class Helper {
|
||||||
*/
|
*/
|
||||||
public static function registerAppHooks() {
|
public static function registerAppHooks() {
|
||||||
|
|
||||||
\OCP\Util::connectHook('OC_App', 'pre_disable', 'OCA\Encryption\Hooks', 'preDisable');
|
\OCP\Util::connectHook('OC_App', 'pre_disable', 'OCA\Files_Encryption\Hooks', 'preDisable');
|
||||||
\OCP\Util::connectHook('OC_App', 'post_disable', 'OCA\Encryption\Hooks', 'postEnable');
|
\OCP\Util::connectHook('OC_App', 'post_disable', 'OCA\Files_Encryption\Hooks', 'postEnable');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,8 +131,6 @@ class Helper {
|
||||||
*
|
*
|
||||||
* @param string $recoveryKeyId
|
* @param string $recoveryKeyId
|
||||||
* @param string $recoveryPassword
|
* @param string $recoveryPassword
|
||||||
* @internal param \OCA\Encryption\Util $util
|
|
||||||
* @internal param string $password
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function adminEnableRecovery($recoveryKeyId, $recoveryPassword) {
|
public static function adminEnableRecovery($recoveryKeyId, $recoveryPassword) {
|
||||||
|
@ -147,13 +145,13 @@ class Helper {
|
||||||
|
|
||||||
if (!Keymanager::recoveryKeyExists($view)) {
|
if (!Keymanager::recoveryKeyExists($view)) {
|
||||||
|
|
||||||
$keypair = \OCA\Encryption\Crypt::createKeypair();
|
$keypair = Crypt::createKeypair();
|
||||||
|
|
||||||
// Save public key
|
// Save public key
|
||||||
Keymanager::setPublicKey($keypair['publicKey'], $recoveryKeyId);
|
Keymanager::setPublicKey($keypair['publicKey'], $recoveryKeyId);
|
||||||
|
|
||||||
$cipher = \OCA\Encryption\Helper::getCipher();
|
$cipher = Helper::getCipher();
|
||||||
$encryptedKey = \OCA\Encryption\Crypt::symmetricEncryptFileContent($keypair['privateKey'], $recoveryPassword, $cipher);
|
$encryptedKey = Crypt::symmetricEncryptFileContent($keypair['privateKey'], $recoveryPassword, $cipher);
|
||||||
if ($encryptedKey) {
|
if ($encryptedKey) {
|
||||||
Keymanager::setPrivateSystemKey($encryptedKey, $recoveryKeyId);
|
Keymanager::setPrivateSystemKey($encryptedKey, $recoveryKeyId);
|
||||||
// Set recoveryAdmin as enabled
|
// Set recoveryAdmin as enabled
|
||||||
|
@ -162,7 +160,7 @@ class Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // get recovery key and check the password
|
} else { // get recovery key and check the password
|
||||||
$util = new \OCA\Encryption\Util(new \OC\Files\View('/'), \OCP\User::getUser());
|
$util = new Util(new \OC\Files\View('/'), \OCP\User::getUser());
|
||||||
$return = $util->checkRecoveryPassword($recoveryPassword);
|
$return = $util->checkRecoveryPassword($recoveryPassword);
|
||||||
if ($return) {
|
if ($return) {
|
||||||
$appConfig->setValue('files_encryption', 'recoveryAdminEnabled', 1);
|
$appConfig->setValue('files_encryption', 'recoveryAdminEnabled', 1);
|
||||||
|
@ -362,14 +360,14 @@ class Helper {
|
||||||
if ($errorCode === null) {
|
if ($errorCode === null) {
|
||||||
$init = $session->getInitialized();
|
$init = $session->getInitialized();
|
||||||
switch ($init) {
|
switch ($init) {
|
||||||
case \OCA\Encryption\Session::INIT_EXECUTED:
|
case Session::INIT_EXECUTED:
|
||||||
$errorCode = \OCA\Encryption\Crypt::ENCRYPTION_PRIVATE_KEY_NOT_VALID_ERROR;
|
$errorCode = Crypt::ENCRYPTION_PRIVATE_KEY_NOT_VALID_ERROR;
|
||||||
break;
|
break;
|
||||||
case \OCA\Encryption\Session::NOT_INITIALIZED:
|
case Session::NOT_INITIALIZED:
|
||||||
$errorCode = \OCA\Encryption\Crypt::ENCRYPTION_NOT_INITIALIZED_ERROR;
|
$errorCode = Crypt::ENCRYPTION_NOT_INITIALIZED_ERROR;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$errorCode = \OCA\Encryption\Crypt::ENCRYPTION_UNKNOWN_ERROR;
|
$errorCode = Crypt::ENCRYPTION_UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ class Hooks {
|
||||||
\OC_Util::setupFS($params['uid']);
|
\OC_Util::setupFS($params['uid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$privateKey = \OCA\Encryption\Keymanager::getPrivateKey($view, $params['uid']);
|
$privateKey = Keymanager::getPrivateKey($view, $params['uid']);
|
||||||
|
|
||||||
// if no private key exists, check server configuration
|
// if no private key exists, check server configuration
|
||||||
if (!$privateKey) {
|
if (!$privateKey) {
|
||||||
|
@ -128,7 +128,7 @@ class Hooks {
|
||||||
* remove keys from session during logout
|
* remove keys from session during logout
|
||||||
*/
|
*/
|
||||||
public static function logout() {
|
public static function logout() {
|
||||||
$session = new \OCA\Encryption\Session(new \OC\Files\View());
|
$session = new Session(new \OC\Files\View());
|
||||||
$session->removeKeys();
|
$session->removeKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ class Hooks {
|
||||||
if (Crypt::mode() === 'server') {
|
if (Crypt::mode() === 'server') {
|
||||||
|
|
||||||
$view = new \OC\Files\View('/');
|
$view = new \OC\Files\View('/');
|
||||||
$session = new \OCA\Encryption\Session($view);
|
$session = new Session($view);
|
||||||
|
|
||||||
// Get existing decrypted private key
|
// Get existing decrypted private key
|
||||||
$privateKey = $session->getPrivateKey();
|
$privateKey = $session->getPrivateKey();
|
||||||
|
@ -236,7 +236,7 @@ class Hooks {
|
||||||
Keymanager::setPublicKey($keypair['publicKey'], $user);
|
Keymanager::setPublicKey($keypair['publicKey'], $user);
|
||||||
|
|
||||||
// Encrypt private key with new password
|
// Encrypt private key with new password
|
||||||
$encryptedKey = \OCA\Encryption\Crypt::symmetricEncryptFileContent($keypair['privateKey'], $newUserPassword, Helper::getCipher());
|
$encryptedKey = Crypt::symmetricEncryptFileContent($keypair['privateKey'], $newUserPassword, Helper::getCipher());
|
||||||
if ($encryptedKey) {
|
if ($encryptedKey) {
|
||||||
Keymanager::setPrivateKey($encryptedKey, $user);
|
Keymanager::setPrivateKey($encryptedKey, $user);
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ class Hooks {
|
||||||
private static function updateKeyfiles($path) {
|
private static function updateKeyfiles($path) {
|
||||||
$view = new \OC\Files\View('/');
|
$view = new \OC\Files\View('/');
|
||||||
$userId = \OCP\User::getUser();
|
$userId = \OCP\User::getUser();
|
||||||
$session = new \OCA\Encryption\Session($view);
|
$session = new Session($view);
|
||||||
$util = new Util($view, $userId);
|
$util = new Util($view, $userId);
|
||||||
$sharingEnabled = \OCP\Share::isEnabled();
|
$sharingEnabled = \OCP\Share::isEnabled();
|
||||||
|
|
||||||
|
@ -504,8 +504,8 @@ class Hooks {
|
||||||
|
|
||||||
\OC::$server->getConfig()->deleteAppFromAllUsers('files_encryption');
|
\OC::$server->getConfig()->deleteAppFromAllUsers('files_encryption');
|
||||||
|
|
||||||
$session = new \OCA\Encryption\Session(new \OC\Files\View('/'));
|
$session = new Session(new \OC\Files\View('/'));
|
||||||
$session->setInitialized(\OCA\Encryption\Session::NOT_INITIALIZED);
|
$session->setInitialized(Session::NOT_INITIALIZED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,8 +515,8 @@ class Hooks {
|
||||||
*/
|
*/
|
||||||
public static function postEnable($params) {
|
public static function postEnable($params) {
|
||||||
if ($params['app'] === 'files_encryption') {
|
if ($params['app'] === 'files_encryption') {
|
||||||
$session = new \OCA\Encryption\Session(new \OC\Files\View('/'));
|
$session = new Session(new \OC\Files\View('/'));
|
||||||
$session->setInitialized(\OCA\Encryption\Session::NOT_INITIALIZED);
|
$session->setInitialized(Session::NOT_INITIALIZED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ class Keymanager {
|
||||||
* store file encryption key
|
* store file encryption key
|
||||||
*
|
*
|
||||||
* @param \OC\Files\View $view
|
* @param \OC\Files\View $view
|
||||||
* @param \OCA\Encryption\Util $util
|
* @param \OCA\Files_Encryption\Util $util
|
||||||
* @param string $path relative path of the file, including filename
|
* @param string $path relative path of the file, including filename
|
||||||
* @param string $catfile keyfile content
|
* @param string $catfile keyfile content
|
||||||
* @return bool true/false
|
* @return bool true/false
|
||||||
|
@ -158,7 +158,7 @@ class Keymanager {
|
||||||
* get path to key folder for a given file
|
* get path to key folder for a given file
|
||||||
*
|
*
|
||||||
* @param \OC\Files\View $view relative to data directory
|
* @param \OC\Files\View $view relative to data directory
|
||||||
* @param \OCA\Encryption\Util $util
|
* @param \OCA\Files_Encryption\Util $util
|
||||||
* @param string $path path to the file, relative to the users file directory
|
* @param string $path path to the file, relative to the users file directory
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -186,7 +186,7 @@ class Keymanager {
|
||||||
* get path to file key for a given file
|
* get path to file key for a given file
|
||||||
*
|
*
|
||||||
* @param \OC\Files\View $view relative to data directory
|
* @param \OC\Files\View $view relative to data directory
|
||||||
* @param \OCA\Encryption\Util $util
|
* @param \OCA\Files_Encryption\Util $util
|
||||||
* @param string $path path to the file, relative to the users file directory
|
* @param string $path path to the file, relative to the users file directory
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -199,7 +199,7 @@ class Keymanager {
|
||||||
* get path to share key for a given user
|
* get path to share key for a given user
|
||||||
*
|
*
|
||||||
* @param \OC\Files\View $view relateive to data directory
|
* @param \OC\Files\View $view relateive to data directory
|
||||||
* @param \OCA\Encryption\Util $util
|
* @param \OCA\Files_Encryption\Util $util
|
||||||
* @param string $path path to file relative to the users files directoy
|
* @param string $path path to file relative to the users files directoy
|
||||||
* @param string $uid user for whom we want the share-key path
|
* @param string $uid user for whom we want the share-key path
|
||||||
* @retrun string
|
* @retrun string
|
||||||
|
@ -243,9 +243,8 @@ class Keymanager {
|
||||||
/**
|
/**
|
||||||
* retrieve keyfile for an encrypted file
|
* retrieve keyfile for an encrypted file
|
||||||
* @param \OC\Files\View $view
|
* @param \OC\Files\View $view
|
||||||
* @param \OCA\Encryption\Util $util
|
* @param \OCA\Files_Encryption\Util $util
|
||||||
* @param string|false $filePath
|
* @param string|false $filePath
|
||||||
* @internal param \OCA\Encryption\file $string name
|
|
||||||
* @return string file key or false
|
* @return string file key or false
|
||||||
* @note The keyfile returned is asymmetrically encrypted. Decryption
|
* @note The keyfile returned is asymmetrically encrypted. Decryption
|
||||||
* of the keyfile must be performed by client code
|
* of the keyfile must be performed by client code
|
||||||
|
@ -347,7 +346,7 @@ class Keymanager {
|
||||||
/**
|
/**
|
||||||
* store multiple share keys for a single file
|
* store multiple share keys for a single file
|
||||||
* @param \OC\Files\View $view
|
* @param \OC\Files\View $view
|
||||||
* @param \OCA\Encryption\Util $util
|
* @param \OCA\Files_Encryption\Util $util
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @param array $shareKeys
|
* @param array $shareKeys
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@ -376,7 +375,7 @@ class Keymanager {
|
||||||
* retrieve shareKey for an encrypted file
|
* retrieve shareKey for an encrypted file
|
||||||
* @param \OC\Files\View $view
|
* @param \OC\Files\View $view
|
||||||
* @param string $userId
|
* @param string $userId
|
||||||
* @param \OCA\Encryption\Util $util
|
* @param \OCA\Files_Encryption\Util $util
|
||||||
* @param string $filePath
|
* @param string $filePath
|
||||||
* @return string file key or false
|
* @return string file key or false
|
||||||
* @note The sharekey returned is encrypted. Decryption
|
* @note The sharekey returned is encrypted. Decryption
|
||||||
|
|
|
@ -35,8 +35,8 @@ class Migration {
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->view = new \OC\Files\View();
|
$this->view = new \OC\Files\View();
|
||||||
$this->public_share_key_id = \OCA\Encryption\Helper::getPublicShareKeyId();
|
$this->public_share_key_id = Helper::getPublicShareKeyId();
|
||||||
$this->recovery_key_id = \OCA\Encryption\Helper::getRecoveryKeyId();
|
$this->recovery_key_id = Helper::getRecoveryKeyId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reorganizeFolderStructure() {
|
public function reorganizeFolderStructure() {
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace OCA\Files_Encryption;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Proxy
|
* Class Proxy
|
||||||
* @package OCA\Encryption
|
* @package OCA\Files_Encryption
|
||||||
*/
|
*/
|
||||||
class Proxy extends \OC_FileProxy {
|
class Proxy extends \OC_FileProxy {
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class Proxy extends \OC_FileProxy {
|
||||||
$view = new \OC\Files\View('/');
|
$view = new \OC\Files\View('/');
|
||||||
|
|
||||||
// get relative path
|
// get relative path
|
||||||
$relativePath = \OCA\Encryption\Helper::stripUserFilesPath($path);
|
$relativePath = Helper::stripUserFilesPath($path);
|
||||||
|
|
||||||
if (!isset($relativePath)) {
|
if (!isset($relativePath)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -338,7 +338,7 @@ class Proxy extends \OC_FileProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get relative path
|
// get relative path
|
||||||
$relativePath = \OCA\Encryption\Helper::stripUserFilesPath($path);
|
$relativePath = Helper::stripUserFilesPath($path);
|
||||||
|
|
||||||
// if path is empty we cannot resolve anything
|
// if path is empty we cannot resolve anything
|
||||||
if (empty($relativePath)) {
|
if (empty($relativePath)) {
|
||||||
|
|
|
@ -72,8 +72,8 @@ class Session {
|
||||||
Keymanager::setPublicKey($keypair['publicKey'], $publicShareKeyId);
|
Keymanager::setPublicKey($keypair['publicKey'], $publicShareKeyId);
|
||||||
|
|
||||||
// Encrypt private key empty passphrase
|
// Encrypt private key empty passphrase
|
||||||
$cipher = \OCA\Encryption\Helper::getCipher();
|
$cipher = Helper::getCipher();
|
||||||
$encryptedKey = \OCA\Encryption\Crypt::symmetricEncryptFileContent($keypair['privateKey'], '', $cipher);
|
$encryptedKey = Crypt::symmetricEncryptFileContent($keypair['privateKey'], '', $cipher);
|
||||||
if ($encryptedKey) {
|
if ($encryptedKey) {
|
||||||
Keymanager::setPrivateSystemKey($encryptedKey, $publicShareKeyId);
|
Keymanager::setPrivateSystemKey($encryptedKey, $publicShareKeyId);
|
||||||
} else {
|
} else {
|
||||||
|
@ -82,7 +82,7 @@ class Session {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\OCA\Encryption\Helper::isPublicAccess() && !self::getPublicSharePrivateKey()) {
|
if (Helper::isPublicAccess() && !self::getPublicSharePrivateKey()) {
|
||||||
// Disable encryption proxy to prevent recursive calls
|
// Disable encryption proxy to prevent recursive calls
|
||||||
$proxyStatus = \OC_FileProxy::$enabled;
|
$proxyStatus = \OC_FileProxy::$enabled;
|
||||||
\OC_FileProxy::$enabled = false;
|
\OC_FileProxy::$enabled = false;
|
||||||
|
@ -151,7 +151,7 @@ class Session {
|
||||||
public function getInitialized() {
|
public function getInitialized() {
|
||||||
if (!is_null(\OC::$server->getSession()->get('encryptionInitialized'))) {
|
if (!is_null(\OC::$server->getSession()->get('encryptionInitialized'))) {
|
||||||
return \OC::$server->getSession()->get('encryptionInitialized');
|
return \OC::$server->getSession()->get('encryptionInitialized');
|
||||||
} else if (\OCA\Encryption\Helper::isPublicAccess() && self::getPublicSharePrivateKey()) {
|
} else if (Helper::isPublicAccess() && self::getPublicSharePrivateKey()) {
|
||||||
return self::INIT_SUCCESSFUL;
|
return self::INIT_SUCCESSFUL;
|
||||||
} else {
|
} else {
|
||||||
return self::NOT_INITIALIZED;
|
return self::NOT_INITIALIZED;
|
||||||
|
@ -165,7 +165,7 @@ class Session {
|
||||||
*/
|
*/
|
||||||
public function getPrivateKey() {
|
public function getPrivateKey() {
|
||||||
// return the public share private key if this is a public access
|
// return the public share private key if this is a public access
|
||||||
if (\OCA\Encryption\Helper::isPublicAccess()) {
|
if (Helper::isPublicAccess()) {
|
||||||
return self::getPublicSharePrivateKey();
|
return self::getPublicSharePrivateKey();
|
||||||
} else {
|
} else {
|
||||||
if (!is_null(\OC::$server->getSession()->get('privateKey'))) {
|
if (!is_null(\OC::$server->getSession()->get('privateKey'))) {
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace OCA\Files_Encryption;
|
namespace OCA\Files_Encryption;
|
||||||
use OCA\Encryption\Exception\EncryptionException;
|
|
||||||
|
use OCA\Files_Encryption\Exception\EncryptionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides 'crypt://' stream wrapper protocol.
|
* Provides 'crypt://' stream wrapper protocol.
|
||||||
|
@ -81,7 +82,7 @@ class Stream {
|
||||||
private $rootView; // a fsview object set to '/'
|
private $rootView; // a fsview object set to '/'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \OCA\Encryption\Session
|
* @var \OCA\Files_Encryption\Session
|
||||||
*/
|
*/
|
||||||
private $session;
|
private $session;
|
||||||
private $privateKey;
|
private $privateKey;
|
||||||
|
@ -92,7 +93,7 @@ class Stream {
|
||||||
* @param int $options
|
* @param int $options
|
||||||
* @param string $opened_path
|
* @param string $opened_path
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throw \OCA\Encryption\Exception\EncryptionException
|
* @throw \OCA\Files_Encryption\Exception\EncryptionException
|
||||||
*/
|
*/
|
||||||
public function stream_open($path, $mode, $options, &$opened_path) {
|
public function stream_open($path, $mode, $options, &$opened_path) {
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ class Stream {
|
||||||
$this->rootView = new \OC\Files\View('/');
|
$this->rootView = new \OC\Files\View('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->session = new \OCA\Encryption\Session($this->rootView);
|
$this->session = new Session($this->rootView);
|
||||||
|
|
||||||
$this->privateKey = $this->session->getPrivateKey();
|
$this->privateKey = $this->session->getPrivateKey();
|
||||||
if ($this->privateKey === false) {
|
if ($this->privateKey === false) {
|
||||||
|
@ -162,7 +163,7 @@ class Stream {
|
||||||
|
|
||||||
if($this->privateKey === false) {
|
if($this->privateKey === false) {
|
||||||
// if private key is not valid redirect user to a error page
|
// if private key is not valid redirect user to a error page
|
||||||
\OCA\Encryption\Helper::redirectToErrorPage($this->session);
|
Helper::redirectToErrorPage($this->session);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->size = $this->rootView->filesize($this->rawPath);
|
$this->size = $this->rootView->filesize($this->rawPath);
|
||||||
|
@ -251,7 +252,7 @@ class Stream {
|
||||||
/**
|
/**
|
||||||
* @param int $count
|
* @param int $count
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
* @throws \OCA\Encryption\Exception\EncryptionException
|
* @throws \OCA\Files_Encryption\Exception\EncryptionException
|
||||||
*/
|
*/
|
||||||
public function stream_read($count) {
|
public function stream_read($count) {
|
||||||
|
|
||||||
|
@ -329,7 +330,7 @@ class Stream {
|
||||||
|
|
||||||
// Fetch and decrypt keyfile
|
// Fetch and decrypt keyfile
|
||||||
// Fetch existing keyfile
|
// Fetch existing keyfile
|
||||||
$util = new \OCA\Encryption\Util($this->rootView, $this->userId);
|
$util = new Util($this->rootView, $this->userId);
|
||||||
$this->encKeyfile = Keymanager::getFileKey($this->rootView, $util, $this->relPath);
|
$this->encKeyfile = Keymanager::getFileKey($this->rootView, $util, $this->relPath);
|
||||||
|
|
||||||
// If a keyfile already exists
|
// If a keyfile already exists
|
||||||
|
@ -340,13 +341,13 @@ class Stream {
|
||||||
// if there is no valid private key return false
|
// if there is no valid private key return false
|
||||||
if ($this->privateKey === false) {
|
if ($this->privateKey === false) {
|
||||||
// if private key is not valid redirect user to a error page
|
// if private key is not valid redirect user to a error page
|
||||||
\OCA\Encryption\Helper::redirectToErrorPage($this->session);
|
Helper::redirectToErrorPage($this->session);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($shareKey === false) {
|
if ($shareKey === false) {
|
||||||
// if no share key is available redirect user to a error page
|
// if no share key is available redirect user to a error page
|
||||||
\OCA\Encryption\Helper::redirectToErrorPage($this->session, \OCA\Encryption\Crypt::ENCRYPTION_NO_SHARE_KEY_FOUND);
|
Helper::redirectToErrorPage($this->session, Crypt::ENCRYPTION_NO_SHARE_KEY_FOUND);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,7 +368,7 @@ class Stream {
|
||||||
/**
|
/**
|
||||||
* write header at beginning of encrypted file
|
* write header at beginning of encrypted file
|
||||||
*
|
*
|
||||||
* @throws Exception\EncryptionException
|
* @throws \OCA\Files_Encryption\Exception\EncryptionException
|
||||||
*/
|
*/
|
||||||
private function writeHeader() {
|
private function writeHeader() {
|
||||||
|
|
||||||
|
@ -589,7 +590,7 @@ class Stream {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if private key is not valid redirect user to a error page
|
// if private key is not valid redirect user to a error page
|
||||||
\OCA\Encryption\Helper::redirectToErrorPage($this->session);
|
Helper::redirectToErrorPage($this->session);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -83,7 +83,7 @@ class Util {
|
||||||
// make sure that the owners home is mounted
|
// make sure that the owners home is mounted
|
||||||
\OC\Files\Filesystem::initMountPoints($userId);
|
\OC\Files\Filesystem::initMountPoints($userId);
|
||||||
|
|
||||||
if (\OCA\Encryption\Helper::isPublicAccess()) {
|
if (Helper::isPublicAccess()) {
|
||||||
$this->keyId = $this->publicShareKeyId;
|
$this->keyId = $this->publicShareKeyId;
|
||||||
$this->isPublic = true;
|
$this->isPublic = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -277,7 +277,7 @@ class Util {
|
||||||
if ($file !== "." && $file !== "..") {
|
if ($file !== "." && $file !== "..") {
|
||||||
|
|
||||||
$filePath = $directory . '/' . $this->view->getRelativePath('/' . $file);
|
$filePath = $directory . '/' . $this->view->getRelativePath('/' . $file);
|
||||||
$relPath = \OCA\Encryption\Helper::stripUserFilesPath($filePath);
|
$relPath = Helper::stripUserFilesPath($filePath);
|
||||||
|
|
||||||
// If the path is a directory, search
|
// If the path is a directory, search
|
||||||
// its contents
|
// its contents
|
||||||
|
@ -451,13 +451,13 @@ class Util {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose($stream);
|
fclose($stream);
|
||||||
$relPath = \OCA\Encryption\Helper::stripUserFilesPath($path);
|
$relPath = Helper::stripUserFilesPath($path);
|
||||||
$shareKey = Keymanager::getShareKey($this->view, $this->keyId, $this, $relPath);
|
$shareKey = Keymanager::getShareKey($this->view, $this->keyId, $this, $relPath);
|
||||||
if($shareKey===false) {
|
if($shareKey===false) {
|
||||||
\OC_FileProxy::$enabled = $proxyStatus;
|
\OC_FileProxy::$enabled = $proxyStatus;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
$session = new \OCA\Encryption\Session($this->view);
|
$session = new Session($this->view);
|
||||||
$privateKey = $session->getPrivateKey();
|
$privateKey = $session->getPrivateKey();
|
||||||
$plainKeyfile = $this->decryptKeyfile($relPath, $privateKey);
|
$plainKeyfile = $this->decryptKeyfile($relPath, $privateKey);
|
||||||
$plainKey = Crypt::multiKeyDecrypt($plainKeyfile, $shareKey, $privateKey);
|
$plainKey = Crypt::multiKeyDecrypt($plainKeyfile, $shareKey, $privateKey);
|
||||||
|
@ -1040,7 +1040,7 @@ class Util {
|
||||||
// Make sure that a share key is generated for the owner too
|
// Make sure that a share key is generated for the owner too
|
||||||
list($owner, $ownerPath) = $this->getUidAndFilename($filePath);
|
list($owner, $ownerPath) = $this->getUidAndFilename($filePath);
|
||||||
|
|
||||||
$ownerPath = \OCA\Encryption\Helper::stripPartialFileExtension($ownerPath);
|
$ownerPath = Helper::stripPartialFileExtension($ownerPath);
|
||||||
|
|
||||||
// always add owner to the list of users with access to the file
|
// always add owner to the list of users with access to the file
|
||||||
$userIds = array($owner);
|
$userIds = array($owner);
|
||||||
|
@ -1402,7 +1402,7 @@ class Util {
|
||||||
if ($this->view->is_dir($this->userFilesDir . '/' . $filePath)) {
|
if ($this->view->is_dir($this->userFilesDir . '/' . $filePath)) {
|
||||||
$this->addRecoveryKeys($filePath . '/');
|
$this->addRecoveryKeys($filePath . '/');
|
||||||
} else {
|
} else {
|
||||||
$session = new \OCA\Encryption\Session(new \OC\Files\View('/'));
|
$session = new Session(new \OC\Files\View('/'));
|
||||||
$sharingEnabled = \OCP\Share::isEnabled();
|
$sharingEnabled = \OCP\Share::isEnabled();
|
||||||
$usersSharing = $this->getSharingUsersArray($sharingEnabled, $filePath);
|
$usersSharing = $this->getSharingUsersArray($sharingEnabled, $filePath);
|
||||||
$this->setSharedFileKeyfiles($session, $usersSharing, $filePath);
|
$this->setSharedFileKeyfiles($session, $usersSharing, $filePath);
|
||||||
|
@ -1559,10 +1559,10 @@ class Util {
|
||||||
*/
|
*/
|
||||||
public function initEncryption($params) {
|
public function initEncryption($params) {
|
||||||
|
|
||||||
$session = new \OCA\Encryption\Session($this->view);
|
$session = new Session($this->view);
|
||||||
|
|
||||||
// we tried to initialize the encryption app for this session
|
// we tried to initialize the encryption app for this session
|
||||||
$session->setInitialized(\OCA\Encryption\Session::INIT_EXECUTED);
|
$session->setInitialized(Session::INIT_EXECUTED);
|
||||||
|
|
||||||
$encryptedKey = Keymanager::getPrivateKey($this->view, $params['uid']);
|
$encryptedKey = Keymanager::getPrivateKey($this->view, $params['uid']);
|
||||||
|
|
||||||
|
@ -1578,7 +1578,7 @@ class Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
$session->setPrivateKey($privateKey);
|
$session->setPrivateKey($privateKey);
|
||||||
$session->setInitialized(\OCA\Encryption\Session::INIT_SUCCESSFUL);
|
$session->setInitialized(Session::INIT_SUCCESSFUL);
|
||||||
|
|
||||||
return $session;
|
return $session;
|
||||||
}
|
}
|
||||||
|
@ -1587,7 +1587,7 @@ class Util {
|
||||||
* remove encryption related keys from the session
|
* remove encryption related keys from the session
|
||||||
*/
|
*/
|
||||||
public function closeEncryptionSession() {
|
public function closeEncryptionSession() {
|
||||||
$session = new \OCA\Encryption\Session($this->view);
|
$session = new Session($this->view);
|
||||||
$session->closeSession();
|
$session->closeSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ $tmpl = new OCP\Template('files_encryption', 'settings-admin');
|
||||||
|
|
||||||
// Check if an adminRecovery account is enabled for recovering files after lost pwd
|
// Check if an adminRecovery account is enabled for recovering files after lost pwd
|
||||||
$recoveryAdminEnabled = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled', '0');
|
$recoveryAdminEnabled = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled', '0');
|
||||||
$session = new \OCA\Encryption\Session(new \OC\Files\View('/'));
|
$session = new \OCA\Files_Encryption\Session(new \OC\Files\View('/'));
|
||||||
$initStatus = $session->getInitialized();
|
$initStatus = $session->getInitialized();
|
||||||
|
|
||||||
$tmpl->assign('recoveryEnabled', $recoveryAdminEnabled);
|
$tmpl->assign('recoveryEnabled', $recoveryAdminEnabled);
|
||||||
|
|
|
@ -13,8 +13,8 @@ $tmpl = new OCP\Template('files_encryption', 'settings-personal');
|
||||||
|
|
||||||
$user = \OCP\USER::getUser();
|
$user = \OCP\USER::getUser();
|
||||||
$view = new \OC\Files\View('/');
|
$view = new \OC\Files\View('/');
|
||||||
$util = new \OCA\Encryption\Util($view, $user);
|
$util = new \OCA\Files_Encryption\Util($view, $user);
|
||||||
$session = new \OCA\Encryption\Session($view);
|
$session = new \OCA\Files_Encryption\Session($view);
|
||||||
|
|
||||||
$privateKeySet = $session->getPrivateKey() !== false;
|
$privateKeySet = $session->getPrivateKey() !== false;
|
||||||
// did we tried to initialize the keys for this session?
|
// did we tried to initialize the keys for this session?
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<?php p($_['message']); ?>
|
<?php p($_['message']); ?>
|
||||||
<br/>
|
<br/>
|
||||||
<?php if($_['errorCode'] === \OCA\Encryption\Crypt::ENCRYPTION_PRIVATE_KEY_NOT_VALID_ERROR): ?>
|
<?php if($_['errorCode'] === \OCA\Files_Encryption\Crypt::ENCRYPTION_PRIVATE_KEY_NOT_VALID_ERROR): ?>
|
||||||
<?php p($l->t('Go directly to your %spersonal settings%s.', array('<a href="'.$location.'">', '</a>'))); ?>
|
<?php p($l->t('Go directly to your %spersonal settings%s.', array('<a href="'.$location.'">', '</a>'))); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<form id="encryption" class="section">
|
<form id="encryption" class="section">
|
||||||
<h2><?php p($l->t('Encryption')); ?></h2>
|
<h2><?php p($l->t('Encryption')); ?></h2>
|
||||||
|
|
||||||
<?php if($_["initStatus"] === \OCA\Encryption\Session::NOT_INITIALIZED): ?>
|
<?php if($_["initStatus"] === \OCA\Files_Encryption\Session::NOT_INITIALIZED): ?>
|
||||||
<?php p($l->t("Encryption App is enabled but your keys are not initialized, please log-out and log-in again")); ?>
|
<?php p($l->t("Encryption App is enabled but your keys are not initialized, please log-out and log-in again")); ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<p id="encryptionSetRecoveryKey">
|
<p id="encryptionSetRecoveryKey">
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<form id="encryption" class="section">
|
<form id="encryption" class="section">
|
||||||
<h2><?php p( $l->t( 'Encryption' ) ); ?></h2>
|
<h2><?php p( $l->t( 'Encryption' ) ); ?></h2>
|
||||||
|
|
||||||
<?php if ( $_["initialized"] === \OCA\Encryption\Session::NOT_INITIALIZED ): ?>
|
<?php if ( $_["initialized"] === \OCA\Files_Encryption\Session::NOT_INITIALIZED ): ?>
|
||||||
|
|
||||||
<?php p($l->t("Encryption App is enabled but your keys are not initialized, please log-out and log-in again")); ?>
|
<?php p($l->t("Encryption App is enabled but your keys are not initialized, please log-out and log-in again")); ?>
|
||||||
|
|
||||||
<?php elseif ( $_["initialized"] === \OCA\Encryption\Session::INIT_EXECUTED ): ?>
|
<?php elseif ( $_["initialized"] === \OCA\Files_Encryption\Session::INIT_EXECUTED ): ?>
|
||||||
<p>
|
<p>
|
||||||
<a name="changePKPasswd" />
|
<a name="changePKPasswd" />
|
||||||
<label for="changePrivateKeyPasswd">
|
<label for="changePrivateKeyPasswd">
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
<span class="msg"></span>
|
<span class="msg"></span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?php elseif ( $_["recoveryEnabled"] && $_["privateKeySet"] && $_["initialized"] === \OCA\Encryption\Session::INIT_SUCCESSFUL ): ?>
|
<?php elseif ( $_["recoveryEnabled"] && $_["privateKeySet"] && $_["initialized"] === \OCA\Files_Encryption\Session::INIT_SUCCESSFUL ): ?>
|
||||||
<br />
|
<br />
|
||||||
<p id="userEnableRecovery">
|
<p id="userEnableRecovery">
|
||||||
<label for="userEnableRecovery"><?php p( $l->t( "Enable password recovery:" ) ); ?></label>
|
<label for="userEnableRecovery"><?php p( $l->t( "Enable password recovery:" ) ); ?></label>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* See the COPYING-README file.
|
* See the COPYING-README file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
use OCA\Files_Encryption\Crypt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Test_Encryption_Crypt
|
* Class Test_Encryption_Crypt
|
||||||
|
@ -52,9 +52,9 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$this->legacyData = __DIR__ . '/legacy-text.txt';
|
$this->legacyData = __DIR__ . '/legacy-text.txt';
|
||||||
$this->legacyEncryptedData = __DIR__ . '/legacy-encrypted-text.txt';
|
$this->legacyEncryptedData = __DIR__ . '/legacy-encrypted-text.txt';
|
||||||
$this->legacyEncryptedDataKey = __DIR__ . '/encryption.key';
|
$this->legacyEncryptedDataKey = __DIR__ . '/encryption.key';
|
||||||
$this->randomKey = Encryption\Crypt::generateKey();
|
$this->randomKey = Crypt::generateKey();
|
||||||
|
|
||||||
$keypair = Encryption\Crypt::createKeypair();
|
$keypair = Crypt::createKeypair();
|
||||||
$this->genPublicKey = $keypair['publicKey'];
|
$this->genPublicKey = $keypair['publicKey'];
|
||||||
$this->genPrivateKey = $keypair['privateKey'];
|
$this->genPrivateKey = $keypair['privateKey'];
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
# TODO: use more accurate (larger) string length for test confirmation
|
# TODO: use more accurate (larger) string length for test confirmation
|
||||||
|
|
||||||
$key = Encryption\Crypt::generateKey();
|
$key = Crypt::generateKey();
|
||||||
|
|
||||||
$this->assertTrue(strlen($key) > 16);
|
$this->assertTrue(strlen($key) > 16);
|
||||||
|
|
||||||
|
@ -104,16 +104,16 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
public function testDecryptPrivateKey() {
|
public function testDecryptPrivateKey() {
|
||||||
|
|
||||||
// test successful decrypt
|
// test successful decrypt
|
||||||
$crypted = Encryption\Crypt::symmetricEncryptFileContent($this->genPrivateKey, 'hat');
|
$crypted = Crypt::symmetricEncryptFileContent($this->genPrivateKey, 'hat');
|
||||||
|
|
||||||
$header = Encryption\Crypt::generateHeader();
|
$header = Crypt::generateHeader();
|
||||||
|
|
||||||
$decrypted = Encryption\Crypt::decryptPrivateKey($header . $crypted, 'hat');
|
$decrypted = Crypt::decryptPrivateKey($header . $crypted, 'hat');
|
||||||
|
|
||||||
$this->assertEquals($this->genPrivateKey, $decrypted);
|
$this->assertEquals($this->genPrivateKey, $decrypted);
|
||||||
|
|
||||||
//test private key decrypt with wrong password
|
//test private key decrypt with wrong password
|
||||||
$wrongPasswd = Encryption\Crypt::decryptPrivateKey($crypted, 'hat2');
|
$wrongPasswd = Crypt::decryptPrivateKey($crypted, 'hat2');
|
||||||
|
|
||||||
$this->assertEquals(false, $wrongPasswd);
|
$this->assertEquals(false, $wrongPasswd);
|
||||||
|
|
||||||
|
@ -127,12 +127,12 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
# TODO: search in keyfile for actual content as IV will ensure this test always passes
|
# TODO: search in keyfile for actual content as IV will ensure this test always passes
|
||||||
|
|
||||||
$crypted = Encryption\Crypt::symmetricEncryptFileContent($this->dataShort, 'hat');
|
$crypted = Crypt::symmetricEncryptFileContent($this->dataShort, 'hat');
|
||||||
|
|
||||||
$this->assertNotEquals($this->dataShort, $crypted);
|
$this->assertNotEquals($this->dataShort, $crypted);
|
||||||
|
|
||||||
|
|
||||||
$decrypt = Encryption\Crypt::symmetricDecryptFileContent($crypted, 'hat');
|
$decrypt = Crypt::symmetricDecryptFileContent($crypted, 'hat');
|
||||||
|
|
||||||
$this->assertEquals($this->dataShort, $decrypt);
|
$this->assertEquals($this->dataShort, $decrypt);
|
||||||
|
|
||||||
|
@ -145,12 +145,12 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
# TODO: search in keyfile for actual content as IV will ensure this test always passes
|
# TODO: search in keyfile for actual content as IV will ensure this test always passes
|
||||||
|
|
||||||
$crypted = Encryption\Crypt::symmetricEncryptFileContent($this->dataShort, 'hat', 'AES-128-CFB');
|
$crypted = Crypt::symmetricEncryptFileContent($this->dataShort, 'hat', 'AES-128-CFB');
|
||||||
|
|
||||||
$this->assertNotEquals($this->dataShort, $crypted);
|
$this->assertNotEquals($this->dataShort, $crypted);
|
||||||
|
|
||||||
|
|
||||||
$decrypt = Encryption\Crypt::symmetricDecryptFileContent($crypted, 'hat', 'AES-128-CFB');
|
$decrypt = Crypt::symmetricDecryptFileContent($crypted, 'hat', 'AES-128-CFB');
|
||||||
|
|
||||||
$this->assertEquals($this->dataShort, $decrypt);
|
$this->assertEquals($this->dataShort, $decrypt);
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
// remove the header to check if we can also decrypt old files without a header,
|
// remove the header to check if we can also decrypt old files without a header,
|
||||||
// this files should fall back to AES-128
|
// this files should fall back to AES-128
|
||||||
$cryptedWithoutHeader = substr($retreivedCryptedFile, Encryption\Crypt::BLOCKSIZE);
|
$cryptedWithoutHeader = substr($retreivedCryptedFile, Crypt::BLOCKSIZE);
|
||||||
$this->view->file_put_contents($this->userId . '/files/' . $filename, $cryptedWithoutHeader);
|
$this->view->file_put_contents($this->userId . '/files/' . $filename, $cryptedWithoutHeader);
|
||||||
|
|
||||||
// Re-enable proxy - our work is done
|
// Re-enable proxy - our work is done
|
||||||
|
@ -367,13 +367,13 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
*/
|
*/
|
||||||
public function testIsEncryptedContent() {
|
public function testIsEncryptedContent() {
|
||||||
|
|
||||||
$this->assertFalse(Encryption\Crypt::isCatfileContent($this->dataUrl));
|
$this->assertFalse(Crypt::isCatfileContent($this->dataUrl));
|
||||||
|
|
||||||
$this->assertFalse(Encryption\Crypt::isCatfileContent($this->legacyEncryptedData));
|
$this->assertFalse(Crypt::isCatfileContent($this->legacyEncryptedData));
|
||||||
|
|
||||||
$keyfileContent = Encryption\Crypt::symmetricEncryptFileContent($this->dataUrl, 'hat', 'AES-128-CFB');
|
$keyfileContent = Crypt::symmetricEncryptFileContent($this->dataUrl, 'hat', 'AES-128-CFB');
|
||||||
|
|
||||||
$this->assertTrue(Encryption\Crypt::isCatfileContent($keyfileContent));
|
$this->assertTrue(Crypt::isCatfileContent($keyfileContent));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +384,7 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
# TODO: search in keyfile for actual content as IV will ensure this test always passes
|
# TODO: search in keyfile for actual content as IV will ensure this test always passes
|
||||||
|
|
||||||
$pair1 = Encryption\Crypt::createKeypair();
|
$pair1 = Crypt::createKeypair();
|
||||||
|
|
||||||
$this->assertEquals(2, count($pair1));
|
$this->assertEquals(2, count($pair1));
|
||||||
|
|
||||||
|
@ -393,12 +393,12 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$this->assertTrue(strlen($pair1['privateKey']) > 1);
|
$this->assertTrue(strlen($pair1['privateKey']) > 1);
|
||||||
|
|
||||||
|
|
||||||
$crypted = Encryption\Crypt::multiKeyEncrypt($this->dataShort, array($pair1['publicKey']));
|
$crypted = Crypt::multiKeyEncrypt($this->dataShort, array($pair1['publicKey']));
|
||||||
|
|
||||||
$this->assertNotEquals($this->dataShort, $crypted['data']);
|
$this->assertNotEquals($this->dataShort, $crypted['data']);
|
||||||
|
|
||||||
|
|
||||||
$decrypt = Encryption\Crypt::multiKeyDecrypt($crypted['data'], $crypted['keys'][0], $pair1['privateKey']);
|
$decrypt = Crypt::multiKeyDecrypt($crypted['data'], $crypted['keys'][0], $pair1['privateKey']);
|
||||||
|
|
||||||
$this->assertEquals($this->dataShort, $decrypt);
|
$this->assertEquals($this->dataShort, $decrypt);
|
||||||
|
|
||||||
|
@ -529,7 +529,7 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
// relogin
|
// relogin
|
||||||
$params['uid'] = $this->userId;
|
$params['uid'] = $this->userId;
|
||||||
$params['password'] = 'test';
|
$params['password'] = 'test';
|
||||||
OCA\Encryption\Hooks::login($params);
|
OCA\Files_Encryption\Hooks::login($params);
|
||||||
|
|
||||||
// Get file decrypted contents
|
// Get file decrypted contents
|
||||||
$newDecrypt = file_get_contents('crypt:///' . $this->userId . '/files/' . $filename);
|
$newDecrypt = file_get_contents('crypt:///' . $this->userId . '/files/' . $filename);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* See the COPYING-README file.
|
* See the COPYING-README file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
use OCA\Files_Encryption\Helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Test_Encryption_Helper
|
* Class Test_Encryption_Helper
|
||||||
|
@ -30,11 +30,11 @@ class Test_Encryption_Helper extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
public static function setupHooks() {
|
public static function setupHooks() {
|
||||||
// Filesystem related hooks
|
// Filesystem related hooks
|
||||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
Helper::registerFilesystemHooks();
|
||||||
|
|
||||||
// clear and register hooks
|
// clear and register hooks
|
||||||
\OC_FileProxy::clearProxies();
|
\OC_FileProxy::clearProxies();
|
||||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
\OC_FileProxy::register(new \OCA\Files_Encryption\Proxy());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function tearDownAfterClass() {
|
public static function tearDownAfterClass() {
|
||||||
|
@ -49,13 +49,13 @@ class Test_Encryption_Helper extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$partFilename = 'testfile.txt.part';
|
$partFilename = 'testfile.txt.part';
|
||||||
$filename = 'testfile.txt';
|
$filename = 'testfile.txt';
|
||||||
|
|
||||||
$this->assertTrue(Encryption\Helper::isPartialFilePath($partFilename));
|
$this->assertTrue(Helper::isPartialFilePath($partFilename));
|
||||||
|
|
||||||
$this->assertEquals('testfile.txt', Encryption\Helper::stripPartialFileExtension($partFilename));
|
$this->assertEquals('testfile.txt', Helper::stripPartialFileExtension($partFilename));
|
||||||
|
|
||||||
$this->assertFalse(Encryption\Helper::isPartialFilePath($filename));
|
$this->assertFalse(Helper::isPartialFilePath($filename));
|
||||||
|
|
||||||
$this->assertEquals('testfile.txt', Encryption\Helper::stripPartialFileExtension($filename));
|
$this->assertEquals('testfile.txt', Helper::stripPartialFileExtension($filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,13 +67,13 @@ class Test_Encryption_Helper extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$partFilename = 'testfile.txt.ocTransferId643653835.part';
|
$partFilename = 'testfile.txt.ocTransferId643653835.part';
|
||||||
$filename = 'testfile.txt';
|
$filename = 'testfile.txt';
|
||||||
|
|
||||||
$this->assertTrue(Encryption\Helper::isPartialFilePath($partFilename));
|
$this->assertTrue(Helper::isPartialFilePath($partFilename));
|
||||||
|
|
||||||
$this->assertEquals('testfile.txt', Encryption\Helper::stripPartialFileExtension($partFilename));
|
$this->assertEquals('testfile.txt', Helper::stripPartialFileExtension($partFilename));
|
||||||
|
|
||||||
$this->assertFalse(Encryption\Helper::isPartialFilePath($filename));
|
$this->assertFalse(Helper::isPartialFilePath($filename));
|
||||||
|
|
||||||
$this->assertEquals('testfile.txt', Encryption\Helper::stripPartialFileExtension($filename));
|
$this->assertEquals('testfile.txt', Helper::stripPartialFileExtension($filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testGetPathToRealFile() {
|
function testGetPathToRealFile() {
|
||||||
|
@ -85,8 +85,8 @@ class Test_Encryption_Helper extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$versionPath = "/user/files_versions/foo/bar/test.txt.v456756835";
|
$versionPath = "/user/files_versions/foo/bar/test.txt.v456756835";
|
||||||
$cachePath = "/user/cache/transferid636483/foo/bar/test.txt";
|
$cachePath = "/user/cache/transferid636483/foo/bar/test.txt";
|
||||||
|
|
||||||
$this->assertEquals($relativePath, Encryption\Helper::getPathToRealFile($versionPath));
|
$this->assertEquals($relativePath, Helper::getPathToRealFile($versionPath));
|
||||||
$this->assertEquals($relativePath, Encryption\Helper::getPathToRealFile($cachePath));
|
$this->assertEquals($relativePath, Helper::getPathToRealFile($cachePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testGetUser() {
|
function testGetUser() {
|
||||||
|
@ -100,17 +100,17 @@ class Test_Encryption_Helper extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
self::loginHelper(self::TEST_ENCRYPTION_HELPER_USER1);
|
self::loginHelper(self::TEST_ENCRYPTION_HELPER_USER1);
|
||||||
|
|
||||||
// if we are logged-in every path should return the currently logged-in user
|
// if we are logged-in every path should return the currently logged-in user
|
||||||
$this->assertEquals(self::TEST_ENCRYPTION_HELPER_USER1, Encryption\Helper::getUser($path3));
|
$this->assertEquals(self::TEST_ENCRYPTION_HELPER_USER1, Helper::getUser($path3));
|
||||||
|
|
||||||
// now log out
|
// now log out
|
||||||
self::logoutHelper();
|
self::logoutHelper();
|
||||||
|
|
||||||
// now we should only get the user from /user/files and user/cache paths
|
// now we should only get the user from /user/files and user/cache paths
|
||||||
$this->assertEquals(self::TEST_ENCRYPTION_HELPER_USER1, Encryption\Helper::getUser($path1));
|
$this->assertEquals(self::TEST_ENCRYPTION_HELPER_USER1, Helper::getUser($path1));
|
||||||
$this->assertEquals(self::TEST_ENCRYPTION_HELPER_USER1, Encryption\Helper::getUser($path2));
|
$this->assertEquals(self::TEST_ENCRYPTION_HELPER_USER1, Helper::getUser($path2));
|
||||||
|
|
||||||
$this->assertFalse(Encryption\Helper::getUser($path3));
|
$this->assertFalse(Helper::getUser($path3));
|
||||||
$this->assertFalse(Encryption\Helper::getUser($path4));
|
$this->assertFalse(Helper::getUser($path4));
|
||||||
|
|
||||||
// Log-in again
|
// Log-in again
|
||||||
self::loginHelper(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1);
|
self::loginHelper(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1);
|
||||||
|
|
|
@ -20,7 +20,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
use OCA\Files_Encryption\Crypt;
|
||||||
|
use OCA\Files_Encryption\Hooks;
|
||||||
|
use OCA\Files_Encryption\Keymanager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Test_Encryption_Hooks
|
* Class Test_Encryption_Hooks
|
||||||
|
@ -104,7 +106,7 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$this->assertTrue(is_array($row));
|
$this->assertTrue(is_array($row));
|
||||||
|
|
||||||
// disabling the app should delete all user specific settings
|
// disabling the app should delete all user specific settings
|
||||||
\OCA\Encryption\Hooks::preDisable(array('app' => 'files_encryption'));
|
Hooks::preDisable(array('app' => 'files_encryption'));
|
||||||
|
|
||||||
// check if user specific settings for the encryption app are really gone
|
// check if user specific settings for the encryption app are really gone
|
||||||
$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*preferences` WHERE `appid` = ?');
|
$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*preferences` WHERE `appid` = ?');
|
||||||
|
@ -407,35 +409,35 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$view = new \OC\Files\View();
|
$view = new \OC\Files\View();
|
||||||
|
|
||||||
// set user password for the first time
|
// set user password for the first time
|
||||||
\OCA\Encryption\Hooks::postCreateUser(array('uid' => 'newUser', 'password' => 'newUserPassword'));
|
Hooks::postCreateUser(array('uid' => 'newUser', 'password' => 'newUserPassword'));
|
||||||
|
|
||||||
$this->assertTrue($view->file_exists(\OCA\Encryption\Keymanager::getPublicKeyPath() . '/newUser.publicKey'));
|
$this->assertTrue($view->file_exists(Keymanager::getPublicKeyPath() . '/newUser.publicKey'));
|
||||||
$this->assertTrue($view->file_exists('newUser/files_encryption/newUser.privateKey'));
|
$this->assertTrue($view->file_exists('newUser/files_encryption/newUser.privateKey'));
|
||||||
|
|
||||||
// check if we are able to decrypt the private key
|
// check if we are able to decrypt the private key
|
||||||
$encryptedKey = \OCA\Encryption\Keymanager::getPrivateKey($view, 'newUser');
|
$encryptedKey = Keymanager::getPrivateKey($view, 'newUser');
|
||||||
$privateKey = \OCA\Encryption\Crypt::decryptPrivateKey($encryptedKey, 'newUserPassword');
|
$privateKey = Crypt::decryptPrivateKey($encryptedKey, 'newUserPassword');
|
||||||
$this->assertTrue(is_string($privateKey));
|
$this->assertTrue(is_string($privateKey));
|
||||||
|
|
||||||
// change the password before the user logged-in for the first time,
|
// change the password before the user logged-in for the first time,
|
||||||
// we can replace the encryption keys
|
// we can replace the encryption keys
|
||||||
\OCA\Encryption\Hooks::setPassphrase(array('uid' => 'newUser', 'password' => 'passwordChanged'));
|
Hooks::setPassphrase(array('uid' => 'newUser', 'password' => 'passwordChanged'));
|
||||||
|
|
||||||
$encryptedKey = \OCA\Encryption\Keymanager::getPrivateKey($view, 'newUser');
|
$encryptedKey = Keymanager::getPrivateKey($view, 'newUser');
|
||||||
$privateKey = \OCA\Encryption\Crypt::decryptPrivateKey($encryptedKey, 'passwordChanged');
|
$privateKey = Crypt::decryptPrivateKey($encryptedKey, 'passwordChanged');
|
||||||
$this->assertTrue(is_string($privateKey));
|
$this->assertTrue(is_string($privateKey));
|
||||||
|
|
||||||
// now create a files folder to simulate a already used account
|
// now create a files folder to simulate a already used account
|
||||||
$view->mkdir('/newUser/files');
|
$view->mkdir('/newUser/files');
|
||||||
|
|
||||||
// change the password after the user logged in, now the password should not change
|
// change the password after the user logged in, now the password should not change
|
||||||
\OCA\Encryption\Hooks::setPassphrase(array('uid' => 'newUser', 'password' => 'passwordChanged2'));
|
Hooks::setPassphrase(array('uid' => 'newUser', 'password' => 'passwordChanged2'));
|
||||||
|
|
||||||
$encryptedKey = \OCA\Encryption\Keymanager::getPrivateKey($view, 'newUser');
|
$encryptedKey = Keymanager::getPrivateKey($view, 'newUser');
|
||||||
$privateKey = \OCA\Encryption\Crypt::decryptPrivateKey($encryptedKey, 'passwordChanged2');
|
$privateKey = Crypt::decryptPrivateKey($encryptedKey, 'passwordChanged2');
|
||||||
$this->assertFalse($privateKey);
|
$this->assertFalse($privateKey);
|
||||||
|
|
||||||
$privateKey = \OCA\Encryption\Crypt::decryptPrivateKey($encryptedKey, 'passwordChanged');
|
$privateKey = Crypt::decryptPrivateKey($encryptedKey, 'passwordChanged');
|
||||||
$this->assertTrue(is_string($privateKey));
|
$this->assertTrue(is_string($privateKey));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
* See the COPYING-README file.
|
* See the COPYING-README file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
use OCA\Files_Encryption\Crypt;
|
||||||
|
use OCA\Files_Encryption\Keymanager;
|
||||||
|
use OCA\Files_Encryption\Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Test_Encryption_Keymanager
|
* Class Test_Encryption_Keymanager
|
||||||
|
@ -50,9 +52,9 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$this->dataUrl = __DIR__ . '/../lib/crypt.php';
|
$this->dataUrl = __DIR__ . '/../lib/crypt.php';
|
||||||
$this->legacyData = __DIR__ . '/legacy-text.txt';
|
$this->legacyData = __DIR__ . '/legacy-text.txt';
|
||||||
$this->legacyEncryptedData = __DIR__ . '/legacy-encrypted-text.txt';
|
$this->legacyEncryptedData = __DIR__ . '/legacy-encrypted-text.txt';
|
||||||
$this->randomKey = Encryption\Crypt::generateKey();
|
$this->randomKey = Crypt::generateKey();
|
||||||
|
|
||||||
$keypair = Encryption\Crypt::createKeypair();
|
$keypair = Crypt::createKeypair();
|
||||||
$this->genPublicKey = $keypair['publicKey'];
|
$this->genPublicKey = $keypair['publicKey'];
|
||||||
$this->genPrivateKey = $keypair['privateKey'];
|
$this->genPrivateKey = $keypair['privateKey'];
|
||||||
|
|
||||||
|
@ -89,9 +91,9 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
*/
|
*/
|
||||||
function testGetPrivateKey() {
|
function testGetPrivateKey() {
|
||||||
|
|
||||||
$key = Encryption\Keymanager::getPrivateKey($this->view, $this->userId);
|
$key = Keymanager::getPrivateKey($this->view, $this->userId);
|
||||||
|
|
||||||
$privateKey = Encryption\Crypt::decryptPrivateKey($key, $this->pass);
|
$privateKey = Crypt::decryptPrivateKey($key, $this->pass);
|
||||||
|
|
||||||
$res = openssl_pkey_get_private($privateKey);
|
$res = openssl_pkey_get_private($privateKey);
|
||||||
|
|
||||||
|
@ -108,7 +110,7 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
*/
|
*/
|
||||||
function testGetPublicKey() {
|
function testGetPublicKey() {
|
||||||
|
|
||||||
$publiceKey = Encryption\Keymanager::getPublicKey($this->view, $this->userId);
|
$publiceKey = Keymanager::getPublicKey($this->view, $this->userId);
|
||||||
|
|
||||||
$res = openssl_pkey_get_public($publiceKey);
|
$res = openssl_pkey_get_public($publiceKey);
|
||||||
|
|
||||||
|
@ -128,7 +130,7 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
$file = 'unittest-' . $this->getUniqueID() . '.txt';
|
$file = 'unittest-' . $this->getUniqueID() . '.txt';
|
||||||
|
|
||||||
$util = new Encryption\Util($this->view, $this->userId);
|
$util = new Util($this->view, $this->userId);
|
||||||
|
|
||||||
// Disable encryption proxy to prevent recursive calls
|
// Disable encryption proxy to prevent recursive calls
|
||||||
$proxyStatus = \OC_FileProxy::$enabled;
|
$proxyStatus = \OC_FileProxy::$enabled;
|
||||||
|
@ -136,7 +138,7 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
$this->view->file_put_contents($this->userId . '/files/' . $file, $this->dataShort);
|
$this->view->file_put_contents($this->userId . '/files/' . $file, $this->dataShort);
|
||||||
|
|
||||||
Encryption\Keymanager::setFileKey($this->view, $util, $file, $key);
|
Keymanager::setFileKey($this->view, $util, $file, $key);
|
||||||
|
|
||||||
$this->assertTrue($this->view->file_exists('/' . $this->userId . '/files_encryption/keys/' . $file . '/fileKey'));
|
$this->assertTrue($this->view->file_exists('/' . $this->userId . '/files_encryption/keys/' . $file . '/fileKey'));
|
||||||
|
|
||||||
|
@ -154,7 +156,7 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
$key = "dummy key";
|
$key = "dummy key";
|
||||||
|
|
||||||
Encryption\Keymanager::setPrivateKey($key, 'dummyUser');
|
Keymanager::setPrivateKey($key, 'dummyUser');
|
||||||
|
|
||||||
$this->assertTrue($this->view->file_exists('/dummyUser/files_encryption/dummyUser.privateKey'));
|
$this->assertTrue($this->view->file_exists('/dummyUser/files_encryption/dummyUser.privateKey'));
|
||||||
|
|
||||||
|
@ -169,13 +171,13 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
$key = "dummy key";
|
$key = "dummy key";
|
||||||
$keyName = "myDummyKey";
|
$keyName = "myDummyKey";
|
||||||
$encHeader = Encryption\Crypt::generateHeader();
|
$encHeader = Crypt::generateHeader();
|
||||||
|
|
||||||
Encryption\Keymanager::setPrivateSystemKey($key, $keyName);
|
Keymanager::setPrivateSystemKey($key, $keyName);
|
||||||
|
|
||||||
$this->assertTrue($this->view->file_exists('/files_encryption/' . $keyName . '.privateKey'));
|
$this->assertTrue($this->view->file_exists('/files_encryption/' . $keyName . '.privateKey'));
|
||||||
|
|
||||||
$result = Encryption\Keymanager::getPrivateSystemKey($keyName);
|
$result = Keymanager::getPrivateSystemKey($keyName);
|
||||||
|
|
||||||
$this->assertSame($encHeader . $key, $result);
|
$this->assertSame($encHeader . $key, $result);
|
||||||
|
|
||||||
|
@ -189,7 +191,7 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
*/
|
*/
|
||||||
function testGetUserKeys() {
|
function testGetUserKeys() {
|
||||||
|
|
||||||
$keys = Encryption\Keymanager::getUserKeys($this->view, $this->userId);
|
$keys = Keymanager::getUserKeys($this->view, $this->userId);
|
||||||
|
|
||||||
$resPublic = openssl_pkey_get_public($keys['publicKey']);
|
$resPublic = openssl_pkey_get_public($keys['publicKey']);
|
||||||
|
|
||||||
|
@ -199,7 +201,7 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
$this->assertArrayHasKey('key', $sslInfoPublic);
|
$this->assertArrayHasKey('key', $sslInfoPublic);
|
||||||
|
|
||||||
$privateKey = Encryption\Crypt::decryptPrivateKey($keys['privateKey'], $this->pass);
|
$privateKey = Crypt::decryptPrivateKey($keys['privateKey'], $this->pass);
|
||||||
|
|
||||||
$resPrivate = openssl_pkey_get_private($privateKey);
|
$resPrivate = openssl_pkey_get_private($privateKey);
|
||||||
|
|
||||||
|
@ -247,9 +249,9 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder/subsubfolder/file2/user3.shareKey', 'data');
|
$this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder/subsubfolder/file2/user3.shareKey', 'data');
|
||||||
|
|
||||||
// recursive delete share keys from user1 and user2
|
// recursive delete share keys from user1 and user2
|
||||||
Encryption\Keymanager::delShareKey($this->view,
|
Keymanager::delShareKey($this->view,
|
||||||
array('user1', 'user2', Test_Encryption_Keymanager::TEST_USER),
|
array('user1', 'user2', Test_Encryption_Keymanager::TEST_USER),
|
||||||
Encryption\Keymanager::getKeyPath($this->view, new Encryption\Util($this->view, Test_Encryption_Keymanager::TEST_USER), '/folder1'),
|
Keymanager::getKeyPath($this->view, new Util($this->view, Test_Encryption_Keymanager::TEST_USER), '/folder1'),
|
||||||
Test_Encryption_Keymanager::TEST_USER,
|
Test_Encryption_Keymanager::TEST_USER,
|
||||||
'/folder1');
|
'/folder1');
|
||||||
|
|
||||||
|
@ -315,9 +317,9 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/existingFile.txt.' . Test_Encryption_Keymanager::TEST_USER . '.shareKey', 'data');
|
$this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/existingFile.txt.' . Test_Encryption_Keymanager::TEST_USER . '.shareKey', 'data');
|
||||||
|
|
||||||
// recursive delete share keys from user1 and user2
|
// recursive delete share keys from user1 and user2
|
||||||
Encryption\Keymanager::delShareKey($this->view,
|
Keymanager::delShareKey($this->view,
|
||||||
array('user1', 'user2', Test_Encryption_Keymanager::TEST_USER),
|
array('user1', 'user2', Test_Encryption_Keymanager::TEST_USER),
|
||||||
Encryption\Keymanager::getKeyPath($this->view, new Encryption\Util($this->view, Test_Encryption_Keymanager::TEST_USER), '/folder1/existingFile.txt'),
|
Keymanager::getKeyPath($this->view, new Util($this->view, Test_Encryption_Keymanager::TEST_USER), '/folder1/existingFile.txt'),
|
||||||
Test_Encryption_Keymanager::TEST_USER,
|
Test_Encryption_Keymanager::TEST_USER,
|
||||||
'/folder1/existingFile.txt');
|
'/folder1/existingFile.txt');
|
||||||
|
|
||||||
|
@ -356,9 +358,9 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dummy class to access protected methods of \OCA\Encryption\Keymanager for testing
|
* dummy class to access protected methods of \OCA\Files_Encryption\Keymanager for testing
|
||||||
*/
|
*/
|
||||||
class TestProtectedKeymanagerMethods extends \OCA\Encryption\Keymanager {
|
class TestProtectedKeymanagerMethods extends \OCA\Files_Encryption\Keymanager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \OC\Files\View $view relative to data/
|
* @param \OC\Files\View $view relative to data/
|
||||||
|
|
|
@ -21,8 +21,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
use OCA\Files_Encryption\Helper;
|
||||||
use OCA\Files_Encryption\Migration;
|
|
||||||
|
|
||||||
class Test_Migration extends \OCA\Files_Encryption\Tests\TestCase {
|
class Test_Migration extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
|
@ -60,8 +59,8 @@ class Test_Migration extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$this->loginHelper(self::TEST_ENCRYPTION_MIGRATION_USER1);
|
$this->loginHelper(self::TEST_ENCRYPTION_MIGRATION_USER1);
|
||||||
$this->view = new \OC\Files\View();
|
$this->view = new \OC\Files\View();
|
||||||
$this->public_share_key_id = Encryption\Helper::getPublicShareKeyId();
|
$this->public_share_key_id = Helper::getPublicShareKeyId();
|
||||||
$this->recovery_key_id = Encryption\Helper::getRecoveryKeyId();
|
$this->recovery_key_id = Helper::getRecoveryKeyId();
|
||||||
if (OC_DB::tableExists('encryption_test')) {
|
if (OC_DB::tableExists('encryption_test')) {
|
||||||
OC_DB::dropTable('encryption_test');
|
OC_DB::dropTable('encryption_test');
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Test_Encryption_Proxy
|
* Class Test_Encryption_Proxy
|
||||||
* this class provide basic proxy app tests
|
* this class provide basic proxy app tests
|
||||||
|
@ -153,7 +151,7 @@ class Test_Encryption_Proxy extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
/**
|
/**
|
||||||
* Dummy class to make protected methods available for testing
|
* Dummy class to make protected methods available for testing
|
||||||
*/
|
*/
|
||||||
class DummyProxy extends \OCA\Encryption\Proxy {
|
class DummyProxy extends \OCA\Files_Encryption\Proxy {
|
||||||
public function isExcludedPathTesting($path, $uid) {
|
public function isExcludedPathTesting($path, $uid) {
|
||||||
return $this->isExcludedPath($path, $uid);
|
return $this->isExcludedPath($path, $uid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
use OCA\Files_Encryption\Helper;
|
||||||
|
use OCA\Files_Encryption\Hooks;
|
||||||
|
use OCA\Files_Encryption\Keymanager;
|
||||||
|
use OCA\Files_Encryption\Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Test_Encryption_Share
|
* Class Test_Encryption_Share
|
||||||
|
@ -651,13 +654,13 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
// login as admin
|
// login as admin
|
||||||
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
|
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
|
||||||
|
|
||||||
\OCA\Encryption\Helper::adminEnableRecovery(null, 'test123');
|
Helper::adminEnableRecovery(null, 'test123');
|
||||||
$recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId');
|
$recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId');
|
||||||
|
|
||||||
// login as admin
|
// login as admin
|
||||||
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
|
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
|
||||||
|
|
||||||
$util = new \OCA\Encryption\Util(new \OC\Files\View('/'), \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
|
$util = new Util(new \OC\Files\View('/'), \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
|
||||||
|
|
||||||
// check if recovery password match
|
// check if recovery password match
|
||||||
$this->assertTrue($util->checkRecoveryPassword('test123'));
|
$this->assertTrue($util->checkRecoveryPassword('test123'));
|
||||||
|
@ -744,8 +747,8 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
. $this->subfolder . $this->subsubfolder . '/'
|
. $this->subfolder . $this->subsubfolder . '/'
|
||||||
. $this->filename . '/' . $recoveryKeyId . '.shareKey'));
|
. $this->filename . '/' . $recoveryKeyId . '.shareKey'));
|
||||||
|
|
||||||
$this->assertTrue(\OCA\Encryption\Helper::adminEnableRecovery(null, 'test123'));
|
$this->assertTrue(Helper::adminEnableRecovery(null, 'test123'));
|
||||||
$this->assertTrue(\OCA\Encryption\Helper::adminDisableRecovery('test123'));
|
$this->assertTrue(Helper::adminDisableRecovery('test123'));
|
||||||
$this->assertEquals(0, \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled'));
|
$this->assertEquals(0, \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,7 +760,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
// login as admin
|
// login as admin
|
||||||
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
|
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
|
||||||
|
|
||||||
$result = \OCA\Encryption\Helper::adminEnableRecovery(null, 'test123');
|
$result = Helper::adminEnableRecovery(null, 'test123');
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
|
||||||
$recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId');
|
$recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId');
|
||||||
|
@ -765,7 +768,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
// login as user2
|
// login as user2
|
||||||
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2);
|
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2);
|
||||||
|
|
||||||
$util = new \OCA\Encryption\Util(new \OC\Files\View('/'), \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2);
|
$util = new Util(new \OC\Files\View('/'), \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2);
|
||||||
|
|
||||||
// enable recovery for admin
|
// enable recovery for admin
|
||||||
$this->assertTrue($util->setRecoveryForUser(1));
|
$this->assertTrue($util->setRecoveryForUser(1));
|
||||||
|
@ -814,7 +817,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$params = array('uid' => \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2,
|
$params = array('uid' => \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2,
|
||||||
'password' => 'test',
|
'password' => 'test',
|
||||||
'recoveryPassword' => 'test123');
|
'recoveryPassword' => 'test123');
|
||||||
\OCA\Encryption\Hooks::setPassphrase($params);
|
Hooks::setPassphrase($params);
|
||||||
|
|
||||||
// login as user2
|
// login as user2
|
||||||
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, false, 'test');
|
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, false, 'test');
|
||||||
|
@ -853,7 +856,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
// enable recovery for admin
|
// enable recovery for admin
|
||||||
$this->assertTrue($util->setRecoveryForUser(0));
|
$this->assertTrue($util->setRecoveryForUser(0));
|
||||||
|
|
||||||
\OCA\Encryption\Helper::adminDisableRecovery('test123');
|
Helper::adminDisableRecovery('test123');
|
||||||
$this->assertEquals(0, \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled'));
|
$this->assertEquals(0, \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled'));
|
||||||
|
|
||||||
//clean up, reset passwords
|
//clean up, reset passwords
|
||||||
|
@ -861,7 +864,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$params = array('uid' => \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2,
|
$params = array('uid' => \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2,
|
||||||
'password' => \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2,
|
'password' => \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2,
|
||||||
'recoveryPassword' => 'test123');
|
'recoveryPassword' => 'test123');
|
||||||
\OCA\Encryption\Hooks::setPassphrase($params);
|
Hooks::setPassphrase($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -892,8 +895,8 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$this->assertGreaterThan(0, $fileInfo['unencrypted_size']);
|
$this->assertGreaterThan(0, $fileInfo['unencrypted_size']);
|
||||||
|
|
||||||
// break users public key
|
// break users public key
|
||||||
$this->view->rename(\OCA\Encryption\Keymanager::getPublicKeyPath() . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey',
|
$this->view->rename(Keymanager::getPublicKeyPath() . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey',
|
||||||
\OCA\Encryption\Keymanager::getPublicKeyPath() . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey_backup');
|
Keymanager::getPublicKeyPath() . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey_backup');
|
||||||
|
|
||||||
// re-enable the file proxy
|
// re-enable the file proxy
|
||||||
\OC_FileProxy::$enabled = $proxyStatus;
|
\OC_FileProxy::$enabled = $proxyStatus;
|
||||||
|
@ -920,8 +923,8 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
// break user1 public key
|
// break user1 public key
|
||||||
$this->view->rename(
|
$this->view->rename(
|
||||||
\OCA\Encryption\Keymanager::getPublicKeyPath() . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey_backup',
|
Keymanager::getPublicKeyPath() . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey_backup',
|
||||||
\OCA\Encryption\Keymanager::getPublicKeyPath() . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey');
|
Keymanager::getPublicKeyPath() . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey');
|
||||||
|
|
||||||
// remove share file
|
// remove share file
|
||||||
$this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/'
|
$this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/'
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Test_Encryption_Stream
|
* Class Test_Encryption_Stream
|
||||||
* this class provide basic stream tests
|
* this class provide basic stream tests
|
||||||
|
@ -208,7 +206,7 @@ class Test_Encryption_Stream extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
file_put_contents($tmpFilename, $encryptedContent);
|
file_put_contents($tmpFilename, $encryptedContent);
|
||||||
|
|
||||||
\OCA\Encryption\Helper::addTmpFileToMapper($tmpFilename, $filename);
|
\OCA\Files_Encryption\Helper::addTmpFileToMapper($tmpFilename, $filename);
|
||||||
|
|
||||||
// try to read the file from /tmp
|
// try to read the file from /tmp
|
||||||
$handle = fopen("crypt://".$tmpFilename, "r");
|
$handle = fopen("crypt://".$tmpFilename, "r");
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
namespace OCA\Files_Encryption\Tests;
|
namespace OCA\Files_Encryption\Tests;
|
||||||
|
|
||||||
use OCA\Encryption;
|
use OCA\Files_Encryption\Helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Test_Encryption_TestCase
|
* Class Test_Encryption_TestCase
|
||||||
|
@ -42,7 +42,7 @@ abstract class TestCase extends \Test\TestCase {
|
||||||
if ($loadEncryption) {
|
if ($loadEncryption) {
|
||||||
$params['uid'] = $user;
|
$params['uid'] = $user;
|
||||||
$params['password'] = $password;
|
$params['password'] = $password;
|
||||||
\OCA\Encryption\Hooks::login($params);
|
\OCA\Files_Encryption\Hooks::login($params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,16 +59,16 @@ abstract class TestCase extends \Test\TestCase {
|
||||||
\OC_User::clearBackends();
|
\OC_User::clearBackends();
|
||||||
\OC_User::useBackend('database');
|
\OC_User::useBackend('database');
|
||||||
|
|
||||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
Helper::registerFilesystemHooks();
|
||||||
\OCA\Encryption\Helper::registerUserHooks();
|
Helper::registerUserHooks();
|
||||||
\OCA\Encryption\Helper::registerShareHooks();
|
Helper::registerShareHooks();
|
||||||
|
|
||||||
\OC::registerShareHooks();
|
\OC::registerShareHooks();
|
||||||
\OCP\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup');
|
\OCP\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup');
|
||||||
|
|
||||||
// clear and register hooks
|
// clear and register hooks
|
||||||
\OC_FileProxy::clearProxies();
|
\OC_FileProxy::clearProxies();
|
||||||
\OC_FileProxy::register(new \OCA\Encryption\Proxy());
|
\OC_FileProxy::register(new \OCA\Files_Encryption\Proxy());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function tearDownAfterClass() {
|
public static function tearDownAfterClass() {
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Test_Encryption_Trashbin
|
* Class Test_Encryption_Trashbin
|
||||||
* this class provide basic trashbin app tests
|
* this class provide basic trashbin app tests
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
* See the COPYING-README file.
|
* See the COPYING-README file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
use OCA\Files_Encryption\Crypt;
|
||||||
|
use OCA\Files_Encryption\Keymanager;
|
||||||
|
use OCA\Files_Encryption\Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Test_Encryption_Util
|
* Class Test_Encryption_Util
|
||||||
|
@ -31,7 +33,7 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
public $publicKeyPath;
|
public $publicKeyPath;
|
||||||
public $privateKeyPath;
|
public $privateKeyPath;
|
||||||
/**
|
/**
|
||||||
* @var \OCA\Encryption\Util
|
* @var \OCA\Files_Encryption\Util
|
||||||
*/
|
*/
|
||||||
public $util;
|
public $util;
|
||||||
public $dataShort;
|
public $dataShort;
|
||||||
|
@ -74,12 +76,12 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$this->legacyEncryptedDataKey = __DIR__ . '/encryption.key';
|
$this->legacyEncryptedDataKey = __DIR__ . '/encryption.key';
|
||||||
$this->legacyKey = "30943623843030686906\0\0\0\0";
|
$this->legacyKey = "30943623843030686906\0\0\0\0";
|
||||||
|
|
||||||
$keypair = Encryption\Crypt::createKeypair();
|
$keypair = Crypt::createKeypair();
|
||||||
|
|
||||||
$this->genPublicKey = $keypair['publicKey'];
|
$this->genPublicKey = $keypair['publicKey'];
|
||||||
$this->genPrivateKey = $keypair['privateKey'];
|
$this->genPrivateKey = $keypair['privateKey'];
|
||||||
|
|
||||||
$this->publicKeyDir = \OCA\Encryption\Keymanager::getPublicKeyPath();
|
$this->publicKeyDir = Keymanager::getPublicKeyPath();
|
||||||
$this->encryptionDir = '/' . $this->userId . '/' . 'files_encryption';
|
$this->encryptionDir = '/' . $this->userId . '/' . 'files_encryption';
|
||||||
$this->keysPath = $this->encryptionDir . '/' . 'keys';
|
$this->keysPath = $this->encryptionDir . '/' . 'keys';
|
||||||
$this->publicKeyPath =
|
$this->publicKeyPath =
|
||||||
|
@ -89,7 +91,7 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
|
|
||||||
$this->view = new \OC\Files\View('/');
|
$this->view = new \OC\Files\View('/');
|
||||||
|
|
||||||
$this->util = new Encryption\Util($this->view, $this->userId);
|
$this->util = new Util($this->view, $this->userId);
|
||||||
|
|
||||||
// remember files_trashbin state
|
// remember files_trashbin state
|
||||||
$this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
|
$this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
|
||||||
|
@ -128,7 +130,7 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
* test that paths set during User construction are correct
|
* test that paths set during User construction are correct
|
||||||
*/
|
*/
|
||||||
function testKeyPaths() {
|
function testKeyPaths() {
|
||||||
$util = new Encryption\Util($this->view, $this->userId);
|
$util = new Util($this->view, $this->userId);
|
||||||
|
|
||||||
$this->assertEquals($this->publicKeyDir, $util->getPath('publicKeyDir'));
|
$this->assertEquals($this->publicKeyDir, $util->getPath('publicKeyDir'));
|
||||||
$this->assertEquals($this->encryptionDir, $util->getPath('encryptionDir'));
|
$this->assertEquals($this->encryptionDir, $util->getPath('encryptionDir'));
|
||||||
|
@ -144,7 +146,7 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
*/
|
*/
|
||||||
function testIsEncryptedPath() {
|
function testIsEncryptedPath() {
|
||||||
|
|
||||||
$util = new Encryption\Util($this->view, $this->userId);
|
$util = new Util($this->view, $this->userId);
|
||||||
|
|
||||||
self::loginHelper($this->userId);
|
self::loginHelper($this->userId);
|
||||||
|
|
||||||
|
@ -197,7 +199,7 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
//
|
//
|
||||||
// $params['uid'] = $this->userId;
|
// $params['uid'] = $this->userId;
|
||||||
// $params['password'] = $this->pass;
|
// $params['password'] = $this->pass;
|
||||||
// $this->assertFalse(OCA\Encryption\Hooks::login($params));
|
// $this->assertFalse(OCA\Files_Encryption\Hooks::login($params));
|
||||||
//
|
//
|
||||||
// $this->view->unlink($this->privateKeyPath);
|
// $this->view->unlink($this->privateKeyPath);
|
||||||
// }
|
// }
|
||||||
|
@ -207,7 +209,7 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
*/
|
*/
|
||||||
function testRecoveryEnabledForUser() {
|
function testRecoveryEnabledForUser() {
|
||||||
|
|
||||||
$util = new Encryption\Util($this->view, $this->userId);
|
$util = new Util($this->view, $this->userId);
|
||||||
|
|
||||||
// Record the value so we can return it to it's original state later
|
// Record the value so we can return it to it's original state later
|
||||||
$enabled = $util->recoveryEnabledForUser();
|
$enabled = $util->recoveryEnabledForUser();
|
||||||
|
@ -241,7 +243,7 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
// Re-enable proxy - our work is done
|
// Re-enable proxy - our work is done
|
||||||
\OC_FileProxy::$enabled = $proxyStatus;
|
\OC_FileProxy::$enabled = $proxyStatus;
|
||||||
|
|
||||||
$util = new Encryption\Util($this->view, $this->userId);
|
$util = new Util($this->view, $this->userId);
|
||||||
|
|
||||||
list($fileOwnerUid, $file) = $util->getUidAndFilename($filename);
|
list($fileOwnerUid, $file) = $util->getUidAndFilename($filename);
|
||||||
|
|
||||||
|
@ -283,7 +285,7 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
function testEncryptAll() {
|
function testEncryptAll() {
|
||||||
|
|
||||||
$filename = "/encryptAll" . $this->getUniqueID() . ".txt";
|
$filename = "/encryptAll" . $this->getUniqueID() . ".txt";
|
||||||
$util = new Encryption\Util($this->view, $this->userId);
|
$util = new Util($this->view, $this->userId);
|
||||||
|
|
||||||
// disable encryption to upload a unencrypted file
|
// disable encryption to upload a unencrypted file
|
||||||
\OC_App::disable('files_encryption');
|
\OC_App::disable('files_encryption');
|
||||||
|
@ -345,11 +347,11 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
'password' => \OCP\User::getUser());
|
'password' => \OCP\User::getUser());
|
||||||
|
|
||||||
$view = new OC\Files\View('/');
|
$view = new OC\Files\View('/');
|
||||||
$util = new \OCA\Encryption\Util($view, \OCP\User::getUser());
|
$util = new Util($view, \OCP\User::getUser());
|
||||||
|
|
||||||
$result = $util->initEncryption($params);
|
$result = $util->initEncryption($params);
|
||||||
|
|
||||||
$this->assertTrue($result instanceof \OCA\Encryption\Session);
|
$this->assertTrue($result instanceof \OCA\Files_Encryption\Session);
|
||||||
|
|
||||||
$successful = $util->decryptAll();
|
$successful = $util->decryptAll();
|
||||||
|
|
||||||
|
@ -401,7 +403,7 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$this->view->file_put_contents($encPath . '/keys/foo/fileKey', 'key');
|
$this->view->file_put_contents($encPath . '/keys/foo/fileKey', 'key');
|
||||||
$this->view->file_put_contents($encPath . '/keys/foo/user1.shareKey', 'share key');
|
$this->view->file_put_contents($encPath . '/keys/foo/user1.shareKey', 'share key');
|
||||||
|
|
||||||
$util = new \OCA\Encryption\Util($this->view, self::TEST_ENCRYPTION_UTIL_USER1);
|
$util = new Util($this->view, self::TEST_ENCRYPTION_UTIL_USER1);
|
||||||
|
|
||||||
$util->backupAllKeys('testBackupAllKeys');
|
$util->backupAllKeys('testBackupAllKeys');
|
||||||
|
|
||||||
|
@ -427,7 +429,7 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
$file1 = "/decryptAll1" . $this->getUniqueID() . ".txt";
|
$file1 = "/decryptAll1" . $this->getUniqueID() . ".txt";
|
||||||
$file2 = "/decryptAll2" . $this->getUniqueID() . ".txt";
|
$file2 = "/decryptAll2" . $this->getUniqueID() . ".txt";
|
||||||
|
|
||||||
$util = new Encryption\Util($this->view, $this->userId);
|
$util = new Util($this->view, $this->userId);
|
||||||
|
|
||||||
$this->view->file_put_contents($this->userId . '/files/' . $file1, $this->dataShort);
|
$this->view->file_put_contents($this->userId . '/files/' . $file1, $this->dataShort);
|
||||||
$this->view->file_put_contents($this->userId . '/files/' . $file2, $this->dataShort);
|
$this->view->file_put_contents($this->userId . '/files/' . $file2, $this->dataShort);
|
||||||
|
@ -598,7 +600,7 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
if ($loadEncryption) {
|
if ($loadEncryption) {
|
||||||
$params['uid'] = $user;
|
$params['uid'] = $user;
|
||||||
$params['password'] = $password;
|
$params['password'] = $password;
|
||||||
OCA\Encryption\Hooks::login($params);
|
\OCA\Files_Encryption\Hooks::login($params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,9 +627,9 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dummy class extends \OCA\Encryption\Util to access protected methods for testing
|
* dummy class extends \OCA\Files_Encryption\Util to access protected methods for testing
|
||||||
*/
|
*/
|
||||||
class DummyUtilClass extends \OCA\Encryption\Util {
|
class DummyUtilClass extends \OCA\Files_Encryption\Util {
|
||||||
public function testIsMountPointApplicableToUser($mount) {
|
public function testIsMountPointApplicableToUser($mount) {
|
||||||
return $this->isMountPointApplicableToUser($mount);
|
return $this->isMountPointApplicableToUser($mount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\Encryption;
|
use OCA\Files_Encryption\Crypt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Test_Encryption_Webdav
|
* Class Test_Encryption_Webdav
|
||||||
|
@ -138,7 +138,7 @@ class Test_Encryption_Webdav extends \OCA\Files_Encryption\Tests\TestCase {
|
||||||
\OC_FileProxy::$enabled = $proxyStatus;
|
\OC_FileProxy::$enabled = $proxyStatus;
|
||||||
|
|
||||||
// check if encrypted content is valid
|
// check if encrypted content is valid
|
||||||
$this->assertTrue(Encryption\Crypt::isCatfileContent($encryptedContent));
|
$this->assertTrue(Crypt::isCatfileContent($encryptedContent));
|
||||||
|
|
||||||
// get decrypted file contents
|
// get decrypted file contents
|
||||||
$decrypt = file_get_contents('crypt:///' . $this->userId . '/files' . $filename);
|
$decrypt = file_get_contents('crypt:///' . $this->userId . '/files' . $filename);
|
||||||
|
|
Loading…
Reference in New Issue