BUG #16476: pgp_sym_encrypt_bytea with compress-level=6 : Wrong key or corrupt data
The Post Office <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: frank.gagnepain@intm.fr
Date: 2020-06-03T07:41:21Z
Lists: pgsql-bugs
The following bug has been logged on the website: Bug reference: 16476 Logged by: Frank Gagnepain Email address: frank.gagnepain@intm.fr PostgreSQL version: 10.13 Operating system: Debian 10 Description: Hello to the support team, I already sent a bug report for this issue, but PostgreSQL version was 9.4.21 which isnt supported anymore So we tested this bug with a 10.13 PostgreSQL version this time and we got the exact same issue. 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... 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. Nevertheless, does this kind of error rings a bell to anyone ?
Commits
-
Fix corner case with 16kB-long decompression in pgcrypto, take 2
- aaa132a65deb 9.5.23 landed
- 8a60f541f3e4 9.6.19 landed
- 9729f99798af 10.14 landed
- 202fc4ca531e 11.9 landed
- 5bd087eb5d77 12.4 landed
- 0caf1fc6e86a 13.0 landed
- a3ab7a707d9e 14.0 landed
-
Fix ancient violation of zlib's API spec.
- d0519e9fea96 9.5.23 landed
- ccf964a80100 9.6.19 landed
- d8ec3b1263d2 10.14 landed
- 475c69c97662 11.9 landed
- 3d4a778152ec 12.4 landed
- b9b610577d7f 14.0 landed
- 7dab4569d193 13.0 landed
-
Revert "Fix corner case with PGP decompression in pgcrypto"
- 43e21fd8f6e8 9.5.23 landed
- 11c320dcebc0 9.6.19 landed
- 9a3c895084c6 10.14 landed
- 6ae2d925b131 11.9 landed
- e30a63f258f5 12.4 landed
- 9f5162ef43c5 13.0 landed
- 38f60f174e32 14.0 landed
-
Fix corner case with PGP decompression in pgcrypto
- dbf17ca1bfab 9.5.23 landed
- e0cb8282d614 9.6.19 landed
- 5bfd0936b460 10.14 landed
- eceb415c6ff0 11.9 landed
- bba2e66aec4c 12.4 landed
- 35e142202b14 13.0 landed
- 9e108984fb35 14.0 landed