2 -- PGP compression support
5 select pgp_sym_decrypt(dearmor('
6 -----BEGIN PGP MESSAGE-----
8 ww0ECQMCsci6AdHnELlh0kQB4jFcVwHMJg0Bulop7m3Mi36s15TAhBo0AnzIrRFrdLVCkKohsS6+
9 DMcmR53SXfLoDJOv/M8uKj3QSq7oWNIp95pxfA==
11 -----END PGP MESSAGE-----
12 '), 'key', 'expect-compress-algo=1');
14 select pgp_sym_decrypt(
15 pgp_sym_encrypt('Secret message', 'key', 'compress-algo=0'),
16 'key', 'expect-compress-algo=0');
18 select pgp_sym_decrypt(
19 pgp_sym_encrypt('Secret message', 'key', 'compress-algo=1'),
20 'key', 'expect-compress-algo=1');
22 select pgp_sym_decrypt(
23 pgp_sym_encrypt('Secret message', 'key', 'compress-algo=2'),
24 'key', 'expect-compress-algo=2');
26 -- level=0 should turn compression off
27 select pgp_sym_decrypt(
28 pgp_sym_encrypt('Secret message', 'key',
29 'compress-algo=2, compress-level=0'),
30 'key', 'expect-compress-algo=0');
32 -- check corner case involving an input string of 16kB, as per bug #16476.
36 -- This generates a random string of 16366 bytes. This is chosen
37 -- as random so that it does not get compressed, and the decompression
38 -- would work on a string with the same length as the origin, making the
39 -- test behavior more predictable. lpad() ensures that the generated
40 -- hexadecimal value is completed by extra zero characters if random()
41 -- has generated a value strictly lower than 16.
42 SELECT string_agg(decode(lpad(to_hex((random()*256)::int), 2, '0'), 'hex'), '') as bytes
43 FROM generate_series(0, 16365)
46 pgp_sym_decrypt_bytea(
47 pgp_sym_encrypt_bytea(bytes, 'key',
48 'compress-algo=1,compress-level=1'),
49 'key', 'expect-compress-algo=1')