| 1 |
-- |
| 2 |
-- PGP encrypt |
| 3 |
-- |
| 4 |
|
| 5 |
select pgp_sym_decrypt(pgp_sym_encrypt('Secret.', 'key'), 'key'); |
| 6 |
|
| 7 |
-- check whether the defaults are ok |
| 8 |
select pgp_sym_decrypt(pgp_sym_encrypt('Secret.', 'key'), |
| 9 |
'key', 'expect-cipher-algo=aes128, |
| 10 |
expect-disable-mdc=0, |
| 11 |
expect-sess-key=0, |
| 12 |
expect-s2k-mode=3, |
| 13 |
expect-s2k-digest-algo=sha1, |
| 14 |
expect-compress-algo=0 |
| 15 |
'); |
| 16 |
|
| 17 |
-- maybe the expect- stuff simply does not work |
| 18 |
select pgp_sym_decrypt(pgp_sym_encrypt('Secret.', 'key'), |
| 19 |
'key', 'expect-cipher-algo=bf, |
| 20 |
expect-disable-mdc=1, |
| 21 |
expect-sess-key=1, |
| 22 |
expect-s2k-mode=0, |
| 23 |
expect-s2k-digest-algo=md5, |
| 24 |
expect-compress-algo=1 |
| 25 |
'); |
| 26 |
|
| 27 |
-- bytea as text |
| 28 |
select pgp_sym_decrypt(pgp_sym_encrypt_bytea('Binary', 'baz'), 'baz'); |
| 29 |
|
| 30 |
-- text as bytea |
| 31 |
select encode(pgp_sym_decrypt_bytea(pgp_sym_encrypt('Text', 'baz'), 'baz'), 'escape'); |
| 32 |
|
| 33 |
|
| 34 |
-- algorithm change |
| 35 |
select pgp_sym_decrypt( |
| 36 |
pgp_sym_encrypt('Secret.', 'key', 'cipher-algo=bf'), |
| 37 |
'key', 'expect-cipher-algo=bf'); |
| 38 |
select pgp_sym_decrypt( |
| 39 |
pgp_sym_encrypt('Secret.', 'key', 'cipher-algo=aes'), |
| 40 |
'key', 'expect-cipher-algo=aes128'); |
| 41 |
select pgp_sym_decrypt( |
| 42 |
pgp_sym_encrypt('Secret.', 'key', 'cipher-algo=aes192'), |
| 43 |
'key', 'expect-cipher-algo=aes192'); |
| 44 |
|
| 45 |
-- s2k change |
| 46 |
select pgp_sym_decrypt( |
| 47 |
pgp_sym_encrypt('Secret.', 'key', 's2k-mode=0'), |
| 48 |
'key', 'expect-s2k-mode=0'); |
| 49 |
select pgp_sym_decrypt( |
| 50 |
pgp_sym_encrypt('Secret.', 'key', 's2k-mode=1'), |
| 51 |
'key', 'expect-s2k-mode=1'); |
| 52 |
select pgp_sym_decrypt( |
| 53 |
pgp_sym_encrypt('Secret.', 'key', 's2k-mode=3'), |
| 54 |
'key', 'expect-s2k-mode=3'); |
| 55 |
|
| 56 |
-- s2k count change |
| 57 |
select pgp_sym_decrypt( |
| 58 |
pgp_sym_encrypt('Secret.', 'key', 's2k-count=1024'), |
| 59 |
'key', 'expect-s2k-count=1024'); |
| 60 |
-- s2k_count rounds up |
| 61 |
select pgp_sym_decrypt( |
| 62 |
pgp_sym_encrypt('Secret.', 'key', 's2k-count=65000000'), |
| 63 |
'key', 'expect-s2k-count=65000000'); |
| 64 |
|
| 65 |
-- s2k digest change |
| 66 |
select pgp_sym_decrypt( |
| 67 |
pgp_sym_encrypt('Secret.', 'key', 's2k-digest-algo=sha1'), |
| 68 |
'key', 'expect-s2k-digest-algo=sha1'); |
| 69 |
|
| 70 |
-- sess key |
| 71 |
select pgp_sym_decrypt( |
| 72 |
pgp_sym_encrypt('Secret.', 'key', 'sess-key=0'), |
| 73 |
'key', 'expect-sess-key=0'); |
| 74 |
select pgp_sym_decrypt( |
| 75 |
pgp_sym_encrypt('Secret.', 'key', 'sess-key=1'), |
| 76 |
'key', 'expect-sess-key=1'); |
| 77 |
select pgp_sym_decrypt( |
| 78 |
pgp_sym_encrypt('Secret.', 'key', 'sess-key=1, cipher-algo=bf'), |
| 79 |
'key', 'expect-sess-key=1, expect-cipher-algo=bf'); |
| 80 |
select pgp_sym_decrypt( |
| 81 |
pgp_sym_encrypt('Secret.', 'key', 'sess-key=1, cipher-algo=aes192'), |
| 82 |
'key', 'expect-sess-key=1, expect-cipher-algo=aes192'); |
| 83 |
select pgp_sym_decrypt( |
| 84 |
pgp_sym_encrypt('Secret.', 'key', 'sess-key=1, cipher-algo=aes256'), |
| 85 |
'key', 'expect-sess-key=1, expect-cipher-algo=aes256'); |
| 86 |
|
| 87 |
-- no mdc |
| 88 |
select pgp_sym_decrypt( |
| 89 |
pgp_sym_encrypt('Secret.', 'key', 'disable-mdc=1'), |
| 90 |
'key', 'expect-disable-mdc=1'); |
| 91 |
|
| 92 |
-- crlf |
| 93 |
select pgp_sym_decrypt_bytea( |
| 94 |
pgp_sym_encrypt(E'1\n2\n3\r\n', 'key', 'convert-crlf=1'), |
| 95 |
'key'); |
| 96 |
|
| 97 |
-- conversion should be lossless |
| 98 |
select digest(pgp_sym_decrypt( |
| 99 |
pgp_sym_encrypt(E'\r\n0\n1\r\r\n\n2\r', 'key', 'convert-crlf=1'), |
| 100 |
'key', 'convert-crlf=1'), 'sha1') as result, |
| 101 |
digest(E'\r\n0\n1\r\r\n\n2\r', 'sha1') as expect; |