AES_Encrypt

2004-07-15 Thread Singer Wang
Hello,

I'm tempted to use the AES_ENCRYPT/AES_DECRYPT function in MySQL; as
documentation says the implementation is 128-bit AES. Thus the keys
are 16bytes in length. Now the 'key_str' in the manual can be
any length; how is the key generated from that?

also, for multi block encryptions what mode is used? ECB? CBC? CFB? OFB?


-- 
Singer X.J. Wang, Ph.D. Candidate
Faculty of Computer Science, Dalhousie University
6050 University Avenue, Halifax, NS, Canada, B3H 1W5
  Email:[EMAIL PROTECTED]
  Fax:  (902) 492-1517
  WWW:  http://www.singerwang.com
  Schedule: http://schedule.singerwang.com
---
  One word sums up probably the responsibility of any vice president,
  and that one word is 'to be prepared'.
 - Dan Quayle

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



AES_ENCRYPT returned value

2004-02-02 Thread Hassan Shaikh
Hi,

What's the best data type to store AES_ENCRYPTed text/password
(without any data conversion)? I believe it can't be stored in CHAR or
VARCHAR due to implicit internal conversions.

Thanks.

Hassan


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: AES_ENCRYPT returned value

2004-02-02 Thread mos
At 07:20 AM 2/2/2004, you wrote:
Hi,

What's the best data type to store AES_ENCRYPTed text/password
(without any data conversion)? I believe it can't be stored in CHAR or
VARCHAR due to implicit internal conversions.
Thanks.

Hassan
Hassan,
I haven't tried it, but can't you use Binary in the CHAR/VARCHAR 
column definition so it doesn't do any conversion?

Mike 



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


aes_encrypt/aes_decrypt returns null for valid input data

2003-02-18 Thread gladerac
Description:
aes_encrypt/aes_decrypt works correctly for a test case. Change only
the last two digits of the string needing to be encrypted and 
it returns null.

I formed the queries below by cut and paste, so I was sure that the
password was constant. The actual problem occured when my C program,
using a server side password that was not altered during execution,
would work correctly for 55 insert statements and have an error on one.

As I was about to send this, I repeated the test except for changing
the key to gary. Everything worked then.

Linux/Red Hat Version 8.0
Tested on 4.0.2-alpha-log and 4.0.10-gamma-standard

How-To-Repeat:
mysql describe sop_uid;
+---+--+--+-+-+---+
| Field | Type | Null | Key | Default | Extra |
+---+--+--+-+-+---+
| sop_uid   | varchar(150) | YES  | | NULL|   |
| case_id   | int(11)  | YES  | | NULL|   |
| study_id  | int(11)  | YES  | | NULL|   |
| series_id | int(11)  | YES  | | NULL|   |
| unique_number | int(11)  | YES  | | NULL|   |
+---+--+--+-+-+---+
5 rows in set (0.00 sec)

mysql delete from sop_uid;
Query OK, 3 rows affected (0.00 sec)

mysql INSERT INTO sop_uid ( sop_uid, case_id, study_id, series_id, unique_number )
- VALUES ( AES_ENCRYPT(1.2.840.113619.2.55.1.1762891793.2470.1041939826.111, 
titepfda), 46, 130, 603, 113177);
Query OK, 1 row affected (0.00 sec)

mysql select aes_decrypt(sop_uid, titepfda), 
case_id,study_id,series_id,unique_number from sop_uid where unique_number=113177;
+--+-+--+---+---+
| aes_decrypt(sop_uid, titepfda) | case_id | study_id | 
|series_id | unique_number |
+--+-+--+---+---+
| 1.2.840.113619.2.55.1.1762891793.2470.1041939826.111 |  46 |  130 |   
|603 |113177 |
+--+-+--+---+---+
1 row in set (0.00 sec)

mysql INSERT INTO sop_uid ( sop_uid, case_id, study_id, series_id, unique_number )
- VALUES ( AES_ENCRYPT(1.2.840.113619.2.55.1.1762891793.2470.1041939826.158, 
titepfda), 46, 130, 603, 113177);
Query OK, 1 row affected (0.00 sec)

mysql select aes_decrypt(sop_uid, titepfda), 
case_id,study_id,series_id,unique_number from sop_uid where unique_number=113177;
+--+-+--+---+---+
| aes_decrypt(sop_uid, titepfda) | case_id | study_id | 
|series_id | unique_number |
+--+-+--+---+---+
| 1.2.840.113619.2.55.1.1762891793.2470.1041939826.111 |  46 |  130 |   
|603 |113177 |
| NULL |  46 |  130 |   
|603 |113177 |
+--+-+--+---+---+
2 rows in set (0.00 sec)

mysql select version();
+---+
| version() |
+---+
| 4.0.10-gamma-standard |
+---+
1 row in set (0.00 sec)

Fix:


Submitter-Id:  submitter ID
Originator:
Organization:
 
MySQL support: none
Synopsis:  aes_encrypt/aes_decrypt returns null for correct input data
Severity:  
Priority:  
Category:  mysql
Class: 
Release:   mysql-4.0.10-gamma-standard (Official MySQL-standard binary)

C compiler:2.95.3
C++ compiler:  2.95.3
Environment:

System: Linux gary.rad.med.umich.edu 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 
i686 i386 GNU/Linux
Architecture: i686

Some paths:  /usr/bin/perl /usr/bin/make /usr/bin/gmake /usr/bin/gcc /usr/bin/cc
GCC: Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking 
--host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
Compilation info: CC='gcc'  CFLAGS='-O2 -mcpu=pentiumpro'  CXX='gcc'  CXXFLAGS='-O2 
-mcpu=pentiumpro -felide-constructors'  LDFLAGS=''  ASFLAGS=''
LIBC: 
lrwxrwxrwx1 root root   14 Oct 15 11:24 /lib/libc.so.6 - 
libc-2.2.93.so
-rwxr-xr-x1 root root  1235468 Sep  5 19:12 /lib/libc-2.2.93.so
-rw-r--r--1 root root  2233342 Sep  5 18:59 /usr/lib/libc.a
-rw-r--r--1 root root  178 Sep  5 18:50 /usr/lib/libc.so
Configure command: ./configure