1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

pgcrypto: Remove explicit hex encoding/decoding from tests

This was from before the hex format was available in bytea.  Now we
can remove the extra explicit encoding/decoding calls and rely on the
default output format.

Discussion: https://www.postgresql.org/message-id/flat/17dcb4f7-7ac1-e2b6-d5f7-2dfba06cd9ee%40enterprisedb.com
This commit is contained in:
Peter Eisentraut
2021-12-08 06:01:35 +01:00
parent 00029deaf6
commit 814e1d9ff7
34 changed files with 808 additions and 1043 deletions

View File

@ -1,31 +1,25 @@
--
-- 3DES cipher
--
-- ensure consistent test output regardless of the default bytea format
SET bytea_output TO escape;
-- test vector from somewhere
SELECT encode(encrypt(
decode('80 00 00 00 00 00 00 00', 'hex'),
decode('01 01 01 01 01 01 01 01
01 01 01 01 01 01 01 01
01 01 01 01 01 01 01 01', 'hex'),
'3des-ecb/pad:none'), 'hex');
-- val 95 F8 A5 E5 DD 31 D9 00
SELECT encrypt('\x8000000000000000',
'\x010101010101010101010101010101010101010101010101',
'3des-ecb/pad:none');
select encode( encrypt('', 'foo', '3des'), 'hex');
select encrypt('', 'foo', '3des');
-- 10 bytes key
select encode( encrypt('foo', '0123456789', '3des'), 'hex');
select encrypt('foo', '0123456789', '3des');
-- 22 bytes key
select encode( encrypt('foo', '0123456789012345678901', '3des'), 'hex');
select encrypt('foo', '0123456789012345678901', '3des');
-- decrypt
select decrypt(encrypt('foo', '0123456', '3des'), '0123456', '3des');
select encode(decrypt(encrypt('foo', '0123456', '3des'), '0123456', '3des'), 'escape');
-- iv
select encode(encrypt_iv('foo', '0123456', 'abcd', '3des'), 'hex');
select decrypt_iv(decode('50735067b073bb93', 'hex'), '0123456', 'abcd', '3des');
select encrypt_iv('foo', '0123456', 'abcd', '3des');
select encode(decrypt_iv('\x50735067b073bb93', '0123456', 'abcd', '3des'), 'escape');
-- long message
select encode(encrypt('Lets try a longer message.', '0123456789012345678901', '3des'), 'hex');
select decrypt(encrypt('Lets try a longer message.', '0123456789012345678901', '3des'), '0123456789012345678901', '3des');
select encrypt('Lets try a longer message.', '0123456789012345678901', '3des');
select encode(decrypt(encrypt('Lets try a longer message.', '0123456789012345678901', '3des'), '0123456789012345678901', '3des'), 'escape');