BUG #16452: pgp_sym_encrypt_bytea with compress-level=6 : Wrong key or corrupt data

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: frank(dot)gagnepain(at)intm(dot)fr
Subject: BUG #16452: pgp_sym_encrypt_bytea with compress-level=6 : Wrong key or corrupt data
Date: 2020-05-19 08:49:13
Message-ID: 16452-79d95977a17e5df7@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16452
Logged by: Frank Gagnepain
Email address: frank(dot)gagnepain(at)intm(dot)fr
PostgreSQL version: Unsupported/Unknown
Operating system: Debian 10
Description:

Hello to the community,

I get "ERROR: Wrong key or corrupt data" when using successively function
pgp_sym_encrypt_bytea and pgp_sym_decrypt_bytea on only some bytea data in
db with those options :
compress-algo=1 (ZIP algo)
cipher-algo=aes256
compress-level=6 (which is the default compress-level)
With any other value for compress-level (0,1,2,3,4,5,7,8,9) for
pgp_sym_encrypt_bytea, i get no error with pgp_sym_decrypt_bytea...
pgsql version is 9.4.21, and pgcrypto module is 1.1.

Here is what i do to test this error :

create or replace function bytea_import(p_path text, p_result out bytea)
language plpgsql as $$
declare
l_oid oid;
r record;
begin
p_result := '';
select lo_import(p_path) into l_oid;
for r in ( select data
from pg_largeobject
where loid = l_oid
order by pageno ) loop
p_result = p_result || r.data;
end loop;
perform lo_unlink(l_oid);
end;$$;

select
pgp_sym_decrypt_bytea(pgp_sym_encrypt_bytea(bytea_import(DATA),'password','compress-algo=1,
cipher-algo=aes256, compress-level=6'),'password','compress-algo=1,
cipher-algo=aes256');

ERROR: Wrong key or corrupt data

Unfortunately i cant post any example of DATA since those are supposed to be
sensitive data.
However, does this kind of error rings a bell to anyone ?

Browse pgsql-bugs by date

  From Date Subject
Next Message shawn wang 2020-05-19 09:40:38 Re: [bug] Table not have typarray when created by single user mode
Previous Message wenjing zeng 2020-05-19 08:19:56 Re: [bug] Table not have typarray when created by single user mode