pgsql: Replace PostmasterRandom() with a stronger way of generating ran

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Replace PostmasterRandom() with a stronger way of generating ran
Date: 2016-10-17 08:53:47
Message-ID: E1bw3g3-0003st-6M@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Replace PostmasterRandom() with a stronger way of generating randomness.

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
- /dev/random

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

Discussion: <CAB7nPqRy3krN8quR9XujMVVHYtXJ0_60nqgVc6oUk8ygyVkZsA(at)mail(dot)gmail(dot)com>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/9e083fd4683294f41544e6d0d72f6e258ff3a77c

Modified Files
--------------
contrib/pgcrypto/Makefile | 2 +-
contrib/pgcrypto/internal.c | 40 +++---
contrib/pgcrypto/random.c | 247 ------------------------------------
src/backend/libpq/auth.c | 27 +++-
src/backend/postmaster/postmaster.c | 153 ++++++----------------
src/include/port.h | 3 +
src/port/Makefile | 2 +-
src/port/pg_strong_random.c | 148 +++++++++++++++++++++
src/tools/msvc/Mkvcbuild.pm | 6 +-
9 files changed, 244 insertions(+), 384 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2016-10-17 09:18:11 pgsql: Fix use-after-free around DISTINCT transition function calls.
Previous Message Andres Freund 2016-10-15 00:28:12 pgsql: Use more efficient hashtable for execGrouping.c to speed up hash

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2016-10-17 08:55:21 Re: Password identifiers, protocol aging and SCRAM protocol
Previous Message Ashutosh Bapat 2016-10-17 07:50:06 Re: postgres_fdw super user checks