forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitfe0a0b5
committed
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 inthe backend, but the upcoming SCRAM authentication patches need strongrandom numbers in libpq as well.pg_strong_random() is based on, and replaces, the existing implementationin 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/urandomUnlike the current pgcrypto function, the source is chosen by configure.That makes it easier to test different implementations, and ensures thatwe don't accidentally fall back to a less secure implementation, if theprimary source fails. All of those methods are quite reliable, it would bepretty surprising for them to fail, so we'd rather find out by failinghard.If no strong random source is available, we fall back to using erand48(),seeded from current timestamp, like PostmasterRandom() was. That isn'tcryptographically secure, but allows us to still work on platforms thatdon'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 inpgcrypto, which is unfortunate, but all modern platforms have /dev/urandom,so it doesn't seem worth the maintenance effort to keep that. pgcryptofunctions that require strong random numbers will be disabled with--disable-strong-random.Original patch by Magnus Hagander, tons of further work by Michael Paquierand me.Discussion:https://www.postgresql.org/message-id/CAB7nPqRy3krN8quR9XujMVVHYtXJ0_60nqgVc6oUk8ygyVkZsA@mail.gmail.comDiscussion:https://www.postgresql.org/message-id/CAB7nPqRWkNYRRPJA7-cF+LfroYV10pvjdz6GNvxk-Eee9FypKA@mail.gmail.com1 parent5dc851a commitfe0a0b5
File tree
42 files changed
+1472
-1104
lines changed- contrib/pgcrypto
- expected
- doc/src/sgml
- src
- backend
- libpq
- postmaster
- storage
- ipc
- lmgr
- utils
- init
- misc
- include
- libpq
- utils
- port
- tools/msvc
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
42 files changed
+1472
-1104
lines changedLines changed: 109 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
739 | 739 |
| |
740 | 740 |
| |
741 | 741 |
| |
| 742 | + | |
742 | 743 |
| |
743 | 744 |
| |
744 | 745 |
| |
| |||
806 | 807 |
| |
807 | 808 |
| |
808 | 809 |
| |
| 810 | + | |
809 | 811 |
| |
810 | 812 |
| |
811 | 813 |
| |
| |||
1478 | 1480 |
| |
1479 | 1481 |
| |
1480 | 1482 |
| |
| 1483 | + | |
1481 | 1484 |
| |
1482 | 1485 |
| |
1483 | 1486 |
| |
| |||
3192 | 3195 |
| |
3193 | 3196 |
| |
3194 | 3197 |
| |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
| 3202 | + | |
| 3203 | + | |
| 3204 | + | |
| 3205 | + | |
| 3206 | + | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
| 3221 | + | |
| 3222 | + | |
| 3223 | + | |
| 3224 | + | |
| 3225 | + | |
3195 | 3226 |
| |
3196 | 3227 |
| |
3197 | 3228 |
| |
| |||
14982 | 15013 |
| |
14983 | 15014 |
| |
14984 | 15015 |
| |
| 15016 | + | |
| 15017 | + | |
| 15018 | + | |
| 15019 | + | |
| 15020 | + | |
| 15021 | + | |
| 15022 | + | |
| 15023 | + | |
| 15024 | + | |
| 15025 | + | |
| 15026 | + | |
| 15027 | + | |
| 15028 | + | |
| 15029 | + | |
| 15030 | + | |
| 15031 | + | |
| 15032 | + | |
| 15033 | + | |
| 15034 | + | |
| 15035 | + | |
| 15036 | + | |
| 15037 | + | |
| 15038 | + | |
| 15039 | + | |
| 15040 | + | |
| 15041 | + | |
| 15042 | + | |
| 15043 | + | |
| 15044 | + | |
| 15045 | + | |
| 15046 | + | |
| 15047 | + | |
| 15048 | + | |
| 15049 | + | |
| 15050 | + | |
| 15051 | + | |
| 15052 | + | |
| 15053 | + | |
| 15054 | + | |
| 15055 | + | |
| 15056 | + | |
| 15057 | + | |
| 15058 | + | |
| 15059 | + | |
| 15060 | + | |
| 15061 | + | |
| 15062 | + | |
| 15063 | + | |
| 15064 | + | |
| 15065 | + | |
| 15066 | + | |
| 15067 | + | |
| 15068 | + | |
| 15069 | + | |
| 15070 | + | |
| 15071 | + | |
| 15072 | + | |
| 15073 | + | |
| 15074 | + | |
| 15075 | + | |
| 15076 | + | |
| 15077 | + | |
| 15078 | + | |
| 15079 | + | |
| 15080 | + | |
| 15081 | + | |
| 15082 | + | |
| 15083 | + | |
| 15084 | + | |
| 15085 | + | |
| 15086 | + | |
| 15087 | + | |
| 15088 | + | |
| 15089 | + | |
| 15090 | + | |
| 15091 | + | |
| 15092 | + | |
| 15093 | + | |
14985 | 15094 |
| |
14986 | 15095 |
| |
14987 | 15096 |
| |
|
Lines changed: 52 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
193 | 193 |
| |
194 | 194 |
| |
195 | 195 |
| |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
196 | 203 |
| |
197 | 204 |
| |
198 | 205 |
| |
| |||
1965 | 1972 |
| |
1966 | 1973 |
| |
1967 | 1974 |
| |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
1968 | 2020 |
| |
1969 | 2021 |
| |
1970 | 2022 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | 3 |
| |
4 |
| - | |
| 4 | + | |
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
|
Lines changed: 42 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + |
0 commit comments
Comments
(0)