Bug #1149 | AES_ENCRYPT & AES_DECRYPT Bug | ||
---|---|---|---|
Submitted: | 27 Aug 2003 6:35 | Modified: | 28 Aug 2003 9:59 |
Reporter: | [ name withheld ] | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S1 (Critical) |
Version: | 4.0.14 & 4.1.0 | OS: | Windows (Windows XP) |
Assigned to: | CPU Architecture: | Any |
[27 Aug 2003 6:35]
[ name withheld ]
[28 Aug 2003 9:59]
Indrek Siitan
The problem is that the AES-encrypted string might contain 0x00 value, which VARCHAR treats as end-of-string, so VARCHAR isn't suitable for storing AES_ENCRYPT() results. Change the field to TEXT or BLOB, that handles binary data, and the problem is solved: mysql> CREATE TABLE `test` ( -> `id` int(11) NOT NULL auto_increment, -> `string` text NOT NULL default '', -> PRIMARY KEY (`id`) -> ) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=2 ; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO test(string) -> VALUES(AES_ENCRYPT('Libero','eKqvqhjXKvrNt3aBjyVXg1')); Query OK, 1 row affected (0.00 sec) mysql> SELECT id,AES_DECRYPT(string,'eKqvqhjXKvrNt3aBjyVXg1') -> as string FROM test; +----+--------+ | id | string | +----+--------+ | 2 | Libero | +----+--------+ 1 row in set (0.00 sec)
[22 Oct 2003 1:44]
Ralf Hauser
please mention on http://www.mysql.com/doc/en/Miscellaneous_functions.html that Blobs are fine too! One interesting observation: sometimes we used the standard sun.jdbc.rowset.CachedRowSet to receive the Blob streams. Normally this worked fine, but after AES_DECRYPT, we receive some complaint about incompatible data types...