pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
scram-sha-256 authentication broken in FIPS mode
13+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2020-09-28 e21cbb4b89 4f48a6fbe2  Change SHA2 implementation based on OpenSSL to use EVP digest routines
* scram-sha-256 authentication broken in FIPS mode
@ 2018-09-05 03:29 Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 04:27 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 13+ messages in thread

From: Alessandro Gherardi @ 2018-09-05 03:29 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

It looks like scram-sha-256 doesn't work when postgres is linked against FIPS-enabled OpenSSL and FIPS mode is turned on.

Specifically, all login attempts fail with an OpenSSL error saying something along the lines of "Low level API call to digest SHA256 forbidden in fips mode".
I think this issue could be solved by refactoring the code in sha2_openssl.c to use the OpenSSL EVP interface (see https://wiki.openssl.org/index.php/EVP_Message_Digests ).
Any thoughts? Is this a known issue?
Thank you in advance.Alessandro

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: scram-sha-256 authentication broken in FIPS mode
  2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
@ 2018-09-05 04:27 ` Michael Paquier <michael@paquier.xyz>
  2018-09-05 13:19   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  0 siblings, 1 reply; 13+ messages in thread

From: Michael Paquier @ 2018-09-05 04:27 UTC (permalink / raw)
  To: Alessandro Gherardi <alessandro.gherardi@yahoo.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Wed, Sep 05, 2018 at 03:29:31AM +0000, Alessandro Gherardi wrote:
> It looks like scram-sha-256 doesn't work when postgres is linked
> against FIPS-enabled OpenSSL and FIPS mode is turned on.
> 
> Specifically, all login attempts fail with an OpenSSL error saying
> something along the lines of "Low level API call to digest SHA256
> forbidden in fips mode".

The error comes from libc, right?  Postgres can of course be configured
to work with FIPS without patching it, it just needs to be enabled
system-wide, which is what RedHat does, and what you are doing I guess?

> I think this issue could be solved by refactoring the code in
> sha2_openssl.c to use the OpenSSL EVP interface
> (see https://wiki.openssl.org/index.php/EVP_Message_Digests ). 
> Any thoughts? Is this a known issue?

This report is the first of this kind since Postgres 10, which is where
the SHA2 interface for OpenSSL has been introduced.  So likely we'd need
to look into that more deeply..  This has the strong smell of a bug.  If
your system is new enough, you should have sha256() & co as system
functions, so you would see the failure as well?  The regression tests
would have likely complained.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: scram-sha-256 authentication broken in FIPS mode
  2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 04:27 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
@ 2018-09-05 13:19   ` Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 18:15     ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 13+ messages in thread

From: Alessandro Gherardi @ 2018-09-05 13:19 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi Michael,I'm actually running postgres on Windows.
I added code to fe-secure-openssl.c and be-secure-openssl.c that reads the Windows "standard" FIPS registry entry, and if FIPS is enabled calls FIPS_mode_set(1). This is to mimic to behavior of the .NET framework.
Below is the code I added to fe-secure-openssl.c, the code in be-secure-openssl.c is similar:
Thoughts? I can try to fix the scram-sha-256 issue by using EVP and send you a merge request for the patch and the code below if you think my approach is correct.
Thanks,Alessandro
 intpgtls_init(PGconn *conn){...
        if (!ssl_lib_initialized) { if (pq_init_ssl_lib) {
#ifdef WIN32 HKEY rootKey;
 DWORD fipsEnabled = 0; DWORD fipsEnabledSize = sizeof(DWORD);
 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\Lsa\\FipsAlgorithmPolicy", 0, KEY_READ, &rootKey) != ERROR_SUCCESS) { printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not open FIPS registry key")); return -1; } if (RegQueryValueEx(rootKey, "Enabled", 0, 0, (LPBYTE) &fipsEnabled, &fipsEnabledSize) != ERROR_SUCCESS) { RegCloseKey(rootKey); printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not read FIPS registry entry")); return -1; } RegCloseKey(rootKey);
 if (fipsEnabled == 1 && FIPS_mode() == 0) { if (FIPS_mode_set(1) != 1) { printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not enable FIPS mode")); return -1; } }#endif
#ifdef HAVE_OPENSSL_INIT_SSL OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL);#else OPENSSL_config(NULL); SSL_library_init(); SSL_load_error_strings();#endif


   On Tuesday, September 4, 2018, 10:27:22 PM MDT, Michael Paquier <michael@paquier.xyz> wrote:  
 
 On Wed, Sep 05, 2018 at 03:29:31AM +0000, Alessandro Gherardi wrote:
> It looks like scram-sha-256 doesn't work when postgres is linked
> against FIPS-enabled OpenSSL and FIPS mode is turned on.
> 
> Specifically, all login attempts fail with an OpenSSL error saying
> something along the lines of "Low level API call to digest SHA256
> forbidden in fips mode".

The error comes from libc, right?  Postgres can of course be configured
to work with FIPS without patching it, it just needs to be enabled
system-wide, which is what RedHat does, and what you are doing I guess?

> I think this issue could be solved by refactoring the code in
> sha2_openssl.c to use the OpenSSL EVP interface
> (see https://wiki.openssl.org/index.php/EVP_Message_Digests ). 
> Any thoughts? Is this a known issue?

This report is the first of this kind since Postgres 10, which is where
the SHA2 interface for OpenSSL has been introduced.  So likely we'd need
to look into that more deeply..  This has the strong smell of a bug.  If
your system is new enough, you should have sha256() & co as system
functions, so you would see the failure as well?  The regression tests
would have likely complained.
--
Michael  

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: scram-sha-256 authentication broken in FIPS mode
  2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 04:27 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-05 13:19   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
@ 2018-09-05 18:15     ` Michael Paquier <michael@paquier.xyz>
  2018-09-07 06:27       ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  0 siblings, 1 reply; 13+ messages in thread

From: Michael Paquier @ 2018-09-05 18:15 UTC (permalink / raw)
  To: Alessandro Gherardi <alessandro.gherardi@yahoo.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Wed, Sep 05, 2018 at 01:19:39PM +0000, Alessandro Gherardi wrote:
> Hi Michael,I'm actually running postgres on Windows.

First you may want to avoid top-posting.  This is not the style of the
community lists and this breaks the logic of a thread.

> I added code to fe-secure-openssl.c and be-secure-openssl.c that reads
> the Windows "standard" FIPS registry entry, and if FIPS is enabled
> calls FIPS_mode_set(1). This is to mimic to behavior of the .NET
> framework.

That's rather uncharted territory, as you are patching both the backend
*and* the client.  If we could prove that sha2-openssl.c is actually
unreliable even if FIPS is enabled system-wide with either SCRAM
authentication or any of the other hashing functions, then I would be
ready to accept a patch.  Now, as far as I can see and heard from other
folks for at least Linux, if FIPS is enabled at the OS level, then
Postgres would use it automatically and SCRAM is able to work.  I have
yet to hear that this part is broken.  As far as I know from companies
within the community which worked on STIG requirements, the thing
works.

> Below is the code I added to fe-secure-openssl.c, the code in
> be-secure-openssl.c is similar: 
> Thoughts? I can try to fix the scram-sha-256 issue by using EVP and
> send you a merge request for the patch and the code below if you think
> my approach is correct.

That's a bit unreadable I am afraid :)
You may want to attach a patch after producing it with for example "git
format-patch -1".
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: scram-sha-256 authentication broken in FIPS mode
  2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 04:27 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-05 13:19   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 18:15     ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
@ 2018-09-07 06:27       ` Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-10 14:52         ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  0 siblings, 1 reply; 13+ messages in thread

From: Alessandro Gherardi @ 2018-09-07 06:27 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

 Hi Michael,
I'm attaching the output of diff <updated source file> <original source file>.
>  If we could prove that sha2-openssl.c is actually
unreliable even if FIPS is enabled system-wide with either SCRAM
authentication or any of the other hashing functions, then I would be
ready to accept a patch.  Now, as far as I can see and heard from other
folks for at least Linux, if FIPS is enabled at the OS level, then
Postgres would use it automatically and SCRAM is able to work.
Not sure why it works on Linux but not on Windows. That the low-level digest APIs can't be used when FIPS is enabled is by design, other people have encountered that problem, e.g., http://openssl.6102.n7.nabble.com/Low-Level-Digest-if-Fips-mode-td54983.html .
Thanks,Alessandro
    

Attachments: download all (4 files, .tar.gz)

be-secure-openssl.c.diff (application/octet-stream, 1.1K) download 146,190d145 < < #ifdef WIN32 < HKEY rootKey; < DWORD fipsEnabled = 0; < DWORD fipsEnabledSize = sizeof(DWORD); < < if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, < "System\\CurrentControlSet\\Control\\Lsa\\FipsAlgorithmPolicy", < 0, < KEY_READ, < &rootKey) != ERROR_SUCCESS) < { < ereport(isServerStart ? FATAL : LOG, < (errmsg("could not open FIPS registry key"))); < goto error; < } < if (RegQueryValueEx(rootKey, < "Enabled", < 0, < 0, < (LPBYTE)&fipsEnabled, < &fipsEnabledSize) != ERROR_SUCCESS) < { < RegCloseKey(rootKey); < ereport(isServerStart ? FATAL : LOG, < (errmsg("could not read FIPS registry entry"))); < goto error; < } < RegCloseKey(rootKey); < < if (fipsEnabled == 1 && FIPS_mode() == 0) < { < if (FIPS_mode_set(1) != 1) < { < ereport(isServerStart ? FATAL : LOG, < (errmsg("could not enable FIPS mode"))); < goto error; < } < < ereport(LOG, < (errmsg("successfully enabled OpenSSL FIPS mode"))); < } < < #endif <
fe-secure-openssl.c.diff (application/octet-stream, 1.0K) download 826,867d825 < < #ifdef WIN32 < HKEY rootKey; < DWORD fipsEnabled = 0; < DWORD fipsEnabledSize = sizeof(DWORD); < < if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, < "System\\CurrentControlSet\\Control\\Lsa\\FipsAlgorithmPolicy", < 0, < KEY_READ, < &rootKey) != ERROR_SUCCESS) < { < printfPQExpBuffer(&conn->errorMessage, < libpq_gettext("could not open FIPS registry key")); < return -1; < } < if (RegQueryValueEx(rootKey, < "Enabled", < 0, < 0, < (LPBYTE) &fipsEnabled, < &fipsEnabledSize) != ERROR_SUCCESS) < { < RegCloseKey(rootKey); < printfPQExpBuffer(&conn->errorMessage, < libpq_gettext("could not read FIPS registry entry")); < return -1; < } < RegCloseKey(rootKey); < < if (fipsEnabled == 1 && FIPS_mode() == 0) < { < if (FIPS_mode_set(1) != 1) < { < printfPQExpBuffer(&conn->errorMessage, < libpq_gettext("could not enable FIPS mode")); < return -1; < } < } < #endif <
sha2.h.diff (application/octet-stream, 123B) download 55d54 < #include <openssl/evp.h> 74c73 < typedef EVP_MD_CTX* pg_sha256_ctx; --- > typedef SHA256_CTX pg_sha256_ctx;
sha2_openssl.c.diff (application/octet-stream, 517B) download 26c26 < #include <assert.h> --- > 32,35c32 < *ctx = EVP_MD_CTX_create(); < assert(*ctx != 0); < int rc = EVP_DigestInit_ex(*ctx, EVP_sha256(), NULL); < assert(rc == 1); --- > SHA256_Init((SHA256_CTX *) ctx); 41,42c38 < int rc = EVP_DigestUpdate(*ctx, data, len); < assert(rc == 1); --- > SHA256_Update((SHA256_CTX *) ctx, data, len); 48,50c44 < int rc = EVP_DigestFinal_ex(*ctx, dest, 0); < assert(rc == 1); < EVP_MD_CTX_destroy(*ctx); --- > SHA256_Final(dest, (SHA256_CTX *) ctx);
^ permalink raw reply [nested|flat] 13+ messages in thread

* Re: scram-sha-256 authentication broken in FIPS mode
  2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 04:27 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-05 13:19   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 18:15     ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-07 06:27       ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
@ 2018-09-10 14:52         ` Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-11 03:02           ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 13+ messages in thread

From: Alessandro Gherardi @ 2018-09-10 14:52 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

 I changed the implementation of the other SHA digests to use EVP also.
I verified that, with these changes, scram-sha-256 works when FIPS is enabled.      

Attachments: download all (2 files, .tar.gz)

sha2.h.diff (application/octet-stream, 354B) download 55d54 < #include <openssl/evp.h> 74,77c73,76 < typedef EVP_MD_CTX* pg_sha256_ctx; < typedef EVP_MD_CTX* pg_sha512_ctx; < typedef EVP_MD_CTX* pg_sha224_ctx; < typedef EVP_MD_CTX* pg_sha384_ctx; --- > typedef SHA256_CTX pg_sha256_ctx; > typedef SHA512_CTX pg_sha512_ctx; > typedef SHA256_CTX pg_sha224_ctx; > typedef SHA512_CTX pg_sha384_ctx;
sha2_openssl.c.diff (application/octet-stream, 1.6K) download 26d25 < #include <assert.h> 28,50d26 < static void < digest_init(EVP_MD_CTX **ctx, const EVP_MD* type) < { < *ctx = EVP_MD_CTX_create(); < assert(*ctx != 0); < int rc = EVP_DigestInit_ex(*ctx, type, NULL); < assert(rc == 1); < } < < static void < digest_update(EVP_MD_CTX **ctx, const uint8 *data, size_t len) < { < int rc = EVP_DigestUpdate(*ctx, data, len); < assert(rc == 1); < } < < static void < digest_final(EVP_MD_CTX **ctx, uint8 *dest) < { < int rc = EVP_DigestFinal_ex(*ctx, dest, 0); < assert(rc == 1); < EVP_MD_CTX_destroy(*ctx); < } 56c32 < digest_init(ctx, EVP_sha256()); --- > SHA256_Init((SHA256_CTX *) ctx); 62c38 < digest_update(ctx, data, len); --- > SHA256_Update((SHA256_CTX *) ctx, data, len); 68c44 < digest_final(ctx, dest); --- > SHA256_Final(dest, (SHA256_CTX *) ctx); 75c51 < digest_init(ctx, EVP_sha512()); --- > SHA512_Init((SHA512_CTX *) ctx); 81c57 < digest_update(ctx, data, len); --- > SHA512_Update((SHA512_CTX *) ctx, data, len); 87c63 < digest_final(ctx, dest); --- > SHA512_Final(dest, (SHA512_CTX *) ctx); 94c70 < digest_init(ctx, EVP_sha384()); --- > SHA384_Init((SHA512_CTX *) ctx); 100c76 < digest_update(ctx, data, len); --- > SHA384_Update((SHA512_CTX *) ctx, data, len); 106c82 < digest_final(ctx, dest); --- > SHA384_Final(dest, (SHA512_CTX *) ctx); 113c89 < digest_init(ctx, EVP_sha224()); --- > SHA224_Init((SHA256_CTX *) ctx); 119c95 < digest_update(ctx, data, len); --- > SHA224_Update((SHA256_CTX *) ctx, data, len); 125c101 < digest_final(ctx, dest); --- > SHA224_Final(dest, (SHA256_CTX *) ctx);
^ permalink raw reply [nested|flat] 13+ messages in thread

* Re: scram-sha-256 authentication broken in FIPS mode
  2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 04:27 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-05 13:19   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 18:15     ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-07 06:27       ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-10 14:52         ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
@ 2018-09-11 03:02           ` Michael Paquier <michael@paquier.xyz>
  2018-09-11 03:09             ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-11 14:32             ` Re: scram-sha-256 authentication broken in FIPS mode Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  0 siblings, 2 replies; 13+ messages in thread

From: Michael Paquier @ 2018-09-11 03:02 UTC (permalink / raw)
  To: Alessandro Gherardi <alessandro.gherardi@yahoo.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Mon, Sep 10, 2018 at 02:52:00PM +0000, Alessandro Gherardi wrote:
> I changed the implementation of the other SHA digests to use EVP
> also.  I verified that, with these changes, scram-sha-256 works when
> FIPS is enabled.

Hm...  I have spent a couple of hours setting up a CentOS 7 VM with FIPS
enabled to track down if there is actually a problem.  Here is what I
have done to enable it:
1) yum install dracut-fips
dracut -v -f
2) Update boot loader, where it is necessary to update
GRUB_CMDLINE_LINUX by adding to it "fips=1 boot=UUID=$PARTITION_UUID"
into /etc/default/grub.  PARTITION_UUID can be found with "blkid=/boot"
(depends on the partition layer by the way).
3) Disable prelinking (requires installation of package prelink) by
adding PRELINKING=no to /etc/sysconfig/prelink, then remove existing
prelinks with "prelink -u -a".

After a reboot, it is possible to see /proc/sys/crypto/fips_enabled set
to 1.  Once I did that, unfortunately I have not been able to spot
deficiencies when calling the low-level SHA APIs from OpenSSL, where
both SCRAM and all the in-core SSL functions are proving to work
correctly.  Calling directly FIPS_mode() within Postgres backends also
prove that FIPS is effectively enabled.  Anyway, on top of the remark
Alessandro has done above, this line from the OpenSSL docs has caught my
eyes:
https://www.openssl.org/docs/man1.1.0/crypto/SHA512_Init.html
"Applications should use the higher level functions EVP_DigestInit
etc. instead of calling the hash functions directly."

This is present in OpenSSL docs for some time:
commit: 4facdbb5fa9d791fc72dc78b9c3512ea1384df33
author: Ulf Möller <ulf@openssl.org>
date: Sun, 6 Feb 2000 23:26:31 +0000

Hence, intrinsically, we are in contradiction with the upstream docs.  I
have worked on the problem with the patch, which works down to OpenSSL
0.9.8, and should fix your issue.  This is based on what you sent
previously, except that I was not able to apply what was sent, so I
reworked the whole.  Alessandro, does this fix your problems?  I would
like to apply that down to v10 where SCRAM has been introduced.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: scram-sha-256 authentication broken in FIPS mode
  2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 04:27 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-05 13:19   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 18:15     ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-07 06:27       ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-10 14:52         ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-11 03:02           ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
@ 2018-09-11 03:09             ` Michael Paquier <michael@paquier.xyz>
  1 sibling, 0 replies; 13+ messages in thread

From: Michael Paquier @ 2018-09-11 03:09 UTC (permalink / raw)
  To: Alessandro Gherardi <alessandro.gherardi@yahoo.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Tue, Sep 11, 2018 at 12:02:50PM +0900, Michael Paquier wrote:
> Hence, intrinsically, we are in contradiction with the upstream docs.  I
> have worked on the problem with the patch, which works down to OpenSSL
> 0.9.8, and should fix your issue.  This is based on what you sent
> previously, except that I was not able to apply what was sent, so I
> reworked the whole.  Alessandro, does this fix your problems?  I would
> like to apply that down to v10 where SCRAM has been introduced.

With the actual patch attached things are better.  So here it is. 
--
Michael

Attachments:

0001-Change-SHA-algorithms-to-use-EVP_CTX-from-OpenSSL.patch (text/x-diff, 3.6K) download From 1b450dee61855f4fd8b9e4a37d2f95c07f26db55 Mon Sep 17 00:00:00 2001 From: Michael Paquier <michael@paquier.xyz> Date: Tue, 11 Sep 2018 11:34:48 +0900 Subject: [PATCH] Change SHA algorithms to use EVP_CTX from OpenSSL This seems to fix issues with FIPS mode on Windows. --- src/common/sha2_openssl.c | 45 +++++++++++++++++++++++++++------------ src/include/common/sha2.h | 10 ++++----- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/common/sha2_openssl.c b/src/common/sha2_openssl.c index 362e1318db..e80dec7b4d 100644 --- a/src/common/sha2_openssl.c +++ b/src/common/sha2_openssl.c @@ -20,83 +20,100 @@ #include "postgres_fe.h" #endif -#include <openssl/sha.h> - #include "common/sha2.h" +static void +digest_init(EVP_MD_CTX **ctx, const EVP_MD *type) +{ + *ctx = EVP_MD_CTX_create(); + EVP_DigestInit_ex(*ctx, type, NULL); +} + +static void +digest_update(EVP_MD_CTX **ctx, const uint8 *data, size_t len) +{ + EVP_DigestUpdate(*ctx, data, len); +} + +static void +digest_final(EVP_MD_CTX **ctx, uint8 *dest) +{ + EVP_DigestFinal_ex(*ctx, dest, 0); + EVP_MD_CTX_destroy(*ctx); +} /* Interface routines for SHA-256 */ void pg_sha256_init(pg_sha256_ctx *ctx) { - SHA256_Init((SHA256_CTX *) ctx); + digest_init(ctx, EVP_sha256()); } void pg_sha256_update(pg_sha256_ctx *ctx, const uint8 *data, size_t len) { - SHA256_Update((SHA256_CTX *) ctx, data, len); + digest_update(ctx, data, len); } void pg_sha256_final(pg_sha256_ctx *ctx, uint8 *dest) { - SHA256_Final(dest, (SHA256_CTX *) ctx); + digest_final(ctx, dest); } /* Interface routines for SHA-512 */ void pg_sha512_init(pg_sha512_ctx *ctx) { - SHA512_Init((SHA512_CTX *) ctx); + digest_init(ctx, EVP_sha512()); } void pg_sha512_update(pg_sha512_ctx *ctx, const uint8 *data, size_t len) { - SHA512_Update((SHA512_CTX *) ctx, data, len); + digest_update(ctx, data, len); } void pg_sha512_final(pg_sha512_ctx *ctx, uint8 *dest) { - SHA512_Final(dest, (SHA512_CTX *) ctx); + digest_final(ctx, dest); } /* Interface routines for SHA-384 */ void pg_sha384_init(pg_sha384_ctx *ctx) { - SHA384_Init((SHA512_CTX *) ctx); + digest_init(ctx, EVP_sha384()); } void pg_sha384_update(pg_sha384_ctx *ctx, const uint8 *data, size_t len) { - SHA384_Update((SHA512_CTX *) ctx, data, len); + digest_update(ctx, data, len); } void pg_sha384_final(pg_sha384_ctx *ctx, uint8 *dest) { - SHA384_Final(dest, (SHA512_CTX *) ctx); + digest_final(ctx, dest); } /* Interface routines for SHA-224 */ void pg_sha224_init(pg_sha224_ctx *ctx) { - SHA224_Init((SHA256_CTX *) ctx); + digest_init(ctx, EVP_sha224()); } void pg_sha224_update(pg_sha224_ctx *ctx, const uint8 *data, size_t len) { - SHA224_Update((SHA256_CTX *) ctx, data, len); + digest_update(ctx, data, len); } void pg_sha224_final(pg_sha224_ctx *ctx, uint8 *dest) { - SHA224_Final(dest, (SHA256_CTX *) ctx); + digest_final(ctx, dest); } diff --git a/src/include/common/sha2.h b/src/include/common/sha2.h index f3fd0d0d28..701647713f 100644 --- a/src/include/common/sha2.h +++ b/src/include/common/sha2.h @@ -51,7 +51,7 @@ #define _PG_SHA2_H_ #ifdef USE_SSL -#include <openssl/sha.h> +#include <openssl/evp.h> #endif /*** SHA224/256/384/512 Various Length Definitions ***********************/ @@ -70,10 +70,10 @@ /* Context Structures for SHA-1/224/256/384/512 */ #ifdef USE_SSL -typedef SHA256_CTX pg_sha256_ctx; -typedef SHA512_CTX pg_sha512_ctx; -typedef SHA256_CTX pg_sha224_ctx; -typedef SHA512_CTX pg_sha384_ctx; +typedef EVP_MD_CTX *pg_sha256_ctx; +typedef EVP_MD_CTX *pg_sha512_ctx; +typedef EVP_MD_CTX *pg_sha224_ctx; +typedef EVP_MD_CTX *pg_sha384_ctx; #else typedef struct pg_sha256_ctx { -- 2.19.0.rc2
signature.asc (application/pgp-signature, 832B) download ^ permalink raw reply [nested|flat] 13+ messages in thread

* Re: scram-sha-256 authentication broken in FIPS mode
  2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 04:27 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-05 13:19   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 18:15     ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-07 06:27       ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-10 14:52         ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-11 03:02           ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
@ 2018-09-11 14:32             ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  2018-09-11 22:24               ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  1 sibling, 1 reply; 13+ messages in thread

From: Peter Eisentraut @ 2018-09-11 14:32 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; Alessandro Gherardi <alessandro.gherardi@yahoo.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On 11/09/2018 05:02, Michael Paquier wrote:
> Hence, intrinsically, we are in contradiction with the upstream docs.  I
> have worked on the problem with the patch, which works down to OpenSSL
> 0.9.8, and should fix your issue.  This is based on what you sent
> previously, except that I was not able to apply what was sent, so I
> reworked the whole.  Alessandro, does this fix your problems?  I would
> like to apply that down to v10 where SCRAM has been introduced.

I recommend letting this bake in the master branch for a while.  There
are a lot weirdly patched and alternative OpenSSL versions out there
that defy any documentation.

Of course, we should also see if this actually fixes the reported problem.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: scram-sha-256 authentication broken in FIPS mode
  2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 04:27 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-05 13:19   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 18:15     ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-07 06:27       ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-10 14:52         ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-11 03:02           ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-11 14:32             ` Re: scram-sha-256 authentication broken in FIPS mode Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
@ 2018-09-11 22:24               ` Michael Paquier <michael@paquier.xyz>
  2018-09-13 03:11                 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 13+ messages in thread

From: Michael Paquier @ 2018-09-11 22:24 UTC (permalink / raw)
  To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: Alessandro Gherardi <alessandro.gherardi@yahoo.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Tue, Sep 11, 2018 at 04:32:27PM +0200, Peter Eisentraut wrote:
> I recommend letting this bake in the master branch for a while.  There
> are a lot weirdly patched and alternative OpenSSL versions out there
> that defy any documentation.

Good point.  Such things have bitten in the past.  Okay, then let's do
something about sha2_openssl.c only on HEAD for now then, which I am
fine to finish wrapping.

> Of course, we should also see if this actually fixes the reported problem.

It seems to me that addressing FIPS concerns on Windows and getting our
hashing functions plugged with OpenSSL correctly are two separate
issues.  The second one also says that we are in the grey based on
OpenSSL docs, which worryies me.  And EVP_DigestInit is used in pgcrypto
for ages, where I don't recall seeing reports about that.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: scram-sha-256 authentication broken in FIPS mode
  2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 04:27 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-05 13:19   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 18:15     ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-07 06:27       ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-10 14:52         ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-11 03:02           ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-11 14:32             ` Re: scram-sha-256 authentication broken in FIPS mode Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  2018-09-11 22:24               ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
@ 2018-09-13 03:11                 ` Michael Paquier <michael@paquier.xyz>
  2018-09-17 14:55                   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  0 siblings, 1 reply; 13+ messages in thread

From: Michael Paquier @ 2018-09-13 03:11 UTC (permalink / raw)
  To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: Alessandro Gherardi <alessandro.gherardi@yahoo.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Wed, Sep 12, 2018 at 07:24:24AM +0900, Michael Paquier wrote:
> Good point.  Such things have bitten in the past.  Okay, then let's do
> something about sha2_openssl.c only on HEAD for now then, which I am
> fine to finish wrapping.

I was looking at trying to commit this patch, however more needs to be
done in terms of error handling, as the proposed patch would happily
crash if EVP_MD_CTX cannot be allocated (understand OOM) in
EVP_DigestInit_ex if I read the OpenSSL code correctly (see
crypto/evp/digest.c).  Our lives would be facilitated if it was possible
to use directly EVP_MD_CTX and EVP_MD_CTX_init so as no allocation is
done but that's not doable as of 1.0.2.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: scram-sha-256 authentication broken in FIPS mode
  2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 04:27 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-05 13:19   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 18:15     ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-07 06:27       ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-10 14:52         ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-11 03:02           ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-11 14:32             ` Re: scram-sha-256 authentication broken in FIPS mode Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  2018-09-11 22:24               ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-13 03:11                 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
@ 2018-09-17 14:55                   ` Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-18 00:33                     ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 13+ messages in thread

From: Alessandro Gherardi @ 2018-09-17 14:55 UTC (permalink / raw)
  To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

 Here's a patch for enabling FIPS in OpenSSL - by calling FIPS_mode_set(1) - on Windows if the FIPS registry entry HKLM\System\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy\Enabled is set to 1. That's the entry that the .NET crypto libraries look at to decide whether or not to operate in FIPS mode.
I thought of submitting a pull request for adding this logic to OpenSSL, however (1) https://www.openssl.org/source/ says they are working on a new FIPS module, so I doubt they would take a pull request for OpenSSL 1.0.X and (2) For Linux, this logic doesn't exist on the standard OpenSSL distribution but only on the RHEL-specific OpenSSL patch (See method init_fips_mode() in https://git.centos.org/raw/rpms/openssl.git/c7/SOURCES!openssl-1.0.2i-fips.patch ).
Therefore, I believe the best option, at least for now, is calling FIPS_mode_set(1) in the application.

Attachments:

0001-On-Windows-call-FIPS_mode_set-1-if-FIPS-registry-ent.patch (application/octet-stream, 3.1K) download From 38d6f522fcb1038df979bd26364d66e82f5f6d1f Mon Sep 17 00:00:00 2001 From: Alessandro Gherardi <alessandro.gherardi@yahoo.com> Date: Sun, 16 Sep 2018 14:11:33 -0600 Subject: [PATCH] On Windows, call FIPS_mode_set(1) if FIPS registry entry indicates that FIPS is enabled --- src/backend/libpq/be-secure-openssl.c | 44 ++++++++++++++++++++++++++++++++ src/interfaces/libpq/fe-secure-openssl.c | 40 +++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c index 6a57657..f4dbef2 100644 --- a/src/backend/libpq/be-secure-openssl.c +++ b/src/backend/libpq/be-secure-openssl.c @@ -81,6 +81,50 @@ be_tls_init(bool isServerStart) /* This stuff need be done only once. */ if (!SSL_initialized) { +#ifdef WIN32 + HKEY rootKey; + DWORD fipsEnabled = 0; + DWORD fipsEnabledSize = sizeof(DWORD); + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "System\\CurrentControlSet\\Control\\Lsa\\FipsAlgorithmPolicy", + 0, + KEY_READ, + &rootKey) != ERROR_SUCCESS) + { + ereport(isServerStart ? FATAL : LOG, + (errmsg("could not open FIPS registry key"))); + goto error; + } + if (RegQueryValueEx(rootKey, + "Enabled", + 0, + 0, + (LPBYTE)&fipsEnabled, + &fipsEnabledSize) != ERROR_SUCCESS) + { + RegCloseKey(rootKey); + ereport(isServerStart ? FATAL : LOG, + (errmsg("could not read FIPS registry entry"))); + goto error; + } + RegCloseKey(rootKey); + + if (fipsEnabled == 1 && FIPS_mode() == 0) + { + if (FIPS_mode_set(1) != 1) + { + ereport(isServerStart ? FATAL : LOG, + (errmsg("could not enable FIPS mode"))); + goto error; + } + + ereport(LOG, + (errmsg("successfully enabled OpenSSL FIPS mode"))); + } + +#endif + #ifdef HAVE_OPENSSL_INIT_SSL OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL); #else diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c index bbae8ef..6c1cf6c 100644 --- a/src/interfaces/libpq/fe-secure-openssl.c +++ b/src/interfaces/libpq/fe-secure-openssl.c @@ -703,6 +703,46 @@ pgtls_init(PGconn *conn) { if (pq_init_ssl_lib) { +#ifdef WIN32 + HKEY rootKey; + DWORD fipsEnabled = 0; + DWORD fipsEnabledSize = sizeof(DWORD); + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "System\\CurrentControlSet\\Control\\Lsa\\FipsAlgorithmPolicy", + 0, + KEY_READ, + &rootKey) != ERROR_SUCCESS) + { + printfPQExpBuffer(&conn->errorMessage, + libpq_gettext("could not open FIPS registry key")); + return -1; + } + if (RegQueryValueEx(rootKey, + "Enabled", + 0, + 0, + (LPBYTE) &fipsEnabled, + &fipsEnabledSize) != ERROR_SUCCESS) + { + RegCloseKey(rootKey); + printfPQExpBuffer(&conn->errorMessage, + libpq_gettext("could not read FIPS registry entry")); + return -1; + } + RegCloseKey(rootKey); + + if (fipsEnabled == 1 && FIPS_mode() == 0) + { + if (FIPS_mode_set(1) != 1) + { + printfPQExpBuffer(&conn->errorMessage, + libpq_gettext("could not enable FIPS mode")); + return -1; + } + } +#endif + #ifdef HAVE_OPENSSL_INIT_SSL OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL); #else -- 2.7.4
^ permalink raw reply [nested|flat] 13+ messages in thread

* Re: scram-sha-256 authentication broken in FIPS mode
  2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 04:27 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-05 13:19   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-05 18:15     ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-07 06:27       ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-10 14:52         ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
  2018-09-11 03:02           ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-11 14:32             ` Re: scram-sha-256 authentication broken in FIPS mode Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
  2018-09-11 22:24               ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-13 03:11                 ` Re: scram-sha-256 authentication broken in FIPS mode Michael Paquier <michael@paquier.xyz>
  2018-09-17 14:55                   ` Re: scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
@ 2018-09-18 00:33                     ` Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 13+ messages in thread

From: Michael Paquier @ 2018-09-18 00:33 UTC (permalink / raw)
  To: Alessandro Gherardi <alessandro.gherardi@yahoo.com>; +Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On Mon, Sep 17, 2018 at 02:55:55PM +0000, Alessandro Gherardi wrote:
> Therefore, I believe the best option, at least for now, is calling
> FIPS_mode_set(1) in the application. 

I am not so sure about that.  As you rightly mention, CentOS and RedHat
patch OpenSSL to allow FIPS to work.  Per my research, Ubuntu can also
enable FIPS but that's not the case of Debian, which is very popular (I
may be wrong about the last one but I use it daily).

One question I have is how are you actually able to use FIPS on Windows
with OpenSSL?  Is that from one of the tarballs available in
openssl.org, which are more than 1 year old?  Pure upstream code does
not give this option, and CentOS/RHEL use a customly-made patch, based
on which Postgres does not complain when calling the low-level hashing
functions, and we rely now on FIPS being enabled system-wide.  And that
actually works.  It seems to me that you are yourself using a custom
patch for OpenSSL, and that's actually a different flavor than the Linux
version as in your case the low-level hashing functions complain if
called directly in FIPS mode.

At the end, I think that we ought to wait and see if upstream OpenSSL
comes up with support for FIPS and how it integrates with it, on both
Linux *and* Windows, and then consider if Postgres needs to do more.
There is little point in merging now a patch for something which may or
may not be supported by OpenSSL now.  My bet, as things stand, is that
we could finish with something similar to what happens on Linux with a
system-wide switch that Postgres knows nothing about.  Perhaps that will
not be the case, but let's think about that once we know for sure.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 13+ messages in thread


end of thread, other threads:[~2018-09-18 00:33 UTC | newest]

Thread overview: 13+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-09-05 03:29 scram-sha-256 authentication broken in FIPS mode Alessandro Gherardi <alessandro.gherardi@yahoo.com>
2018-09-05 04:27 ` Michael Paquier <michael@paquier.xyz>
2018-09-05 13:19   ` Alessandro Gherardi <alessandro.gherardi@yahoo.com>
2018-09-05 18:15     ` Michael Paquier <michael@paquier.xyz>
2018-09-07 06:27       ` Alessandro Gherardi <alessandro.gherardi@yahoo.com>
2018-09-10 14:52         ` Alessandro Gherardi <alessandro.gherardi@yahoo.com>
2018-09-11 03:02           ` Michael Paquier <michael@paquier.xyz>
2018-09-11 03:09             ` Michael Paquier <michael@paquier.xyz>
2018-09-11 14:32             ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2018-09-11 22:24               ` Michael Paquier <michael@paquier.xyz>
2018-09-13 03:11                 ` Michael Paquier <michael@paquier.xyz>
2018-09-17 14:55                   ` Alessandro Gherardi <alessandro.gherardi@yahoo.com>
2018-09-18 00:33                     ` Michael Paquier <michael@paquier.xyz>

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