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

From: Frank Gagnepain <frank(dot)gagnepain(at)intm(dot)fr>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: RE: BUG #16476: pgp_sym_encrypt_bytea with compress-level=6 : Wrong key or corrupt data
Date: 2020-06-10 15:17:51
Message-ID: AM0PR02MB53960FAC211D184EFDFA6B9DFC830@AM0PR02MB5396.eurprd02.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello again,

Thank you for this script ,

We managed to get you an example of data that triggers the error message (with compress-level=6) in attachments.
You would have to unzip first and then test it (I mean it hasnt been zipped by pgcrypto).

Cheers,

Frank GAGNEPAIN

________________________________
De : Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Envoyé : mercredi 3 juin 2020 14:35
À : Frank Gagnepain <frank(dot)gagnepain(at)intm(dot)fr>; pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Objet : Re: BUG #16476: pgp_sym_encrypt_bytea with compress-level=6 : Wrong key or corrupt data

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

Attachment Content-Type Size
CP04003072_PART2_SANS_ENTETE.zip application/zip 676.2 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Geoghegan 2020-06-11 01:10:25 Re: Potential G2-item cycles under serializable isolation
Previous Message David G. Johnston 2020-06-10 15:09:46 Re: pg_cancel_backend() doesn't abort a transaction