postgresql/src/include/libpq
Michael Paquier b3bb7d12af Remove hardcoded dependency to cryptohash type in the internals of SCRAM
SCRAM_KEY_LEN was a variable used in the internal routines of SCRAM to
size a set of fixed-sized arrays used in the SHA and HMAC computations
during the SASL exchange or when building a SCRAM password.  This had a
hard dependency on SHA-256, reducing the flexibility of SCRAM when it
comes to the addition of more hash methods.  A second issue was that
SHA-256 is assumed as the cryptohash method to use all the time.

This commit renames SCRAM_KEY_LEN to a more generic SCRAM_KEY_MAX_LEN,
which is used as the size of the buffers used by the internal routines
of SCRAM.  This is aimed at tracking centrally the maximum size
necessary for all the hash methods supported by SCRAM.  A global
variable has the advantage of keeping the code in its simplest form,
reducing the need of more alloc/free logic for all the buffers used in
the hash calculations.

A second change is that the key length (SHA digest length) and hash
types are now tracked by the state data in the backend and the frontend,
the common portions being extended to handle these as arguments by the
internal routines of SCRAM.  There are a few RFC proposals floating
around to extend the SCRAM protocol, including some to use stronger
cryptohash algorithms, so this lifts some of the existing restrictions
in the code.

The code in charge of parsing and building SCRAM secrets is extended to
rely on the key length and on the cryptohash type used for the exchange,
assuming currently that only SHA-256 is supported for the moment.  Note
that the mock authentication simply enforces SHA-256.

Author: Michael Paquier
Reviewed-by: Peter Eisentraut, Jonathan Katz
Discussion: https://postgr.es/m/Y5k3Qiweo/1g9CG6@paquier.xyz
2022-12-20 08:53:22 +09:00
..
auth.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
be-fsstubs.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
be-gssapi-common.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
crypt.h Improve error handling of cryptohash computations 2022-01-11 09:55:16 +09:00
hba.h Rework memory contexts in charge of HBA/ident tokenization 2022-11-24 08:21:55 +09:00
ifaddr.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
libpq-be.h Allow parallel workers to retrieve some data from Port 2022-08-24 12:57:13 +09:00
libpq-fs.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
libpq.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
pqcomm.h Remove configure probes for sockaddr_storage members. 2022-08-22 17:50:30 +12:00
pqformat.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pqmq.h Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
pqsignal.h Provide sigaction() for Windows. 2022-11-09 13:06:31 +13:00
sasl.h Fix collection of typos in the code and the documentation 2022-03-15 11:29:35 +09:00
scram.h Remove hardcoded dependency to cryptohash type in the internals of SCRAM 2022-12-20 08:53:22 +09:00