By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,994 Members | 2,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,994 IT Pros & Developers. It's quick & easy.

Corrupt Data error in Decryption in PostgreSQL using GnuPG

P: 5
I am using GnuPG software for assymetric encryption in PostgreSQL.
I have done encryption using

Expand|Select|Wrap|Line Numbers
  1. ->INSERT INTO "test1"("test") 
  2.  ->   VALUES (pgp_pub_encrypt('testing', dearmor('------>BEGIN PGP PUBLIC KEY BLOCK-----
  3. ->Version: GnuPG v2.0.17 (MingW32)
  5. ->..............
  6. ->-----END PGP PUBLIC KEY BLOCK-----'
  8. ->)));
and got succeded

but when i am doing decryption with syntax:-

Expand|Select|Wrap|Line Numbers
  1. ->SELECT pgp_pub_decrypt(bytea ("test"),
  2. ->dearmor('-----BEGIN PGP PRIVATE KEY BLOCK-----
  3. ->Version: GnuPG v2.0.17 (MingW32)
  4. ->.............................
  5. ->-----END PGP PRIVATE KEY BLOCK-----'),'decrypt123')  --> ->this is the passphrase 
  6.  -> FROM "test1"; 

I am getting error as:-

->ERROR: Corrupt data

->********** Error **********

->ERROR: Corrupt data
->SQL state: 39000

Please guide me where i am going i need this urgently
Oct 9 '12 #1
Share this Question
Share on Google+
6 Replies

Expert Mod 10K+
P: 12,349
Please use code tags when posting code.

This is from the PostgreSQL manual: Decrypting bytea data with pgp_pub_decrypt is disallowed. This is to avoid outputting invalid character data.
Oct 9 '12 #2

P: 5
I have even tried with pgp_pub_decrypt_bytea but am getting same erorr..please help..
Oct 9 '12 #3

Expert Mod 10K+
P: 12,349
It could be that the public key and secret key you're using is out of sync. Try generating new pairs and using those. Or it could be that the password you're using for the secret key is wrong. It's hard to say because the error is so generic.
Oct 9 '12 #4

P: 5
I regenerated the keys and even used the correct passphrase. I am still getting this error. Am i using the correct approach for public key encryption? Do i need to write some extra code for making decryption successful?
please help.
Oct 10 '12 #5

Expert Mod 10K+
P: 12,349
Sorry, I haven't used that function much. Hopefully there's someone here with more experience with that.
Oct 10 '12 #6

P: 5
Its ok and thanx for your help. I got success after making keys passwrdless. After removing passphrase column,decryption is successful.
Oct 11 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.