summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-04-18 16:02:35 +0200
committerRobin Appelman <icewind@owncloud.com>2012-04-18 20:54:28 +0200
commitd1ad4dc8d60a656606b6c237df9f4c931f828c73 (patch)
tree1c9c3d7be8c17fc134ed6ffa43fa0b402354767d
parentb39c3d4c4edbb9a7fd2be22e2d2684e4185ca0e5 (diff)
downloadnextcloud-server-d1ad4dc8d60a656606b6c237df9f4c931f828c73.tar.gz
nextcloud-server-d1ad4dc8d60a656606b6c237df9f4c931f828c73.zip
add test cases for cryptstream
-rw-r--r--apps/files_encryption/lib/proxy.php7
-rw-r--r--apps/files_encryption/tests/encryption.php6
2 files changed, 13 insertions, 0 deletions
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index c68df06f9fa..a0de411a7b6 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -28,6 +28,7 @@
class OC_FileProxy_Encryption extends OC_FileProxy{
private static $blackList=null; //mimetypes blacklisted from encryption
private static $metaData=array(); //metadata cache
+ private static $enableEncryption=null;
/**
* check if a file should be encrypted during write
@@ -35,6 +36,12 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
* @return bool
*/
private static function shouldEncrypt($path){
+ if(is_null($this->enableEncryption)){
+ $this->enableEncryption=(OC_Appconfig::getValue('files_encryption','enabled','true')=='true');
+ }
+ if(!$this->enableEncryption){
+ return false;
+ }
if(is_null(self::$blackList)){
self::$blackList=explode(',',OC_Appconfig::getValue('files_encryption','type_blacklist','jpg,png,jpeg,avi,mpg,mpeg,mkv,mp3,oga,ogv,ogg'));
}
diff --git a/apps/files_encryption/tests/encryption.php b/apps/files_encryption/tests/encryption.php
index 140fe6b126d..13093256717 100644
--- a/apps/files_encryption/tests/encryption.php
+++ b/apps/files_encryption/tests/encryption.php
@@ -15,6 +15,12 @@ class Test_Encryption extends UnitTestCase {
$decrypted=OC_Crypt::decrypt($encrypted,$key);
$this->assertNotEqual($encrypted,$source);
$this->assertEqual($decrypted,$source);
+
+ $chunk=substr($source,0,8192);
+ $encrypted=OC_Crypt::encrypt($chunk,$key);
+ $this->assertEqual(strlen($chunk),strlen($encrypted));
+ $decrypted=OC_Crypt::decrypt($encrypted,$key);
+ $this->assertEqual($decrypted,$chunk);
$encrypted=OC_Crypt::blockEncrypt($source,$key);
$decrypted=OC_Crypt::blockDecrypt($encrypted,$key);