From 09c7793b23ae77c54e25d12b63d8ca9c9232efeb Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Tue, 31 Aug 2010 13:17:10 -0500 Subject: Significant changes to the Encryption library - Removed double-encoding with XOR scheme when Mcrypt is available. Additional obfuscation was not significantly aiding security, and came at a very high performance cost. - Changed the default encryption mode from ECB to CBC for much improved security - Added an encode_from_legacy() method to allow re-encoding of permanent data that was originally encoded with the older methods. --- user_guide/libraries/encryption.html | 44 ++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'user_guide/libraries') diff --git a/user_guide/libraries/encryption.html b/user_guide/libraries/encryption.html index dac1db911..fbffd63c6 100644 --- a/user_guide/libraries/encryption.html +++ b/user_guide/libraries/encryption.html @@ -58,12 +58,11 @@ Encryption Class

Encryption Class

-

The Encryption Class provides two-way data encryption. It uses a scheme that pre-compiles -the message using a randomly hashed bitwise XOR encoding scheme, which is then encrypted using +

The Encryption Class provides two-way data encryption. It uses a scheme that either compiles +the message using a randomly hashed bitwise XOR encoding scheme, or is encrypted using the Mcrypt library. If Mcrypt is not available on your server the encoded message will still provide a reasonable degree of security for encrypted sessions or other such "light" purposes. -If Mcrypt is available, you'll effectively end up with a double-encrypted message string, which should -provide a very high degree of security.

+If Mcrypt is available, you'll be provided with a high degree of security appropriate for storage.

Setting your Key

@@ -153,7 +152,7 @@ $encrypted_string = $this->encrypt->decode($msg, $key);

$this->encrypt->set_mode();

-

Permits you to set an Mcrypt mode. By default it uses MCRYPT_MODE_ECB. Example:

+

Permits you to set an Mcrypt mode. By default it uses MCRYPT_MODE_CBC. Example:

$this->encrypt->set_mode(MCRYPT_MODE_CFB);

Please visit php.net for a list of available modes.

@@ -169,7 +168,42 @@ function:

If your server does not support SHA1 you can use the provided function.

+

$this->encrypt->encode_from_legacy($orig_data, $legacy_mode = MCRYPT_MODE_ECB, $key = '');

+

Enables you to re-encode data that was originally encrypted with CodeIgniter 1.x to be compatible with the Encryption library in CodeIgniter 2.x. It is only + necessary to use this method if you have encrypted data stored permanently such as in a file or database and are on a server that supports Mcrypt. "Light" use encryption + such as encrypted session data or transitory encrypted flashdata require no intervention on your part. However, existing encrypted Sessions will be + destroyed since data encrypted prior to 2.x will not be decoded.

+

Why only a method to re-encode the data instead of maintaining legacy methods for both encoding and decoding? The algorithms in + the Encryption library have improved in CodeIgniter 2.x both for performance and security, and we do not wish to encourage continued use of the older methods. + You can of course extend the Encryption library if you wish and replace the new methods with the old and retain seamless compatibility with CodeIgniter 1.x + encrypted data, but this a decision that a developer should make cautiously and deliberately, if at all.

+ +$new_data = $this->encrypt->encode_from_legacy($old_encrypted_string); + + + + + + + + + + + + + + + + + + + + + + +
ParameterDefaultDescription
$orig_datan/aThe original encrypted data from CodeIgniter 1.x's Encryption library
$legacy_modeMCRYPT_MODE_ECBThe Mcrypt mode that was used to generate the original encrypted data. CodeIgniter 1.x's default was MCRYPT_MODE_ECB, and it will + assume that to be the case unless overridden by this parameter.
$keyn/aThe encryption key. This it typically specified in your config file as outlined above.
-- cgit v1.2.3-24-g4f1b