MySQL Forums
Forum List  »  Security

Re: AES_ENCRYPT() in php
Posted by: Yuriy Pavlutkin
Date: May 08, 2006 02:04PM

I can't to see your problem in details, but it seems the bug is in the fields length:
both AES_Encrypt() and rijindael_128 make padding of the plain text to 16-bytes blocks before encryption. Padding is made by ASCII-symbol, which code is equal to number of padded bytes.
Let we will think, that "xx" are chars hex code of our plain text. There are some examples of plain text padding:

00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
--------------------------------------------------
xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx 01
xx xx xx xx xx xx xx xx xx xx xx xx xx xx 02 02
xx xx xx xx xx xx xx xx xx xx 06 06 06 06 06 06
xx xx xx xx xx 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B


if plain text block is equal to 16 or 32 bytes (multiply of AES block size) one more block will be added:

xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10

Try to increase variables (or fields) length for source plain text for encryption and for destination plain text for decryption: add 16 or more bytes.

One more advice: use Trim() for decryption result.



Edited 1 time(s). Last edit at 05/08/2006 02:11PM by Yuriy Pavlutkin.

Options: ReplyQuote


Subject
Views
Written By
Posted
21566
December 19, 2005 08:48AM
9764
March 10, 2006 01:21PM
7171
April 19, 2006 08:57PM
Re: AES_ENCRYPT() in php
6863
May 08, 2006 02:04PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.