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

Jeff Janes <jeff.janes@gmail.com>

From: Jeff Janes <jeff.janes@gmail.com>
To: frank.gagnepain@intm.fr, pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Date: 2020-06-03T12:35:02Z
Lists: pgsql-bugs

Attachments

> 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');
>
>
decryption reads the settings from the encrypted message header, there is
no need to specify them again.

I can reproduce this at any compression level if the data is random (not
compressible) and exactly 16365 bytes long.  If the data is compressible,
then you need a longer length of message to reproduce it and it depends on
the random content and compression level.

I'm attaching the reproducer as a Perl script.  I have not investigated the
C code of pgcrypto itself.

Cheers,

Jeff

Commits

  1. Fix corner case with 16kB-long decompression in pgcrypto, take 2

  2. Fix ancient violation of zlib's API spec.

  3. Revert "Fix corner case with PGP decompression in pgcrypto"

  4. Fix corner case with PGP decompression in pgcrypto