summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/libraries
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-05 17:51:15 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-05 17:51:15 +0100
commitf401767c04a24677e11a3b6c4e3590e8b2e06e88 (patch)
treeba71b9ae6c9e3b1c41ef9c7ede983a8437625d0a /tests/codeigniter/libraries
parentd9a48da095e2b76c65b1b9ebd26b6f06c94cb0e5 (diff)
CI_Encryption: More MCrypt/OpenSSL compatibility and get rid of the MCRYPT_MODE_* constants
Diffstat (limited to 'tests/codeigniter/libraries')
-rw-r--r--tests/codeigniter/libraries/Encryption_test.php59
1 files changed, 46 insertions, 13 deletions
diff --git a/tests/codeigniter/libraries/Encryption_test.php b/tests/codeigniter/libraries/Encryption_test.php
index b13cb3140..ca1a4cd60 100644
--- a/tests/codeigniter/libraries/Encryption_test.php
+++ b/tests/codeigniter/libraries/Encryption_test.php
@@ -21,17 +21,51 @@ class Encryption_test extends CI_TestCase {
$message = 'This is a message encrypted via MCrypt and decrypted via OpenSSL, or vice-versa.';
- // Format is: <MCrypt cipher name>, <OpenSSL cipher name>, <key size>
+ // Format is: <Cipher name>, <Cipher mode>, <Key size>
$portable = array(
- array('rijndael-128', 'aes-128', 16),
- array('rijndael-128', 'aes-192', 24),
- array('rijndael-128', 'aes-256', 32),
- array('des', 'des', 7),
- array('tripledes', 'des-ede3', 7),
- array('tripledes', 'des-ede3', 14),
- array('tripledes', 'des-ede3', 21),
- array('blowfish', 'bf', 16),
- array('blowfish', 'bf', 56)
+ array('aes-128', 'cbc', 16),
+ array('aes-128', 'cfb', 16),
+ array('aes-128', 'cfb8', 16),
+ array('aes-128', 'ofb', 16),
+ array('aes-128', 'ecb', 16),
+ array('aes-128', 'ctr', 16),
+ array('aes-192', 'cbc', 24),
+ array('aes-192', 'cfb', 24),
+ array('aes-192', 'cfb8', 24),
+ array('aes-192', 'ofb', 24),
+ array('aes-192', 'ecb', 24),
+ array('aes-192', 'ctr', 24),
+ array('aes-256', 'cbc', 32),
+ array('aes-256', 'cfb', 32),
+ array('aes-256', 'cfb8', 32),
+ array('aes-256', 'ofb', 32),
+ array('aes-256', 'ecb', 32),
+ array('aes-256', 'ctr', 32),
+ array('des', 'cbc', 7),
+ array('des', 'cfb', 7),
+ array('des', 'cfb8', 7),
+ array('des', 'ofb', 7),
+ array('des', 'ecb', 7),
+ array('tripledes', 'cbc', 7),
+ array('tripledes', 'cfb', 7),
+ array('tripledes', 'cfb8', 7),
+ array('tripledes', 'ofb', 7),
+ array('tripledes', 'cbc', 14),
+ array('tripledes', 'cfb', 14),
+ array('tripledes', 'cfb8', 14),
+ array('tripledes', 'ofb', 14),
+ array('tripledes', 'cbc', 21),
+ array('tripledes', 'cfb', 21),
+ array('tripledes', 'cfb8', 21),
+ array('tripledes', 'ofb', 21),
+ array('blowfish', 'cbc', 16),
+ array('blowfish', 'cfb', 16),
+ array('blowfish', 'ofb', 16),
+ array('blowfish', 'ecb', 16),
+ array('blowfish', 'cbc', 56),
+ array('blowfish', 'cfb', 56),
+ array('blowfish', 'ofb', 56),
+ array('blowfish', 'ecb', 56),
);
$driver_index = array('mcrypt', 'openssl');
@@ -40,8 +74,8 @@ class Encryption_test extends CI_TestCase {
// Add some randomness to the selected driver
$driver = mt_rand(0,1);
$params = array(
- 'cipher' => $test[$driver],
- 'mode' => 'cbc',
+ 'cipher' => $test[0],
+ 'mode' => $test[1],
'key' => openssl_random_pseudo_bytes($test[2])
);
@@ -49,7 +83,6 @@ class Encryption_test extends CI_TestCase {
$ciphertext = $this->encryption->encrypt($message, $params);
$driver = (int) ! $driver;
- $params['cipher'] = $test[$driver];
$this->encryption->initialize(array('driver' => $driver_index[$driver]));
$this->assertEquals($message, $this->encryption->decrypt($ciphertext, $params));