mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
6a8eb1a7b6
* test error handling * add tests for des, 3des, cast5 * add some tests to blowfish, rijndael * Makefile: ability to specify different tests for different crypto libraries, so we can skip des, 3des and cast5 for builtin. Marko Kreen
43 lines
1.0 KiB
SQL
43 lines
1.0 KiB
SQL
--
|
|
-- Cast5 cipher
|
|
--
|
|
|
|
-- test vectors from RFC2144
|
|
|
|
-- 128 bit key
|
|
SELECT encode(encrypt(
|
|
decode('01 23 45 67 89 AB CD EF', 'hex'),
|
|
decode('01 23 45 67 12 34 56 78 23 45 67 89 34 56 78 9A', 'hex'),
|
|
'cast5-ecb/pad:none'), 'hex');
|
|
-- result: 23 8B 4F E5 84 7E 44 B2
|
|
|
|
-- 80 bit key
|
|
SELECT encode(encrypt(
|
|
decode('01 23 45 67 89 AB CD EF', 'hex'),
|
|
decode('01 23 45 67 12 34 56 78 23 45', 'hex'),
|
|
'cast5-ecb/pad:none'), 'hex');
|
|
-- result: EB 6A 71 1A 2C 02 27 1B
|
|
|
|
-- 40 bit key
|
|
SELECT encode(encrypt(
|
|
decode('01 23 45 67 89 AB CD EF', 'hex'),
|
|
decode('01 23 45 67 12', 'hex'),
|
|
'cast5-ecb/pad:none'), 'hex');
|
|
-- result: 7A C8 16 D1 6E 9B 30 2E
|
|
|
|
-- cbc
|
|
|
|
-- empty data
|
|
select encode( encrypt('', 'foo', 'cast5'), 'hex');
|
|
-- 10 bytes key
|
|
select encode( encrypt('foo', '0123456789', 'cast5'), 'hex');
|
|
|
|
-- decrypt
|
|
select decrypt(encrypt('foo', '0123456', 'cast5'), '0123456', 'cast5');
|
|
|
|
-- iv
|
|
select encode(encrypt_iv('foo', '0123456', 'abcd', 'cast5'), 'hex');
|
|
select decrypt_iv(decode('384a970695ce016a', 'hex'),
|
|
'0123456', 'abcd', 'cast5');
|
|
|