Description:
Hi. I tested this on FreeBSD with a current pull of BK 4.1.16. The customer reported it on Linux.
I change a single bit in the key I'm using in the AES_ENCRYPT and AES_DECRYPT function pair, and I get NULL back from AES_DECRYPT instead of the correct results:
mysql> set @key = 'corydog2004vcruler';
Query OK, 0 rows affected (0.00 sec)
mysql> UPDATE tbd_test SET user_password=AES_ENCRYPT('movitz75', @key);
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> SELECT AES_DECRYPT(user_password, @key) from tbd_test;
+----------------------------------+
| AES_DECRYPT(user_password, @key) |
+----------------------------------+
| movitz75 |
+----------------------------------+
1 row in set (0.00 sec)
mysql> set @key = 'corydog2004vcrules';
Query OK, 0 rows affected (0.00 sec)
mysql> UPDATE tbd_test SET user_password=AES_ENCRYPT('movitz75', @key);
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT AES_DECRYPT(user_password, @key) from tbd_test;
+----------------------------------+
| AES_DECRYPT(user_password, @key) |
+----------------------------------+
| NULL |
+----------------------------------+
1 row in set (0.00 sec)
Aside from 'corydog2004vcrules', I have not found another key which causes the problem. :) But I'm sure there must be some others as well.
How to repeat:
CREATE TABLE tbd_test (user_password varchar(255));
INSERT INTO tbd_test VALUES ('one');
set @key = 'corydog2004vcruler';
UPDATE tbd_test SET user_password=AES_ENCRYPT('movitz75', @key);
SELECT AES_DECRYPT(user_password, @key) from tbd_test;
set @key = 'corydog2004vcrules';
UPDATE tbd_test SET user_password=AES_ENCRYPT('movitz75', @key);
SELECT AES_DECRYPT(user_password, @key) from tbd_test;
Suggested fix:
Unknown.