Re: Cryptohash OpenSSL error queue in FIPS enabled builds

2022-05-08 Thread Michael Paquier
On Tue, Apr 26, 2022 at 03:15:24PM +0200, Daniel Gustafsson wrote: > On 26 Apr 2022, at 03:55, Michael Paquier wrote: >> I am a bit annoyed to assume that having only a localized >> ERR_clear_error() in the error code path of the init() call is the >> only problem that would occur, only because th

Re: Cryptohash OpenSSL error queue in FIPS enabled builds

2022-04-26 Thread Daniel Gustafsson
> On 26 Apr 2022, at 03:55, Michael Paquier wrote: > > On Tue, Apr 26, 2022 at 12:07:32AM +0200, Daniel Gustafsson wrote: >> In this particular codepath I think we can afford clearing it on the way out, >> with a comment explaining why. It's easily reproducible and adding a call >> and >> a com

Re: Cryptohash OpenSSL error queue in FIPS enabled builds

2022-04-25 Thread Michael Paquier
On Tue, Apr 26, 2022 at 12:07:32AM +0200, Daniel Gustafsson wrote: > In this particular codepath I think we can afford clearing it on the way out, > with a comment explaining why. It's easily reproducible and adding a call and > a comment is a good documentation for ourselves of this OpenSSL behav

Re: Cryptohash OpenSSL error queue in FIPS enabled builds

2022-04-25 Thread Tom Lane
Daniel Gustafsson writes: > In this particular codepath I think we can afford clearing it on the way out, > with a comment explaining why. Yeah. It seems out of the ordinary for an OpenSSL call to stack two error conditions, so treating a known case of that specially seems reasonable. Patches s

Re: Cryptohash OpenSSL error queue in FIPS enabled builds

2022-04-25 Thread Daniel Gustafsson
> On 25 Apr 2022, at 02:50, Michael Paquier wrote: > On Sat, Apr 23, 2022 at 11:40:19PM +0200, Daniel Gustafsson wrote: >> On 22 Apr 2022, at 19:01, Tom Lane wrote: >>> It seems like that solution means you're leaving an extra error in the >>> queue to >>> break unrelated code. Wouldn't it be

Re: Cryptohash OpenSSL error queue in FIPS enabled builds

2022-04-24 Thread Michael Paquier
On Sat, Apr 23, 2022 at 11:40:19PM +0200, Daniel Gustafsson wrote: > On 22 Apr 2022, at 19:01, Tom Lane wrote: >> Daniel Gustafsson writes: >>> Consuming all (both) errors and creating a concatenated string seems >>> overkill >>> as it would alter the API from a const error string to something t

Re: Cryptohash OpenSSL error queue in FIPS enabled builds

2022-04-23 Thread Daniel Gustafsson
> On 22 Apr 2022, at 19:01, Tom Lane wrote: > Daniel Gustafsson writes: >> Consuming all (both) errors and creating a concatenated string seems overkill >> as it would alter the API from a const error string to something that needs >> freeing etc (also, very few OpenSSL consumers actually drain

Re: Cryptohash OpenSSL error queue in FIPS enabled builds

2022-04-22 Thread Tom Lane
Daniel Gustafsson writes: > It turns out that OpenSSL places two errors in the queue for this operation, > and we only consume one without clearing the queue in between, so we grab an > error from the previous run. Ugh. > Consuming all (both) errors and creating a concatenated string seems overk

Cryptohash OpenSSL error queue in FIPS enabled builds

2022-04-22 Thread Daniel Gustafsson
In trying out an OpenSSL 3.1 build with FIPS enabled I realized that our cryptohash code had a small issue. Calling a banned cipher generated two different error messages interleaved: postgres=# select md5('foo'); ERROR: could not compute MD5 hash: unsupported postgres=# select md5('foo');