pgp encryption functions

From: Christian Petzold <C(dot)Petzold(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: pgp encryption functions
Date: 2009-11-07 20:35:15
Message-ID: 4AF5DA03.6060207@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,
I'm trying to use the pgp_pub_encrypt and pgp_pub_decrypt_bytea
functions to store some data in my db.

This is how I encrypt:

INSERT INTO "Test"(
"test")
VALUES (pgp_pub_encrypt('test', dearmor('-----BEGIN PGP PUBLIC KEY
BLOCK-----
Version: GnuPG v2.0.12 (MingW32)

mQENBErk2KkBCAC.... (public key block) ...
-----END PGP PUBLIC KEY BLOCK-----
')));

And this is how I try to decrypt:

SELECT pgp_pub_decrypt_bytea(bytea ("test"), dearmor('-----BEGIN PGP
PRIVATE KEY BLOCK-----
Version: GnuPG v2.0.12 (MingW32)

lQO+BErk2KkBC... (private key block) ...
-----END PGP PRIVATE KEY BLOCK-----
'), 'ktulu3437') --> this is the passphrase
FROM "Test";

Encryptions works fine, but the decrypting returns "Corrupt data".
What am I doing wrong?

Christian Petzold.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vlad Romascanu 2009-11-08 01:33:22 Why the mismatch? {row size reported by VACUUM} vs. {table size on disk / number of rows} vs. {sum of column type sizes}
Previous Message Jeff Davis 2009-11-07 19:06:16 Re: slony issues.