postgresql/src/include/common
Michael Paquier e6bdfd9700 Refactor HMAC implementations
Similarly to the cryptohash implementations, this refactors the existing
HMAC code into a single set of APIs that can be plugged with any crypto
libraries PostgreSQL is built with (only OpenSSL currently).  If there
is no such libraries, a fallback implementation is available.  Those new
APIs are designed similarly to the existing cryptohash layer, so there
is no real new design here, with the same logic around buffer bound
checks and memory handling.

HMAC has a dependency on cryptohashes, so all the cryptohash types
supported by cryptohash{_openssl}.c can be used with HMAC.  This
refactoring is an advantage mainly for SCRAM, that included its own
implementation of HMAC with SHA256 without relying on the existing
crypto libraries even if PostgreSQL was built with their support.

This code has been tested on Windows and Linux, with and without
OpenSSL, across all the versions supported on HEAD from 1.1.1 down to
1.0.1.  I have also checked that the implementations are working fine
using some sample results, a custom extension of my own, and doing
cross-checks across different major versions with SCRAM with the client
and the backend.

Author: Michael Paquier
Reviewed-by: Bruce Momjian
Discussion: https://postgr.es/m/X9m0nkEJEzIPXjeZ@paquier.xyz
2021-04-03 17:30:49 +09:00
..
archive.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
base64.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
checksum_helper.h Fix and simplify some code related to cryptohashes 2021-01-08 10:37:03 +09:00
config_info.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
connect.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
controldata_utils.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
cryptohash.h Add result size as argument of pg_cryptohash_final() for overflow checks 2021-02-15 10:18:34 +09:00
fe_memutils.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
file_perm.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
file_utils.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
hashfn.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
hex.h Rework refactoring of hex and encoding routines 2021-01-14 11:13:24 +09:00
hmac.h Refactor HMAC implementations 2021-04-03 17:30:49 +09:00
int.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
int128.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
ip.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonapi.h Improve reporting for syntax errors in multi-line JSON data. 2021-03-01 16:44:17 -05:00
keywords.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
kwlookup.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
link-canary.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
logging.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
md5.h Refactor HMAC implementations 2021-04-03 17:30:49 +09:00
openssl.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_lzcompress.h Optimize partial TOAST decompression 2019-10-01 14:28:28 +02:00
relpath.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
restricted_token.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
saslprep.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
scram-common.h Refactor HMAC implementations 2021-04-03 17:30:49 +09:00
sha1.h Refactor HMAC implementations 2021-04-03 17:30:49 +09:00
sha2.h Remove PG_SHA*_DIGEST_STRING_LENGTH from sha2.h 2021-01-15 11:46:34 +09:00
shortest_dec.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
string.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
unicode_combining_table.h Update Unicode data to Unicode 13.0.0 and CLDR 37 2020-04-24 09:52:59 +02:00
unicode_norm.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
unicode_norm_hashfunc.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
unicode_norm_table.h Update copyright for 2021 2021-01-02 13:06:25 -05:00
unicode_normprops_table.h Review format of code generated by PerfectHash.pm 2020-10-21 09:22:27 +09:00
username.h Update copyright for 2021 2021-01-02 13:06:25 -05:00