pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Alessandro Gherardi <alessandro.gherardi@yahoo.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: scram-sha-256 authentication broken in FIPS mode
Date: Fri, 7 Sep 2018 06:27:33 +0000 (UTC)
Message-ID: <1924578892.946938.1536301653576@mail.yahoo.com> (raw )
In-Reply-To: <1691863835.972001.1536301001998@mail.yahoo.com >
References: <898098721.1290085.1536118171911.ref@mail.yahoo.com >
<898098721.1290085.1536118171911@mail.yahoo.com >
<20180905042717.GL20696@paquier.xyz >
<767499000.1481233.1536153579656@mail.yahoo.com >
<20180905181545.GC2726@paquier.xyz >
<1691863835.972001.1536301001998@mail.yahoo.com >
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);
view thread (13+ messages) latest in thread
Message-ID: <1924578892.946938.1536301653576@mail.yahoo.com>
Permalink: ../1924578892.946938.1536301653576@mail.yahoo.com/
Also on: postgresql.org/message-id/1924578892.946938.1536301653576@mail.yahoo.com
copy link · copy postgr.es · copy git am
reply 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: alessandro.gherardi@yahoo.com, michael@paquier.xyz
Subject: Re: scram-sha-256 authentication broken in FIPS mode
In-Reply-To: <1924578892.946938.1536301653576@mail.yahoo.com>
References: <898098721.1290085.1536118171911.ref@mail.yahoo.com> <898098721.1290085.1536118171911@mail.yahoo.com> <20180905042717.GL20696@paquier.xyz> <767499000.1481233.1536153579656@mail.yahoo.com> <20180905181545.GC2726@paquier.xyz> <1691863835.972001.1536301001998@mail.yahoo.com> <1924578892.946938.1536301653576@mail.yahoo.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