Thread: pgp encryption functions

pgp encryption functions

From
Christian Petzold
Date:
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.



Re: pgp encryption functions

From
Martin Gainty
Date:
i have to ask ..any relation to guru charles petzold?
http://en.wikipedia.org/wiki/Charles_Petzold

Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.





> Date: Sat, 7 Nov 2009 21:35:15 +0100
> From: C.Petzold@gmx.net
> To: pgsql-general@postgresql.org
> Subject: [GENERAL] pgp encryption functions
>
> 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.
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general


Hotmail: Trusted email with powerful SPAM protection. Sign up now.

Re: pgp encryption functions

From
Marko Kreen
Date:
On 11/7/09, Christian Petzold <C.Petzold@gmx.net> wrote:
>  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?

- if this is the SQL you test with, make sure the table is empty...

- this message may also appear if the passphrase for secret key is wrong.
  [this needs fixing]

- make sure the secret key really corresponds to public key

If none of these fix your problem, please send repeatable test-case
(with temp key).

--
marko