summaryrefslogtreecommitdiff
path: root/src/include/port.h
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2016-10-17 11:52:50 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2016-10-17 11:52:50 +0300
commit9e083fd4683294f41544e6d0d72f6e258ff3a77c (patch)
treebbacc73b0c4a29a0d7b62d3c5a7bb4583d592ad1 /src/include/port.h
parent5dfc198146b49ce7ecc8a1fc9d5e171fb75f6ba5 (diff)
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@mail.gmail.com>
Diffstat (limited to 'src/include/port.h')
-rw-r--r--src/include/port.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/include/port.h b/src/include/port.h
index b81fa4a89eb..4bb9feeb019 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -454,6 +454,9 @@ extern int pg_codepage_to_encoding(UINT cp);
extern char *inet_net_ntop(int af, const void *src, int bits,
char *dst, size_t size);
+/* port/pg_strong_random.c */
+extern bool pg_strong_random(void *buf, size_t len);
+
/* port/pgcheckdir.c */
extern int pg_check_dir(const char *dir);