0

I have a weird behaviour after upgrading our database server from Postgresql 12 to Postgresql 15. I created all the required extensions with pgcrypto even the same version 1.3. It looks like the pgp decryption function with pgp_pub_decrypt works differently. I am using two functions to encypt and decrypt messages:

encode(pgp_pub_encrypt(toencode, dearmor(PGPPublic)), 'hex');

pgp_pub_decrypt(decode(todecode ,'hex'), dearmor(PGPPrivate), 'banana');

It works for years with Postgresql 12 but now with Postgresql 15 I get the error message: "Wrong key or corrupt data"

I compared the results from decode, dearmor and encode and they all behave the same. The public and private key are also exactly the same on both systems.

I checked the documentation and there are no changes I can see and I can't find any other help.

Just pgp_pub_decrypt(decode(todecode ,'hex'), dearmor(PGPPrivate), 'banana'); causes problems

Niels
  • 193
  • 2
  • 13

1 Answers1

0

I just recreated the pgp keys on the new machine and swapped them in the stored procedure. That seems to work. Perhaps it was related to a different OpenPGP version on the new db server? Shouldn't be but it works now ;-)

Niels
  • 193
  • 2
  • 13
  • 1
    Glad you got it working. Not precisely sure what the issue there was, but there were changes in the required openSSL() library that may play into the issue. I'll remember that if I have to update between versions where crypto functions are used. – David C. Rankin Jun 01 '23 at 08:20