pgcrypto pgp_pub_decrypt() fails with secret key password

From: Eric Lukather <ericlukather(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: pgcrypto pgp_pub_decrypt() fails with secret key password
Date: 2010-09-12 19:57:54
Message-ID: 917399.19825.qm@web55701.mail.re3.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have pgcrypto working fine with gpg keys that do *not* have a passphrase. But,
if I try the exact same gpg -a --export commands and application code with gpg
keys that are generated *with* a passphrase, then I get the following
pgp_pub_decrypt() error within psql:

\set pubkey '''' `sed -e "s/'/''/g" -e 's/\\n/\\r\\n/g' -e 's/\\/\\\\/g' <
test-public.key` ''''
\set prvkey '''' `sed -e "s/'/''/g" -e 's/\\n/\\r\\n/g' -e 's/\\/\\\\/g' <
test-secret.key` ''''
SELECT pgp_pub_decrypt( dearmor( (SELECT armor((SELECT pgp_pub_encrypt('mypass',
dearmor(:pubkey))))) ), dearmor(:prvkey), 'test' );
ERROR: Corrupt data

Here are my versions:

PostgreSQL version: 8.4.4
GPG version: 1.4.10
(both were built with OpenSSL support)

I've verified my SQL code via psql and I feel pretty confident it's OK, since I
have it narrowed down to where the only difference is whether the gpg exported
keys were originally assigned with a passphrase, or not assigned a passphrase
(just press enter when prompted), when running "gpg --gen-key".

Any troubleshooting help or suggestions would be greatly appreciated!

Thanks, -Eric

Browse pgsql-general by date

  From Date Subject
Next Message sunpeng 2010-09-12 20:48:59 Re: why can't see the updated value after SPI_execute("update ....", false, 1);
Previous Message Casey Jones 2010-09-12 18:44:22 Re: Huge amount of memory errors with libpq