postgresql/contrib
Michael Paquier 87ae9691d2 Move SHA2 routines to a new generic API layer for crypto hashes
Two new routines to allocate a hash context and to free it are created,
as these become necessary for the goal behind this refactoring: switch
the all cryptohash implementations for OpenSSL to use EVP (for FIPS and
also because upstream does not recommend the use of low-level cryptohash
functions for 20 years).  Note that OpenSSL hides the internals of
cryptohash contexts since 1.1.0, so it is necessary to leave the
allocation to OpenSSL itself, explaining the need for those two new
routines.  This part is going to require more work to properly track
hash contexts with resource owners, but this not introduced here.
Still, this refactoring makes the move possible.

This reduces the number of routines for all SHA2 implementations from
twelve (SHA{224,256,386,512} with init, update and final calls) to five
(create, free, init, update and final calls) by incorporating the hash
type directly into the hash context data.

The new cryptohash routines are moved to a new file, called cryptohash.c
for the fallback implementations, with SHA2 specifics becoming a part
internal to src/common/.  OpenSSL specifics are part of
cryptohash_openssl.c.  This infrastructure is usable for more hash
types, like MD5 or HMAC.

Any code paths using the internal SHA2 routines are adapted to report
correctly errors, which are most of the changes of this commit.  The
zones mostly impacted are checksum manifests, libpq and SCRAM.

Note that e21cbb4 was a first attempt to switch SHA2 to EVP, but it
lacked the refactoring needed for libpq, as done here.

This patch has been tested on Linux and Windows, with and without
OpenSSL, and down to 1.0.1, the oldest version supported on HEAD.

Author: Michael Paquier
Reviewed-by: Daniel Gustafsson
Discussion: https://postgr.es/m/20200924025314.GE7405@paquier.xyz
2020-12-02 10:37:20 +09:00
..
adminpack Read until EOF vice stat-reported size in read_binary_file 2020-07-04 06:26:53 -04:00
amcheck Fix some typos 2020-11-14 11:43:10 +09:00
auth_delay
auto_explain
bloom Invent "amadjustmembers" AM method for validating opclass members. 2020-08-01 17:12:47 -04:00
bool_plperl
btree_gin
btree_gist Expose internal function for converting int64 to numeric 2020-09-09 20:16:28 +02:00
citext Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
cube Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
dblink Move catalog index declarations 2020-11-07 12:26:24 +01:00
dict_int
dict_xsyn
earthdistance Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
file_fdw Remove leftover comments, left behind by removal of WITH OIDS. 2020-11-30 10:26:43 +02:00
fuzzystrmatch
hstore Remove no-longer-usable hstore--1.0--1.1.sql update script. 2020-08-15 12:04:19 -04:00
hstore_plperl Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
hstore_plpython
intagg Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
intarray Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
isn
jsonb_plperl Expose internal function for converting int64 to numeric 2020-09-09 20:16:28 +02:00
jsonb_plpython Support infinity and -infinity in the numeric data type. 2020-07-22 19:19:44 -04:00
lo
ltree Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
ltree_plpython
oid2name Remove arbitrary restrictions on password length. 2020-09-03 20:09:18 -04:00
old_snapshot Add new 'old_snapshot' contrib module. 2020-09-24 13:55:47 -04:00
pageinspect Remove unused parameter 2020-09-04 08:08:23 +02:00
passwordcheck passwordcheck: Log cracklib diagnostics 2020-08-28 08:18:24 +02:00
pg_buffercache
pg_freespacemap
pg_prewarm Fix and simplify some usages of TimestampDifference(). 2020-11-10 22:51:54 -05:00
pg_standby
pg_stat_statements pg_stat_statements: Track number of times pgss entries were deallocated. 2020-11-26 21:18:05 +09:00
pg_surgery pg_surgery: Try to stabilize regression tests. 2020-09-18 13:26:48 -04:00
pg_trgm Handle equality operator in contrib/pg_trgm 2020-11-15 08:52:35 +03:00
pg_visibility snapshot scalability: Don't compute global horizons while building snapshots. 2020-08-12 16:03:49 -07:00
pgcrypto Move SHA2 routines to a new generic API layer for crypto hashes 2020-12-02 10:37:20 +09:00
pgrowlocks
pgstattuple Redefine pg_class.reltuples to be -1 before the first VACUUM or ANALYZE. 2020-08-30 12:21:51 -04:00
postgres_fdw Move per-agg and per-trans duplicate finding to the planner. 2020-11-24 10:45:00 +02:00
seg Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
sepgsql Fix expected output: the order of agg permission checks changed. 2020-11-24 12:50:16 +02:00
spi
sslinfo Use be_tls_* API for SSL information in sslinfo 2020-11-03 09:47:36 +01:00
start-scripts
tablefunc tablefunc: Reject negative number of tuples passed to normal_rand() 2020-11-25 15:30:18 +01:00
tcn
test_decoding Fix 'skip-empty-xacts' option in test_decoding for streaming mode. 2020-11-17 12:14:53 +05:30
tsm_system_rows
tsm_system_time
unaccent
uuid-ossp
vacuumlo Remove arbitrary restrictions on password length. 2020-09-03 20:09:18 -04:00
xml2
contrib-global.mk
Makefile Add new 'old_snapshot' contrib module. 2020-09-24 13:55:47 -04:00
README

The PostgreSQL contrib tree
---------------------------

This subtree contains porting tools, analysis utilities, and plug-in
features that are not part of the core PostgreSQL system, mainly
because they address a limited audience or are too experimental to be
part of the main source tree.  This does not preclude their
usefulness.

User documentation for each module appears in the main SGML
documentation.

When building from the source distribution, these modules are not
built automatically, unless you build the "world" target.  You can
also build and install them all by running "make all" and "make
install" in this directory; or to build and install just one selected
module, do the same in that module's subdirectory.

Some directories supply new user-defined functions, operators, or
types.  To make use of one of these modules, after you have installed
the code you need to register the new SQL objects in the database
system by executing a CREATE EXTENSION command.  In a fresh database,
you can simply do

    CREATE EXTENSION module_name;

See the PostgreSQL documentation for more information about this
procedure.