Re: Move OpenSSL random under USE_OPENSSL_RANDOM

Daniel Gustafsson <daniel@yesql.se>

From: Daniel Gustafsson <daniel@yesql.se>
To: Michael Paquier <michael@paquier.xyz>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Magnus Hagander <magnus@hagander.net>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-11-19T09:25:20Z
Lists: pgsql-hackers
> On 19 Nov 2020, at 04:34, Michael Paquier <michael@paquier.xyz> wrote:
> 
> On Wed, Nov 18, 2020 at 10:43:35AM +0100, Daniel Gustafsson wrote:
>> While it does simplify configure.ac, I'm just not a fan of the strict ordering
>> which is required without the labels even implying it.  But that might just be
>> my personal preference.
> 
> I just looked at that, and the attached seems more intuitive to me.

Ok.  I would add a strongly worded comment about the importance of the ordering
since that is now crucial not to break.

-#ifdef USE_WIN32_RANDOM
+#ifdef WIN32
 #include <wincrypt.h>
 #endif
 
-#ifdef USE_WIN32_RANDOM
+#ifdef WIN32
 /*
  * Cache a global crypto provider that only gets freed when the process
  * exits, in case we need random numbers more than once.
@@ -39,7 +39,7 @@
 static HCRYPTPROV hProvider = 0;
 #endif

This will pull in headers and define hProvider for all Windows builds even if
they use OpenSSL, but perhaps that doesn't matter?

cheers ./daniel


Commits

  1. Remove ability to independently select random number generator

  2. Add pg_strong_random_init function to initialize random number generator