2021-08-10 21:08:46 +08:00
|
|
|
--
|
|
|
|
-- Blowfish cipher
|
|
|
|
--
|
|
|
|
-- some standard Blowfish testvalues
|
2021-12-08 13:01:35 +08:00
|
|
|
SELECT encrypt('\x0000000000000000', '\x0000000000000000', 'bf-ecb/pad:none');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-12-08 13:01:35 +08:00
|
|
|
SELECT encrypt('\xffffffffffffffff', '\xffffffffffffffff', 'bf-ecb/pad:none');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-12-08 13:01:35 +08:00
|
|
|
SELECT encrypt('\x1000000000000001', '\x3000000000000000', 'bf-ecb/pad:none');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-12-08 13:01:35 +08:00
|
|
|
SELECT encrypt('\x1111111111111111', '\x1111111111111111', 'bf-ecb/pad:none');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-12-08 13:01:35 +08:00
|
|
|
SELECT encrypt('\x0123456789abcdef', '\xfedcba9876543210', 'bf-ecb/pad:none');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-12-08 13:01:35 +08:00
|
|
|
SELECT encrypt('\x01a1d6d039776742', '\xfedcba9876543210', 'bf-ecb/pad:none');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-12-08 13:01:35 +08:00
|
|
|
SELECT encrypt('\xffffffffffffffff', '\x0000000000000000', 'bf-ecb/pad:none');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-08-10 21:08:46 +08:00
|
|
|
-- setkey
|
2021-12-08 13:01:35 +08:00
|
|
|
SELECT encrypt('\xfedcba9876543210', '\xf0e1d2c3b4a5968778695a4b3c2d1e0f', 'bf-ecb/pad:none');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-08-10 21:08:46 +08:00
|
|
|
-- with padding
|
2021-12-08 13:01:35 +08:00
|
|
|
SELECT encrypt('\x01234567890123456789', '\x33443344334433443344334433443344', 'bf-ecb');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-08-10 21:08:46 +08:00
|
|
|
-- cbc
|
|
|
|
-- 28 bytes key
|
2021-12-08 13:01:35 +08:00
|
|
|
SELECT encrypt('\x6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5',
|
|
|
|
'\x37363534333231204e6f77206973207468652074696d6520666f7220',
|
|
|
|
'bf-cbc');
|
2021-08-10 21:08:46 +08:00
|
|
|
ERROR: encrypt error: Key was too big
|
|
|
|
-- 29 bytes key
|
2021-12-08 13:01:35 +08:00
|
|
|
SELECT encrypt('\x6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc',
|
|
|
|
'\x37363534333231204e6f77206973207468652074696d6520666f722000',
|
|
|
|
'bf-cbc');
|
2021-08-10 21:08:46 +08:00
|
|
|
ERROR: encrypt error: Key was too big
|
|
|
|
-- blowfish-448
|
2021-12-08 13:01:35 +08:00
|
|
|
SELECT encrypt('\xfedcba9876543210',
|
|
|
|
'\xf0e1d2c3b4a5968778695a4b3c2d1e0f001122334455667704689104c2fd3b2f584023641aba61761f1f1f1f0e0e0e0effffffffffffffff',
|
|
|
|
'bf-ecb/pad:none');
|
2021-08-10 21:08:46 +08:00
|
|
|
ERROR: encrypt error: Key was too big
|
|
|
|
-- empty data
|
2021-12-08 13:01:35 +08:00
|
|
|
select encrypt('', 'foo', 'bf');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-08-10 21:08:46 +08:00
|
|
|
-- 10 bytes key
|
2021-12-08 13:01:35 +08:00
|
|
|
select encrypt('foo', '0123456789', 'bf');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-08-10 21:08:46 +08:00
|
|
|
-- 22 bytes key
|
2021-12-08 13:01:35 +08:00
|
|
|
select encrypt('foo', '0123456789012345678901', 'bf');
|
2021-08-10 21:08:46 +08:00
|
|
|
ERROR: encrypt error: Key was too big
|
|
|
|
-- decrypt
|
2021-12-08 13:01:35 +08:00
|
|
|
select encode(decrypt(encrypt('foo', '0123456', 'bf'), '0123456', 'bf'), 'escape');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-08-10 21:08:46 +08:00
|
|
|
-- iv
|
2021-12-08 13:01:35 +08:00
|
|
|
select encrypt_iv('foo', '0123456', 'abcd', 'bf');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt_iv error: Cipher cannot be initialized
|
2021-12-08 13:01:35 +08:00
|
|
|
select encode(decrypt_iv('\x95c7e89322525d59', '0123456', 'abcd', 'bf'), 'escape');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: decrypt_iv error: Cipher cannot be initialized
|
2021-08-10 21:08:46 +08:00
|
|
|
-- long message
|
2021-12-08 13:01:35 +08:00
|
|
|
select encrypt('Lets try a longer message.', '0123456789', 'bf');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|
2021-12-08 13:01:35 +08:00
|
|
|
select encode(decrypt(encrypt('Lets try a longer message.', '0123456789', 'bf'), '0123456789', 'bf'), 'escape');
|
2022-05-06 20:41:36 +08:00
|
|
|
ERROR: encrypt error: Cipher cannot be initialized
|