| Bug #8669 | AES_DECRYPT fails on null values | ||
|---|---|---|---|
| Submitted: | 22 Feb 2005 5:56 | Modified: | 10 Mar 2005 18:16 | 
| Reporter: | Ralf Hauser | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) | 
| Version: | mysqld Ver 4.0.21-log for pc-linux-gnu | OS: | Any (*) | 
| Assigned to: | Igor Babaev | CPU Architecture: | Any | 
   [22 Feb 2005 5:56]
   Ralf Hauser        
  
 
   [22 Feb 2005 13:07]
   Aleksey Kishkin        
  confirm for 4.0.23. I tested also against 4.1.10, it works properly with 4.1.10 (attached a testcase that I used)
   [22 Feb 2005 13:08]
   Aleksey Kishkin        
  java source of testcase (according to authors description)
Attachment: bug8669.java (application/octet-stream, text), 6.44 KiB.
   [8 Mar 2005 20:57]
   Jim Winstead        
  This looks like a bug in join processing or optimization. With this test:
create table t1 (id int auto_increment primary key, str char(255) not null);
create table t2 (id int not null unique);
insert into t2 values (1),(2);
insert into t1 (str) values (aes_encrypt('foo', 'bar'));
insert into t1 (str) values ('not valid');
select t1.id, aes_decrypt(str,'bar') from t1, t2 where t1.id = t2.id order by t1.id asc;
drop table t1, t2;
If I remove 'not null' on t1.str, the query returns the expected results.
 
   [9 Mar 2005 8:09]
   Igor Babaev        
  For the database presented by Jim:
the following query returns a correst result:
mysql> SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id;
+----+-------------------------+
| id | aes_decrypt(str, 'bar') |
+----+-------------------------+
|  1 | foo                     |
|  2 | NULL                    |
+----+-------------------------+
While this modification does not:
mysql> SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id
    ->  ORDER BY t1.id;
+----+-------------------------+
| id | aes_decrypt(str, 'bar') |
+----+-------------------------+
|  1 | foo                     |
|  2 | foo                     |
+----+-------------------------+
 
   [9 Mar 2005 8:16]
   Bugs System        
  A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/22823
   [10 Mar 2005 4:43]
   Igor Babaev        
  The function AES_DECRYPT can return NULL value even in the case when its first
argument refers to a column declared as NOT NULL.
This fact was not taken into account.
The fix will appear in releases 4.0.24, 4.1.11, 5.0.3.
ChangeSet
  1.2082 05/03/09 00:15:51 igor@rurik.mysql.com +3 -0
  func_str.result, func_str.test:
    Added a test case for bug #8669.
  item_strfunc.cc:
    Fixed bug #8669.
    Function AES_DECRYPT can return NULL value.
 
   [10 Mar 2005 18:16]
   Paul DuBois        
  Noted in 4.0.24, 4.1.11, 5.0.3 changelogs.
   [3 Jun 2005 21:29]
   Ralf Hauser        
  in a variant, it happens again with non-null values how to reproduce insert string "1111" with AES key 1 insert string "2222" with AES key 2 select * with AES_DECRYPT with key 1 result received (wrong) -------------------------- 1111 1111 result expected ------------------ �,о�w�/ %� (i.e. decryption error) 1
   [3 Jun 2005 21:30]
   Ralf Hauser        
  forgot to mention - now I am on 4.0.24

