postgresql/src/include
Heikki Linnakangas fe0a0b5993 Replace PostmasterRandom() with a stronger source, second attempt.
This adds a new routine, pg_strong_random() for generating random bytes,
for use in both frontend and backend. At the moment, it's only used in
the backend, but the upcoming SCRAM authentication patches need strong
random numbers in libpq as well.

pg_strong_random() is based on, and replaces, the existing implementation
in pgcrypto. It can acquire strong random numbers from a number of sources,
depending on what's available:

- OpenSSL RAND_bytes(), if built with OpenSSL
- On Windows, the native cryptographic functions are used
- /dev/urandom

Unlike the current pgcrypto function, the source is chosen by configure.
That makes it easier to test different implementations, and ensures that
we don't accidentally fall back to a less secure implementation, if the
primary source fails. All of those methods are quite reliable, it would be
pretty surprising for them to fail, so we'd rather find out by failing
hard.

If no strong random source is available, we fall back to using erand48(),
seeded from current timestamp, like PostmasterRandom() was. That isn't
cryptographically secure, but allows us to still work on platforms that
don't have any of the above stronger sources. Because it's not very secure,
the built-in implementation is only used if explicitly requested with
--disable-strong-random.

This replaces the more complicated Fortuna algorithm we used to have in
pgcrypto, which is unfortunate, but all modern platforms have /dev/urandom,
so it doesn't seem worth the maintenance effort to keep that. pgcrypto
functions that require strong random numbers will be disabled with
--disable-strong-random.

Original patch by Magnus Hagander, tons of further work by Michael Paquier
and me.

Discussion: https://www.postgresql.org/message-id/CAB7nPqRy3krN8quR9XujMVVHYtXJ0_60nqgVc6oUk8ygyVkZsA@mail.gmail.com
Discussion: https://www.postgresql.org/message-id/CAB7nPqRWkNYRRPJA7-cF+LfroYV10pvjdz6GNvxk-Eee9FypKA@mail.gmail.com
2016-12-05 13:42:59 +02:00
..
access Improve hash index bucket split behavior. 2016-11-30 15:39:21 -05:00
bootstrap
catalog Delete deleteWhatDependsOn() in favor of more performDeletion() flag bits. 2016-12-02 14:57:55 -05:00
commands Delete deleteWhatDependsOn() in favor of more performDeletion() flag bits. 2016-12-02 14:57:55 -05:00
common Rename "pg_xlog" directory to "pg_wal". 2016-10-20 11:32:18 -04:00
datatype
executor Simplify code by getting rid of SPI_push, SPI_pop, SPI_restore_connection. 2016-11-08 17:39:57 -05:00
fe_utils
foreign
lib Permit dump/reload of not-too-large >1GB tuples 2016-12-02 00:34:01 -03:00
libpq Replace PostmasterRandom() with a stronger source, second attempt. 2016-12-05 13:42:59 +02:00
mb Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodes User narrower representative tuples in the hash-agg hashtable. 2016-11-30 17:30:09 -08:00
optimizer Speed up planner's scanning for parallel-query hazards. 2016-08-19 14:03:13 -04:00
parser Improve handling of "UPDATE ... SET (column_list) = row_constructor". 2016-11-22 15:20:10 -05:00
port
portability
postmaster Add max_parallel_workers GUC. 2016-12-02 07:42:58 -05:00
regex
replication Fix Windows build for 78c8c81439 2016-12-02 09:40:36 -03:00
rewrite
snowball Update copyright for 2016 2016-01-02 13:33:40 -05:00
storage Bring some clarity to the defaults for the xxx_flush_after parameters. 2016-11-25 18:36:10 -05:00
tcop
tsearch
utils Replace PostmasterRandom() with a stronger source, second attempt. 2016-12-05 13:42:59 +02:00
.gitignore Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
c.h
fmgr.h
funcapi.h Widen query numbers-of-tuples-processed counters to uint64. 2016-03-12 16:05:29 -05:00
getaddrinfo.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
getopt_long.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
Makefile Create src/fe_utils/, and move stuff into there from pg_dump's dumputils. 2016-03-24 15:55:57 -04:00
miscadmin.h Replace PostmasterRandom() with a stronger source, second attempt. 2016-12-05 13:42:59 +02:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32
pg_config_manual.h Bring some clarity to the defaults for the xxx_flush_after parameters. 2016-11-25 18:36:10 -05:00
pg_config.h.in Replace PostmasterRandom() with a stronger source, second attempt. 2016-12-05 13:42:59 +02:00
pg_config.h.win32 Replace PostmasterRandom() with a stronger source, second attempt. 2016-12-05 13:42:59 +02:00
pg_getopt.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
pg_trace.h
pgstat.h Use latch instead of select() in walreceiver 2016-12-01 20:23:28 -05:00
pgtar.h Allow pg_basebackup to stream transaction log in tar mode 2016-10-23 15:23:11 +02:00
pgtime.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
port.h Replace PostmasterRandom() with a stronger source, second attempt. 2016-12-05 13:42:59 +02:00
postgres_ext.h
postgres_fe.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
postgres.h Be pickier about converting between Name and Datum. 2016-09-13 17:17:48 -04:00
rusagestub.h
windowapi.h Update copyright for 2016 2016-01-02 13:33:40 -05:00