Re: Problem with encode () and hmac() in pgcrypto - Mailing list pgsql-general

From Marko Kreen
Subject Re: Problem with encode () and hmac() in pgcrypto
Date
Msg-id AANLkTikJdpiv9GDcS_9sXhTE=ZMxfvWV4BzxCKDcQ0MQ@mail.gmail.com
Whole thread Raw
In response to Problem with encode () and hmac() in pgcrypto  (hlcborg <h.luis.cardoso@gmail.com>)
Responses Re: Problem with encode () and hmac() in pgcrypto  (hlcborg <h.luis.cardoso@gmail.com>)
List pgsql-general
On Tue, Feb 1, 2011 at 5:36 PM, hlcborg <h.luis.cardoso@gmail.com> wrote:
> encode(hmac(v_em_crt_conc, v_Private,'sha1'),'base64');

HMAC - key-dependant SHA1

> The Result:
>
> h6CpmrP1QCE/Mp3xn3utUEPtftg=      This hash has 28 chars
>
> When I use OpenSSL in command line like this:
>
> ~$ echo "2011-01-31;2011-02-01T13:33:38;100036;684.40; " | openssl dgst
> -sha1 -sign abc.pem | openssl enc -base64 -A

Plain SHA1, which is signed with RSA signature.

> The Result is:
>
>
nKfxnt31+kk/RnKihJ0jKufq+nZvmPjVauGo8+tqJ1Y/ah/mAu4jSS1wnzU+wRygZ4CLIV9DGSs9bxBc4r9e71C8s9B5ms6Kpggmc12kdmqVHBRO28bPWb/YLCej59gZFFkvcCudweNAT4qHvVqWsOtFCf9kE4q92UIv1JcwSDU=
>
> This hash has 172 chars
>
> Does someone know where is my problem? Is there other way to implement?  or
> is it simply impossible??

These two operations are not equivalent.

--
marko

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Some Problems - Shall I reinstall the DB?
Next
From: "Joshua D. Drake"
Date:
Subject: Re: cast problem in Postgresql 9.0.1