|
|
@ -13,6 +13,7 @@ class Test_Encryption extends UnitTestCase { |
|
|
|
$source=file_get_contents($file); //nice large text file |
|
|
|
$source=file_get_contents($file); //nice large text file |
|
|
|
$encrypted=OC_Crypt::encrypt($source,$key); |
|
|
|
$encrypted=OC_Crypt::encrypt($source,$key); |
|
|
|
$decrypted=OC_Crypt::decrypt($encrypted,$key); |
|
|
|
$decrypted=OC_Crypt::decrypt($encrypted,$key); |
|
|
|
|
|
|
|
$decrypted=rtrim($decrypted, "\0"); |
|
|
|
$this->assertNotEqual($encrypted,$source); |
|
|
|
$this->assertNotEqual($encrypted,$source); |
|
|
|
$this->assertEqual($decrypted,$source); |
|
|
|
$this->assertEqual($decrypted,$source); |
|
|
|
|
|
|
|
|
|
|
@ -20,6 +21,7 @@ class Test_Encryption extends UnitTestCase { |
|
|
|
$encrypted=OC_Crypt::encrypt($chunk,$key); |
|
|
|
$encrypted=OC_Crypt::encrypt($chunk,$key); |
|
|
|
$this->assertEqual(strlen($chunk),strlen($encrypted)); |
|
|
|
$this->assertEqual(strlen($chunk),strlen($encrypted)); |
|
|
|
$decrypted=OC_Crypt::decrypt($encrypted,$key); |
|
|
|
$decrypted=OC_Crypt::decrypt($encrypted,$key); |
|
|
|
|
|
|
|
$decrypted=rtrim($decrypted, "\0"); |
|
|
|
$this->assertEqual($decrypted,$chunk); |
|
|
|
$this->assertEqual($decrypted,$chunk); |
|
|
|
|
|
|
|
|
|
|
|
$encrypted=OC_Crypt::blockEncrypt($source,$key); |
|
|
|
$encrypted=OC_Crypt::blockEncrypt($source,$key); |
|
|
@ -43,6 +45,7 @@ class Test_Encryption extends UnitTestCase { |
|
|
|
$source=file_get_contents($file); //binary file |
|
|
|
$source=file_get_contents($file); //binary file |
|
|
|
$encrypted=OC_Crypt::encrypt($source,$key); |
|
|
|
$encrypted=OC_Crypt::encrypt($source,$key); |
|
|
|
$decrypted=OC_Crypt::decrypt($encrypted,$key); |
|
|
|
$decrypted=OC_Crypt::decrypt($encrypted,$key); |
|
|
|
|
|
|
|
$decrypted=rtrim($decrypted, "\0"); |
|
|
|
$this->assertEqual($decrypted,$source); |
|
|
|
$this->assertEqual($decrypted,$source); |
|
|
|
|
|
|
|
|
|
|
|
$encrypted=OC_Crypt::blockEncrypt($source,$key); |
|
|
|
$encrypted=OC_Crypt::blockEncrypt($source,$key); |
|
|
@ -50,4 +53,20 @@ class Test_Encryption extends UnitTestCase { |
|
|
|
$this->assertEqual($decrypted,$source); |
|
|
|
$this->assertEqual($decrypted,$source); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function testBinary(){ |
|
|
|
|
|
|
|
$key=uniqid(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$file=__DIR__.'/binary'; |
|
|
|
|
|
|
|
$source=file_get_contents($file); //binary file |
|
|
|
|
|
|
|
$encrypted=OC_Crypt::encrypt($source,$key); |
|
|
|
|
|
|
|
$decrypted=OC_Crypt::decrypt($encrypted,$key); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$decrypted=rtrim($decrypted, "\0"); |
|
|
|
|
|
|
|
$this->assertEqual($decrypted,$source); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$encrypted=OC_Crypt::blockEncrypt($source,$key); |
|
|
|
|
|
|
|
$decrypted=OC_Crypt::blockDecrypt($encrypted,$key); |
|
|
|
|
|
|
|
$this->assertEqual($decrypted,$source); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|