summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-11-07 15:57:41 +0100
committerAndrey Andreev <narf@devilix.net>2014-11-07 15:57:41 +0100
commit50c9ea154c125f5ce1a2d0384470f4e71188d628 (patch)
tree6b3f8ebfe2e44cef0d591513fe4175e0af726bfd
parentd8e31ec82d4f25378d6032df81fc5e9af5de5738 (diff)
Fix #3317 ... MCrypt sucks
-rw-r--r--system/libraries/Encryption.php1
-rw-r--r--tests/codeigniter/libraries/Encryption_test.php7
2 files changed, 5 insertions, 3 deletions
diff --git a/system/libraries/Encryption.php b/system/libraries/Encryption.php
index fe8434c46..2a28714f5 100644
--- a/system/libraries/Encryption.php
+++ b/system/libraries/Encryption.php
@@ -212,6 +212,7 @@ class CI_Encryption {
log_message('debug', "Encryption: Auto-configured driver '".$this->_driver."'.");
}
+ empty($params['cipher']) && $params['cipher'] = $this->_cipher;
empty($params['key']) OR $this->_key = $params['key'];
$this->{'_'.$this->_driver.'_initialize'}($params);
return $this;
diff --git a/tests/codeigniter/libraries/Encryption_test.php b/tests/codeigniter/libraries/Encryption_test.php
index f457fe325..cbcae3133 100644
--- a/tests/codeigniter/libraries/Encryption_test.php
+++ b/tests/codeigniter/libraries/Encryption_test.php
@@ -155,15 +155,16 @@ class Encryption_test extends CI_TestCase {
);
$output = $this->encryption->__get_params($params);
- unset($output['handle'], $params['raw_data']);
+ unset($output['handle'], $output['cipher'], $params['raw_data'], $params['cipher']);
$params['base64'] = FALSE;
$this->assertEquals($params, $output);
// HMAC disabled
unset($params['hmac_key'], $params['hmac_digest']);
$params['hmac'] = $params['raw_data'] = FALSE;
+ $params['cipher'] = 'aes-128';
$output = $this->encryption->__get_params($params);
- unset($output['handle'], $params['hmac'], $params['raw_data']);
+ unset($output['handle'], $output['cipher'], $params['hmac'], $params['raw_data'], $params['cipher']);
$params['base64'] = TRUE;
$params['hmac_digest'] = $params['hmac_key'] = NULL;
$this->assertEquals($params, $output);
@@ -195,7 +196,7 @@ class Encryption_test extends CI_TestCase {
$this->assertEquals($message, $this->encryption->decrypt($this->encryption->encrypt($message)));
// Try DES in ECB mode, just for the sake of changing stuff
- $this->encryption->initialize(array('cipher' => 'des', 'mode' => 'ecb'));
+ $this->encryption->initialize(array('cipher' => 'des', 'mode' => 'ecb', 'key' => substr($key, 0, 8)));
$this->assertEquals($message, $this->encryption->decrypt($this->encryption->encrypt($message)));
}