]> source.dussan.org Git - nextcloud-server.git/commitdiff
move old files_encryption out of the way
authorBjörn Schießle <schiessle@owncloud.com>
Fri, 24 May 2013 10:05:13 +0000 (12:05 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Fri, 24 May 2013 10:05:13 +0000 (12:05 +0200)
78 files changed:
apps/files_encryption/appinfo/app.php [deleted file]
apps/files_encryption/appinfo/database.xml [deleted file]
apps/files_encryption/appinfo/info.xml [deleted file]
apps/files_encryption/appinfo/routes.php [deleted file]
apps/files_encryption/appinfo/spec.txt [deleted file]
apps/files_encryption/appinfo/version [deleted file]
apps/files_encryption/hooks/hooks.php [deleted file]
apps/files_encryption/js/settings.js [deleted file]
apps/files_encryption/l10n/.gitkeep [deleted file]
apps/files_encryption/l10n/ar.php [deleted file]
apps/files_encryption/l10n/bg_BG.php [deleted file]
apps/files_encryption/l10n/bn_BD.php [deleted file]
apps/files_encryption/l10n/ca.php [deleted file]
apps/files_encryption/l10n/cs_CZ.php [deleted file]
apps/files_encryption/l10n/da.php [deleted file]
apps/files_encryption/l10n/de.php [deleted file]
apps/files_encryption/l10n/de_DE.php [deleted file]
apps/files_encryption/l10n/el.php [deleted file]
apps/files_encryption/l10n/eo.php [deleted file]
apps/files_encryption/l10n/es.php [deleted file]
apps/files_encryption/l10n/es_AR.php [deleted file]
apps/files_encryption/l10n/et_EE.php [deleted file]
apps/files_encryption/l10n/eu.php [deleted file]
apps/files_encryption/l10n/fa.php [deleted file]
apps/files_encryption/l10n/fi_FI.php [deleted file]
apps/files_encryption/l10n/fr.php [deleted file]
apps/files_encryption/l10n/gl.php [deleted file]
apps/files_encryption/l10n/he.php [deleted file]
apps/files_encryption/l10n/hu_HU.php [deleted file]
apps/files_encryption/l10n/id.php [deleted file]
apps/files_encryption/l10n/is.php [deleted file]
apps/files_encryption/l10n/it.php [deleted file]
apps/files_encryption/l10n/ja_JP.php [deleted file]
apps/files_encryption/l10n/ko.php [deleted file]
apps/files_encryption/l10n/ku_IQ.php [deleted file]
apps/files_encryption/l10n/lt_LT.php [deleted file]
apps/files_encryption/l10n/lv.php [deleted file]
apps/files_encryption/l10n/mk.php [deleted file]
apps/files_encryption/l10n/nb_NO.php [deleted file]
apps/files_encryption/l10n/nl.php [deleted file]
apps/files_encryption/l10n/pl.php [deleted file]
apps/files_encryption/l10n/pt_BR.php [deleted file]
apps/files_encryption/l10n/pt_PT.php [deleted file]
apps/files_encryption/l10n/ro.php [deleted file]
apps/files_encryption/l10n/ru.php [deleted file]
apps/files_encryption/l10n/ru_RU.php [deleted file]
apps/files_encryption/l10n/si_LK.php [deleted file]
apps/files_encryption/l10n/sk_SK.php [deleted file]
apps/files_encryption/l10n/sl.php [deleted file]
apps/files_encryption/l10n/sr.php [deleted file]
apps/files_encryption/l10n/sv.php [deleted file]
apps/files_encryption/l10n/ta_LK.php [deleted file]
apps/files_encryption/l10n/th_TH.php [deleted file]
apps/files_encryption/l10n/tr.php [deleted file]
apps/files_encryption/l10n/uk.php [deleted file]
apps/files_encryption/l10n/vi.php [deleted file]
apps/files_encryption/l10n/zh_CN.GB2312.php [deleted file]
apps/files_encryption/l10n/zh_CN.php [deleted file]
apps/files_encryption/l10n/zh_TW.php [deleted file]
apps/files_encryption/lib/capabilities.php [deleted file]
apps/files_encryption/lib/crypt.php [deleted file]
apps/files_encryption/lib/keymanager.php [deleted file]
apps/files_encryption/lib/proxy.php [deleted file]
apps/files_encryption/lib/session.php [deleted file]
apps/files_encryption/lib/stream.php [deleted file]
apps/files_encryption/lib/util.php [deleted file]
apps/files_encryption/settings-personal.php [deleted file]
apps/files_encryption/settings.php [deleted file]
apps/files_encryption/templates/settings-personal.php [deleted file]
apps/files_encryption/templates/settings.php [deleted file]
apps/files_encryption/test/binary [deleted file]
apps/files_encryption/test/crypt.php [deleted file]
apps/files_encryption/test/keymanager.php [deleted file]
apps/files_encryption/test/legacy-encrypted-text.txt [deleted file]
apps/files_encryption/test/proxy.php [deleted file]
apps/files_encryption/test/stream.php [deleted file]
apps/files_encryption/test/util.php [deleted file]
apps/files_encryption/test/zeros [deleted file]

diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php
deleted file mode 100644 (file)
index bf16fec..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-OC::$CLASSPATH['OCA\Encryption\Crypt'] = 'files_encryption/lib/crypt.php';
-OC::$CLASSPATH['OCA\Encryption\Hooks'] = 'files_encryption/hooks/hooks.php';
-OC::$CLASSPATH['OCA\Encryption\Util'] = 'files_encryption/lib/util.php';
-OC::$CLASSPATH['OCA\Encryption\Keymanager'] = 'files_encryption/lib/keymanager.php';
-OC::$CLASSPATH['OCA\Encryption\Stream'] = 'files_encryption/lib/stream.php';
-OC::$CLASSPATH['OCA\Encryption\Proxy'] = 'files_encryption/lib/proxy.php';
-OC::$CLASSPATH['OCA\Encryption\Session'] = 'files_encryption/lib/session.php';
-OC::$CLASSPATH['OCA\Encryption\Capabilities'] = 'files_encryption/lib/capabilities.php';
-
-OC_FileProxy::register( new OCA\Encryption\Proxy() );
-
-// User-related hooks
-OCP\Util::connectHook( 'OC_User', 'post_login', 'OCA\Encryption\Hooks', 'login' );
-OCP\Util::connectHook( 'OC_User', 'pre_setPassword', 'OCA\Encryption\Hooks', 'setPassphrase' );
-
-// Sharing-related hooks
-OCP\Util::connectHook( 'OCP\Share', 'post_shared', 'OCA\Encryption\Hooks', 'postShared' );
-OCP\Util::connectHook( 'OCP\Share', 'pre_unshare', 'OCA\Encryption\Hooks', 'preUnshare' );
-OCP\Util::connectHook( 'OCP\Share', 'pre_unshareAll', 'OCA\Encryption\Hooks', 'preUnshareAll' );
-
-// Webdav-related hooks
-OCP\Util::connectHook( 'OC_Webdav_Properties', 'update', 'OCA\Encryption\Hooks', 'updateKeyfile' );
-
-stream_wrapper_register( 'crypt', 'OCA\Encryption\Stream' );
-
-$session = new OCA\Encryption\Session();
-
-if ( 
-       ! $session->getPrivateKey( \OCP\USER::getUser() )
-       && OCP\User::isLoggedIn() 
-       && OCA\Encryption\Crypt::mode() == 'server' 
-) {
-
-       // Force the user to log-in again if the encryption key isn't unlocked 
-       // (happens when a user is logged in before the encryption app is 
-       // enabled)
-       OCP\User::logout();
-       
-       header( "Location: " . OC::$WEBROOT.'/' );
-       
-       exit();
-
-}
-
-// Register settings scripts
-OCP\App::registerAdmin( 'files_encryption', 'settings' );
-OCP\App::registerPersonal( 'files_encryption', 'settings-personal' );
diff --git a/apps/files_encryption/appinfo/database.xml b/apps/files_encryption/appinfo/database.xml
deleted file mode 100644 (file)
index d294c35..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<database>
-        <name>*dbname*</name>
-        <create>true</create>
-        <overwrite>false</overwrite>
-        <charset>utf8</charset>
-        <table>
-               <name>*dbprefix*encryption</name>
-               <declaration>
-                       <field>
-                               <name>uid</name>
-                               <type>text</type>
-                               <notnull>true</notnull>
-                               <length>64</length>
-                       </field>
-                       <field>
-                               <name>mode</name>
-                               <type>text</type>
-                               <notnull>true</notnull>
-                               <length>64</length>
-                       </field>
-               </declaration>
-       </table>
-</database>
\ No newline at end of file
diff --git a/apps/files_encryption/appinfo/info.xml b/apps/files_encryption/appinfo/info.xml
deleted file mode 100644 (file)
index 39ea155..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0"?>
-<info>
-       <id>files_encryption</id>
-       <name>Encryption</name>
-       <description>Server side encryption of files. Warning: You will lose your data if you enable this App and forget your password. Encryption is not yet compatible with LDAP.</description>
-       <licence>AGPL</licence>
-       <author>Sam Tuke</author>
-       <require>4</require>
-       <shipped>true</shipped>
-       <types>
-               <filesystem/>
-       </types>
-</info>
diff --git a/apps/files_encryption/appinfo/routes.php b/apps/files_encryption/appinfo/routes.php
deleted file mode 100644 (file)
index ab83432..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-/**
- * Copyright (c) 2013, Tom Needham <tom@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or later.
- * See the COPYING-README file.
- */
-
-// Register with the capabilities API
-OC_API::register('get', '/cloud/capabilities', array('OCA\Encryption\Capabilities', 'getCapabilities'), 'files_encryption', OC_API::USER_AUTH);
\ No newline at end of file
diff --git a/apps/files_encryption/appinfo/spec.txt b/apps/files_encryption/appinfo/spec.txt
deleted file mode 100644 (file)
index 2d22dff..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-Encrypted files
----------------
-
-- Each encrypted file has at least two components: the encrypted data file
-  ('catfile'), and it's corresponding key file ('keyfile'). Shared files have an
-  additional key file ('share key'). The catfile contains the encrypted data
-  concatenated with delimiter text, followed by the initialisation vector ('IV'),
-  and padding. e.g.:
-
-  [encrypted data string][delimiter][IV][padding]
-  [anhAAjAmcGXqj1X9g==][00iv00][MSHU5N5gECP7aAg7][xx] (square braces added)
-
-Notes
------
-
-- The user passphrase is required in order to set up or upgrade the app. New 
-  keypair generation, and the re-encryption of legacy encrypted files requires
-  it. Therefore an appinfo/update.php script cannot be used, and upgrade logic
-  is handled in the login hook listener.
\ No newline at end of file
diff --git a/apps/files_encryption/appinfo/version b/apps/files_encryption/appinfo/version
deleted file mode 100644 (file)
index 1d71ef9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-0.3
\ No newline at end of file
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
deleted file mode 100644 (file)
index 2731d5a..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-<?php\r
-\r
-/**\r
- * ownCloud\r
- *\r
- * @author Sam Tuke\r
- * @copyright 2012 Sam Tuke samtuke@owncloud.org\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.\r
- *\r
- * You should have received a copy of the GNU Affero General Public\r
- * License along with this library.  If not, see <http://www.gnu.org/licenses/>.\r
- *\r
- */\r
-\r
-namespace OCA\Encryption;\r
-\r
-/**\r
- * Class for hook specific logic\r
- */\r
-\r
-class Hooks {\r
-\r
-       // TODO: use passphrase for encrypting private key that is separate to \r
-       // the login password\r
-\r
-       /**\r
-        * @brief Startup encryption backend upon user login\r
-        * @note This method should never be called for users using client side encryption\r
-        */\r
-       public static function login( $params ) {\r
-       \r
-               // Manually initialise Filesystem{} singleton with correct \r
-               // fake root path, in order to avoid fatal webdav errors\r
-               \OC\Files\Filesystem::init( $params['uid'], $params['uid'] . '/' . 'files' . '/' );\r
-       \r
-               $view = new \OC_FilesystemView( '/' );\r
-\r
-               $util = new Util( $view, $params['uid'] );\r
-               \r
-               // Check files_encryption infrastructure is ready for action\r
-               if ( ! $util->ready() ) {\r
-                       \r
-                       \OC_Log::write( 'Encryption library', 'User account "' . $params['uid'] . '" is not ready for encryption; configuration started', \OC_Log::DEBUG );\r
-                       \r
-                       return $util->setupServerSide( $params['password'] );\r
-\r
-               }\r
-       \r
-               \OC_FileProxy::$enabled = false;\r
-               \r
-               $encryptedKey = Keymanager::getPrivateKey( $view, $params['uid'] );\r
-               \r
-               \OC_FileProxy::$enabled = true;\r
-               \r
-               $privateKey = Crypt::symmetricDecryptFileContent( $encryptedKey, $params['password'] );\r
-               \r
-               $session = new Session();\r
-               \r
-               $session->setPrivateKey( $privateKey, $params['uid'] );\r
-               \r
-               $view1 = new \OC_FilesystemView( '/' . $params['uid'] );\r
-               \r
-               // Set legacy encryption key if it exists, to support \r
-               // depreciated encryption system\r
-               if ( \r
-                       $view1->file_exists( 'encryption.key' )\r
-                       && $encLegacyKey = $view1->file_get_contents( 'encryption.key' ) \r
-               ) {\r
-               \r
-                       $plainLegacyKey = Crypt::legacyDecrypt( $encLegacyKey, $params['password'] );\r
-                       \r
-                       $session->setLegacyKey( $plainLegacyKey );\r
-               \r
-               }\r
-               \r
-               $publicKey = Keymanager::getPublicKey( $view, $params['uid'] );\r
-               \r
-               // Encrypt existing user files:\r
-               // This serves to upgrade old versions of the encryption\r
-               // app (see appinfo/spec.txt)\r
-               if ( \r
-                       $util->encryptAll( $publicKey,  '/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password'] )\r
-               ) {\r
-                       \r
-                       \OC_Log::write( \r
-                               'Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" started at login'\r
-                               , \OC_Log::INFO \r
-                       );\r
-               \r
-               }\r
-\r
-               return true;\r
-\r
-       }\r
-       \r
-       /**\r
-        * @brief Change a user's encryption passphrase\r
-        * @param array $params keys: uid, password\r
-        */\r
-       public static function setPassphrase( $params ) {\r
-               \r
-               // Only attempt to change passphrase if server-side encryption\r
-               // is in use (client-side encryption does not have access to \r
-               // the necessary keys)\r
-               if ( Crypt::mode() == 'server' ) {\r
-                       \r
-                       $session = new Session();\r
-                       \r
-                       // Get existing decrypted private key\r
-                       $privateKey = $session->getPrivateKey();\r
-                       \r
-                       // Encrypt private key with new user pwd as passphrase\r
-                       $encryptedPrivateKey = Crypt::symmetricEncryptFileContent( $privateKey, $params['password'] );\r
-                       \r
-                       // Save private key\r
-                       Keymanager::setPrivateKey( $encryptedPrivateKey );\r
-                       \r
-                       // NOTE: Session does not need to be updated as the \r
-                       // private key has not changed, only the passphrase \r
-                       // used to decrypt it has changed\r
-                       \r
-               }\r
-       \r
-       }\r
-       \r
-       /**\r
-        * @brief update the encryption key of the file uploaded by the client\r
-        */\r
-       public static function updateKeyfile( $params ) {\r
-       \r
-               if ( Crypt::mode() == 'client' ) {\r
-                       \r
-                       if ( isset( $params['properties']['key'] ) ) {\r
-                               \r
-                               $view = new \OC_FilesystemView( '/' );\r
-                               $userId = \OCP\User::getUser();\r
-                               \r
-                               Keymanager::setFileKey( $view, $params['path'], $userId, $params['properties']['key'] );\r
-                               \r
-                       } else {\r
-                               \r
-                               \OC_Log::write( \r
-                                       'Encryption library', "Client side encryption is enabled but the client doesn't provide a encryption key for the file!"\r
-                                       , \OC_Log::ERROR \r
-                               );\r
-                               \r
-                               error_log( "Client side encryption is enabled but the client doesn't provide an encryption key for the file!" );\r
-                               \r
-                       }\r
-                       \r
-               }\r
-               \r
-       }\r
-       \r
-       /**\r
-        * @brief \r
-        */\r
-       public static function postShared( $params ) {\r
-       }\r
-       \r
-       /**\r
-        * @brief \r
-        */\r
-       public static function preUnshare( $params ) {\r
-               \r
-               // Delete existing catfile\r
-               \r
-               // Generate new catfile and env keys\r
-               \r
-               // Save env keys to user folders\r
-       }\r
-       \r
-       /**\r
-        * @brief \r
-        */\r
-       public static function preUnshareAll( $params ) {\r
-               \r
-               trigger_error( "preUnshareAll" );\r
-               \r
-       }\r
-       \r
-}\r
diff --git a/apps/files_encryption/js/settings.js b/apps/files_encryption/js/settings.js
deleted file mode 100644 (file)
index 0be857b..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
- * This file is licensed under the Affero General Public License version 3 or later.
- * See the COPYING-README file.
- */
-
-
-$(document).ready(function(){
-       $('#encryption_blacklist').multiSelect({
-               oncheck:blackListChange,
-               onuncheck:blackListChange,
-               createText:'...'
-       });
-       
-       function blackListChange(){
-               var blackList=$('#encryption_blacklist').val().join(',');
-               OC.AppConfig.setValue('files_encryption','type_blacklist',blackList);
-       }
-})
\ No newline at end of file
diff --git a/apps/files_encryption/l10n/.gitkeep b/apps/files_encryption/l10n/.gitkeep
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/apps/files_encryption/l10n/ar.php b/apps/files_encryption/l10n/ar.php
deleted file mode 100644 (file)
index 375fbd9..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "التشفير",
-"None" => "لا شيء"
-);
diff --git a/apps/files_encryption/l10n/bg_BG.php b/apps/files_encryption/l10n/bg_BG.php
deleted file mode 100644 (file)
index 07a97f5..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Криптиране",
-"None" => "Няма"
-);
diff --git a/apps/files_encryption/l10n/bn_BD.php b/apps/files_encryption/l10n/bn_BD.php
deleted file mode 100644 (file)
index 43767d5..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "সংকেতায়ন",
-"None" => "কোনটিই নয়"
-);
diff --git a/apps/files_encryption/l10n/ca.php b/apps/files_encryption/l10n/ca.php
deleted file mode 100644 (file)
index 0c66135..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Encriptatge",
-"File encryption is enabled." => "L'encriptació de fitxers està activada.",
-"The following file types will not be encrypted:" => "Els tipus de fitxers següents no s'encriptaran:",
-"Exclude the following file types from encryption:" => "Exclou els tipus de fitxers següents de l'encriptatge:",
-"None" => "Cap"
-);
diff --git a/apps/files_encryption/l10n/cs_CZ.php b/apps/files_encryption/l10n/cs_CZ.php
deleted file mode 100644 (file)
index d225688..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Šifrování",
-"File encryption is enabled." => "Šifrování je povoleno.",
-"The following file types will not be encrypted:" => "Následující typy souborů nebudou šifrovány:",
-"Exclude the following file types from encryption:" => "Vyjmout následující typy souborů ze šifrování:",
-"None" => "Žádné"
-);
diff --git a/apps/files_encryption/l10n/da.php b/apps/files_encryption/l10n/da.php
deleted file mode 100644 (file)
index b085381..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Kryptering",
-"File encryption is enabled." => "Fil kryptering aktiveret.",
-"The following file types will not be encrypted:" => "De følgende filtyper vil ikke blive krypteret:",
-"Exclude the following file types from encryption:" => "Ekskluder de følgende fil typer fra kryptering:",
-"None" => "Ingen"
-);
diff --git a/apps/files_encryption/l10n/de.php b/apps/files_encryption/l10n/de.php
deleted file mode 100644 (file)
index cdcd8a4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Verschlüsselung",
-"File encryption is enabled." => "Dateiverschlüsselung ist aktiviert",
-"The following file types will not be encrypted:" => "Die folgenden Dateitypen werden nicht verschlüsselt:",
-"Exclude the following file types from encryption:" => "Schließe die folgenden Dateitypen von der Verschlüsselung aus:",
-"None" => "Keine"
-);
diff --git a/apps/files_encryption/l10n/de_DE.php b/apps/files_encryption/l10n/de_DE.php
deleted file mode 100644 (file)
index 4f08b98..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Verschlüsselung",
-"File encryption is enabled." => "Datei-Verschlüsselung ist aktiviert",
-"The following file types will not be encrypted:" => "Die folgenden Dateitypen werden nicht verschlüsselt:",
-"Exclude the following file types from encryption:" => "Die folgenden Dateitypen von der Verschlüsselung ausnehmen:",
-"None" => "Keine"
-);
diff --git a/apps/files_encryption/l10n/el.php b/apps/files_encryption/l10n/el.php
deleted file mode 100644 (file)
index 0031a73..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Κρυπτογράφηση",
-"File encryption is enabled." => "Η κρυπτογράφηση αρχείων είναι ενεργή.",
-"The following file types will not be encrypted:" => "Οι παρακάτω τύποι αρχείων δεν θα κρυπτογραφηθούν:",
-"Exclude the following file types from encryption:" => "Εξαίρεση των παρακάτω τύπων αρχείων από την κρυπτογράφηση:",
-"None" => "Καμία"
-);
diff --git a/apps/files_encryption/l10n/eo.php b/apps/files_encryption/l10n/eo.php
deleted file mode 100644 (file)
index 5084706..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Ĉifrado",
-"None" => "Nenio"
-);
diff --git a/apps/files_encryption/l10n/es.php b/apps/files_encryption/l10n/es.php
deleted file mode 100644 (file)
index 4ea87b9..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Cifrado",
-"File encryption is enabled." => "La encriptacion de archivo esta activada.",
-"The following file types will not be encrypted:" => "Los siguientes tipos de archivo no seran encriptados:",
-"Exclude the following file types from encryption:" => "Excluir los siguientes tipos de archivo de la encriptacion:",
-"None" => "Ninguno"
-);
diff --git a/apps/files_encryption/l10n/es_AR.php b/apps/files_encryption/l10n/es_AR.php
deleted file mode 100644 (file)
index af52287..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Encriptación",
-"File encryption is enabled." => "La encriptación de archivos no está habilitada",
-"The following file types will not be encrypted:" => "Los siguientes tipos de archivos no serán encriptados",
-"Exclude the following file types from encryption:" => "Excluir los siguientes tipos de archivos de encriptación:",
-"None" => "Ninguno"
-);
diff --git a/apps/files_encryption/l10n/et_EE.php b/apps/files_encryption/l10n/et_EE.php
deleted file mode 100644 (file)
index 0d189ac..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Krüpteerimine",
-"File encryption is enabled." => "Faili krüpteerimine on sisse lülitatud.",
-"The following file types will not be encrypted:" => "Järgnevaid failitüüpe ei krüpteerita:",
-"Exclude the following file types from encryption:" => "Järgnevaid failitüüpe ei krüpteerita:",
-"None" => "Pole"
-);
diff --git a/apps/files_encryption/l10n/eu.php b/apps/files_encryption/l10n/eu.php
deleted file mode 100644 (file)
index 5a22b65..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Enkriptazioa",
-"File encryption is enabled." => "Fitxategien enkriptazioa gaituta dago.",
-"The following file types will not be encrypted:" => "Hurrengo fitxategi motak ez dira enkriptatuko:",
-"Exclude the following file types from encryption:" => "Baztertu hurrengo fitxategi motak enkriptatzetik:",
-"None" => "Bat ere ez"
-);
diff --git a/apps/files_encryption/l10n/fa.php b/apps/files_encryption/l10n/fa.php
deleted file mode 100644 (file)
index 21ad7e5..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "رمزگذاری",
-"None" => "هیچ‌کدام"
-);
diff --git a/apps/files_encryption/l10n/fi_FI.php b/apps/files_encryption/l10n/fi_FI.php
deleted file mode 100644 (file)
index 6352d39..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Salaus",
-"File encryption is enabled." => "Tiedostojen salaus on käytössä.",
-"The following file types will not be encrypted:" => "Seuraavia tiedostotyyppejä ei salata:",
-"Exclude the following file types from encryption:" => "Älä salaa seuravia tiedostotyyppejä:",
-"None" => "Ei mitään"
-);
diff --git a/apps/files_encryption/l10n/fr.php b/apps/files_encryption/l10n/fr.php
deleted file mode 100644 (file)
index 88f1e4a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Chiffrement",
-"File encryption is enabled." => "Le chiffrement des fichiers est activé",
-"The following file types will not be encrypted:" => "Les fichiers de types suivants ne seront pas chiffrés :",
-"Exclude the following file types from encryption:" => "Ne pas chiffrer les fichiers dont les types sont les suivants :",
-"None" => "Aucun"
-);
diff --git a/apps/files_encryption/l10n/gl.php b/apps/files_encryption/l10n/gl.php
deleted file mode 100644 (file)
index 3210f71..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Cifrado",
-"File encryption is enabled." => "O cifrado de ficheiros está activado",
-"The following file types will not be encrypted:" => "Os seguintes tipos de ficheiros non van seren cifrados:",
-"Exclude the following file types from encryption:" => "Excluír os seguintes tipos de ficheiros do cifrado:",
-"None" => "Ningún"
-);
diff --git a/apps/files_encryption/l10n/he.php b/apps/files_encryption/l10n/he.php
deleted file mode 100644 (file)
index cbb74bf..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "הצפנה",
-"None" => "כלום"
-);
diff --git a/apps/files_encryption/l10n/hu_HU.php b/apps/files_encryption/l10n/hu_HU.php
deleted file mode 100644 (file)
index 4043da1..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Titkosítás",
-"File encryption is enabled." => "Az állományok titkosítása be van kapcsolva.",
-"The following file types will not be encrypted:" => "A következő fájltípusok nem kerülnek titkosításra:",
-"Exclude the following file types from encryption:" => "Zárjuk ki a titkosításból a következő fájltípusokat:",
-"None" => "Egyik sem"
-);
diff --git a/apps/files_encryption/l10n/id.php b/apps/files_encryption/l10n/id.php
deleted file mode 100644 (file)
index 6044348..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Enkripsi",
-"File encryption is enabled." => "Enkripsi berkas aktif.",
-"The following file types will not be encrypted:" => "Tipe berkas berikut tidak akan dienkripsi:",
-"Exclude the following file types from encryption:" => "Kecualikan tipe berkas berikut dari enkripsi:",
-"None" => "Tidak ada"
-);
diff --git a/apps/files_encryption/l10n/is.php b/apps/files_encryption/l10n/is.php
deleted file mode 100644 (file)
index bd96418..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Dulkóðun",
-"None" => "Ekkert"
-);
diff --git a/apps/files_encryption/l10n/it.php b/apps/files_encryption/l10n/it.php
deleted file mode 100644 (file)
index 9ab9bc4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Cifratura",
-"File encryption is enabled." => "La cifratura dei file è abilitata.",
-"The following file types will not be encrypted:" => "I seguenti tipi di file non saranno cifrati:",
-"Exclude the following file types from encryption:" => "Escludi i seguenti tipi di file dalla cifratura:",
-"None" => "Nessuna"
-);
diff --git a/apps/files_encryption/l10n/ja_JP.php b/apps/files_encryption/l10n/ja_JP.php
deleted file mode 100644 (file)
index 35fba61..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "暗号化",
-"File encryption is enabled." => "ファイルの暗号化は有効です。",
-"The following file types will not be encrypted:" => "次のファイルタイプは暗号化されません:",
-"Exclude the following file types from encryption:" => "次のファイルタイプを暗号化から除外:",
-"None" => "なし"
-);
diff --git a/apps/files_encryption/l10n/ko.php b/apps/files_encryption/l10n/ko.php
deleted file mode 100644 (file)
index bd15805..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "암호화",
-"None" => "없음"
-);
diff --git a/apps/files_encryption/l10n/ku_IQ.php b/apps/files_encryption/l10n/ku_IQ.php
deleted file mode 100644 (file)
index 02c0300..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "نهێنیکردن",
-"None" => "هیچ"
-);
diff --git a/apps/files_encryption/l10n/lt_LT.php b/apps/files_encryption/l10n/lt_LT.php
deleted file mode 100644 (file)
index 67769c8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Šifravimas",
-"None" => "Nieko"
-);
diff --git a/apps/files_encryption/l10n/lv.php b/apps/files_encryption/l10n/lv.php
deleted file mode 100644 (file)
index fc31ccd..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Šifrēšana",
-"File encryption is enabled." => "Datņu šifrēšana ir aktivēta.",
-"The following file types will not be encrypted:" => "Sekojošās datnes netiks šifrētas:",
-"Exclude the following file types from encryption:" => "Sekojošos datņu tipus izslēgt no šifrēšanas:",
-"None" => "Nav"
-);
diff --git a/apps/files_encryption/l10n/mk.php b/apps/files_encryption/l10n/mk.php
deleted file mode 100644 (file)
index 513606f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Енкрипција",
-"None" => "Ништо"
-);
diff --git a/apps/files_encryption/l10n/nb_NO.php b/apps/files_encryption/l10n/nb_NO.php
deleted file mode 100644 (file)
index a5e16a0..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Kryptering",
-"File encryption is enabled." => "Fil-kryptering er aktivert.",
-"The following file types will not be encrypted:" => "Følgende filtyper vil ikke bli kryptert:",
-"Exclude the following file types from encryption:" => "Ekskluder følgende filtyper fra kryptering:",
-"None" => "Ingen"
-);
diff --git a/apps/files_encryption/l10n/nl.php b/apps/files_encryption/l10n/nl.php
deleted file mode 100644 (file)
index b1cba96..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Versleuteling",
-"File encryption is enabled." => "Bestandsversleuteling geactiveerd.",
-"The following file types will not be encrypted:" => "De volgende bestandstypen zullen niet worden versleuteld:",
-"Exclude the following file types from encryption:" => "Sluit de volgende bestandstypen uit van versleuteling:",
-"None" => "Geen"
-);
diff --git a/apps/files_encryption/l10n/pl.php b/apps/files_encryption/l10n/pl.php
deleted file mode 100644 (file)
index 2fa86f4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Szyfrowanie",
-"File encryption is enabled." => "Szyfrowanie plików jest włączone",
-"The following file types will not be encrypted:" => "Poniższe typy plików nie będą szyfrowane:",
-"Exclude the following file types from encryption:" => "Wyłącz poniższe typy plików z szyfrowania:",
-"None" => "Brak"
-);
diff --git a/apps/files_encryption/l10n/pt_BR.php b/apps/files_encryption/l10n/pt_BR.php
deleted file mode 100644 (file)
index 28807db..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Criptografia",
-"File encryption is enabled." => "A criptografia de arquivos está ativada.",
-"The following file types will not be encrypted:" => "Os seguintes tipos de arquivo não serão criptografados:",
-"Exclude the following file types from encryption:" => "Excluir os seguintes tipos de arquivo da criptografia:",
-"None" => "Nenhuma"
-);
diff --git a/apps/files_encryption/l10n/pt_PT.php b/apps/files_encryption/l10n/pt_PT.php
deleted file mode 100644 (file)
index 1c46011..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Encriptação",
-"File encryption is enabled." => "A encriptação de ficheiros está ligada",
-"The following file types will not be encrypted:" => "Os seguintes ficheiros não serão encriptados:",
-"Exclude the following file types from encryption:" => "Excluir da encriptação os seguintes tipos de ficheiro:",
-"None" => "Nenhum"
-);
diff --git a/apps/files_encryption/l10n/ro.php b/apps/files_encryption/l10n/ro.php
deleted file mode 100644 (file)
index a5a6fb3..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Încriptare",
-"None" => "Niciuna"
-);
diff --git a/apps/files_encryption/l10n/ru.php b/apps/files_encryption/l10n/ru.php
deleted file mode 100644 (file)
index 22c1e3d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Шифрование",
-"File encryption is enabled." => "Шифрование файла включено.",
-"The following file types will not be encrypted:" => "Следующие типы файлов не будут зашифрованы:",
-"Exclude the following file types from encryption:" => "Исключить следующие типы файлов из шифрованных:",
-"None" => "Ничего"
-);
diff --git a/apps/files_encryption/l10n/ru_RU.php b/apps/files_encryption/l10n/ru_RU.php
deleted file mode 100644 (file)
index 7222235..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Шифрование",
-"None" => "Ни один"
-);
diff --git a/apps/files_encryption/l10n/si_LK.php b/apps/files_encryption/l10n/si_LK.php
deleted file mode 100644 (file)
index d9cec4b..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "ගුප්ත කේතනය",
-"None" => "කිසිවක් නැත"
-);
diff --git a/apps/files_encryption/l10n/sk_SK.php b/apps/files_encryption/l10n/sk_SK.php
deleted file mode 100644 (file)
index bebb623..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Šifrovanie",
-"File encryption is enabled." => "Šifrovanie súborov nastavené.",
-"The following file types will not be encrypted:" => "Uvedené typy súborov nebudú šifrované:",
-"Exclude the following file types from encryption:" => "Nešifrovať uvedené typy súborov",
-"None" => "Žiadne"
-);
diff --git a/apps/files_encryption/l10n/sl.php b/apps/files_encryption/l10n/sl.php
deleted file mode 100644 (file)
index 39a5a0d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Šifriranje",
-"File encryption is enabled." => "Šifriranje datotek je omogočeno.",
-"The following file types will not be encrypted:" => "Navedene vrste datotek ne bodo šifrirane:",
-"Exclude the following file types from encryption:" => "Izloči navedene vrste datotek med šifriranjem:",
-"None" => "Brez"
-);
diff --git a/apps/files_encryption/l10n/sr.php b/apps/files_encryption/l10n/sr.php
deleted file mode 100644 (file)
index 91f7fc6..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Шифровање",
-"None" => "Ништа"
-);
diff --git a/apps/files_encryption/l10n/sv.php b/apps/files_encryption/l10n/sv.php
deleted file mode 100644 (file)
index e214a93..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Kryptering",
-"File encryption is enabled." => "Filkryptering är aktiverat.",
-"The following file types will not be encrypted:" => "Följande filtyper kommer inte att krypteras:",
-"Exclude the following file types from encryption:" => "Exkludera följande filtyper från kryptering:",
-"None" => "Ingen"
-);
diff --git a/apps/files_encryption/l10n/ta_LK.php b/apps/files_encryption/l10n/ta_LK.php
deleted file mode 100644 (file)
index 152e631..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "மறைக்குறியீடு",
-"None" => "ஒன்றுமில்லை"
-);
diff --git a/apps/files_encryption/l10n/th_TH.php b/apps/files_encryption/l10n/th_TH.php
deleted file mode 100644 (file)
index e46d249..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "การเข้ารหัส",
-"None" => "ไม่ต้อง"
-);
diff --git a/apps/files_encryption/l10n/tr.php b/apps/files_encryption/l10n/tr.php
deleted file mode 100644 (file)
index 6b42c75..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Şifreleme",
-"File encryption is enabled." => "Dosya şifreleme aktif.",
-"The following file types will not be encrypted:" => "Belirtilen dosya tipleri şifrelenmeyecek:",
-"Exclude the following file types from encryption:" => "Seçilen dosya tiplerini şifreleme:",
-"None" => "Hiçbiri"
-);
diff --git a/apps/files_encryption/l10n/uk.php b/apps/files_encryption/l10n/uk.php
deleted file mode 100644 (file)
index d495714..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Шифрування",
-"File encryption is enabled." => "Увімкнуто шифрування файлів.",
-"The following file types will not be encrypted:" => "Такі типи файлів шифруватись не будуть:",
-"Exclude the following file types from encryption:" => "Виключити наступні типи файлів з ​​шифрування:",
-"None" => "Жоден"
-);
diff --git a/apps/files_encryption/l10n/vi.php b/apps/files_encryption/l10n/vi.php
deleted file mode 100644 (file)
index 0a88d1b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "Mã hóa",
-"File encryption is enabled." => "Mã hóa file đã mở",
-"The following file types will not be encrypted:" => "Loại file sau sẽ không được mã hóa",
-"Exclude the following file types from encryption:" => "Việc mã hóa không bao gồm loại file sau",
-"None" => "Không có gì hết"
-);
diff --git a/apps/files_encryption/l10n/zh_CN.GB2312.php b/apps/files_encryption/l10n/zh_CN.GB2312.php
deleted file mode 100644 (file)
index 12d903e..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "加密",
-"None" => "无"
-);
diff --git a/apps/files_encryption/l10n/zh_CN.php b/apps/files_encryption/l10n/zh_CN.php
deleted file mode 100644 (file)
index 867d000..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "加密",
-"None" => "None"
-);
diff --git a/apps/files_encryption/l10n/zh_TW.php b/apps/files_encryption/l10n/zh_TW.php
deleted file mode 100644 (file)
index 1655e17..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php $TRANSLATIONS = array(
-"Encryption" => "加密",
-"None" => "無"
-);
diff --git a/apps/files_encryption/lib/capabilities.php b/apps/files_encryption/lib/capabilities.php
deleted file mode 100644 (file)
index 72baddc..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Copyright (c) 2013 Tom Needham <tom@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-namespace OCA\Encryption; 
-
-class Capabilities {
-       
-       public static function getCapabilities() {
-               return new \OC_OCS_Result(array(
-                       'capabilities' => array(
-                               'files' => array(
-                                       'encryption' => true,
-                                       ),
-                               ),
-                       ));
-       }
-       
-}
\ No newline at end of file
diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php
deleted file mode 100755 (executable)
index 437a186..0000000
+++ /dev/null
@@ -1,695 +0,0 @@
-<?php\r
-\r
-/**\r
- * ownCloud\r
- *\r
- * @author Sam Tuke, Frank Karlitschek, Robin Appelman\r
- * @copyright 2012 Sam Tuke samtuke@owncloud.com,\r
- * Robin Appelman icewind@owncloud.com, Frank Karlitschek\r
- * frank@owncloud.org\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE\r
- * License as published by the Free Software Foundation; either\r
- * version 3 of the License, or any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.\r
- *\r
- * You should have received a copy of the GNU Affero General Public\r
- * License along with this library.  If not, see <http://www.gnu.org/licenses/>.\r
- *\r
- */\r
-\r
-namespace OCA\Encryption;\r
-\r
-require_once 'Crypt_Blowfish/Blowfish.php';\r
-\r
-// Todo:\r
-//  - Add a setting "Don´t encrypt files larger than xx because of performance"\r
-//  - Don't use a password directly as encryption key. but a key which is \r
-//    stored on the server and encrypted with the user password. -> change pass \r
-//    faster\r
-\r
-/**\r
- * Class for common cryptography functionality\r
- */\r
-\r
-class Crypt {\r
-\r
-       /**\r
-        * @brief return encryption mode client or server side encryption\r
-        * @param string user name (use system wide setting if name=null)\r
-        * @return string 'client' or 'server'\r
-        */\r
-       public static function mode( $user = null ) {\r
-\r
-               return 'server';\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Create a new encryption keypair\r
-        * @return array publicKey, privatekey\r
-        */\r
-       public static function createKeypair() {\r
-\r
-               $res = openssl_pkey_new();\r
-\r
-               // Get private key\r
-               openssl_pkey_export( $res, $privateKey );\r
-\r
-               // Get public key\r
-               $publicKey = openssl_pkey_get_details( $res );\r
-\r
-               $publicKey = $publicKey['key'];\r
-\r
-               return( array( 'publicKey' => $publicKey, 'privateKey' => $privateKey ) );\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Add arbitrary padding to encrypted data\r
-        * @param string $data data to be padded\r
-        * @return padded data\r
-        * @note In order to end up with data exactly 8192 bytes long we must\r
-        * add two letters. It is impossible to achieve exactly 8192 length\r
-        * blocks with encryption alone, hence padding is added to achieve the\r
-        * required length.\r
-        */\r
-       public static function addPadding( $data ) {\r
-\r
-               $padded = $data . 'xx';\r
-\r
-               return $padded;\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Remove arbitrary padding to encrypted data\r
-        * @param string $padded padded data to remove padding from\r
-        * @return unpadded data on success, false on error\r
-        */\r
-       public static function removePadding( $padded ) {\r
-\r
-               if ( substr( $padded, -2 ) == 'xx' ) {\r
-\r
-                       $data = substr( $padded, 0, -2 );\r
-\r
-                       return $data;\r
-\r
-               } else {\r
-\r
-                       // TODO: log the fact that unpadded data was submitted for removal of padding\r
-                       return false;\r
-\r
-               }\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Check if a file's contents contains an IV and is symmetrically encrypted\r
-        * @return true / false\r
-        * @note see also OCA\Encryption\Util->isEncryptedPath()\r
-        */\r
-       public static function isCatfile( $content ) {\r
-\r
-               if ( !$content ) {\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-               $noPadding = self::removePadding( $content );\r
-\r
-               // Fetch encryption metadata from end of file\r
-               $meta = substr( $noPadding, -22 );\r
-\r
-               // Fetch IV from end of file\r
-               $iv = substr( $meta, -16 );\r
-\r
-               // Fetch identifier from start of metadata\r
-               $identifier = substr( $meta, 0, 6 );\r
-\r
-               if ( $identifier == '00iv00') {\r
-\r
-                       return true;\r
-\r
-               } else {\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-       }\r
-\r
-       /**\r
-        * Check if a file is encrypted according to database file cache\r
-        * @param string $path\r
-        * @return bool\r
-        */\r
-       public static function isEncryptedMeta( $path ) {\r
-\r
-               // TODO: Use DI to get \OC\Files\Filesystem out of here\r
-\r
-               // Fetch all file metadata from DB\r
-               $metadata = \OC\Files\Filesystem::getFileInfo( $path, '' );\r
-\r
-               // Return encryption status\r
-               return isset( $metadata['encrypted'] ) and ( bool )$metadata['encrypted'];\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Check if a file is encrypted via legacy system\r
-        * @param string $relPath The path of the file, relative to user/data;\r
-        *        e.g. filename or /Docs/filename, NOT admin/files/filename\r
-        * @return true / false\r
-        */\r
-       public static function isLegacyEncryptedContent( $data, $relPath ) {\r
-\r
-               // Fetch all file metadata from DB\r
-               $metadata = \OC\Files\Filesystem::getFileInfo( $relPath, '' );\r
-\r
-               // If a file is flagged with encryption in DB, but isn't a \r
-               // valid content + IV combination, it's probably using the \r
-               // legacy encryption system\r
-               if (\r
-                       isset( $metadata['encrypted'] )\r
-                       and $metadata['encrypted'] === true\r
-                       and ! self::isCatfile( $data )\r
-               ) {\r
-\r
-                       return true;\r
-\r
-               } else {\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Symmetrically encrypt a string\r
-        * @returns encrypted file\r
-        */\r
-       public static function encrypt( $plainContent, $iv, $passphrase = '' ) {\r
-\r
-               if ( $encryptedContent = openssl_encrypt( $plainContent, 'AES-128-CFB', $passphrase, false, $iv ) ) {\r
-\r
-                       return $encryptedContent;\r
-\r
-               } else {\r
-\r
-                       \OC_Log::write( 'Encryption library', 'Encryption (symmetric) of content failed', \OC_Log::ERROR );\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Symmetrically decrypt a string\r
-        * @returns decrypted file\r
-        */\r
-       public static function decrypt( $encryptedContent, $iv, $passphrase ) {\r
-\r
-               if ( $plainContent = openssl_decrypt( $encryptedContent, 'AES-128-CFB', $passphrase, false, $iv ) ) {\r
-\r
-                       return $plainContent;\r
-\r
-\r
-               } else {\r
-\r
-                       throw new \Exception( 'Encryption library: Decryption (symmetric) of content failed' );\r
-\r
-               }\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Concatenate encrypted data with its IV and padding\r
-        * @param string $content content to be concatenated\r
-        * @param string $iv IV to be concatenated\r
-        * @returns string concatenated content\r
-        */\r
-       public static function concatIv ( $content, $iv ) {\r
-\r
-               $combined = $content . '00iv00' . $iv;\r
-\r
-               return $combined;\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Split concatenated data and IV into respective parts\r
-        * @param string $catFile concatenated data to be split\r
-        * @returns array keys: encrypted, iv\r
-        */\r
-       public static function splitIv ( $catFile ) {\r
-\r
-               // Fetch encryption metadata from end of file\r
-               $meta = substr( $catFile, -22 );\r
-\r
-               // Fetch IV from end of file\r
-               $iv = substr( $meta, -16 );\r
-\r
-               // Remove IV and IV identifier text to expose encrypted content\r
-               $encrypted = substr( $catFile, 0, -22 );\r
-\r
-               $split = array(\r
-                       'encrypted' => $encrypted\r
-               , 'iv' => $iv\r
-               );\r
-\r
-               return $split;\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Symmetrically encrypts a string and returns keyfile content\r
-        * @param $plainContent content to be encrypted in keyfile\r
-        * @returns encrypted content combined with IV\r
-        * @note IV need not be specified, as it will be stored in the returned keyfile\r
-        * and remain accessible therein.\r
-        */\r
-       public static function symmetricEncryptFileContent( $plainContent, $passphrase = '' ) {\r
-\r
-               if ( !$plainContent ) {\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-               $iv = self::generateIv();\r
-\r
-               if ( $encryptedContent = self::encrypt( $plainContent, $iv, $passphrase ) ) {\r
-\r
-                       // Combine content to encrypt with IV identifier and actual IV\r
-                       $catfile = self::concatIv( $encryptedContent, $iv );\r
-\r
-                       $padded = self::addPadding( $catfile );\r
-\r
-                       return $padded;\r
-\r
-               } else {\r
-\r
-                       \OC_Log::write( 'Encryption library', 'Encryption (symmetric) of keyfile content failed', \OC_Log::ERROR );\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-       }\r
-\r
-\r
-       /**\r
-        * @brief Symmetrically decrypts keyfile content\r
-        * @param string $source\r
-        * @param string $target\r
-        * @param string $key the decryption key\r
-        * @returns decrypted content\r
-        *\r
-        * This function decrypts a file\r
-        */\r
-       public static function symmetricDecryptFileContent( $keyfileContent, $passphrase = '' ) {\r
-\r
-               if ( !$keyfileContent ) {\r
-\r
-                       throw new \Exception( 'Encryption library: no data provided for decryption' );\r
-\r
-               }\r
-\r
-               // Remove padding\r
-               $noPadding = self::removePadding( $keyfileContent );\r
-\r
-               // Split into enc data and catfile\r
-               $catfile = self::splitIv( $noPadding );\r
-\r
-               if ( $plainContent = self::decrypt( $catfile['encrypted'], $catfile['iv'], $passphrase ) ) {\r
-\r
-                       return $plainContent;\r
-\r
-               }\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Creates symmetric keyfile content using a generated key\r
-        * @param string $plainContent content to be encrypted\r
-        * @returns array keys: key, encrypted\r
-        * @note symmetricDecryptFileContent() can be used to decrypt files created using this method\r
-        *\r
-        * This function decrypts a file\r
-        */\r
-       public static function symmetricEncryptFileContentKeyfile( $plainContent ) {\r
-\r
-               $key = self::generateKey();\r
-\r
-               if( $encryptedContent = self::symmetricEncryptFileContent( $plainContent, $key ) ) {\r
-\r
-                       return array(\r
-                               'key' => $key\r
-                       , 'encrypted' => $encryptedContent\r
-                       );\r
-\r
-               } else {\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Create asymmetrically encrypted keyfile content using a generated key\r
-        * @param string $plainContent content to be encrypted\r
-        * @returns array keys: key, encrypted\r
-        * @note symmetricDecryptFileContent() can be used to decrypt files created using this method\r
-        *\r
-        * This function decrypts a file\r
-        */\r
-       public static function multiKeyEncrypt( $plainContent, array $publicKeys ) {\r
-\r
-               // Set empty vars to be set by openssl by reference\r
-               $sealed = '';\r
-               $envKeys = array();\r
-\r
-               if( openssl_seal( $plainContent, $sealed, $envKeys, $publicKeys ) ) {\r
-\r
-                       return array(\r
-                               'keys' => $envKeys\r
-                       , 'encrypted' => $sealed\r
-                       );\r
-\r
-               } else {\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Asymmetrically encrypt a file using multiple public keys\r
-        * @param string $plainContent content to be encrypted\r
-        * @returns string $plainContent decrypted string\r
-        * @note symmetricDecryptFileContent() can be used to decrypt files created using this method\r
-        *\r
-        * This function decrypts a file\r
-        */\r
-       public static function multiKeyDecrypt( $encryptedContent, $envKey, $privateKey ) {\r
-\r
-               if ( !$encryptedContent ) {\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-               if ( openssl_open( $encryptedContent, $plainContent, $envKey, $privateKey ) ) {\r
-\r
-                       return $plainContent;\r
-\r
-               } else {\r
-\r
-                       \OC_Log::write( 'Encryption library', 'Decryption (asymmetric) of sealed content failed', \OC_Log::ERROR );\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Asymmetrically encrypt a string using a public key\r
-        * @returns encrypted file\r
-        */\r
-       public static function keyEncrypt( $plainContent, $publicKey ) {\r
-\r
-               openssl_public_encrypt( $plainContent, $encryptedContent, $publicKey );\r
-\r
-               return $encryptedContent;\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Asymetrically decrypt a file using a private key\r
-        * @returns decrypted file\r
-        */\r
-       public static function keyDecrypt( $encryptedContent, $privatekey ) {\r
-\r
-               openssl_private_decrypt( $encryptedContent, $plainContent, $privatekey );\r
-\r
-               return $plainContent;\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Encrypts content symmetrically and generates keyfile asymmetrically\r
-        * @returns array containing catfile and new keyfile.\r
-        * keys: data, key\r
-        * @note this method is a wrapper for combining other crypt class methods\r
-        */\r
-       public static function keyEncryptKeyfile( $plainContent, $publicKey ) {\r
-\r
-               // Encrypt plain data, generate keyfile & encrypted file\r
-               $cryptedData = self::symmetricEncryptFileContentKeyfile( $plainContent );\r
-\r
-               // Encrypt keyfile\r
-               $cryptedKey = self::keyEncrypt( $cryptedData['key'], $publicKey );\r
-\r
-               return array( 'data' => $cryptedData['encrypted'], 'key' => $cryptedKey );\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Takes catfile, keyfile, and private key, and\r
-        * performs decryption\r
-        * @returns decrypted content\r
-        * @note this method is a wrapper for combining other crypt class methods\r
-        */\r
-       public static function keyDecryptKeyfile( $catfile, $keyfile, $privateKey ) {\r
-\r
-               // Decrypt the keyfile with the user's private key\r
-               $decryptedKeyfile = self::keyDecrypt( $keyfile, $privateKey );\r
-\r
-               // Decrypt the catfile symmetrically using the decrypted keyfile\r
-               $decryptedData = self::symmetricDecryptFileContent( $catfile, $decryptedKeyfile );\r
-\r
-               return $decryptedData;\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Symmetrically encrypt a file by combining encrypted component data blocks\r
-        */\r
-       public static function symmetricBlockEncryptFileContent( $plainContent, $key ) {\r
-\r
-               $crypted = '';\r
-\r
-               $remaining = $plainContent;\r
-\r
-               $testarray = array();\r
-\r
-               while( strlen( $remaining ) ) {\r
-\r
-                       //echo "\n\n\$block = ".substr( $remaining, 0, 6126 );\r
-\r
-                       // Encrypt a chunk of unencrypted data and add it to the rest\r
-                       $block = self::symmetricEncryptFileContent( substr( $remaining, 0, 6126 ), $key );\r
-\r
-                       $padded = self::addPadding( $block );\r
-\r
-                       $crypted .= $block;\r
-\r
-                       $testarray[] = $block;\r
-\r
-                       // Remove the data already encrypted from remaining unencrypted data\r
-                       $remaining = substr( $remaining, 6126 );\r
-\r
-               }\r
-\r
-               return $crypted;\r
-\r
-       }\r
-\r
-\r
-       /**\r
-        * @brief Symmetrically decrypt a file by combining encrypted component data blocks\r
-        */\r
-       public static function symmetricBlockDecryptFileContent( $crypted, $key ) {\r
-\r
-               $decrypted = '';\r
-\r
-               $remaining = $crypted;\r
-\r
-               $testarray = array();\r
-\r
-               while( strlen( $remaining ) ) {\r
-\r
-                       $testarray[] = substr( $remaining, 0, 8192 );\r
-\r
-                       // Decrypt a chunk of unencrypted data and add it to the rest\r
-                       $decrypted .= self::symmetricDecryptFileContent( $remaining, $key );\r
-\r
-                       // Remove the data already encrypted from remaining unencrypted data\r
-                       $remaining = substr( $remaining, 8192 );\r
-\r
-               }\r
-\r
-               return $decrypted;\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Generates a pseudo random initialisation vector\r
-        * @return String $iv generated IV\r
-        */\r
-       public static function generateIv() {\r
-\r
-               if ( $random = openssl_random_pseudo_bytes( 12, $strong ) ) {\r
-\r
-                       if ( !$strong ) {\r
-\r
-                               // If OpenSSL indicates randomness is insecure, log error\r
-                               \OC_Log::write( 'Encryption library', 'Insecure symmetric key was generated using openssl_random_pseudo_bytes()', \OC_Log::WARN );\r
-\r
-                       }\r
-\r
-                       // We encode the iv purely for string manipulation \r
-                       // purposes - it gets decoded before use\r
-                       $iv = base64_encode( $random );\r
-\r
-                       return $iv;\r
-\r
-               } else {\r
-\r
-                       throw new \Exception( 'Generating IV failed' );\r
-\r
-               }\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Generate a pseudo random 1024kb ASCII key\r
-        * @returns $key Generated key\r
-        */\r
-       public static function generateKey() {\r
-\r
-               // Generate key\r
-               if ( $key = base64_encode( openssl_random_pseudo_bytes( 183, $strong ) ) ) {\r
-\r
-                       if ( !$strong ) {\r
-\r
-                               // If OpenSSL indicates randomness is insecure, log error\r
-                               throw new \Exception ( 'Encryption library, Insecure symmetric key was generated using openssl_random_pseudo_bytes()' );\r
-\r
-                       }\r
-\r
-                       return $key;\r
-\r
-               } else {\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Get the blowfish encryption handeler for a key\r
-        * @param $key string (optional)\r
-        * @return Crypt_Blowfish blowfish object\r
-        *\r
-        * if the key is left out, the default handeler will be used\r
-        */\r
-       public static function getBlowfish( $key = '' ) {\r
-\r
-               if ( $key ) {\r
-\r
-                       return new \Crypt_Blowfish( $key );\r
-\r
-               } else {\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-       }\r
-\r
-       public static function legacyCreateKey( $passphrase ) {\r
-\r
-               // Generate a random integer\r
-               $key = mt_rand( 10000, 99999 ) . mt_rand( 10000, 99999 ) . mt_rand( 10000, 99999 ) . mt_rand( 10000, 99999 );\r
-\r
-               // Encrypt the key with the passphrase\r
-               $legacyEncKey = self::legacyEncrypt( $key, $passphrase );\r
-\r
-               return $legacyEncKey;\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief encrypts content using legacy blowfish system\r
-        * @param $content the cleartext message you want to encrypt\r
-        * @param $key the encryption key (optional)\r
-        * @returns encrypted content\r
-        *\r
-        * This function encrypts an content\r
-        */\r
-       public static function legacyEncrypt( $content, $passphrase = '' ) {\r
-\r
-               $bf = self::getBlowfish( $passphrase );\r
-\r
-               return $bf->encrypt( $content );\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief decrypts content using legacy blowfish system\r
-        * @param $content the cleartext message you want to decrypt\r
-        * @param $key the encryption key (optional)\r
-        * @returns cleartext content\r
-        *\r
-        * This function decrypts an content\r
-        */\r
-       public static function legacyDecrypt( $content, $passphrase = '' ) {\r
-\r
-               $bf = self::getBlowfish( $passphrase );\r
-\r
-               $decrypted = $bf->decrypt( $content );\r
-\r
-               $trimmed = rtrim( $decrypted, "\0" );\r
-\r
-               return $trimmed;\r
-\r
-       }\r
-\r
-       public static function legacyKeyRecryptKeyfile( $legacyEncryptedContent, $legacyPassphrase, $publicKey, $newPassphrase ) {\r
-\r
-               $decrypted = self::legacyDecrypt( $legacyEncryptedContent, $legacyPassphrase );\r
-\r
-               $recrypted = self::keyEncryptKeyfile( $decrypted, $publicKey );\r
-\r
-               return $recrypted;\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Re-encryptes a legacy blowfish encrypted file using AES with integrated IV\r
-        * @param $legacyContent the legacy encrypted content to re-encrypt\r
-        * @returns cleartext content\r
-        *\r
-        * This function decrypts an content\r
-        */\r
-       public static function legacyRecrypt( $legacyContent, $legacyPassphrase, $newPassphrase ) {\r
-\r
-               // TODO: write me\r
-\r
-       }\r
-\r
-}
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
deleted file mode 100755 (executable)
index 9558779..0000000
+++ /dev/null
@@ -1,323 +0,0 @@
-<?php
-
-/**
- * ownCloud
- *
- * @author Bjoern Schiessle
- * @copyright 2012 Bjoern Schiessle <schiessle@owncloud.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OCA\Encryption;
-
-/**
- * @brief Class to manage storage and retrieval of encryption keys
- * @note Where a method requires a view object, it's root must be '/'
- */
-class Keymanager {
-               
-       /**
-        * @brief retrieve the ENCRYPTED private key from a user
-        * 
-        * @return string private key or false
-        * @note the key returned by this method must be decrypted before use
-        */
-       public static function getPrivateKey( \OC_FilesystemView $view, $user ) {
-       
-               $path =  '/' . $user . '/' . 'files_encryption' . '/' . $user.'.private.key';
-               
-               $key = $view->file_get_contents( $path );
-               
-               return $key;
-       }
-
-       /**
-        * @brief retrieve public key for a specified user
-        * @param \OC_FilesystemView $view
-        * @param $userId
-        * @return string public key or false
-        */
-       public static function getPublicKey( \OC_FilesystemView $view, $userId ) {
-               
-               return $view->file_get_contents( '/public-keys/' . '/' . $userId . '.public.key' );
-               
-       }
-       
-       /**
-        * @brief retrieve both keys from a user (private and public)
-        * @param \OC_FilesystemView $view
-        * @param $userId
-        * @return array keys: privateKey, publicKey
-        */
-       public static function getUserKeys( \OC_FilesystemView $view, $userId ) {
-       
-               return array(
-                       'publicKey' => self::getPublicKey( $view, $userId )
-                       , 'privateKey' => self::getPrivateKey( $view, $userId )
-               );
-       
-       }
-       
-       /**
-        * @brief Retrieve public keys of all users with access to a file
-        * @param string $path Path to file
-        * @return array of public keys for the given file
-        * @note Checks that the sharing app is enabled should be performed 
-        * by client code, that isn't checked here
-        */
-       public static function getPublicKeys( \OC_FilesystemView $view, $userId, $filePath ) {
-               
-               $path = ltrim( $path, '/' );
-               
-               $filepath = '/' . $userId . '/files/' . $filePath;
-               
-               // Check if sharing is enabled
-               if ( OC_App::isEnabled( 'files_sharing' ) ) {
-                       
-
-               
-               } else {
-               
-                       // check if it is a file owned by the user and not shared at all
-                       $userview = new \OC_FilesystemView( '/'.$userId.'/files/' );
-                       
-                       if ( $userview->file_exists( $path ) ) {
-                       
-                               $users[] = $userId;
-                               
-                       }
-                       
-               }
-               
-               $view = new \OC_FilesystemView( '/public-keys/' );
-               
-               $keylist = array();
-               
-               $count = 0;
-               
-               foreach ( $users as $user ) {
-               
-                       $keylist['key'.++$count] = $view->file_get_contents( $user.'.public.key' );
-                       
-               }
-               
-               return $keylist;
-               
-       }
-       
-       /**
-        * @brief store file encryption key
-        *
-        * @param string $path relative path of the file, including filename
-        * @param string $key
-        * @return bool true/false
-        * @note The keyfile is not encrypted here. Client code must 
-        * asymmetrically encrypt the keyfile before passing it to this method
-        */
-       public static function setFileKey( \OC_FilesystemView $view, $path, $userId, $catfile ) {
-               
-               $basePath = '/' . $userId . '/files_encryption/keyfiles';
-               
-               $targetPath = self::keySetPreparation( $view, $path, $basePath, $userId );
-               
-               if ( $view->is_dir( $basePath . '/' . $targetPath ) ) {
-               
-                       
-               
-               } else {
-
-                       // Save the keyfile in parallel directory
-                       return $view->file_put_contents( $basePath . '/' . $targetPath . '.key', $catfile );
-               
-               }
-               
-       }
-       
-       /**
-        * @brief retrieve keyfile for an encrypted file
-        * @param \OC_FilesystemView $view
-        * @param $userId
-        * @param $filePath
-        * @internal param \OCA\Encryption\file $string name
-        * @return string file key or false
-        * @note The keyfile returned is asymmetrically encrypted. Decryption
-        * of the keyfile must be performed by client code
-        */
-       public static function getFileKey( \OC_FilesystemView $view, $userId, $filePath ) {
-               
-               $filePath_f = ltrim( $filePath, '/' );
-               
-               $catfilePath = '/' . $userId . '/files_encryption/keyfiles/' . $filePath_f . '.key';
-               
-               if ( $view->file_exists( $catfilePath ) ) {
-
-                       return $view->file_get_contents( $catfilePath );
-                       
-               } else {
-               
-                       return false;
-                       
-               }
-               
-       }
-       
-       /**
-        * @brief Delete a keyfile
-        *
-        * @param OC_FilesystemView $view
-        * @param string $userId username
-        * @param string $path path of the file the key belongs to
-        * @return bool Outcome of unlink operation
-        * @note $path must be relative to data/user/files. e.g. mydoc.txt NOT
-        *       /data/admin/files/mydoc.txt
-        */
-       public static function deleteFileKey( \OC_FilesystemView $view, $userId, $path ) {
-               
-               $trimmed = ltrim( $path, '/' );
-               $keyPath =  '/' . $userId . '/files_encryption/keyfiles/' . $trimmed . '.key';
-               
-               // Unlink doesn't tell us if file was deleted (not found returns
-               // true), so we perform our own test
-               if ( $view->file_exists( $keyPath ) ) {
-               
-                       return $view->unlink( $keyPath );
-                       
-               } else {
-                       
-                       \OC_Log::write( 'Encryption library', 'Could not delete keyfile; does not exist: "' . $keyPath, \OC_Log::ERROR );
-                       
-                       return false;
-                       
-               }
-               
-       }
-       
-       /**
-        * @brief store private key from the user
-        * @param string key
-        * @return bool
-        * @note Encryption of the private key must be performed by client code
-        * as no encryption takes place here
-        */
-       public static function setPrivateKey( $key ) {
-               
-               $user = \OCP\User::getUser();
-               
-               $view = new \OC_FilesystemView( '/' . $user . '/files_encryption' );
-               
-               \OC_FileProxy::$enabled = false;
-               
-               if ( !$view->file_exists( '' ) )
-                       $view->mkdir( '' );
-               
-               return $view->file_put_contents( $user . '.private.key', $key );
-
-       }
-       
-       /**
-        * @brief store private keys from the user
-        *
-        * @param string privatekey
-        * @param string publickey
-        * @return bool true/false
-        */
-       public static function setUserKeys($privatekey, $publickey) {
-       
-               return ( self::setPrivateKey( $privatekey ) && self::setPublicKey( $publickey ) );
-       
-       }
-       
-       /**
-        * @brief store public key of the user
-        *
-        * @param string key
-        * @return bool true/false
-        */
-       public static function setPublicKey( $key ) {
-               
-               $view = new \OC_FilesystemView( '/public-keys' );
-               
-               \OC_FileProxy::$enabled = false;
-               
-               if ( !$view->file_exists( '' ) )
-                       $view->mkdir( '' );
-               
-               return $view->file_put_contents( \OCP\User::getUser() . '.public.key', $key );
-
-               
-       }
-       
-       /**
-        * @brief store file encryption key
-        *
-        * @param string $path relative path of the file, including filename
-        * @param string $key
-        * @param null $view
-        * @param string $dbClassName
-        * @return bool true/false
-        * @note The keyfile is not encrypted here. Client code must
-        * asymmetrically encrypt the keyfile before passing it to this method
-        */
-       public static function setShareKey( \OC_FilesystemView $view, $path, $userId, $shareKey ) {
-               
-               $basePath = '/' . $userId . '/files_encryption/share-keys';
-               
-               $shareKeyPath = self::keySetPreparation( $view, $path, $basePath, $userId );
-               
-               return $view->file_put_contents( $basePath . '/' . $shareKeyPath . '.shareKey', $shareKey );
-               
-       }
-       
-       /**
-        * @brief Make preparations to vars and filesystem for saving a keyfile
-        */
-       public static function keySetPreparation( \OC_FilesystemView $view, $path, $basePath, $userId ) {
-               
-               $targetPath = ltrim( $path, '/' );
-               
-               $path_parts = pathinfo( $targetPath );
-               
-               // If the file resides within a subdirectory, create it
-               if ( 
-               isset( $path_parts['dirname'] )
-               && ! $view->file_exists( $basePath . '/' . $path_parts['dirname'] ) 
-               ) {
-               
-                       $view->mkdir( $basePath . '/' . $path_parts['dirname'] );
-                       
-               }
-               
-               return $targetPath;
-       
-       }
-
-       /**
-        * @brief Fetch the legacy encryption key from user files
-        * @param string $login used to locate the legacy key
-        * @param string $passphrase used to decrypt the legacy key
-        * @return true / false
-        *
-        * if the key is left out, the default handler will be used
-        */
-       public function getLegacyKey() {
-               
-               $user = \OCP\User::getUser();
-               $view = new \OC_FilesystemView( '/' . $user );
-               return $view->file_get_contents( 'encryption.key' );
-               
-       }
-       
-}
\ No newline at end of file
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
deleted file mode 100644 (file)
index 55cddf2..0000000
+++ /dev/null
@@ -1,389 +0,0 @@
-<?php
-
-/**
-* ownCloud
-*
-* @author Sam Tuke, Robin Appelman
-* @copyright 2012 Sam Tuke samtuke@owncloud.com, Robin Appelman 
-* icewind1991@gmail.com
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*
-* You should have received a copy of the GNU Affero General Public
-* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
-*
-*/
-
-/**
-* @brief Encryption proxy which handles filesystem operations before and after
-*        execution and encrypts, and handles keyfiles accordingly. Used for 
-*        webui.
-*/
-
-namespace OCA\Encryption;
-
-class Proxy extends \OC_FileProxy {
-
-       private static $blackList = null; //mimetypes blacklisted from encryption
-       
-       private static $enableEncryption = null;
-       
-       /**
-        * Check if a file requires encryption
-        * @param string $path
-        * @return bool
-        *
-        * Tests if server side encryption is enabled, and file is allowed by blacklists
-        */
-       private static function shouldEncrypt( $path ) {
-               
-               if ( is_null( self::$enableEncryption ) ) {
-               
-                       if ( 
-                               \OCP\Config::getAppValue( 'files_encryption', 'enable_encryption', 'true' ) == 'true' 
-                               && Crypt::mode() == 'server' 
-                       ) {
-                       
-                               self::$enableEncryption = true;
-                       
-                       } else {
-                               
-                               self::$enableEncryption = false;
-                       
-                       }
-                       
-               }
-               
-               if ( !self::$enableEncryption ) {
-               
-                       return false;
-                       
-               }
-               
-               if ( is_null(self::$blackList ) ) {
-               
-                       self::$blackList = explode(',', \OCP\Config::getAppValue( 'files_encryption', 'type_blacklist', 'jpg,png,jpeg,avi,mpg,mpeg,mkv,mp3,oga,ogv,ogg' ) );
-                       
-               }
-               
-               if ( Crypt::isCatfile( $path ) ) {
-               
-                       return true;
-                       
-               }
-               
-               $extension = substr( $path, strrpos( $path, '.' ) +1 );
-               
-               if ( array_search( $extension, self::$blackList ) === false ) {
-               
-                       return true;
-                       
-               }
-               
-               return false;
-       }
-       
-       public function preFile_put_contents( $path, &$data ) {
-               
-               if ( self::shouldEncrypt( $path ) ) {
-               
-                       if ( !is_resource( $data ) ) { //stream put contents should have been converted to fopen
-                       
-                               $userId = \OCP\USER::getUser();
-                               
-                               $rootView = new \OC_FilesystemView( '/' );
-                       
-                               // Set the filesize for userland, before encrypting
-                               $size = strlen( $data );
-                               
-                               // Disable encryption proxy to prevent recursive calls
-                               \OC_FileProxy::$enabled = false;
-                               
-                               // TODO: Check if file is shared, if so, use multiKeyEncrypt
-                               
-                               // Encrypt plain data and fetch key
-                               $encrypted = Crypt::keyEncryptKeyfile( $data, Keymanager::getPublicKey( $rootView, $userId ) );
-                               
-                               // Replace plain content with encrypted content by reference
-                               $data = $encrypted['data'];
-                               
-                               $filePath = explode( '/', $path );
-                               
-                               $filePath = array_slice( $filePath, 3 );
-                               
-                               $filePath = '/' . implode( '/', $filePath );
-                               
-                               // TODO: make keyfile dir dynamic from app config
-                               
-                               $view = new \OC_FilesystemView( '/' );
-                               
-                               // Save keyfile for newly encrypted file in parallel directory tree
-                               Keymanager::setFileKey( $view, $filePath, $userId, $encrypted['key'] );
-                               
-                               // Update the file cache with file info
-                               \OC\Files\Filesystem::putFileInfo( $path, array( 'encrypted'=>true, 'size' => $size ), '' );
-                               
-                               // Re-enable proxy - our work is done
-                               \OC_FileProxy::$enabled = true;
-                               
-                       }
-               }
-               
-       }
-       
-       /**
-        * @param string $path Path of file from which has been read
-        * @param string $data Data that has been read from file
-        */
-       public function postFile_get_contents( $path, $data ) {
-       
-               // TODO: Use dependency injection to add required args for view and user etc. to this method
-
-               // Disable encryption proxy to prevent recursive calls
-               \OC_FileProxy::$enabled = false;
-               
-               // If data is a catfile
-               if ( 
-                       Crypt::mode() == 'server' 
-                       && Crypt::isCatfile( $data ) 
-               ) {
-                       
-                       $split = explode( '/', $path );
-                       
-                       $filePath = array_slice( $split, 3 );
-                       
-                       $filePath = '/' . implode( '/', $filePath );
-                       
-                       //$cached = \OC\Files\Filesystem::getFileInfo( $path, '' );
-                       
-                       $view = new \OC_FilesystemView( '' );
-                       
-                       $userId = \OCP\USER::getUser();
-                       
-                       // TODO: Check if file is shared, if so, use multiKeyDecrypt
-                       
-                       $encryptedKeyfile = Keymanager::getFileKey( $view, $userId, $filePath );
-
-                       $session = new Session();
-                       
-                       $decrypted = Crypt::keyDecryptKeyfile( $data, $encryptedKeyfile, $session->getPrivateKey( $split[1] ) );
-                       
-               } elseif (
-               Crypt::mode() == 'server' 
-               && isset( $_SESSION['legacyenckey'] )
-               && Crypt::isEncryptedMeta( $path ) 
-               ) {
-                       
-                       $decrypted = Crypt::legacyDecrypt( $data, $_SESSION['legacyenckey'] );
-                       
-               }
-               
-               \OC_FileProxy::$enabled = true;
-               
-               if ( ! isset( $decrypted ) ) {
-               
-                       $decrypted = $data;
-                       
-               }
-               
-               return $decrypted;
-               
-       }
-       
-       /**
-        * @brief When a file is deleted, remove its keyfile also
-        */
-       public function preUnlink( $path ) {
-       
-               // Disable encryption proxy to prevent recursive calls
-               \OC_FileProxy::$enabled = false;
-               
-               $view = new \OC_FilesystemView( '/' );
-               
-               $userId = \OCP\USER::getUser();
-               
-               // Format path to be relative to user files dir
-               $trimmed = ltrim( $path, '/' );
-               $split = explode( '/', $trimmed );
-               $sliced = array_slice( $split, 2 );
-               $relPath = implode( '/', $sliced );
-               
-               if ( $view->is_dir( $path ) ) {
-                       
-                       // Dirs must be handled separately as deleteFileKey 
-                       // doesn't handle them
-                       $view->unlink( $userId . '/' . 'files_encryption' . '/' . 'keyfiles' . '/'. $relPath );
-                       
-               } else {
-               
-                       // Delete keyfile so it isn't orphaned
-                       $result = Keymanager::deleteFileKey( $view, $userId, $relPath );
-               
-                       \OC_FileProxy::$enabled = true;
-                       
-                       return $result;
-               
-               }
-       
-       }
-
-       /**
-        * @brief When a file is renamed, rename its keyfile also
-        * @return bool Result of rename()
-        * @note This is pre rather than post because using post didn't work
-        */
-       public function preRename( $oldPath, $newPath ) {
-               
-               // Disable encryption proxy to prevent recursive calls
-               \OC_FileProxy::$enabled = false;
-               
-               $view = new \OC_FilesystemView( '/' );
-               
-               $userId = \OCP\USER::getUser();
-       
-               // Format paths to be relative to user files dir
-               $oldTrimmed = ltrim( $oldPath, '/' );
-               $oldSplit = explode( '/', $oldTrimmed );
-               $oldSliced = array_slice( $oldSplit, 2 );
-               $oldRelPath = implode( '/', $oldSliced );
-               $oldKeyfilePath = $userId . '/' . 'files_encryption' . '/' . 'keyfiles' . '/' . $oldRelPath . '.key';
-               
-               $newTrimmed = ltrim( $newPath, '/' );
-               $newSplit = explode( '/', $newTrimmed );
-               $newSliced = array_slice( $newSplit, 2 );
-               $newRelPath = implode( '/', $newSliced );
-               $newKeyfilePath = $userId . '/' . 'files_encryption' . '/' . 'keyfiles' . '/' . $newRelPath . '.key';
-               
-               // Rename keyfile so it isn't orphaned
-               $result = $view->rename( $oldKeyfilePath, $newKeyfilePath );
-               
-               \OC_FileProxy::$enabled = true;
-               
-               return $result;
-       
-       }
-       
-       public function postFopen( $path, &$result ){
-       
-               if ( !$result ) {
-               
-                       return $result;
-                       
-               }
-               
-               // Reformat path for use with OC_FSV
-               $path_split = explode( '/', $path );
-               $path_f = implode( array_slice( $path_split, 3 ) );
-               
-               // Disable encryption proxy to prevent recursive calls
-               \OC_FileProxy::$enabled = false;
-               
-               $meta = stream_get_meta_data( $result );
-               
-               $view = new \OC_FilesystemView( '' );
-               
-               $util = new Util( $view, \OCP\USER::getUser());
-               
-               // If file is already encrypted, decrypt using crypto protocol
-               if ( 
-                       Crypt::mode() == 'server' 
-                       && $util->isEncryptedPath( $path ) 
-               ) {
-                       
-                       // Close the original encrypted file
-                       fclose( $result );
-                       
-                       // Open the file using the crypto stream wrapper 
-                       // protocol and let it do the decryption work instead
-                       $result = fopen( 'crypt://' . $path_f, $meta['mode'] );
-                       
-                       
-               } elseif ( 
-                       self::shouldEncrypt( $path ) 
-                       and $meta ['mode'] != 'r' 
-                       and $meta['mode'] != 'rb' 
-               ) {
-               // If the file is not yet encrypted, but should be 
-               // encrypted when it's saved (it's not read only)
-               
-               // NOTE: this is the case for new files saved via WebDAV
-               
-                       if ( 
-                       $view->file_exists( $path ) 
-                       and $view->filesize( $path ) > 0 
-                       ) {
-                               $x = $view->file_get_contents( $path );
-                               
-                               $tmp = tmpfile();
-                               
-//                             // Make a temporary copy of the original file
-//                             \OCP\Files::streamCopy( $result, $tmp );
-//                             
-//                             // Close the original stream, we'll return another one
-//                             fclose( $result );
-//                             
-//                             $view->file_put_contents( $path_f, $tmp );
-//                             
-//                             fclose( $tmp );
-                       
-                       }
-                       
-                       $result = fopen( 'crypt://'.$path_f, $meta['mode'] );
-               
-               }
-               
-               // Re-enable the proxy
-               \OC_FileProxy::$enabled = true;
-               
-               return $result;
-       
-       }
-
-       public function postGetMimeType( $path, $mime ) {
-               
-               if ( Crypt::isCatfile( $path ) ) {
-               
-                       $mime = \OCP\Files::getMimeType( 'crypt://' . $path, 'w' );
-               
-               }
-               
-               return $mime;
-               
-       }
-
-       public function postStat( $path, $data ) {
-       
-               if ( Crypt::isCatfile( $path ) ) {
-               
-                       $cached = \OC\Files\Filesystem::getFileInfo( $path, '' );
-                       
-                       $data['size'] = $cached['size'];
-                       
-               }
-               
-               return $data;
-       }
-
-       public function postFileSize( $path, $size ) {
-               
-               if ( Crypt::isCatfile( $path ) ) {
-                       
-                       $cached = \OC\Files\Filesystem::getFileInfo( $path, '' );
-                       
-                       return  $cached['size'];
-               
-               } else {
-               
-                       return $size;
-                       
-               }
-       }
-}
diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php
deleted file mode 100644 (file)
index 769a40b..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/**
- * ownCloud
- *
- * @author Sam Tuke
- * @copyright 2012 Sam Tuke samtuke@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OCA\Encryption;
-
-/**
- * Class for handling encryption related session data
- */
-
-class Session {
-
-       /**
-        * @brief Sets user private key to session
-        * @return bool
-        *
-        */
-       public function setPrivateKey( $privateKey ) {
-       
-               $_SESSION['privateKey'] = $privateKey;
-               
-               return true;
-               
-       }
-       
-       /**
-        * @brief Gets user private key from session
-        * @returns string $privateKey The user's plaintext private key
-        *
-        */
-       public function getPrivateKey() {
-       
-               if ( 
-                       isset( $_SESSION['privateKey'] )
-                       && !empty( $_SESSION['privateKey'] )
-               ) {
-               
-                       return $_SESSION['privateKey'];
-               
-               } else {
-               
-                       return false;
-                       
-               }
-               
-       }
-       
-       /**
-        * @brief Sets user legacy key to session
-        * @return bool
-        *
-        */
-       public function setLegacyKey( $legacyKey ) {
-       
-               if ( $_SESSION['legacyKey'] = $legacyKey ) {
-               
-                       return true;
-                       
-               }
-               
-       }
-       
-       /**
-        * @brief Gets user legacy key from session
-        * @returns string $legacyKey The user's plaintext legacy key
-        *
-        */
-       public function getLegacyKey() {
-       
-               if ( 
-                       isset( $_SESSION['legacyKey'] )
-                       && !empty( $_SESSION['legacyKey'] )
-               ) {
-               
-                       return $_SESSION['legacyKey'];
-               
-               } else {
-               
-                       return false;
-                       
-               }
-               
-       }
-
-}
\ No newline at end of file
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
deleted file mode 100644 (file)
index 65d7d57..0000000
+++ /dev/null
@@ -1,495 +0,0 @@
-<?php
-/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2012 Sam Tuke <samtuke@owncloud.com>, 2011 Robin Appelman 
- * <icewind1991@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * transparently encrypted filestream
- *
- * you can use it as wrapper around an existing stream by setting CryptStream::$sourceStreams['foo']=array('path'=>$path,'stream'=>$stream)
- * and then fopen('crypt://streams/foo');
- */
-
-namespace OCA\Encryption;
-
-/**
- * @brief Provides 'crypt://' stream wrapper protocol.
- * @note We use a stream wrapper because it is the most secure way to handle 
- * decrypted content transfers. There is no safe way to decrypt the entire file
- * somewhere on the server, so we have to encrypt and decrypt blocks on the fly.
- * @note Paths used with this protocol MUST BE RELATIVE. Use URLs like:
- * crypt://filename, or crypt://subdirectory/filename, NOT 
- * crypt:///home/user/owncloud/data. Otherwise keyfiles will be put in 
- * [owncloud]/data/user/files_encryption/keyfiles/home/user/owncloud/data and 
- * will not be accessible to other methods.
- * @note Data read and written must always be 8192 bytes long, as this is the 
- * buffer size used internally by PHP. The encryption process makes the input 
- * data longer, and input is chunked into smaller pieces in order to result in 
- * a 8192 encrypted block size.
- */
-class Stream {
-
-       public static $sourceStreams = array();
-
-       // TODO: make all below properties private again once unit testing is 
-       // configured correctly
-       public $rawPath; // The raw path received by stream_open
-       public $path_f; // The raw path formatted to include username and data dir
-       private $userId;
-       private $handle; // Resource returned by fopen
-       private $path;
-       private $readBuffer; // For streams that dont support seeking
-       private $meta = array(); // Header / meta for source stream
-       private $count;
-       private $writeCache;
-       public $size;
-       private $publicKey;
-       private $keyfile;
-       private $encKeyfile;
-       private static $view; // a fsview object set to user dir
-       private $rootView; // a fsview object set to '/'
-
-       public function stream_open( $path, $mode, $options, &$opened_path ) {
-               
-               // Get access to filesystem via filesystemview object
-               if ( !self::$view ) {
-
-                       self::$view = new \OC_FilesystemView( $this->userId . '/' );
-
-               }
-               
-               // Set rootview object if necessary
-               if ( ! $this->rootView ) {
-
-                       $this->rootView = new \OC_FilesystemView( $this->userId . '/' );
-
-               }
-               
-               $this->userId = \OCP\User::getUser();
-               
-               // Get the bare file path
-               $path = str_replace( 'crypt://', '', $path );
-               
-               $this->rawPath = $path;
-               
-               $this->path_f = $this->userId . '/files/' . $path;
-               
-               if ( 
-               dirname( $path ) == 'streams' 
-               and isset( self::$sourceStreams[basename( $path )] ) 
-               ) {
-               
-                       // Is this just for unit testing purposes?
-
-                       $this->handle = self::$sourceStreams[basename( $path )]['stream'];
-
-                       $this->path = self::$sourceStreams[basename( $path )]['path'];
-
-                       $this->size = self::$sourceStreams[basename( $path )]['size'];
-
-               } else {
-
-                       if ( 
-                       $mode == 'w' 
-                       or $mode == 'w+' 
-                       or $mode == 'wb' 
-                       or $mode == 'wb+' 
-                       ) {
-
-                               $this->size = 0;
-
-                       } else {
-                               
-                               
-                               
-                               $this->size = self::$view->filesize( $this->path_f, $mode );
-                               
-                               //$this->size = filesize( $path );
-                               
-                       }
-
-                       // Disable fileproxies so we can open the source file without recursive encryption
-                       \OC_FileProxy::$enabled = false;
-
-                       //$this->handle = fopen( $path, $mode );
-                       
-                       $this->handle = self::$view->fopen( $this->path_f, $mode );
-                       
-                       \OC_FileProxy::$enabled = true;
-
-                       if ( !is_resource( $this->handle ) ) {
-
-                               \OCP\Util::writeLog( 'files_encryption', 'failed to open '.$path, \OCP\Util::ERROR );
-
-                       }
-
-               }
-
-               if ( is_resource( $this->handle ) ) {
-
-                       $this->meta = stream_get_meta_data( $this->handle );
-
-               }
-
-               return is_resource( $this->handle );
-
-       }
-       
-       public function stream_seek( $offset, $whence = SEEK_SET ) {
-       
-               $this->flush();
-               
-               fseek( $this->handle, $offset, $whence );
-               
-       }
-       
-       public function stream_tell() {
-               return ftell($this->handle);
-       }
-       
-       public function stream_read( $count ) {
-       
-               $this->writeCache = '';
-
-               if ( $count != 8192 ) {
-                       
-                       // $count will always be 8192 https://bugs.php.net/bug.php?id=21641
-                       // This makes this function a lot simpler, but will break this class if the above 'bug' gets 'fixed'
-                       \OCP\Util::writeLog( 'files_encryption', 'PHP "bug" 21641 no longer holds, decryption system requires refactoring', \OCP\Util::FATAL );
-
-                       die();
-
-               }
-
-//             $pos = ftell( $this->handle );
-// 
-               // Get the data from the file handle
-               $data = fread( $this->handle, 8192 );
-               if ( strlen( $data ) ) {
-                       
-                       $this->getKey();
-                       
-                       $result = Crypt::symmetricDecryptFileContent( $data, $this->keyfile );
-                       
-               } else {
-
-                       $result = '';
-
-               }
-
-//             $length = $this->size - $pos;
-// 
-//             if ( $length < 8192 ) {
-// 
-//                     $result = substr( $result, 0, $length );
-// 
-//             }
-
-               return $result;
-
-       }
-       
-       /**
-        * @brief Encrypt and pad data ready for writing to disk
-        * @param string $plainData data to be encrypted
-        * @param string $key key to use for encryption
-        * @return encrypted data on success, false on failure
-        */
-       public function preWriteEncrypt( $plainData, $key ) {
-               
-               // Encrypt data to 'catfile', which includes IV
-               if ( $encrypted = Crypt::symmetricEncryptFileContent( $plainData, $key ) ) {
-               
-                       return $encrypted; 
-                       
-               } else {
-               
-                       return false;
-                       
-               }
-               
-       }
-       
-       /**
-        * @brief Get the keyfile for the current file, generate one if necessary
-        * @param bool $generate if true, a new key will be generated if none can be found
-        * @return bool true on key found and set, false on key not found and new key generated and set
-        */
-       public function getKey() {
-               
-               // If a keyfile already exists for a file named identically to 
-               // file to be written
-               if ( self::$view->file_exists( $this->userId . '/'. 'files_encryption' . '/' . 'keyfiles' . '/' . $this->rawPath . '.key' ) ) {
-               
-                       // TODO: add error handling for when file exists but no 
-                       // keyfile
-                       
-                       // Fetch existing keyfile
-                       $this->encKeyfile = Keymanager::getFileKey( $this->rootView, $this->userId, $this->rawPath );
-                       
-                       $this->getUser();
-                       
-                       $session = new Session();
-                       
-                       $privateKey = $session->getPrivateKey( $this->userId );
-                       
-                       $this->keyfile = Crypt::keyDecrypt( $this->encKeyfile, $privateKey );
-                       
-                       return true;
-                       
-               } else {
-               
-                       return false;
-               
-               }
-               
-       }
-       
-       public function getuser() {
-       
-               // Only get the user again if it isn't already set
-               if ( empty( $this->userId ) ) {
-       
-                       // TODO: Move this user call out of here - it belongs 
-                       // elsewhere
-                       $this->userId = \OCP\User::getUser();
-               
-               }
-               
-               // TODO: Add a method for getting the user in case OCP\User::
-               // getUser() doesn't work (can that scenario ever occur?)
-               
-       }
-       
-       /**
-        * @brief Handle plain data from the stream, and write it in 8192 byte blocks
-        * @param string $data data to be written to disk
-        * @note the data will be written to the path stored in the stream handle, set in stream_open()
-        * @note $data is only ever be a maximum of 8192 bytes long. This is set by PHP internally. stream_write() is called multiple times in a loop on data larger than 8192 bytes
-        * @note Because the encryption process used increases the length of $data, a writeCache is used to carry over data which would not fit in the required block size
-        * @note Padding is added to each encrypted block to ensure that the resulting block is exactly 8192 bytes. This is removed during stream_read
-        * @note PHP automatically updates the file pointer after writing data to reflect it's length. There is generally no need to update the poitner manually using fseek
-        */
-       public function stream_write( $data ) {
-               
-               // Disable the file proxies so that encryption is not 
-               // automatically attempted when the file is written to disk - 
-               // we are handling that separately here and we don't want to 
-               // get into an infinite loop
-               \OC_FileProxy::$enabled = false;
-               
-               // Get the length of the unencrypted data that we are handling
-               $length = strlen( $data );
-               
-               // So far this round, no data has been written
-               $written = 0;
-               
-               // Find out where we are up to in the writing of data to the 
-               // file
-               $pointer = ftell( $this->handle );
-               
-               // Make sure the userId is set
-               $this->getuser();
-               
-               // TODO: Check if file is shared, if so, use multiKeyEncrypt and
-               // save shareKeys in necessary user directories
-               
-               // Get / generate the keyfile for the file we're handling
-               // If we're writing a new file (not overwriting an existing 
-               // one), save the newly generated keyfile
-               if ( ! $this->getKey() ) {
-               
-                       $this->keyfile = Crypt::generateKey();
-                       
-                       $this->publicKey = Keymanager::getPublicKey( $this->rootView, $this->userId );
-                       
-                       $this->encKeyfile = Crypt::keyEncrypt( $this->keyfile, $this->publicKey );
-                       
-                       $view = new \OC_FilesystemView( '/' );
-                       $userId = \OCP\User::getUser();
-                       
-                       // Save the new encrypted file key
-                       Keymanager::setFileKey( $view, $this->rawPath, $userId, $this->encKeyfile );
-                       
-               }
-
-               // If extra data is left over from the last round, make sure it 
-               // is integrated into the next 6126 / 8192 block
-               if ( $this->writeCache ) {
-                       
-                       // Concat writeCache to start of $data
-                       $data = $this->writeCache . $data;
-                       
-                       // Clear the write cache, ready for resuse - it has been
-                       // flushed and its old contents processed
-                       $this->writeCache = '';
-
-               }
-//             
-//             // Make sure we always start on a block start
-               if ( 0 != ( $pointer % 8192 ) ) { 
-               // if the current position of 
-               // file indicator is not aligned to a 8192 byte block, fix it 
-               // so that it is
-
-//                     fseek( $this->handle, - ( $pointer % 8192 ), SEEK_CUR );
-//                     
-//                     $pointer = ftell( $this->handle );
-// 
-//                     $unencryptedNewBlock = fread( $this->handle, 8192 );
-//                     
-//                     fseek( $this->handle, - ( $currentPos % 8192 ), SEEK_CUR );
-// 
-//                     $block = Crypt::symmetricDecryptFileContent( $unencryptedNewBlock, $this->keyfile );
-// 
-//                     $x =  substr( $block, 0, $currentPos % 8192 );
-// 
-//                     $data = $x . $data;
-//                     
-//                     fseek( $this->handle, - ( $currentPos % 8192 ), SEEK_CUR );
-// 
-               }
-
-//             $currentPos = ftell( $this->handle );
-               
-//             // While there still remains somed data to be processed & written
-               while( strlen( $data ) > 0 ) {
-//                     
-//                     // Remaining length for this iteration, not of the 
-//                     // entire file (may be greater than 8192 bytes)
-//                     $remainingLength = strlen( $data );
-//                     
-//                     // If data remaining to be written is less than the 
-//                     // size of 1 6126 byte block
-                       if ( strlen( $data ) < 6126 ) {
-                               
-                               // Set writeCache to contents of $data
-                               // The writeCache will be carried over to the 
-                               // next write round, and added to the start of 
-                               // $data to ensure that written blocks are 
-                               // always the correct length. If there is still 
-                               // data in writeCache after the writing round 
-                               // has finished, then the data will be written 
-                               // to disk by $this->flush().
-                               $this->writeCache = $data;
-
-                               // Clear $data ready for next round
-                               $data = '';
-// 
-                       } else {
-                               
-                               // Read the chunk from the start of $data
-                               $chunk = substr( $data, 0, 6126 );
-                               
-                               $encrypted = $this->preWriteEncrypt( $chunk, $this->keyfile );
-                               
-                               // Write the data chunk to disk. This will be 
-                               // attended to the last data chunk if the file
-                               // being handled totals more than 6126 bytes
-                               fwrite( $this->handle, $encrypted );
-                               
-                               $writtenLen = strlen( $encrypted );
-                               //fseek( $this->handle, $writtenLen, SEEK_CUR );
-
-                               // Remove the chunk we just processed from 
-                               // $data, leaving only unprocessed data in $data
-                               // var, for handling on the next round
-                               $data = substr( $data, 6126 );
-
-                       }
-               
-               }
-
-               $this->size = max( $this->size, $pointer + $length );
-               
-               return $length;
-
-       }
-
-
-       public function stream_set_option( $option, $arg1, $arg2 ) {
-               switch($option) {
-                       case STREAM_OPTION_BLOCKING:
-                               stream_set_blocking( $this->handle, $arg1 );
-                               break;
-                       case STREAM_OPTION_READ_TIMEOUT:
-                               stream_set_timeout( $this->handle, $arg1, $arg2 );
-                               break;
-                       case STREAM_OPTION_WRITE_BUFFER:
-                               stream_set_write_buffer( $this->handle, $arg1, $arg2 );
-               }
-       }
-
-       public function stream_stat() {
-               return fstat($this->handle);
-       }
-       
-       public function stream_lock( $mode ) {
-               flock( $this->handle, $mode );
-       }
-       
-       public function stream_flush() {
-       
-               return fflush( $this->handle ); 
-               // Not a typo: http://php.net/manual/en/function.fflush.php
-               
-       }
-
-       public function stream_eof() {
-               return feof($this->handle);
-       }
-
-       private function flush() {
-               
-               if ( $this->writeCache ) {
-                       
-                       // Set keyfile property for file in question
-                       $this->getKey();
-                       
-                       $encrypted = $this->preWriteEncrypt( $this->writeCache, $this->keyfile );
-                       
-                       fwrite( $this->handle, $encrypted );
-                       
-                       $this->writeCache = '';
-               
-               }
-       
-       }
-
-       public function stream_close() {
-       
-               $this->flush();
-
-               if ( 
-               $this->meta['mode']!='r' 
-               and $this->meta['mode']!='rb' 
-               ) {
-
-                       \OC\Files\Filesystem::putFileInfo( $this->path, array( 'encrypted' => true, 'size' => $this->size ), '' );
-
-               }
-
-               return fclose( $this->handle );
-
-       }
-
-}
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
deleted file mode 100644 (file)
index 52bc74d..0000000
+++ /dev/null
@@ -1,476 +0,0 @@
-<?php
-/**
- * ownCloud
- *
- * @author Sam Tuke, Frank Karlitschek
- * @copyright 2012 Sam Tuke samtuke@owncloud.com, 
- * Frank Karlitschek frank@owncloud.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-// Todo:
-//  - Crypt/decrypt button in the userinterface
-//  - Setting if crypto should be on by default
-//  - Add a setting "Don´t encrypt files larger than xx because of performance 
-//    reasons"
-//  - Transparent decrypt/encrypt in filesystem.php. Autodetect if a file is 
-//    encrypted (.encrypted extension)
-//  - Don't use a password directly as encryption key. but a key which is 
-//    stored on the server and encrypted with the user password. -> password 
-//    change faster
-//  - IMPORTANT! Check if the block lenght of the encrypted data stays the same
-
-namespace OCA\Encryption;
-
-/**
- * @brief Class for utilities relating to encrypted file storage system
- * @param OC_FilesystemView $view expected to have OC '/' as root path
- * @param string $userId ID of the logged in user
- * @param int $client indicating status of client side encryption. Currently
- * unused, likely to become obsolete shortly
- */
-
-class Util {
-       
-       
-       // Web UI:
-       
-       //// DONE: files created via web ui are encrypted
-       //// DONE: file created & encrypted via web ui are readable in web ui
-       //// DONE: file created & encrypted via web ui are readable via webdav
-       
-       
-       // WebDAV:
-       
-       //// DONE: new data filled files added via webdav get encrypted
-       //// DONE: new data filled files added via webdav are readable via webdav
-       //// DONE: reading unencrypted files when encryption is enabled works via 
-       ////       webdav
-       //// DONE: files created & encrypted via web ui are readable via webdav
-       
-       
-       // Legacy support:
-       
-       //// DONE: add method to check if file is encrypted using new system
-       //// DONE: add method to check if file is encrypted using old system
-       //// DONE: add method to fetch legacy key
-       //// DONE: add method to decrypt legacy encrypted data
-       
-       
-       // Admin UI:
-       
-       //// DONE: changing user password also changes encryption passphrase
-       
-       //// TODO: add support for optional recovery in case of lost passphrase / keys
-       //// TODO: add admin optional required long passphrase for users
-       //// TODO: add UI buttons for encrypt / decrypt everything
-       //// TODO: implement flag system to allow user to specify encryption by folder, subfolder, etc.
-       
-       
-       // Sharing:
-       
-       //// TODO: add support for encrypting to multiple public keys
-       //// TODO: add support for decrypting to multiple private keys
-       
-       
-       // Integration testing:
-       
-       //// TODO: test new encryption with versioning
-       //// TODO: test new encryption with sharing
-       //// TODO: test new encryption with proxies
-       
-       
-       private $view; // OC_FilesystemView object for filesystem operations
-       private $userId; // ID of the currently logged-in user
-       private $pwd; // User Password
-       private $client; // Client side encryption mode flag
-       private $publicKeyDir; // Dir containing all public user keys
-       private $encryptionDir; // Dir containing user's files_encryption
-       private $keyfilesPath; // Dir containing user's keyfiles
-       private $shareKeysPath; // Dir containing env keys for shared files
-       private $publicKeyPath; // Path to user's public key
-       private $privateKeyPath; // Path to user's private key
-
-       public function __construct( \OC_FilesystemView $view, $userId, $client = false ) {
-       
-               $this->view = $view;
-               $this->userId = $userId;
-               $this->client = $client;
-               $this->userDir =  '/' . $this->userId;
-               $this->userFilesDir =  '/' . $this->userId . '/' . 'files';
-               $this->publicKeyDir =  '/' . 'public-keys';
-               $this->encryptionDir =  '/' . $this->userId . '/' . 'files_encryption';
-               $this->keyfilesPath = $this->encryptionDir . '/' . 'keyfiles';
-               $this->shareKeysPath = $this->encryptionDir . '/' . 'share-keys';
-               $this->publicKeyPath = $this->publicKeyDir . '/' . $this->userId . '.public.key'; // e.g. data/public-keys/admin.public.key
-               $this->privateKeyPath = $this->encryptionDir . '/' . $this->userId . '.private.key'; // e.g. data/admin/admin.private.key
-               
-       }
-       
-       public function ready() {
-               
-               if( 
-               !$this->view->file_exists( $this->encryptionDir )
-               or !$this->view->file_exists( $this->keyfilesPath )
-               or !$this->view->file_exists( $this->shareKeysPath )
-               or !$this->view->file_exists( $this->publicKeyPath )
-               or !$this->view->file_exists( $this->privateKeyPath ) 
-               ) {
-               
-                       return false;
-                       
-               } else {
-               
-                       return true;
-                       
-               }
-       
-       }
-       
-        /**
-         * @brief Sets up user folders and keys for serverside encryption
-         * @param $passphrase passphrase to encrypt server-stored private key with
-         */
-       public function setupServerSide( $passphrase = null ) {
-               
-               // Create user dir
-               if( !$this->view->file_exists( $this->userDir ) ) {
-               
-                       $this->view->mkdir( $this->userDir );
-               
-               }
-               
-               // Create user files dir
-               if( !$this->view->file_exists( $this->userFilesDir ) ) {
-               
-                       $this->view->mkdir( $this->userFilesDir );
-               
-               }
-               
-               // Create shared public key directory
-               if( !$this->view->file_exists( $this->publicKeyDir ) ) {
-               
-                       $this->view->mkdir( $this->publicKeyDir );
-               
-               }
-               
-               // Create encryption app directory
-               if( !$this->view->file_exists( $this->encryptionDir ) ) {
-               
-                       $this->view->mkdir( $this->encryptionDir );
-               
-               }
-               
-               // Create mirrored keyfile directory
-               if( !$this->view->file_exists( $this->keyfilesPath ) ) {
-               
-                       $this->view->mkdir( $this->keyfilesPath );
-               
-               }
-
-               // Create mirrored share env keys directory
-               if( !$this->view->file_exists( $this->shareKeysPath ) ) {
-               
-                       $this->view->mkdir( $this->shareKeysPath );
-               
-               }
-               
-               // Create user keypair
-               if ( 
-                       ! $this->view->file_exists( $this->publicKeyPath ) 
-                       or ! $this->view->file_exists( $this->privateKeyPath ) 
-               ) {
-               
-                       // Generate keypair
-                       $keypair = Crypt::createKeypair();
-                       
-                       \OC_FileProxy::$enabled = false;
-                       
-                       // Save public key
-                       $this->view->file_put_contents( $this->publicKeyPath, $keypair['publicKey'] );
-                       
-                       // Encrypt private key with user pwd as passphrase
-                       $encryptedPrivateKey = Crypt::symmetricEncryptFileContent( $keypair['privateKey'], $passphrase );
-                       
-                       // Save private key
-                       $this->view->file_put_contents( $this->privateKeyPath, $encryptedPrivateKey );
-                       
-                       \OC_FileProxy::$enabled = true;
-                       
-               }
-               
-               return true;
-       
-       }
-       
-       /**
-        * @brief Find all files and their encryption status within a directory
-        * @param string $directory The path of the parent directory to search
-        * @return mixed false if 0 found, array on success. Keys: name, path
-        
-        * @note $directory needs to be a path relative to OC data dir. e.g.
-        *       /admin/files NOT /backup OR /home/www/oc/data/admin/files
-        */
-       public function findFiles( $directory ) {
-               
-               // Disable proxy - we don't want files to be decrypted before
-               // we handle them
-               \OC_FileProxy::$enabled = false;
-               
-               $found = array( 'plain' => array(), 'encrypted' => array(), 'legacy' => array() );
-               
-               if ( 
-                       $this->view->is_dir( $directory ) 
-                       && $handle = $this->view->opendir( $directory ) 
-               ) {
-               
-                       while ( false !== ( $file = readdir( $handle ) ) ) {
-                               
-                               if (
-                               $file != "." 
-                               && $file != ".."
-                               ) {
-                                       
-                                       $filePath = $directory . '/' . $this->view->getRelativePath( '/' . $file );
-                                       $relPath = $this->stripUserFilesPath( $filePath );
-                                       
-                                       // If the path is a directory, search 
-                                       // its contents
-                                       if ( $this->view->is_dir( $filePath ) ) { 
-                                               
-                                               $this->findFiles( $filePath );
-                                       
-                                       // If the path is a file, determine 
-                                       // its encryption status
-                                       } elseif ( $this->view->is_file( $filePath ) ) {
-                                               
-                                               // Disable proxies again, some-
-                                               // where they got re-enabled :/
-                                               \OC_FileProxy::$enabled = false;
-                                               
-                                               $data = $this->view->file_get_contents( $filePath );
-                                               
-                                               // If the file is encrypted
-                                               // NOTE: If the userId is 
-                                               // empty or not set, file will 
-                                               // detected as plain
-                                               // NOTE: This is inefficient;
-                                               // scanning every file like this
-                                               // will eat server resources :(
-                                               if ( 
-                                                       Keymanager::getFileKey( $this->view, $this->userId, $file ) 
-                                                       && Crypt::isCatfile( $data )
-                                               ) {
-                                               
-                                                       $found['encrypted'][] = array( 'name' => $file, 'path' => $filePath );
-                                               
-                                               // If the file uses old 
-                                               // encryption system
-                                               } elseif (  Crypt::isLegacyEncryptedContent( $this->view->file_get_contents( $filePath ), $relPath ) ) {
-                                                       
-                                                       $found['legacy'][] = array( 'name' => $file, 'path' => $filePath );
-                                                       
-                                               // If the file is not encrypted
-                                               } else {
-                                               
-                                                       $found['plain'][] = array( 'name' => $file, 'path' => $filePath );
-                                               
-                                               }
-                                       
-                                       }
-                                       
-                               }
-                               
-                       }
-                       
-                       \OC_FileProxy::$enabled = true;
-                       
-                       if ( empty( $found ) ) {
-                       
-                               return false;
-                       
-                       } else {
-                               
-                               return $found;
-                       
-                       }
-               
-               }
-               
-               \OC_FileProxy::$enabled = true;
-               
-               return false;
-
-       }
-       
-        /**
-         * @brief Check if a given path identifies an encrypted file
-         * @return true / false
-         */
-       public function isEncryptedPath( $path ) {
-       
-               // Disable encryption proxy so data retreived is in its 
-               // original form
-               \OC_FileProxy::$enabled = false;
-       
-               $data = $this->view->file_get_contents( $path );
-               
-               \OC_FileProxy::$enabled = true;
-               
-               return Crypt::isCatfile( $data );
-       
-       }
-       
-       /**
-        * @brief Format a path to be relative to the /user/files/ directory
-        */
-       public function stripUserFilesPath( $path ) {
-       
-               $trimmed = ltrim( $path, '/' );
-               $split = explode( '/', $trimmed );
-               $sliced = array_slice( $split, 2 );
-               $relPath = implode( '/', $sliced );
-               
-               return $relPath;
-       
-       }
-       
-       /**
-        * @brief Encrypt all files in a directory
-        * @param string $publicKey the public key to encrypt files with
-        * @param string $dirPath the directory whose files will be encrypted
-        * @note Encryption is recursive
-        */
-       public function encryptAll( $publicKey, $dirPath, $legacyPassphrase = null, $newPassphrase = null ) {
-       
-               if ( $found = $this->findFiles( $dirPath ) ) {
-               
-                       // Disable proxy to prevent file being encrypted twice
-                       \OC_FileProxy::$enabled = false;
-               
-                       // Encrypt unencrypted files
-                       foreach ( $found['plain'] as $plainFile ) {
-                               
-                               // Fetch data from file
-                               $plainData = $this->view->file_get_contents( $plainFile['path'] );
-                               
-                               // Encrypt data, generate catfile
-                               $encrypted = Crypt::keyEncryptKeyfile( $plainData, $publicKey );
-                               
-                               $relPath = $this->stripUserFilesPath( $plainFile['path'] );
-                               
-                               // Save keyfile
-                               Keymanager::setFileKey( $this->view, $relPath, $this->userId, $encrypted['key'] );
-                               
-                               // Overwrite the existing file with the encrypted one
-                               $this->view->file_put_contents( $plainFile['path'], $encrypted['data'] );
-                               
-                               $size = strlen( $encrypted['data'] );
-                               
-                               // Add the file to the cache
-                               \OC\Files\Filesystem::putFileInfo( $plainFile['path'], array( 'encrypted'=>true, 'size' => $size ), '' );
-                       
-                       }
-                       
-                       // Encrypt legacy encrypted files
-                       if ( 
-                               ! empty( $legacyPassphrase ) 
-                               && ! empty( $newPassphrase ) 
-                       ) {
-                       
-                               foreach ( $found['legacy'] as $legacyFile ) {
-                               
-                                       // Fetch data from file
-                                       $legacyData = $this->view->file_get_contents( $legacyFile['path'] );
-                               
-                                       // Recrypt data, generate catfile
-                                       $recrypted = Crypt::legacyKeyRecryptKeyfile( $legacyData, $legacyPassphrase, $publicKey, $newPassphrase );
-                                       
-                                       $relPath = $this->stripUserFilesPath( $legacyFile['path'] );
-                                       
-                                       // Save keyfile
-                                       Keymanager::setFileKey( $this->view, $relPath, $this->userId, $recrypted['key'] );
-                                       
-                                       // Overwrite the existing file with the encrypted one
-                                       $this->view->file_put_contents( $legacyFile['path'], $recrypted['data'] );
-                                       
-                                       $size = strlen( $recrypted['data'] );
-                                       
-                                       // Add the file to the cache
-                                       \OC\Files\Filesystem::putFileInfo( $legacyFile['path'], array( 'encrypted'=>true, 'size' => $size ), '' );
-                               
-                               }
-                               
-                       }
-                       
-                       \OC_FileProxy::$enabled = true;
-                       
-                       // If files were found, return true
-                       return true;
-               
-               } else {
-               
-                       // If no files were found, return false
-                       return false;
-                       
-               }
-               
-       }
-       
-       /**
-        * @brief Return important encryption related paths
-        * @param string $pathName Name of the directory to return the path of
-        * @return string path
-        */
-       public function getPath( $pathName ) {
-       
-               switch ( $pathName ) {
-                       
-                       case 'publicKeyDir':
-                       
-                               return $this->publicKeyDir;
-                               
-                               break;
-                               
-                       case 'encryptionDir':
-                       
-                               return $this->encryptionDir;
-                               
-                               break;
-                               
-                       case 'keyfilesPath':
-                       
-                               return $this->keyfilesPath;
-                               
-                               break;
-                               
-                       case 'publicKeyPath':
-                       
-                               return $this->publicKeyPath;
-                               
-                               break;
-                               
-                       case 'privateKeyPath':
-                       
-                               return $this->privateKeyPath;
-                               
-                               break;
-                       
-               }
-               
-       }
-
-}
diff --git a/apps/files_encryption/settings-personal.php b/apps/files_encryption/settings-personal.php
deleted file mode 100644 (file)
index af0273c..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php\r
-/**\r
- * Copyright (c) 2013 Sam Tuke <samtuke@owncloud.com>\r
- * This file is licensed under the Affero General Public License version 3 or\r
- * later.\r
- * See the COPYING-README file.\r
- */\r
-\r
-$tmpl = new OCP\Template( 'files_encryption', 'settings-personal');\r
-\r
-$blackList = explode( ',', \OCP\Config::getAppValue( 'files_encryption', 'type_blacklist', 'jpg,png,jpeg,avi,mpg,mpeg,mkv,mp3,oga,ogv,ogg' ) );\r
-\r
-$tmpl->assign( 'blacklist', $blackList );\r
-\r
-return $tmpl->fetchPage();\r
-\r
-return null;\r
diff --git a/apps/files_encryption/settings.php b/apps/files_encryption/settings.php
deleted file mode 100644 (file)
index d1260f4..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-\OC_Util::checkAdminUser();
-
-$tmpl = new OCP\Template( 'files_encryption', 'settings' );
-
-$blackList = explode( ',', \OCP\Config::getAppValue( 'files_encryption', 'type_blacklist', 'jpg,png,jpeg,avi,mpg,mpeg,mkv,mp3,oga,ogv,ogg' ) );
-
-$tmpl->assign( 'blacklist', $blackList );
-$tmpl->assign( 'encryption_mode', \OC_Appconfig::getValue( 'files_encryption', 'mode', 'none' ) );
-
-\OCP\Util::addscript( 'files_encryption', 'settings' );
-\OCP\Util::addscript( 'core', 'multiselect' );
-
-return $tmpl->fetchPage();
diff --git a/apps/files_encryption/templates/settings-personal.php b/apps/files_encryption/templates/settings-personal.php
deleted file mode 100644 (file)
index 5f0acca..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<form id="encryption">\r
-       <fieldset class="personalblock">\r
-               <legend>\r
-                       <?php p($l->t( 'Encryption' )); ?>\r
-               </legend>\r
-               <p>\r
-                       <?php p($l->t( 'File encryption is enabled.' )); ?>\r
-               </p>\r
-               <?php if ( ! empty( $_["blacklist"] ) ): ?>\r
-               <p>\r
-                       <?php p($l->t( 'The following file types will not be encrypted:' )); ?>\r
-               </p>\r
-               <ul>\r
-                       <?php foreach( $_["blacklist"] as $type ): ?>\r
-                       <li>\r
-                               <?php p($type); ?>\r
-                       </li>\r
-                       <?php endforeach; ?>\r
-               </ul>\r
-               <?php endif; ?>\r
-       </fieldset>\r
-</form>\r
diff --git a/apps/files_encryption/templates/settings.php b/apps/files_encryption/templates/settings.php
deleted file mode 100644 (file)
index b873d7f..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<form id="encryption">
-       <fieldset class="personalblock">
-               
-               <p>
-                       <strong><?php p($l->t( 'Encryption' )); ?></strong>
-                       
-                       <?php p($l->t( "Exclude the following file types from encryption:" )); ?>
-                       <br />
-                       
-                       <select 
-                       id='encryption_blacklist' 
-                       title="<?php p($l->t( 'None' ))?>" 
-                       multiple="multiple">
-                       <?php foreach($_["blacklist"] as $type): ?>
-                               <option selected="selected" value="<?php p($type); ?>"> <?php p($type); ?> </option>
-                       <?php endforeach;?>
-                       </select>
-               </p>
-       </fieldset>
-</form>
diff --git a/apps/files_encryption/test/binary b/apps/files_encryption/test/binary
deleted file mode 100644 (file)
index 79bc994..0000000
Binary files a/apps/files_encryption/test/binary and /dev/null differ
diff --git a/apps/files_encryption/test/crypt.php b/apps/files_encryption/test/crypt.php
deleted file mode 100755 (executable)
index aa87ec3..0000000
+++ /dev/null
@@ -1,667 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012 Sam Tuke <samtuke@owncloud.com>, and
- * Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-//require_once "PHPUnit/Framework/TestCase.php";
-require_once realpath( dirname(__FILE__).'/../../../3rdparty/Crypt_Blowfish/Blowfish.php' );
-require_once realpath( dirname(__FILE__).'/../../../lib/base.php' );
-require_once realpath( dirname(__FILE__).'/../lib/crypt.php' );
-require_once realpath( dirname(__FILE__).'/../lib/keymanager.php' );
-require_once realpath( dirname(__FILE__).'/../lib/proxy.php' );
-require_once realpath( dirname(__FILE__).'/../lib/stream.php' );
-require_once realpath( dirname(__FILE__).'/../lib/util.php' );
-require_once realpath( dirname(__FILE__).'/../appinfo/app.php' );
-
-use OCA\Encryption;
-
-// This has to go here because otherwise session errors arise, and the private 
-// encryption key needs to be saved in the session
-\OC_User::login( 'admin', 'admin' );
-
-/**
- * @note It would be better to use Mockery here for mocking out the session 
- * handling process, and isolate calls to session class and data from the unit 
- * tests relating to them (stream etc.). However getting mockery to work and 
- * overload classes whilst also using the OC autoloader is difficult due to 
- * load order Pear errors.
- */
-
-class Test_Crypt extends \PHPUnit_Framework_TestCase {
-       
-       function setUp() {
-               
-               // set content for encrypting / decrypting in tests
-               $this->dataLong = file_get_contents( realpath( dirname(__FILE__).'/../lib/crypt.php' ) );
-               $this->dataShort = 'hats';
-               $this->dataUrl = realpath( dirname(__FILE__).'/../lib/crypt.php' );
-               $this->legacyData = realpath( dirname(__FILE__).'/legacy-text.txt' );
-               $this->legacyEncryptedData = realpath( dirname(__FILE__).'/legacy-encrypted-text.txt' );
-               $this->randomKey = Encryption\Crypt::generateKey();
-               
-               $keypair = Encryption\Crypt::createKeypair();
-               $this->genPublicKey =  $keypair['publicKey'];
-               $this->genPrivateKey = $keypair['privateKey'];
-               
-               $this->view = new \OC_FilesystemView( '/' );
-               
-               \OC_User::setUserId( 'admin' );
-               $this->userId = 'admin';
-               $this->pass = 'admin';
-               
-               \OC_Filesystem::init( '/' );
-               \OC_Filesystem::mount( 'OC_Filestorage_Local', array('datadir' => \OC_User::getHome($this->userId)), '/' );
-               
-       }
-       
-       function tearDown() {
-       
-       }
-
-       function testGenerateKey() {
-       
-               # TODO: use more accurate (larger) string length for test confirmation
-               
-               $key = Encryption\Crypt::generateKey();
-               
-               $this->assertTrue( strlen( $key ) > 16 );
-       
-       }
-       
-       function testGenerateIv() {
-               
-               $iv = Encryption\Crypt::generateIv();
-               
-               $this->assertEquals( 16, strlen( $iv ) );
-               
-               return $iv;
-       
-       }
-       
-       /**
-        * @depends testGenerateIv
-        */
-       function testConcatIv( $iv ) {
-               
-               $catFile = Encryption\Crypt::concatIv( $this->dataLong, $iv );
-               
-               // Fetch encryption metadata from end of file
-               $meta = substr( $catFile, -22 );
-               
-               $identifier = substr( $meta, 0, 6);
-               
-               // Fetch IV from end of file
-               $foundIv = substr( $meta, 6 );
-               
-               $this->assertEquals( '00iv00', $identifier );
-               
-               $this->assertEquals( $iv, $foundIv );
-               
-               // Remove IV and IV identifier text to expose encrypted content
-               $data = substr( $catFile, 0, -22 );
-               
-               $this->assertEquals( $this->dataLong, $data );
-               
-               return array(
-                       'iv' => $iv
-                       , 'catfile' => $catFile
-               );
-       
-       }
-       
-       /**
-        * @depends testConcatIv
-        */
-       function testSplitIv( $testConcatIv ) {
-               
-               // Split catfile into components
-               $splitCatfile = Encryption\Crypt::splitIv( $testConcatIv['catfile'] );
-               
-               // Check that original IV and split IV match
-               $this->assertEquals( $testConcatIv['iv'], $splitCatfile['iv'] );
-               
-               // Check that original data and split data match
-               $this->assertEquals( $this->dataLong, $splitCatfile['encrypted'] );
-       
-       }
-       
-       function testAddPadding() {
-       
-               $padded = Encryption\Crypt::addPadding( $this->dataLong );
-               
-               $padding = substr( $padded, -2 );
-               
-               $this->assertEquals( 'xx' , $padding );
-               
-               return $padded;
-       
-       }
-       
-       /**
-        * @depends testAddPadding
-        */
-       function testRemovePadding( $padded ) {
-       
-               $noPadding = Encryption\Crypt::RemovePadding( $padded );
-               
-               $this->assertEquals( $this->dataLong, $noPadding );
-       
-       }
-       
-       function testEncrypt() {
-       
-               $random = openssl_random_pseudo_bytes( 13 );
-
-               $iv = substr( base64_encode( $random ), 0, -4 ); // i.e. E5IG033j+mRNKrht
-
-               $crypted = Encryption\Crypt::encrypt( $this->dataUrl, $iv, 'hat' );
-
-               $this->assertNotEquals( $this->dataUrl, $crypted );
-       
-       }
-       
-       function testDecrypt() {
-       
-               $random = openssl_random_pseudo_bytes( 13 );
-
-               $iv = substr( base64_encode( $random ), 0, -4 ); // i.e. E5IG033j+mRNKrht
-
-               $crypted = Encryption\Crypt::encrypt( $this->dataUrl, $iv, 'hat' );
-       
-               $decrypt = Encryption\Crypt::decrypt( $crypted, $iv, 'hat' );
-
-               $this->assertEquals( $this->dataUrl, $decrypt );
-       
-       }
-       
-       function testSymmetricEncryptFileContent() {
-       
-               # TODO: search in keyfile for actual content as IV will ensure this test always passes
-               
-               $crypted = Encryption\Crypt::symmetricEncryptFileContent( $this->dataShort, 'hat' );
-
-               $this->assertNotEquals( $this->dataShort, $crypted );
-               
-
-               $decrypt = Encryption\Crypt::symmetricDecryptFileContent( $crypted, 'hat' );
-
-               $this->assertEquals( $this->dataShort, $decrypt );
-               
-       }
-       
-       // These aren't used for now
-//     function testSymmetricBlockEncryptShortFileContent() {
-//             
-//             $crypted = Encryption\Crypt::symmetricBlockEncryptFileContent( $this->dataShort, $this->randomKey );
-//             
-//             $this->assertNotEquals( $this->dataShort, $crypted );
-//             
-// 
-//             $decrypt = Encryption\Crypt::symmetricBlockDecryptFileContent( $crypted, $this->randomKey );
-// 
-//             $this->assertEquals( $this->dataShort, $decrypt );
-//             
-//     }
-//     
-//     function testSymmetricBlockEncryptLongFileContent() {
-//             
-//             $crypted = Encryption\Crypt::symmetricBlockEncryptFileContent( $this->dataLong, $this->randomKey );
-//             
-//             $this->assertNotEquals( $this->dataLong, $crypted );
-//             
-// 
-//             $decrypt = Encryption\Crypt::symmetricBlockDecryptFileContent( $crypted, $this->randomKey );
-// 
-//             $this->assertEquals( $this->dataLong, $decrypt );
-//             
-//     }
-       
-       function testSymmetricStreamEncryptShortFileContent() { 
-               
-               $filename = 'tmp-'.time();
-               
-               $cryptedFile = file_put_contents( 'crypt://' . $filename, $this->dataShort );
-               
-               // Test that data was successfully written
-               $this->assertTrue( is_int( $cryptedFile ) );
-               
-               
-               // Get file contents without using any wrapper to get it's actual contents on disk
-               $retreivedCryptedFile = $this->view->file_get_contents( $this->userId . '/files/' . $filename );
-               
-               // Check that the file was encrypted before being written to disk
-               $this->assertNotEquals( $this->dataShort, $retreivedCryptedFile );
-               
-               // Get private key
-               $encryptedPrivateKey = Encryption\Keymanager::getPrivateKey( $this->view, $this->userId );
-               
-               $decryptedPrivateKey = Encryption\Crypt::symmetricDecryptFileContent( $encryptedPrivateKey, $this->pass );
-               
-               
-               // Get keyfile
-               $encryptedKeyfile = Encryption\Keymanager::getFileKey( $this->view, $this->userId, $filename );
-               
-               $decryptedKeyfile = Encryption\Crypt::keyDecrypt( $encryptedKeyfile, $decryptedPrivateKey );
-               
-               
-               // Manually decrypt
-               $manualDecrypt = Encryption\Crypt::symmetricBlockDecryptFileContent( $retreivedCryptedFile, $decryptedKeyfile );
-               
-               // Check that decrypted data matches
-               $this->assertEquals( $this->dataShort, $manualDecrypt );
-               
-       }
-       
-       /**
-        * @brief Test that data that is written by the crypto stream wrapper
-        * @note Encrypted data is manually prepared and decrypted here to avoid dependency on success of stream_read
-        * @note If this test fails with truncate content, check that enough array slices are being rejoined to form $e, as the crypt.php file may have gotten longer and broken the manual 
-        * reassembly of its data
-        */
-       function testSymmetricStreamEncryptLongFileContent() {
-               
-               // Generate a a random filename
-               $filename = 'tmp-'.time();
-               
-               // Save long data as encrypted file using stream wrapper
-               $cryptedFile = file_put_contents( 'crypt://' . $filename, $this->dataLong.$this->dataLong );
-               
-               // Test that data was successfully written
-               $this->assertTrue( is_int( $cryptedFile ) );
-               
-               // Get file contents without using any wrapper to get it's actual contents on disk
-               $retreivedCryptedFile = $this->view->file_get_contents( $this->userId . '/files/' . $filename );
-               
-//             echo "\n\n\$retreivedCryptedFile = $retreivedCryptedFile\n\n";
-               
-               // Check that the file was encrypted before being written to disk
-               $this->assertNotEquals( $this->dataLong.$this->dataLong, $retreivedCryptedFile );
-               
-               // Manuallly split saved file into separate IVs and encrypted chunks
-               $r = preg_split('/(00iv00.{16,18})/', $retreivedCryptedFile, NULL, PREG_SPLIT_DELIM_CAPTURE);
-               
-               //print_r($r);
-               
-               // Join IVs and their respective data chunks
-               $e = array( $r[0].$r[1], $r[2].$r[3], $r[4].$r[5], $r[6].$r[7], $r[8].$r[9], $r[10].$r[11], $r[12].$r[13] );//.$r[11], $r[12].$r[13], $r[14] );
-               
-               //print_r($e);
-               
-               
-               // Get private key
-               $encryptedPrivateKey = Encryption\Keymanager::getPrivateKey( $this->view, $this->userId );
-               
-               $decryptedPrivateKey = Encryption\Crypt::symmetricDecryptFileContent( $encryptedPrivateKey, $this->pass );
-               
-               
-               // Get keyfile
-               $encryptedKeyfile = Encryption\Keymanager::getFileKey( $this->view, $this->userId, $filename );
-               
-               $decryptedKeyfile = Encryption\Crypt::keyDecrypt( $encryptedKeyfile, $decryptedPrivateKey );
-               
-               
-               // Set var for reassembling decrypted content
-               $decrypt = '';
-               
-               // Manually decrypt chunk
-               foreach ($e as $e) {
-               
-//                     echo "\n\$e = $e";
-                       
-                       $chunkDecrypt = Encryption\Crypt::symmetricDecryptFileContent( $e, $decryptedKeyfile );
-                       
-                       // Assemble decrypted chunks
-                       $decrypt .= $chunkDecrypt;
-                       
-//                     echo "\n\$chunkDecrypt = $chunkDecrypt";
-                       
-               }
-               
-//             echo "\n\$decrypt = $decrypt";
-               
-               $this->assertEquals( $this->dataLong.$this->dataLong, $decrypt );
-               
-               // Teardown
-               
-               $this->view->unlink( $filename );
-               
-               Encryption\Keymanager::deleteFileKey( $filename );
-               
-       }
-       
-       /**
-        * @brief Test that data that is read by the crypto stream wrapper
-        */
-       function testSymmetricStreamDecryptShortFileContent() {
-               
-               $filename = 'tmp-'.time();
-               
-               // Save long data as encrypted file using stream wrapper
-               $cryptedFile = file_put_contents( 'crypt://' . $filename, $this->dataShort );
-               
-               // Test that data was successfully written
-               $this->assertTrue( is_int( $cryptedFile ) );
-               
-               
-               // Get file contents without using any wrapper to get it's actual contents on disk
-               $retreivedCryptedFile = $this->view->file_get_contents( $this->userId . '/files/' . $filename );
-               
-               $decrypt = file_get_contents( 'crypt://' . $filename );
-               
-               $this->assertEquals( $this->dataShort, $decrypt );
-               
-       }
-       
-       function testSymmetricStreamDecryptLongFileContent() {
-               
-               $filename = 'tmp-'.time();
-               
-               // Save long data as encrypted file using stream wrapper
-               $cryptedFile = file_put_contents( 'crypt://' . $filename, $this->dataLong );
-               
-               // Test that data was successfully written
-               $this->assertTrue( is_int( $cryptedFile ) );
-               
-               
-               // Get file contents without using any wrapper to get it's actual contents on disk
-               $retreivedCryptedFile = $this->view->file_get_contents( $this->userId . '/files/' . $filename );
-               
-               $decrypt = file_get_contents( 'crypt://' . $filename );
-               
-               $this->assertEquals( $this->dataLong, $decrypt );
-               
-       }
-       
-       // Is this test still necessary?
-//     function testSymmetricBlockStreamDecryptFileContent() {
-//     
-//             \OC_User::setUserId( 'admin' );
-//             
-//             // Disable encryption proxy to prevent unwanted en/decryption
-//             \OC_FileProxy::$enabled = false;
-//             
-//             $cryptedFile = file_put_contents( 'crypt://' . '/blockEncrypt', $this->dataUrl );
-//             
-//             // Disable encryption proxy to prevent unwanted en/decryption
-//             \OC_FileProxy::$enabled = false;
-//             
-//             echo "\n\n\$cryptedFile = " . $this->view->file_get_contents( '/blockEncrypt' );
-//             
-//             $retreivedCryptedFile = file_get_contents( 'crypt://' . '/blockEncrypt' );
-//             
-//             $this->assertEquals( $this->dataUrl, $retreivedCryptedFile );
-//             
-//             \OC_FileProxy::$enabled = false;
-//             
-//     }
-
-       function testSymmetricEncryptFileContentKeyfile() {
-       
-               # TODO: search in keyfile for actual content as IV will ensure this test always passes
-       
-               $crypted = Encryption\Crypt::symmetricEncryptFileContentKeyfile( $this->dataUrl );
-               
-               $this->assertNotEquals( $this->dataUrl, $crypted['encrypted'] );
-               
-               
-               $decrypt = Encryption\Crypt::symmetricDecryptFileContent( $crypted['encrypted'], $crypted['key'] );
-               
-               $this->assertEquals( $this->dataUrl, $decrypt );
-       
-       }
-       
-       function testIsEncryptedContent() {
-               
-               $this->assertFalse( Encryption\Crypt::isCatfile( $this->dataUrl ) );
-               
-               $this->assertFalse( Encryption\Crypt::isCatfile( $this->legacyEncryptedData ) );
-               
-               $keyfileContent = Encryption\Crypt::symmetricEncryptFileContent( $this->dataUrl, 'hat' );
-
-               $this->assertTrue( Encryption\Crypt::isCatfile( $keyfileContent ) );
-               
-       }
-       
-       function testMultiKeyEncrypt() {
-               
-               # TODO: search in keyfile for actual content as IV will ensure this test always passes
-               
-               $pair1 = Encryption\Crypt::createKeypair();
-               
-               $this->assertEquals( 2, count( $pair1 ) );
-               
-               $this->assertTrue( strlen( $pair1['publicKey'] ) > 1 );
-               
-               $this->assertTrue( strlen( $pair1['privateKey'] ) > 1 );
-               
-
-               $crypted = Encryption\Crypt::multiKeyEncrypt( $this->dataUrl, array( $pair1['publicKey'] ) );
-               
-               $this->assertNotEquals( $this->dataUrl, $crypted['encrypted'] );
-               
-
-               $decrypt = Encryption\Crypt::multiKeyDecrypt( $crypted['encrypted'], $crypted['keys'][0], $pair1['privateKey'] );
-               
-               $this->assertEquals( $this->dataUrl, $decrypt );
-       
-       }
-       
-       function testKeyEncrypt() {
-               
-               // Generate keypair
-               $pair1 = Encryption\Crypt::createKeypair();
-               
-               // Encrypt data
-               $crypted = Encryption\Crypt::keyEncrypt( $this->dataUrl, $pair1['publicKey'] );
-               
-               $this->assertNotEquals( $this->dataUrl, $crypted );
-               
-               // Decrypt data
-               $decrypt = Encryption\Crypt::keyDecrypt( $crypted, $pair1['privateKey'] );
-               
-               $this->assertEquals( $this->dataUrl, $decrypt );
-       
-       }
-       
-       // What is the point of this test? It doesn't use keyEncryptKeyfile()
-       function testKeyEncryptKeyfile() {
-       
-               # TODO: Don't repeat encryption from previous tests, use PHPUnit test interdependency instead
-               
-               // Generate keypair
-               $pair1 = Encryption\Crypt::createKeypair();
-               
-               // Encrypt plain data, generate keyfile & encrypted file
-               $cryptedData = Encryption\Crypt::symmetricEncryptFileContentKeyfile( $this->dataUrl );
-               
-               // Encrypt keyfile
-               $cryptedKey = Encryption\Crypt::keyEncrypt( $cryptedData['key'], $pair1['publicKey'] );
-               
-               // Decrypt keyfile
-               $decryptKey = Encryption\Crypt::keyDecrypt( $cryptedKey, $pair1['privateKey'] );
-               
-               // Decrypt encrypted file
-               $decryptData = Encryption\Crypt::symmetricDecryptFileContent( $cryptedData['encrypted'], $decryptKey );
-               
-               $this->assertEquals( $this->dataUrl, $decryptData );
-       
-       }
-       
-       /**
-        * @brief test functionality of keyEncryptKeyfile() and 
-        * keyDecryptKeyfile()
-        */
-       function testKeyDecryptKeyfile() {
-               
-               $encrypted = Encryption\Crypt::keyEncryptKeyfile( $this->dataShort, $this->genPublicKey );
-               
-               $this->assertNotEquals( $encrypted['data'], $this->dataShort );
-               
-               $decrypted = Encryption\Crypt::keyDecryptKeyfile( $encrypted['data'], $encrypted['key'], $this->genPrivateKey );
-               
-               $this->assertEquals( $decrypted, $this->dataShort );
-               
-       }
-
-       
-       /**
-        * @brief test encryption using legacy blowfish method
-        */
-       function testLegacyEncryptShort() {
-       
-               $crypted = Encryption\Crypt::legacyEncrypt( $this->dataShort, $this->pass );
-
-               $this->assertNotEquals( $this->dataShort, $crypted );
-               
-               # TODO: search inencrypted text for actual content to ensure it
-               # genuine transformation
-               
-               return $crypted;
-               
-       }
-       
-       /**
-        * @brief test decryption using legacy blowfish method
-        * @depends testLegacyEncryptShort
-        */
-       function testLegacyDecryptShort( $crypted ) {
-       
-               $decrypted = Encryption\Crypt::legacyDecrypt( $crypted, $this->pass );
-               
-               $this->assertEquals( $this->dataShort, $decrypted );
-               
-       }
-
-       /**
-        * @brief test encryption using legacy blowfish method
-        */
-       function testLegacyEncryptLong() {
-       
-               $crypted = Encryption\Crypt::legacyEncrypt( $this->dataLong, $this->pass );
-
-               $this->assertNotEquals( $this->dataLong, $crypted );
-               
-               # TODO: search inencrypted text for actual content to ensure it
-               # genuine transformation
-               
-               return $crypted;
-               
-       }
-       
-       /**
-        * @brief test decryption using legacy blowfish method
-        * @depends testLegacyEncryptLong
-        */
-       function testLegacyDecryptLong( $crypted ) {
-       
-               $decrypted = Encryption\Crypt::legacyDecrypt( $crypted, $this->pass );
-               
-               $this->assertEquals( $this->dataLong, $decrypted );
-               
-       }
-       
-       /**
-        * @brief test generation of legacy encryption key
-        * @depends testLegacyDecryptShort
-        */
-       function testLegacyCreateKey() {
-       
-               // Create encrypted key
-               $encKey = Encryption\Crypt::legacyCreateKey( $this->pass );
-               
-               // Decrypt key
-               $key = Encryption\Crypt::legacyDecrypt( $encKey, $this->pass );
-               
-               $this->assertTrue( is_numeric( $key ) );
-               
-               // Check that key is correct length
-               $this->assertEquals( 20, strlen( $key ) );
-               
-       }
-
-       /**
-        * @brief test decryption using legacy blowfish method
-        * @depends testLegacyEncryptLong
-        */
-       function testLegacyKeyRecryptKeyfileEncrypt( $crypted ) {
-       
-               $recrypted = Encryption\Crypt::LegacyKeyRecryptKeyfile( $crypted, $this->pass, $this->genPublicKey, $this->pass );
-               
-               $this->assertNotEquals( $this->dataLong, $recrypted['data'] );
-               
-               return $recrypted;
-               
-               # TODO: search inencrypted text for actual content to ensure it
-               # genuine transformation
-               
-       }
-
-//     function testEncryption(){
-//     
-//             $key=uniqid();
-//             $file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
-//             $source=file_get_contents($file); //nice large text file
-//             $encrypted=OC_Encryption\Crypt::encrypt($source,$key);
-//             $decrypted=OC_Encryption\Crypt::decrypt($encrypted,$key);
-//             $decrypted=rtrim($decrypted, "\0");
-//             $this->assertNotEquals($encrypted,$source);
-//             $this->assertEquals($decrypted,$source);
-// 
-//             $chunk=substr($source,0,8192);
-//             $encrypted=OC_Encryption\Crypt::encrypt($chunk,$key);
-//             $this->assertEquals(strlen($chunk),strlen($encrypted));
-//             $decrypted=OC_Encryption\Crypt::decrypt($encrypted,$key);
-//             $decrypted=rtrim($decrypted, "\0");
-//             $this->assertEquals($decrypted,$chunk);
-//             
-//             $encrypted=OC_Encryption\Crypt::blockEncrypt($source,$key);
-//             $decrypted=OC_Encryption\Crypt::blockDecrypt($encrypted,$key);
-//             $this->assertNotEquals($encrypted,$source);
-//             $this->assertEquals($decrypted,$source);
-// 
-//             $tmpFileEncrypted=OCP\Files::tmpFile();
-//             OC_Encryption\Crypt::encryptfile($file,$tmpFileEncrypted,$key);
-//             $encrypted=file_get_contents($tmpFileEncrypted);
-//             $decrypted=OC_Encryption\Crypt::blockDecrypt($encrypted,$key);
-//             $this->assertNotEquals($encrypted,$source);
-//             $this->assertEquals($decrypted,$source);
-// 
-//             $tmpFileDecrypted=OCP\Files::tmpFile();
-//             OC_Encryption\Crypt::decryptfile($tmpFileEncrypted,$tmpFileDecrypted,$key);
-//             $decrypted=file_get_contents($tmpFileDecrypted);
-//             $this->assertEquals($decrypted,$source);
-// 
-//             $file=OC::$SERVERROOT.'/core/img/weather-clear.png';
-//             $source=file_get_contents($file); //binary file
-//             $encrypted=OC_Encryption\Crypt::encrypt($source,$key);
-//             $decrypted=OC_Encryption\Crypt::decrypt($encrypted,$key);
-//             $decrypted=rtrim($decrypted, "\0");
-//             $this->assertEquals($decrypted,$source);
-// 
-//             $encrypted=OC_Encryption\Crypt::blockEncrypt($source,$key);
-//             $decrypted=OC_Encryption\Crypt::blockDecrypt($encrypted,$key);
-//             $this->assertEquals($decrypted,$source);
-// 
-//     }
-// 
-//     function testBinary(){
-//             $key=uniqid();
-//     
-//             $file=__DIR__.'/binary';
-//             $source=file_get_contents($file); //binary file
-//             $encrypted=OC_Encryption\Crypt::encrypt($source,$key);
-//             $decrypted=OC_Encryption\Crypt::decrypt($encrypted,$key);
-// 
-//             $decrypted=rtrim($decrypted, "\0");
-//             $this->assertEquals($decrypted,$source);
-// 
-//             $encrypted=OC_Encryption\Crypt::blockEncrypt($source,$key);
-//             $decrypted=OC_Encryption\Crypt::blockDecrypt($encrypted,$key,strlen($source));
-//             $this->assertEquals($decrypted,$source);
-//     }
-       
-}
diff --git a/apps/files_encryption/test/keymanager.php b/apps/files_encryption/test/keymanager.php
deleted file mode 100644 (file)
index bf453fe..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012 Sam Tuke <samtuke@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-//require_once "PHPUnit/Framework/TestCase.php";
-require_once realpath( dirname(__FILE__).'/../../../lib/base.php' );
-require_once realpath( dirname(__FILE__).'/../lib/crypt.php' );
-require_once realpath( dirname(__FILE__).'/../lib/keymanager.php' );
-require_once realpath( dirname(__FILE__).'/../lib/proxy.php' );
-require_once realpath( dirname(__FILE__).'/../lib/stream.php' );
-require_once realpath( dirname(__FILE__).'/../lib/util.php' );
-require_once realpath( dirname(__FILE__).'/../appinfo/app.php' );
-
-use OCA\Encryption;
-
-// This has to go here because otherwise session errors arise, and the private 
-// encryption key needs to be saved in the session
-\OC_User::login( 'admin', 'admin' );
-
-class Test_Keymanager extends \PHPUnit_Framework_TestCase {
-       
-       function setUp() {
-               
-               \OC_FileProxy::$enabled = false;
-               
-               // set content for encrypting / decrypting in tests
-               $this->dataLong = file_get_contents( realpath( dirname(__FILE__).'/../lib/crypt.php' ) );
-               $this->dataShort = 'hats';
-               $this->dataUrl = realpath( dirname(__FILE__).'/../lib/crypt.php' );
-               $this->legacyData = realpath( dirname(__FILE__).'/legacy-text.txt' );
-               $this->legacyEncryptedData = realpath( dirname(__FILE__).'/legacy-encrypted-text.txt' );
-               $this->randomKey = Encryption\Crypt::generateKey();
-               
-               $keypair = Encryption\Crypt::createKeypair();
-               $this->genPublicKey =  $keypair['publicKey'];
-               $this->genPrivateKey = $keypair['privateKey'];
-               
-               $this->view = new \OC_FilesystemView( '/' );
-               
-               \OC_User::setUserId( 'admin' );
-               $this->userId = 'admin';
-               $this->pass = 'admin';
-               
-               \OC_Filesystem::init( '/' );
-               \OC_Filesystem::mount( 'OC_Filestorage_Local', array('datadir' => \OC_User::getHome($this->userId)), '/' );
-       
-       }
-       
-       function tearDown(){
-       
-               \OC_FileProxy::$enabled = true;
-               
-       }
-
-       function testGetPrivateKey() {
-       
-               $key = Encryption\Keymanager::getPrivateKey( $this->view, $this->userId );
-                
-               // Will this length vary? Perhaps we should use a range instead
-               $this->assertEquals( 2296, strlen( $key ) );
-       
-       }
-       
-       function testGetPublicKey() {
-
-               $key = Encryption\Keymanager::getPublicKey( $this->view, $this->userId );
-               
-               $this->assertEquals( 451, strlen( $key ) );
-               
-               $this->assertEquals( '-----BEGIN PUBLIC KEY-----', substr( $key, 0, 26 ) );
-       }
-       
-       function testSetFileKey() {
-       
-               # NOTE: This cannot be tested until we are able to break out 
-               # of the FileSystemView data directory root
-       
-               $key = Encryption\Crypt::symmetricEncryptFileContentKeyfile( $this->randomKey, 'hat' );
-               
-               $path = 'unittest-'.time().'txt';
-               
-               //$view = new \OC_FilesystemView( '/' . $this->userId . '/files_encryption/keyfiles' );
-               
-               Encryption\Keymanager::setFileKey( $this->view, $path, $this->userId, $key['key'] );
-       
-       }
-       
-//     /**
-//      * @depends testGetPrivateKey
-//      */
-//     function testGetPrivateKey_decrypt() {
-//     
-//             $key = Encryption\Keymanager::getPrivateKey( $this->view, $this->userId );
-//             
-//             # TODO: replace call to Crypt with a mock object?
-//             $decrypted = Encryption\Crypt::symmetricDecryptFileContent( $key, $this->passphrase );
-//             
-//             $this->assertEquals( 1704, strlen( $decrypted ) );
-//             
-//             $this->assertEquals( '-----BEGIN PRIVATE KEY-----', substr( $decrypted, 0, 27 ) );
-//     
-//     }
-       
-       function testGetUserKeys() {
-       
-               $keys = Encryption\Keymanager::getUserKeys( $this->view, $this->userId );
-               
-               $this->assertEquals( 451, strlen( $keys['publicKey'] ) );
-               $this->assertEquals( '-----BEGIN PUBLIC KEY-----', substr( $keys['publicKey'], 0, 26 ) );
-               $this->assertEquals( 2296, strlen( $keys['privateKey'] ) );
-       
-       }
-       
-       function testGetPublicKeys() {
-               
-               # TODO: write me
-               
-       }
-       
-       function testGetFileKey() {
-       
-//             Encryption\Keymanager::getFileKey( $this->view, $this->userId, $this->filePath );
-       
-       }
-       
-}
diff --git a/apps/files_encryption/test/legacy-encrypted-text.txt b/apps/files_encryption/test/legacy-encrypted-text.txt
deleted file mode 100644 (file)
index cb5bf50..0000000
Binary files a/apps/files_encryption/test/legacy-encrypted-text.txt and /dev/null differ
diff --git a/apps/files_encryption/test/proxy.php b/apps/files_encryption/test/proxy.php
deleted file mode 100644 (file)
index 709730f..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012 Sam Tuke <samtuke@owncloud.com>, 
- * and Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-// require_once "PHPUnit/Framework/TestCase.php";
-// require_once realpath( dirname(__FILE__).'/../../../lib/base.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery/Generator.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery/MockInterface.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery/Mock.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery/Container.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery/Configuration.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery/CompositeExpectation.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery/ExpectationDirector.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery/Expectation.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery/Exception.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery/CountValidator/CountValidatorAbstract.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery/CountValidator/Exception.php' );
-// require_once realpath( dirname(__FILE__).'/../../../3rdparty/mockery/Mockery/CountValidator/Exact.php' );
-// 
-// use \Mockery as m;
-// use OCA\Encryption;
-
-// class Test_Util extends \PHPUnit_Framework_TestCase {
-// 
-//     public function setUp() {
-//     
-//             $this->proxy = new Encryption\Proxy();
-//             
-//             $this->tmpFileName = "tmpFile-".time();
-//             
-//             $this->privateKey = file_get_contents( realpath( dirname(__FILE__).'/data/admin.public.key' ) );
-//             $this->publicKey = file_get_contents( realpath( dirname(__FILE__).'/data/admin.private.key' ) );
-//             $this->encDataShort = file_get_contents( realpath( dirname(__FILE__).'/data/yoga-manchester-enc' ) );
-//             $this->encDataShortKey = file_get_contents( realpath( dirname(__FILE__).'/data/yoga-manchester.key' ) );
-//             
-//             $this->dataShort = file_get_contents( realpath( dirname(__FILE__).'/data/yoga-manchester' ) );
-//             $this->dataLong = file_get_contents( realpath( dirname(__FILE__).'/../lib/crypt.php' ) );
-//             $this->longDataPath = realpath( dirname(__FILE__).'/../lib/crypt.php' );
-//             
-//             $this->data1 = file_get_contents( realpath( dirname(__FILE__).'/../../../data/admin/files/enc-test.txt' ) );
-//             
-//             \OC_FileProxy::$enabled = false;
-//             $this->Encdata1 = file_get_contents( realpath( dirname(__FILE__).'/../../../data/admin/files/enc-test.txt' ) );
-//             \OC_FileProxy::$enabled = true;
-//             
-//             $this->userId = 'admin';
-//             $this->pass = 'admin';
-//             
-//             $this->session = new Encryption\Session();
-//             
-// $this->session->setPrivateKey( 
-// '-----BEGIN PRIVATE KEY-----
-// MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDiH3EA4EpFA7Fx
-// s2dyyfL5jwXeYXrTqQJ6DqKgGn8VsbT3eu8R9KzM2XitVwZe8c8L52DvJ06o5vg0
-// GqPYxilFdOFJe/ggac5Tq8UmJiZS4EqYEMwxBIfIyWTxeGV06/0HOwnVAkqHMcBz
-// 64qldtgi5O8kZMEM2/gKBgU0kMLJzM+8oEWhL1+gsUWQhxd8cKLXypS6iWgqFJrz
-// f/X0hJsJR+gyYxNpahtnjzd/LxLAETrOMsl2tue+BAxmjbAM0aG0NEM0div+b59s
-// 2uz/iWbxImp5pOdYVKcVW89D4XBMyGegR40trV2VwiuX1blKCfdjMsJhiaL9pymp
-// ug1wzyQFAgMBAAECggEAK6c+PZkPPXuVCgpEcliiW6NM0r2m5K3AGKgypQ34csu3
-// z/8foCvIIFPrhCtEw5eTDQ1CHWlNOjY8vHJYJ0U6Onpx86nHIRrMBkMm8FJ1G5LJ
-// U8oKYXwqaozWu/cuPwA//OFc6I5krOzh5n8WaRMkbrgbor8AtebRX74By0AXGrXe
-// cswJI7zR96oFn4Dm7Pgvpg5Zhk1vFJ+w6QtH+4DDJ6PBvlZsRkGxYBLGVd/3qhAI
-// sBAyjFlSzuP4eCRhHOhHC/e4gmAH9evFVXB88jFyRZm3K+jQ5W5CwrVRBCV2lph6
-// 2B6P7CBJN+IjGKMhy+75y13UvvKPv9IwH8Fzl2x1gQKBgQD8qQOr7a6KhSj16wQE
-// jim2xqt9gQ2jH5No405NrKs/PFQQZnzD4YseQsiK//NUjOJiUhaT+L5jhIpzINHt
-// RJpt3bGkEZmLyjdjgTpB3GwZdXa28DNK9VdXZ19qIl/ZH0qAjKmJCRahUDASMnVi
-// M4Pkk9yx9ZIKkri4TcuMWqc0DQKBgQDlHKBTITZq/arYPD6Nl3NsoOdqVRqJrGay
-// 0TjXAVbBXe46+z5lnMsqwXb79nx14hdmSEsZULrw/3f+MnQbdjMTYLFP24visZg9
-// MN8vAiALiiiR1a+Crz+DTA1Q8sGOMVCMqMDmD7QBys3ZuWxuapm0txAiIYUtsjJZ
-// XN76T4nZ2QKBgQCHaT3igzwsWTmesxowJtEMeGWomeXpKx8h89EfqA8PkRGsyIDN
-// qq+YxEoe1RZgljEuaLhZDdNcGsjo8woPk9kAUPTH7fbRCMuutK+4ZJ469s1tNkcH
-// QX5SBcEJbOrZvv967ehe3VQXmJZq6kgnHVzuwKBjcC2ZJRGDFY6l5l/+cQKBgCqh
-// +Adf/8NK7paMJ0urqfPFwSodKfICXZ3apswDWMRkmSbqh4La+Uc8dsqN5Dz/VEFZ
-// JHhSeGbN8uMfOlG93eU2MehdPxtw1pZUWMNjjtj23XO9ooob2CKzbSrp8TBnZsi1
-// widNNr66oTFpeo7VUUK6acsgF6sYJJxSVr+XO1yJAoGAEhvitq8shNKcEY0xCipS
-// k1kbgyS7KKB7opVxI5+ChEqyUDijS3Y9FZixrRIWE6i2uGu86UG+v2lbKvSbM4Qm
-// xvbOcX9OVMnlRb7n8woOP10UMY+ZE2x+YEUXQTLtPYq7F66e1OfxltstMxLQA+3d
-// Y1d5piFV8PXK3Fg2F+Cj5qg=
-// -----END PRIVATE KEY-----
-// '
-// , $this->userId 
-// );
-//             
-//             \OC_User::setUserId( $this->userId );
-//             
-//     }
-// 
-//     public function testpreFile_get_contents() {
-//     
-//             // This won't work for now because mocking of the static keymanager class isn't working :(
-//     
-// //          $mock = m::mock( 'alias:OCA\Encryption\Keymanager' );
-// //          
-// //          $mock->shouldReceive( 'getFileKey' )->times(2)->andReturn( $this->encDataShort );
-// //  
-// //          $encrypted = $this->proxy->postFile_get_contents( 'data/'.$this->tmpFileName, $this->encDataShortKey );
-// //          
-// //          $this->assertNotEquals( $this->dataShort, $encrypted );
-// 
-//             $decrypted = $this->proxy->postFile_get_contents( 'data/admin/files/enc-test.txt', $this->data1 );
-//             
-//     }
-// 
-// }
-
-// class Test_CryptProxy extends PHPUnit_Framework_TestCase {
-//     private $oldConfig;
-//     private $oldKey;
-//     
-//     public function setUp(){
-//             $user=OC_User::getUser();
-// 
-//             $this->oldConfig=OCP\Config::getAppValue('files_encryption','enable_encryption','true');
-//             OCP\Config::setAppValue('files_encryption','enable_encryption','true');
-//             $this->oldKey=isset($_SESSION['privateKey'])?$_SESSION['privateKey']:null;
-//     
-//             
-//             //set testing key
-//             $_SESSION['privateKey']=md5(time());
-//     
-//             //clear all proxies and hooks so we can do clean testing
-//             OC_FileProxy::clearProxies();
-//             OC_Hook::clear('OC_Filesystem');
-// 
-//             //enable only the encryption hook
-//             OC_FileProxy::register(new OC_FileProxy_Encryption());
-// 
-//             //set up temporary storage
-//             OC_Filesystem::clearMounts();
-//             OC_Filesystem::mount('OC_Filestorage_Temporary',array(),'/');
-// 
-//             OC_Filesystem::init('/'.$user.'/files');
-// 
-//             //set up the users home folder in the temp storage
-//             $rootView=new OC_FilesystemView('');
-//             $rootView->mkdir('/'.$user);
-//             $rootView->mkdir('/'.$user.'/files');
-//     }
-// 
-//     public function tearDown(){
-//             OCP\Config::setAppValue('files_encryption','enable_encryption',$this->oldConfig);
-//             if(!is_null($this->oldKey)){
-//                     $_SESSION['privateKey']=$this->oldKey;
-//             }
-//     }
-// 
-//     public function testSimple(){
-//             $file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
-//             $original=file_get_contents($file);
-// 
-//             OC_Filesystem::file_put_contents('/file',$original);
-//             
-//             OC_FileProxy::$enabled=false;
-//             $stored=OC_Filesystem::file_get_contents('/file');
-//             OC_FileProxy::$enabled=true;
-//             
-//             $fromFile=OC_Filesystem::file_get_contents('/file');
-//             $this->assertNotEquals($original,$stored);
-//             $this->assertEquals(strlen($original),strlen($fromFile));
-//             $this->assertEquals($original,$fromFile);
-// 
-//     }
-// 
-//     public function testView(){
-//             $file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
-//             $original=file_get_contents($file);
-// 
-//             $rootView=new OC_FilesystemView('');
-//             $view=new OC_FilesystemView('/'.OC_User::getUser());
-//             $userDir='/'.OC_User::getUser().'/files';
-// 
-//             $rootView->file_put_contents($userDir.'/file',$original);
-// 
-//             OC_FileProxy::$enabled=false;
-//             $stored=$rootView->file_get_contents($userDir.'/file');
-//             OC_FileProxy::$enabled=true;
-// 
-//             $this->assertNotEquals($original,$stored);
-//             $fromFile=$rootView->file_get_contents($userDir.'/file');
-//             $this->assertEquals($original,$fromFile);
-// 
-//             $fromFile=$view->file_get_contents('files/file');
-//             $this->assertEquals($original,$fromFile);
-//     }
-// 
-//     public function testBinary(){
-//             $file=__DIR__.'/binary';
-//             $original=file_get_contents($file);
-// 
-//             OC_Filesystem::file_put_contents('/file',$original);
-// 
-//             OC_FileProxy::$enabled=false;
-//             $stored=OC_Filesystem::file_get_contents('/file');
-//             OC_FileProxy::$enabled=true;
-// 
-//             $fromFile=OC_Filesystem::file_get_contents('/file');
-//             $this->assertNotEquals($original,$stored);
-//             $this->assertEquals(strlen($original),strlen($fromFile));
-//             $this->assertEquals($original,$fromFile);
-// 
-//             $file=__DIR__.'/zeros';
-//             $original=file_get_contents($file);
-// 
-//             OC_Filesystem::file_put_contents('/file',$original);
-// 
-//             OC_FileProxy::$enabled=false;
-//             $stored=OC_Filesystem::file_get_contents('/file');
-//             OC_FileProxy::$enabled=true;
-// 
-//             $fromFile=OC_Filesystem::file_get_contents('/file');
-//             $this->assertNotEquals($original,$stored);
-//             $this->assertEquals(strlen($original),strlen($fromFile));
-//     }
-// }
diff --git a/apps/files_encryption/test/stream.php b/apps/files_encryption/test/stream.php
deleted file mode 100644 (file)
index ba82ac8..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
-// <?php
-// /**
-//  * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
-//  * This file is licensed under the Affero General Public License version 3 or
-//  * later.
-//  * See the COPYING-README file.
-//  */
-//  
-// namespace OCA\Encryption;
-// 
-// class Test_Stream extends \PHPUnit_Framework_TestCase {
-// 
-//     function setUp() {
-//     
-//             \OC_Filesystem::mount( 'OC_Filestorage_Local', array(), '/' );
-//     
-//             $this->empty = '';
-//     
-//             $this->stream = new Stream();
-//             
-//             $this->dataLong = file_get_contents( realpath( dirname(__FILE__).'/../lib/crypt.php' ) );
-//             $this->dataShort = 'hats';
-//             
-//             $this->emptyTmpFilePath = \OCP\Files::tmpFile();
-//             
-//             $this->dataTmpFilePath = \OCP\Files::tmpFile();
-//             
-//             file_put_contents( $this->dataTmpFilePath, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est." );
-//     
-//     }
-//     
-//     function testStreamOpen() {
-//             
-//             $stream1 = new Stream();
-//             
-//             $handle1 = $stream1->stream_open( $this->emptyTmpFilePath, 'wb', array(), $this->empty );
-//             
-//             // Test that resource was returned successfully
-//             $this->assertTrue( $handle1 );
-//             
-//             // Test that file has correct size
-//             $this->assertEquals( 0, $stream1->size );
-//             
-//             // Test that path is correct
-//             $this->assertEquals( $this->emptyTmpFilePath, $stream1->rawPath );
-//             
-//             $stream2 = new Stream();
-//             
-//             $handle2 = $stream2->stream_open( 'crypt://' . $this->emptyTmpFilePath, 'wb', array(), $this->empty );
-//             
-//             // Test that protocol identifier is removed from path
-//             $this->assertEquals( $this->emptyTmpFilePath, $stream2->rawPath );
-// 
-//             // "Stat failed error" prevents this test from executing
-// //          $stream3 = new Stream();
-// //          
-// //          $handle3 = $stream3->stream_open( $this->dataTmpFilePath, 'r', array(), $this->empty );
-// //          
-// //          $this->assertEquals( 0, $stream3->size );
-//     
-//     }
-//     
-//     function testStreamWrite() {
-//             
-//             $stream1 = new Stream();
-//             
-//             $handle1 = $stream1->stream_open( $this->emptyTmpFilePath, 'r+b', array(), $this->empty );
-//             
-//             # what about the keymanager? there is no key for the newly created temporary file!
-//             
-//             $stream1->stream_write( $this->dataShort );
-//     
-//     }
-// 
-// //  function getStream( $id, $mode, $size ) {
-// //  
-// //          if ( $id === '' ) {
-// //                  
-// //                  $id = uniqid();
-// //          }
-// //          
-// //          
-// //          if ( !isset( $this->tmpFiles[$id] ) ) {
-// //          
-// //                  // If tempfile with given name does not already exist, create it
-// //                  
-// //                  $file = OCP\Files::tmpFile();
-// //                  
-// //                  $this->tmpFiles[$id] = $file;
-// //          
-// //          } else {
-// //          
-// //                  $file = $this->tmpFiles[$id];
-// //          
-// //          }
-// //          
-// //          $stream = fopen( $file, $mode );
-// //          
-// //          Stream::$sourceStreams[$id] = array( 'path' => 'dummy' . $id, 'stream' => $stream, 'size' => $size );
-// //          
-// //          return fopen( 'crypt://streams/'.$id, $mode );
-// //  
-// //  }
-// // 
-// //  function testStream(  ){
-// // 
-// //          $stream = $this->getStream( 'test1', 'w', strlen( 'foobar' ) );
-// // 
-// //          fwrite( $stream, 'foobar' );
-// // 
-// //          fclose( $stream );
-// // 
-// // 
-// //          $stream = $this->getStream( 'test1', 'r', strlen( 'foobar' ) );
-// // 
-// //          $data = fread( $stream, 6 );
-// // 
-// //          fclose( $stream );
-// // 
-// //          $this->assertEquals( 'foobar', $data );
-// // 
-// // 
-// //          $file = OC::$SERVERROOT.'/3rdparty/MDB2.php';
-// // 
-// //          $source = fopen( $file, 'r' );
-// // 
-// //          $target = $this->getStream( 'test2', 'w', 0 );
-// // 
-// //          OCP\Files::streamCopy( $source, $target );
-// // 
-// //          fclose( $target );
-// // 
-// //          fclose( $source );
-// // 
-// // 
-// //          $stream = $this->getStream( 'test2', 'r', filesize( $file ) );
-// // 
-// //          $data = stream_get_contents( $stream );
-// // 
-// //          $original = file_get_contents( $file );
-// // 
-// //          $this->assertEquals( strlen( $original ), strlen( $data ) );
-// // 
-// //          $this->assertEquals( $original, $data );
-// // 
-// //  }
-// 
-// }
-// 
-// // class Test_CryptStream extends PHPUnit_Framework_TestCase {
-// //  private $tmpFiles=array();
-// //  
-// //  function testStream(){
-// //          $stream=$this->getStream('test1','w',strlen('foobar'));
-// //          fwrite($stream,'foobar');
-// //          fclose($stream);
-// // 
-// //          $stream=$this->getStream('test1','r',strlen('foobar'));
-// //          $data=fread($stream,6);
-// //          fclose($stream);
-// //          $this->assertEquals('foobar',$data);
-// // 
-// //          $file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
-// //          $source=fopen($file,'r');
-// //          $target=$this->getStream('test2','w',0);
-// //          OCP\Files::streamCopy($source,$target);
-// //          fclose($target);
-// //          fclose($source);
-// // 
-// //          $stream=$this->getStream('test2','r',filesize($file));
-// //          $data=stream_get_contents($stream);
-// //          $original=file_get_contents($file);
-// //          $this->assertEquals(strlen($original),strlen($data));
-// //          $this->assertEquals($original,$data);
-// //  }
-// // 
-// //  /**
-// //   * get a cryptstream to a temporary file
-// //   * @param string $id
-// //   * @param string $mode
-// //   * @param int size
-// //   * @return resource
-// //   */
-// //  function getStream($id,$mode,$size){
-// //          if($id===''){
-// //                  $id=uniqid();
-// //          }
-// //          if(!isset($this->tmpFiles[$id])){
-// //                  $file=OCP\Files::tmpFile();
-// //                  $this->tmpFiles[$id]=$file;
-// //          }else{
-// //                  $file=$this->tmpFiles[$id];
-// //          }
-// //          $stream=fopen($file,$mode);
-// //          OC_CryptStream::$sourceStreams[$id]=array('path'=>'dummy'.$id,'stream'=>$stream,'size'=>$size);
-// //          return fopen('crypt://streams/'.$id,$mode);
-// //  }
-// // 
-// //  function testBinary(){
-// //          $file=__DIR__.'/binary';
-// //          $source=file_get_contents($file);
-// // 
-// //          $stream=$this->getStream('test','w',strlen($source));
-// //          fwrite($stream,$source);
-// //          fclose($stream);
-// // 
-// //          $stream=$this->getStream('test','r',strlen($source));
-// //          $data=stream_get_contents($stream);
-// //          fclose($stream);
-// //          $this->assertEquals(strlen($data),strlen($source));
-// //          $this->assertEquals($source,$data);
-// // 
-// //          $file=__DIR__.'/zeros';
-// //          $source=file_get_contents($file);
-// // 
-// //          $stream=$this->getStream('test2','w',strlen($source));
-// //          fwrite($stream,$source);
-// //          fclose($stream);
-// // 
-// //          $stream=$this->getStream('test2','r',strlen($source));
-// //          $data=stream_get_contents($stream);
-// //          fclose($stream);
-// //          $this->assertEquals(strlen($data),strlen($source));
-// //          $this->assertEquals($source,$data);
-// //  }
-// // }
diff --git a/apps/files_encryption/test/util.php b/apps/files_encryption/test/util.php
deleted file mode 100755 (executable)
index 1cdeff8..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012 Sam Tuke <samtuke@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-//require_once "PHPUnit/Framework/TestCase.php";
-require_once realpath( dirname(__FILE__).'/../../../lib/base.php' );
-require_once realpath( dirname(__FILE__).'/../lib/crypt.php' );
-require_once realpath( dirname(__FILE__).'/../lib/keymanager.php' );
-require_once realpath( dirname(__FILE__).'/../lib/proxy.php' );
-require_once realpath( dirname(__FILE__).'/../lib/stream.php' );
-require_once realpath( dirname(__FILE__).'/../lib/util.php' );
-require_once realpath( dirname(__FILE__).'/../appinfo/app.php' );
-
-// Load mockery files
-require_once 'Mockery/Loader.php';
-require_once 'Hamcrest/Hamcrest.php';
-$loader = new \Mockery\Loader;
-$loader->register();
-
-use \Mockery as m;
-use OCA\Encryption;
-
-class Test_Enc_Util extends \PHPUnit_Framework_TestCase {
-       
-       function setUp() {
-       
-               \OC_Filesystem::mount( 'OC_Filestorage_Local', array(), '/' );
-               
-               // set content for encrypting / decrypting in tests
-               $this->dataUrl = realpath( dirname(__FILE__).'/../lib/crypt.php' );
-               $this->dataShort = 'hats';
-               $this->dataLong = file_get_contents( realpath( dirname(__FILE__).'/../lib/crypt.php' ) );
-               $this->legacyData = realpath( dirname(__FILE__).'/legacy-text.txt' );
-               $this->legacyEncryptedData = realpath( dirname(__FILE__).'/legacy-encrypted-text.txt' );
-               
-               $this->userId = 'admin';
-               $this->pass = 'admin';
-               
-               $keypair = Encryption\Crypt::createKeypair();
-               
-               $this->genPublicKey =  $keypair['publicKey'];
-               $this->genPrivateKey = $keypair['privateKey'];
-               
-               $this->publicKeyDir =  '/' . 'public-keys';
-               $this->encryptionDir =  '/' . $this->userId . '/' . 'files_encryption';
-               $this->keyfilesPath = $this->encryptionDir . '/' . 'keyfiles';
-               $this->publicKeyPath = $this->publicKeyDir . '/' . $this->userId . '.public.key'; // e.g. data/public-keys/admin.public.key
-               $this->privateKeyPath = $this->encryptionDir . '/' . $this->userId . '.private.key'; // e.g. data/admin/admin.private.key
-               
-               $this->view = new \OC_FilesystemView( '/' );
-               
-               $this->mockView = m::mock('OC_FilesystemView');
-               $this->util = new Encryption\Util( $this->mockView, $this->userId );
-       
-       }
-       
-       function tearDown(){
-       
-               m::close();
-       
-       }
-       
-       /**
-        * @brief test that paths set during User construction are correct
-        */
-       function testKeyPaths() {
-       
-               $mockView = m::mock('OC_FilesystemView');
-               
-               $util = new Encryption\Util( $mockView, $this->userId );
-               
-               $this->assertEquals( $this->publicKeyDir, $util->getPath( 'publicKeyDir' ) );
-               $this->assertEquals( $this->encryptionDir, $util->getPath( 'encryptionDir' ) );
-               $this->assertEquals( $this->keyfilesPath, $util->getPath( 'keyfilesPath' ) );
-               $this->assertEquals( $this->publicKeyPath, $util->getPath( 'publicKeyPath' ) );
-               $this->assertEquals( $this->privateKeyPath, $util->getPath( 'privateKeyPath' ) );
-       
-       }
-       
-       /**
-        * @brief test setup of encryption directories when they don't yet exist
-        */
-       function testSetupServerSideNotSetup() {
-       
-               $mockView = m::mock('OC_FilesystemView');
-               
-               $mockView->shouldReceive( 'file_exists' )->times(5)->andReturn( false );
-               $mockView->shouldReceive( 'mkdir' )->times(4)->andReturn( true );
-               $mockView->shouldReceive( 'file_put_contents' )->withAnyArgs();
-               
-               $util = new Encryption\Util( $mockView, $this->userId );
-               
-               $this->assertEquals( true, $util->setupServerSide( $this->pass ) );
-       
-       }
-       
-       /**
-        * @brief test setup of encryption directories when they already exist
-        */
-       function testSetupServerSideIsSetup() {
-       
-               $mockView = m::mock('OC_FilesystemView');
-               
-               $mockView->shouldReceive( 'file_exists' )->times(6)->andReturn( true );
-               $mockView->shouldReceive( 'file_put_contents' )->withAnyArgs();
-               
-               $util = new Encryption\Util( $mockView, $this->userId );
-               
-               $this->assertEquals( true, $util->setupServerSide( $this->pass ) );
-               
-       }
-       
-       /**
-        * @brief test checking whether account is ready for encryption, when it isn't ready
-        */
-       function testReadyNotReady() {
-       
-               $mockView = m::mock('OC_FilesystemView');
-               
-               $mockView->shouldReceive( 'file_exists' )->times(1)->andReturn( false );
-               
-               $util = new Encryption\Util( $mockView, $this->userId );
-               
-               $this->assertEquals( false, $util->ready() );
-               
-               # TODO: Add more tests here to check that if any of the dirs are 
-               # then false will be returned. Use strict ordering?
-               
-       }
-       
-       /**
-        * @brief test checking whether account is ready for encryption, when it is ready
-        */
-       function testReadyIsReady() {
-       
-               $mockView = m::mock('OC_FilesystemView');
-               
-               $mockView->shouldReceive( 'file_exists' )->times(3)->andReturn( true );
-               
-               $util = new Encryption\Util( $mockView, $this->userId );
-               
-               $this->assertEquals( true, $util->ready() );
-               
-               # TODO: Add more tests here to check that if any of the dirs are 
-               # then false will be returned. Use strict ordering?
-               
-       }
-       
-       function testFindFiles() {
-       
-//             $this->view->chroot( "/data/{$this->userId}/files" );
-
-               $util = new Encryption\Util( $this->view, $this->userId );
-               
-               $files = $util->findFiles( '/', 'encrypted' );
-               
-               var_dump( $files );
-               
-               # TODO: Add more tests here to check that if any of the dirs are 
-               # then false will be returned. Use strict ordering?
-               
-       }
-
-//     /**
-//      * @brief test decryption using legacy blowfish method
-//      * @depends testLegacyEncryptLong
-//      */
-//     function testLegacyKeyRecryptKeyfileDecrypt( $recrypted ) {
-//     
-//             $decrypted = Encryption\Crypt::keyDecryptKeyfile( $recrypted['data'], $recrypted['key'], $this->genPrivateKey );
-//             
-//             $this->assertEquals( $this->dataLong, $decrypted );
-//             
-//     }
-       
-//     // Cannot use this test for now due to hidden dependencies in OC_FileCache
-//     function testIsLegacyEncryptedContent() {
-//             
-//             $keyfileContent = OCA\Encryption\Crypt::symmetricEncryptFileContent( $this->legacyEncryptedData, 'hat' );
-//             
-//             $this->assertFalse( OCA\Encryption\Crypt::isLegacyEncryptedContent( $keyfileContent, '/files/admin/test.txt' ) );
-//             
-//             OC_FileCache::put( '/admin/files/legacy-encrypted-test.txt', $this->legacyEncryptedData );
-//             
-//             $this->assertTrue( OCA\Encryption\Crypt::isLegacyEncryptedContent( $this->legacyEncryptedData, '/files/admin/test.txt' ) );
-//             
-//     }
-
-//     // Cannot use this test for now due to need for different root in OC_Filesystem_view class
-//     function testGetLegacyKey() {
-//             
-//             $c = new \OCA\Encryption\Util( $view, false );
-// 
-//             $bool = $c->getLegacyKey( 'admin' );
-//
-//             $this->assertTrue( $bool );
-//             
-//             $this->assertTrue( $c->legacyKey );
-//             
-//             $this->assertTrue( is_int( $c->legacyKey ) );
-//             
-//             $this->assertTrue( strlen( $c->legacyKey ) == 20 );
-//     
-//     }
-
-//     // Cannot use this test for now due to need for different root in OC_Filesystem_view class
-//     function testLegacyDecrypt() {
-// 
-//             $c = new OCA\Encryption\Util( $this->view, false );
-//             
-//             $bool = $c->getLegacyKey( 'admin' );
-// 
-//             $encrypted = $c->legacyEncrypt( $this->data, $c->legacyKey );
-//             
-//             $decrypted = $c->legacyDecrypt( $encrypted, $c->legacyKey );
-// 
-//             $this->assertEquals( $decrypted, $this->data );
-//     
-//     }
-
-}
\ No newline at end of file
diff --git a/apps/files_encryption/test/zeros b/apps/files_encryption/test/zeros
deleted file mode 100644 (file)
index ff982ac..0000000
Binary files a/apps/files_encryption/test/zeros and /dev/null differ