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

From Jeff Janes
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
Msg-id CAMkU=1ykOR3A4vOBiuYTKYvB0o9bg9j5r_txNUcLwQKTBQwFrw@mail.gmail.com
Whole thread Raw
In response to BUG #11905: "Error: Wrong key or corrupt data" with pgp_sym_decrypt when bytea size is 2^x - 6 where x >=14  (connor.penhale@openlogic.com)
Responses Re: BUG #11905: "Error: Wrong key or corrupt data" with pgp_sym_decrypt when bytea size is 2^x - 6 where x >=14  (Marko Tiikkaja <marko@joh.to>)
List pgsql-bugs
On Fri, Nov 7, 2014 at 1:56 PM, <connor.penhale@openlogic.com> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      11905
> Logged by:          Connor Penhale
> Email address:      connor.penhale@openlogic.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 =E2=80=9CError: Wrong key or corrupt data=E2=80=9D messa=
ge.
>
...


> I=E2=80=99ve 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=3D1')


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

pgsql-bugs by date:

Previous
From: Marti Raudsepp
Date:
Subject: Re: [DOCS] BUG #11661: CASE ELSE is evaluated although condition is true
Next
From: Marko Tiikkaja
Date:
Subject: Re: BUG #11905: "Error: Wrong key or corrupt data" with pgp_sym_decrypt when bytea size is 2^x - 6 where x >=14