diff options
author | unknown <peter@mysql.com> | 2002-07-23 19:29:06 +0400 |
---|---|---|
committer | unknown <peter@mysql.com> | 2002-07-23 19:29:06 +0400 |
commit | 67c5a37982844f710999b8a9b0b495304bf1905e (patch) | |
tree | 5256210763edbaa78f3e7c9bfa1d0043e5a2ff69 /mysys/my_aes.c | |
parent | 9f4871cb3204e9d1838cc8fe97161c837767fce5 (diff) | |
download | mariadb-git-67c5a37982844f710999b8a9b0b495304bf1905e.tar.gz |
Possibility to weaken AES key as Mark asked
mysys/my_aes.c:
Small addition which used only in case of special define which weakens AES key length for some
Export limitations
Diffstat (limited to 'mysys/my_aes.c')
-rw-r--r-- | mysys/my_aes.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mysys/my_aes.c b/mysys/my_aes.c index b67166f8367..10ef62ae0a5 100644 --- a/mysys/my_aes.c +++ b/mysys/my_aes.c @@ -74,6 +74,32 @@ static int my_aes_create_key(KEYINSTANCE *aes_key, ptr= rkey; /* Just loop over tmp_key until we used all key */ *ptr^= *sptr; } +#ifdef AES_USE_KEY_BITS + /* + This block is intended to allow more weak encryption if application + build with libmysqld needs to correspond to export regulations + It should be never used in normal distribution as does not give + any speed improvement. + To get worse security define AES_USE_KEY_BITS to number of bits + you want key to be. It should be divisible by 8 + + WARNING: Changing this value results in changing of enryption for + all key lengths so altering this value will result in impossibility + to decrypt data encrypted with previous value + */ +#define AES_USE_KEY_BYTES (AES_USE_KEY_BITS/8) + /* + To get weaker key we use first AES_USE_KEY_BYTES bytes of created key + and cyclically copy them until we created all required key length + */ + for (ptr= rkey+AES_USE_KEY_BYTES, sptr=rkey ; ptr < rkey_end; + ptr++,sptr++) + { + if (sptr == rkey+AES_USE_KEY_BYTES) + sptr=rkey; + *ptr=*sptr; + } +#endif if (direction == AES_DECRYPT) aes_key->nr = rijndaelKeySetupDec(aes_key->rk, rkey, AES_KEY_LENGTH); else |