Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/core/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
* @var string
*
*/
const CI_VERSION = '3.4.7';
const CI_VERSION = '3.4.8';

/*
* ------------------------------------------------------
Expand Down
14 changes: 4 additions & 10 deletions system/libraries/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ public function create_key($length)
*/
public function encrypt($data, $params = NULL)
{
$data === NULL && $data = '';

if (($params = $this->_get_params($params)) === FALSE)
{
return FALSE;
Expand Down Expand Up @@ -470,11 +472,6 @@ protected function _mcrypt_encrypt($data, $params)
*/
protected function _openssl_encrypt($data, $params)
{
if ($data === NULL)
{
return NULL;
}

if (empty($params['handle']))
{
return FALSE;
Expand Down Expand Up @@ -511,6 +508,8 @@ protected function _openssl_encrypt($data, $params)
*/
public function decrypt($data, $params = NULL)
{
$data === NULL && $data = '';

if (($params = $this->_get_params($params)) === FALSE)
{
return FALSE;
Expand Down Expand Up @@ -631,11 +630,6 @@ protected function _mcrypt_decrypt($data, $params)
*/
protected function _openssl_decrypt($data, $params)
{
if ($data === NULL)
{
return NULL;
}

if ($iv_size = openssl_cipher_iv_length($params['handle']))
{
$iv = self::substr($data, 0, $iv_size);
Expand Down
38 changes: 38 additions & 0 deletions tests/codeigniter/libraries/Encryption_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,44 @@ public function test_encrypt_decrypt_custom()

// --------------------------------------------------------------------

/**
* @depends test__get_params
*/
public function test_encrypt_decrypt_null()
{
$this->encryption->initialize(array('key' => str_repeat("\x1", 16)));

$notices = array();
set_error_handler(function ($severity, $message) use (&$notices) {
$notices[] = $message;
return TRUE;
});

$ciphertext = $this->encryption->encrypt(NULL);
$plaintext = $this->encryption->decrypt($ciphertext);
$null_plaintext = $this->encryption->decrypt(NULL);

$binary_params = array(
'cipher' => 'aes-128',
'mode' => 'cbc',
'key' => str_repeat("\x1", 16),
'hmac' => FALSE
);
$binary_ciphertext = $this->encryption->encrypt(NULL, $binary_params);
$binary_plaintext = $this->encryption->decrypt($binary_ciphertext, $binary_params);
$binary_null_plaintext = $this->encryption->decrypt(NULL, $binary_params);

restore_error_handler();

$this->assertSame(array(), $notices);
$this->assertSame('', $plaintext);
$this->assertFalse($null_plaintext);
$this->assertSame('', $binary_plaintext);
$this->assertFalse($binary_null_plaintext);
}

// --------------------------------------------------------------------

/**
* _mcrypt_get_handle() test
*/
Expand Down