2001-10-02 00:12:23 +08:00
|
|
|
--
|
|
|
|
-- AES / Rijndael-128 cipher
|
|
|
|
--
|
|
|
|
|
|
|
|
-- some standard Rijndael testvalues
|
2002-10-19 02:41:22 +08:00
|
|
|
SELECT encode(encrypt(
|
2001-10-02 00:12:23 +08:00
|
|
|
decode('00112233445566778899aabbccddeeff', 'hex'),
|
|
|
|
decode('000102030405060708090a0b0c0d0e0f', 'hex'),
|
|
|
|
'aes-ecb/pad:none'), 'hex');
|
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
SELECT encode(encrypt(
|
2001-10-02 00:12:23 +08:00
|
|
|
decode('00112233445566778899aabbccddeeff', 'hex'),
|
|
|
|
decode('000102030405060708090a0b0c0d0e0f1011121314151617', 'hex'),
|
|
|
|
'aes-ecb/pad:none'), 'hex');
|
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
SELECT encode(encrypt(
|
2001-10-02 00:12:23 +08:00
|
|
|
decode('00112233445566778899aabbccddeeff', 'hex'),
|
|
|
|
decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex'),
|
|
|
|
'aes-ecb/pad:none'), 'hex');
|
|
|
|
|
|
|
|
-- cbc
|
2002-10-19 02:41:22 +08:00
|
|
|
SELECT encode(encrypt(
|
2001-10-02 00:12:23 +08:00
|
|
|
decode('00112233445566778899aabbccddeeff', 'hex'),
|
|
|
|
decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex'),
|
|
|
|
'aes-cbc/pad:none'), 'hex');
|
|
|
|
|
|
|
|
-- key padding
|
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
SELECT encode(encrypt(
|
2001-10-02 00:12:23 +08:00
|
|
|
decode('0011223344', 'hex'),
|
|
|
|
decode('000102030405', 'hex'),
|
|
|
|
'aes-cbc'), 'hex');
|
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
SELECT encode(encrypt(
|
2001-10-02 00:12:23 +08:00
|
|
|
decode('0011223344', 'hex'),
|
|
|
|
decode('000102030405060708090a0b0c0d0e0f10111213', 'hex'),
|
|
|
|
'aes-cbc'), 'hex');
|
|
|
|
|
2002-10-19 02:41:22 +08:00
|
|
|
SELECT encode(encrypt(
|
2001-10-02 00:12:23 +08:00
|
|
|
decode('0011223344', 'hex'),
|
|
|
|
decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b', 'hex'),
|
|
|
|
'aes-cbc'), 'hex');
|
|
|
|
|
2005-03-21 13:24:52 +08:00
|
|
|
-- empty data
|
|
|
|
select encode( encrypt('', 'foo', 'aes'), 'hex');
|
|
|
|
-- 10 bytes key
|
|
|
|
select encode( encrypt('foo', '0123456789', 'aes'), 'hex');
|
|
|
|
-- 22 bytes key
|
|
|
|
select encode( encrypt('foo', '0123456789012345678901', 'aes'), 'hex');
|
|
|
|
|
|
|
|
-- decrypt
|
|
|
|
select decrypt(encrypt('foo', '0123456', 'aes'), '0123456', 'aes');
|
|
|
|
|
|
|
|
-- iv
|
|
|
|
select encode(encrypt_iv('foo', '0123456', 'abcd', 'aes'), 'hex');
|
|
|
|
select decrypt_iv(decode('2c24cb7da91d6d5699801268b0f5adad', 'hex'),
|
|
|
|
'0123456', 'abcd', 'aes');
|
|
|
|
|
2005-07-13 04:27:45 +08:00
|
|
|
-- long message
|
|
|
|
select encode(encrypt('Lets try a longer message.', '0123456789', 'aes'), 'hex');
|
|
|
|
select decrypt(encrypt('Lets try a longer message.', '0123456789', 'aes'), '0123456789', 'aes');
|
|
|
|
|