From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Moreno Andreo <moreno.andreo@evolu-s.it>
To: PostgreSQL mailing lists <pgsql-general@postgresql.org>
Subject: Re: pgp_sym_decrypt() - error 39000: wrong key or corrupt data
Date: Thu, 21 Jun 2018 14:31:16 -0700
Message-ID: <94ecaa31-5960-6264-81f9-c8560a3f9fed@aklaver.com> (raw)
In-Reply-To: <1d7de609-5738-bf51-f0b9-b32a889f04e1@evolu-s.it>
References: <1d7de609-5738-bf51-f0b9-b32a889f04e1@evolu-s.it>
On 06/21/2018 08:36 AM, Moreno Andreo wrote:
> Hi,
> while playing with pgcrypto I ran into a strange issue (postgresql
> 9.5.3 x86 on Windows 7)
>
> Having a table with a field
> dateofbirth text
>
> I made the following sequence of SQL commands
> update tbl_p set dateofbirth = pgp_sym_encrypt('2018-06-21', 'AES_KEY')
> where codguid = '00000001-0001-0001-0001-000000000001';
> OK
>
> select pgp_sym_decrypt(dateofbirth::bytea, 'AES_KEY') as datanasc from
> tbl_p where codguid = '00000001-0001-0001-0001-000000000001'
> '2018-06-21'
>
> select * from tab_paz where pgp_sym_decrypt(natoil::bytea, 'AES_KEY') =
> '2018-06-21'
You switched gears above.
What is the data type of the natoil field in table tab_paz?
Was the data encrypted in it using the 'AES_KEY'?
I can replicate the below by doing:
select pgp_sym_decrypt(pgp_sym_encrypt('2018-06-21', 'AES_KEY'), 'AES');
ERROR: Wrong key or corrupt data
> ERROR: Wrong key or corrupt data
> ********** Error **********
>
> ERROR: Wrong key or corrupt data
> SQL state: 39000
>
> Can't find reference anywhere...
> Any help would be appreciated.
> Thanks,
> Moreno.-
>
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, moreno.andreo@evolu-s.it
Subject: Re: pgp_sym_decrypt() - error 39000: wrong key or corrupt data
In-Reply-To: <94ecaa31-5960-6264-81f9-c8560a3f9fed@aklaver.com>
References: <1d7de609-5738-bf51-f0b9-b32a889f04e1@evolu-s.it> <94ecaa31-5960-6264-81f9-c8560a3f9fed@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox