Re: BUG #11905: "Error: Wrong key or corrupt data" with pgp_sym_decrypt when bytea size is 2^x - 6 where x >=14

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: connor(dot)penhale(at)openlogic(dot)com
Cc: Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #11905: "Error: Wrong key or corrupt data" with pgp_sym_decrypt when bytea size is 2^x - 6 where x >=14
Date: 2014-11-11 17:52:08
Message-ID: CAMkU=1ykOR3A4vOBiuYTKYvB0o9bg9j5r_txNUcLwQKTBQwFrw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Nov 7, 2014 at 1:56 PM, <connor(dot)penhale(at)openlogic(dot)com> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 11905
> Logged by: Connor Penhale
> Email address: connor(dot)penhale(at)openlogic(dot)com
> PostgreSQL version: 9.3.1
> Operating system: OS X Yosemitie
> Description:
>
> Hello Postgres Community,
>
> When I attempt to decrypt a file I successfully encrypted with a size of
> 65530, I get the “Error: Wrong key or corrupt data” message.
>
...

> I’ve been able to reproduce this on Postgres 9.1 and 9.3.
>

I can reproduce this error, and first get it at a size of 16378 (i.e.
2^14-6).

I can reproduce it also against the development head code, including after
applying the recently proposed patch
http://www.postgresql.org/message-id/5454F3C2.608@joh.to

I can reproduce it easily with the single query:

select pgp_sym_decrypt(pgp_sym_encrypt(?,'I am the password'),'I am the
password','debug=1')

The problem is that mdc_read is getting invoked with an len argument of 0.
When it successfully reads 0 bytes, it interprets that as an error. I
can't figure out why it is getting invoked with a length of 0, too many
pointer indirections for me to follow at this time.

Cheers,

Jeff

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Marko Tiikkaja 2014-11-11 18:11:20 Re: BUG #11905: "Error: Wrong key or corrupt data" with pgp_sym_decrypt when bytea size is 2^x - 6 where x >=14
Previous Message robert.wysocki 2014-11-11 15:58:41 BUG #11939: Missing "actual time" in auto_explain plans