Skip to content

Commit

Permalink
Fix #3317 ... MCrypt sucks
Browse files Browse the repository at this point in the history
  • Loading branch information
narfbg committed Nov 7, 2014
1 parent d8e31ec commit 50c9ea1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions system/libraries/Encryption.php
Expand Up @@ -212,6 +212,7 @@ public function initialize(array $params)
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;
Expand Down
7 changes: 4 additions & 3 deletions tests/codeigniter/libraries/Encryption_test.php
Expand Up @@ -155,15 +155,16 @@ public function test__get_params()
);

$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);
Expand Down Expand Up @@ -195,7 +196,7 @@ public function test_initialize_encrypt_decrypt()
$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)));
}

Expand Down

0 comments on commit 50c9ea1

Please sign in to comment.