postgresql/src/include/common
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
..
archive.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
base64.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
checksum_helper.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
compression.h Refactor code parsing compression option values (-Z/--compress) 2022-11-30 09:34:32 +09:00
config_info.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
connect.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
controldata_utils.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
cryptohash.h Improve error handling of cryptohash computations 2022-01-11 09:55:16 +09:00
fe_memutils.h Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
file_perm.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
file_utils.h Introduce pg_pwrite_zeros() in fileutils.c 2022-11-08 12:23:46 +09:00
hashfn.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
hmac.h Improve error handling of HMAC computations 2022-01-13 16:17:21 +09:00
int.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
int128.h Static assertions cleanup 2022-12-15 10:10:32 +01:00
ip.h Remove replacement code for getaddrinfo. 2022-08-14 09:53:28 +12:00
jsonapi.h Convert json_in and jsonb_in to report errors softly. 2022-12-11 11:28:15 -05:00
keywords.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
kwlookup.h Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
link-canary.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
logging.h Remove PGDLLIMPORT marker from __pg_log_level 2022-05-13 09:39:13 +09:00
md5.h Improve error handling of cryptohash computations 2022-01-11 09:55:16 +09:00
openssl.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_lzcompress.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
pg_prng.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
relpath.h Revert 56-bit relfilenode change and follow-up commits. 2022-09-28 09:55:28 -04:00
restricted_token.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
saslprep.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
scram-common.h Remove hardcoded dependency to cryptohash type in the internals of SCRAM 2022-12-20 08:53:22 +09:00
sha1.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
sha2.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
shortest_dec.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
string.h Mark sigint_interrupt_enabled as sig_atomic_t 2022-09-29 14:28:13 +09:00
unicode_east_asian_fw_table.h Update Unicode data to Unicode 15.0.0 2022-09-19 18:30:05 -04:00
unicode_nonspacing_table.h Update Unicode data to Unicode 15.0.0 2022-09-19 18:30:05 -04:00
unicode_norm.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
unicode_norm_hashfunc.h Update Unicode data to Unicode 15.0.0 2022-09-19 18:30:05 -04:00
unicode_norm_table.h Update Unicode data to Unicode 15.0.0 2022-09-19 18:30:05 -04:00
unicode_normprops_table.h Update Unicode data to Unicode 15.0.0 2022-09-19 18:30:05 -04:00
username.h Update copyright for 2022 2022-01-07 19:04:57 -05:00