EMAIL REMOVED wrote:
> I am trying to understand how MySQL converts the "key_str" (AES
> p***word) argument in functions "AES_ENCRYPT(str,key_str)" or
> "AES_DECRYPT(crypt_str,key_str)" if the length of the "key_str"
> characters is > 16 characters.
"use the source, Luke!"
from $MYSQL_SOURCE/mysys/my_aes.c:
static int my_aes_create_key(KEYINSTANCE *aes_key,
enum encrypt_dir direction, const char *key,
int key_length)
{
uint8 rkey[AES_KEY_LENGTH/8]; /* The real key to be used for encryption */
uint8 *rkey_end=rkey+AES_KEY_LENGTH/8; /* Real key boundary */
uint8 *ptr; /* Start of the real key*/
const char *sptr; /* Start of the working key */
const char *key_end=key+key_length; /* Working key boundary*/
bzero((char*) rkey,AES_KEY_LENGTH/8); /* Set initial key */
for (ptr= rkey, sptr= key; sptr < key_end; ptr++, sptr++)
{
if (ptr == rkey_end)
ptr= rkey; /* Just loop over tmp_key until we used all key */
*ptr^= (uint8) *sptr;
}
....
1. the AES key is initialized with all zeros
2. the AES key is XORed with the given key; if there are more bytes in
the key than in the AES key, it starts over at the beginning of the
AES key until all key material is used
XL
--
Axel Schwenke, Support Engineer, MySQL AB
Online User Manual:
http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums:
http://forums.mysql.com/