git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: 1d9c5d0) | patch
Refactor HMAC implementations
Sat, 3 Apr 2021 08:30:49 +0000 (17:30 +0900)
Sat, 3 Apr 2021 08:30:49 +0000 (17:30 +0900)
commit e6bdfd9700ebfc7df811c97c2fc46d7e94e329a2
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
18 files changed:
configure diff | blob | blame | history
configure.ac diff | blob | blame | history
src/backend/libpq/auth-scram.c diff | blob | blame | history
src/backend/utils/resowner/resowner.c diff | blob | blame | history
src/common/Makefile diff | blob | blame | history
src/common/hmac.c [new file with mode: 0644] blob
src/common/hmac_openssl.c [new file with mode: 0644] blob
src/common/scram-common.c diff | blob | blame | history
src/include/common/hmac.h [new file with mode: 0644] blob
src/include/common/md5.h diff | blob | blame | history
src/include/common/scram-common.h diff | blob | blame | history
src/include/common/sha1.h diff | blob | blame | history
src/include/pg_config.h.in diff | blob | blame | history
src/include/utils/resowner_private.h diff | blob | blame | history
src/interfaces/libpq/fe-auth-scram.c diff | blob | blame | history
src/tools/msvc/Mkvcbuild.pm diff | blob | blame | history
src/tools/msvc/Solution.pm diff | blob | blame | history
src/tools/pgindent/typedefs.list diff | blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /