forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit87ae969
committed
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: switchthe all cryptohash implementations for OpenSSL to use EVP (for FIPS andalso because upstream does not recommend the use of low-level cryptohashfunctions for 20 years). Note that OpenSSL hides the internals ofcryptohash contexts since 1.1.0, so it is necessary to leave theallocation to OpenSSL itself, explaining the need for those two newroutines. This part is going to require more work to properly trackhash 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 fromtwelve (SHA{224,256,386,512} with init, update and final calls) to five(create, free, init, update and final calls) by incorporating the hashtype directly into the hash context data.The new cryptohash routines are moved to a new file, called cryptohash.cfor the fallback implementations, with SHA2 specifics becoming a partinternal to src/common/. OpenSSL specifics are part ofcryptohash_openssl.c. This infrastructure is usable for more hashtypes, like MD5 or HMAC.Any code paths using the internal SHA2 routines are adapted to reportcorrectly errors, which are most of the changes of this commit. Thezones mostly impacted are checksum manifests, libpq and SCRAM.Note thate21cbb4 was a first attempt to switch SHA2 to EVP, but itlacked the refactoring needed for libpq, as done here.This patch has been tested on Linux and Windows, with and withoutOpenSSL, and down to 1.0.1, the oldest version supported on HEAD.Author: Michael PaquierReviewed-by: Daniel GustafssonDiscussion:https://postgr.es/m/20200924025314.GE7405@paquier.xyz1 parent888671a commit87ae969
File tree
23 files changed
+1039
-549
lines changed- contrib/pgcrypto
- src
- backend
- libpq
- replication
- utils/adt
- bin/pg_verifybackup
- common
- include
- common
- replication
- interfaces/libpq
- tools
- msvc
- pgindent
23 files changed
+1039
-549
lines changedLines changed: 41 additions & 147 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
| 36 | + | |
36 | 37 |
| |
37 | 38 |
| |
38 | 39 |
| |
| |||
42 | 43 |
| |
43 | 44 |
| |
44 | 45 |
| |
45 |
| - | |
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
| |||
55 | 55 |
| |
56 | 56 |
| |
57 | 57 |
| |
58 |
| - | |
59 |
| - | |
60 |
| - | |
61 |
| - | |
62 |
| - | |
63 |
| - | |
64 |
| - | |
65 |
| - | |
66 |
| - | |
67 |
| - | |
68 |
| - | |
69 |
| - | |
70 |
| - | |
71 |
| - | |
72 |
| - | |
73 |
| - | |
74 |
| - | |
75 |
| - | |
76 |
| - | |
77 |
| - | |
78 |
| - | |
79 |
| - | |
80 |
| - | |
81 |
| - | |
82 |
| - | |
83 |
| - | |
84 |
| - | |
85 |
| - | |
86 |
| - | |
87 |
| - | |
88 |
| - | |
89 |
| - | |
90 |
| - | |
91 |
| - | |
92 | 58 |
| |
93 |
| - | |
94 | 59 |
| |
95 | 60 |
| |
96 | 61 |
| |
| |||
103 | 68 |
| |
104 | 69 |
| |
105 | 70 |
| |
106 |
| - | |
107 |
| - | |
108 |
| - | |
109 |
| - | |
110 |
| - | |
111 |
| - | |
112 |
| - | |
113 |
| - | |
114 |
| - | |
115 |
| - | |
116 |
| - | |
117 |
| - | |
118 |
| - | |
119 |
| - | |
120 |
| - | |
121 |
| - | |
122 |
| - | |
123 |
| - | |
124 |
| - | |
125 |
| - | |
126 |
| - | |
127 |
| - | |
128 |
| - | |
129 |
| - | |
130 |
| - | |
131 |
| - | |
132 |
| - | |
133 |
| - | |
134 |
| - | |
135 |
| - | |
136 |
| - | |
137 |
| - | |
138 |
| - | |
139 |
| - | |
140 | 71 |
| |
141 |
| - | |
142 | 72 |
| |
143 | 73 |
| |
144 | 74 |
| |
| |||
151 | 81 |
| |
152 | 82 |
| |
153 | 83 |
| |
154 |
| - | |
155 |
| - | |
156 |
| - | |
157 |
| - | |
158 |
| - | |
159 |
| - | |
160 |
| - | |
161 |
| - | |
162 |
| - | |
163 |
| - | |
164 |
| - | |
165 |
| - | |
166 |
| - | |
167 |
| - | |
168 |
| - | |
169 |
| - | |
170 |
| - | |
171 |
| - | |
172 |
| - | |
173 |
| - | |
174 |
| - | |
175 |
| - | |
176 |
| - | |
177 |
| - | |
178 |
| - | |
179 |
| - | |
180 |
| - | |
181 |
| - | |
182 |
| - | |
183 |
| - | |
184 |
| - | |
185 |
| - | |
186 |
| - | |
187 |
| - | |
188 | 84 |
| |
189 |
| - | |
190 | 85 |
| |
191 | 86 |
| |
192 | 87 |
| |
| |||
199 | 94 |
| |
200 | 95 |
| |
201 | 96 |
| |
| 97 | + | |
202 | 98 |
| |
203 |
| - | |
| 99 | + | |
204 | 100 |
| |
205 |
| - | |
| 101 | + | |
206 | 102 |
| |
207 |
| - | |
| 103 | + | |
| 104 | + | |
208 | 105 |
| |
209 | 106 |
| |
210 | 107 |
| |
211 |
| - | |
| 108 | + | |
212 | 109 |
| |
213 |
| - | |
| 110 | + | |
214 | 111 |
| |
215 |
| - | |
| 112 | + | |
| 113 | + | |
216 | 114 |
| |
217 | 115 |
| |
218 | 116 |
| |
219 |
| - | |
| 117 | + | |
220 | 118 |
| |
221 |
| - | |
| 119 | + | |
222 | 120 |
| |
223 |
| - | |
| 121 | + | |
| 122 | + | |
224 | 123 |
| |
225 | 124 |
| |
226 | 125 |
| |
227 |
| - | |
| 126 | + | |
228 | 127 |
| |
229 |
| - | |
| 128 | + | |
230 | 129 |
| |
231 |
| - | |
232 |
| - | |
| 130 | + | |
233 | 131 |
| |
234 | 132 |
| |
235 | 133 |
| |
| |||
238 | 136 |
| |
239 | 137 |
| |
240 | 138 |
| |
241 |
| - | |
242 |
| - | |
243 |
| - | |
| 139 | + | |
244 | 140 |
| |
| 141 | + | |
245 | 142 |
| |
246 | 143 |
| |
247 | 144 |
| |
248 | 145 |
| |
249 |
| - | |
250 |
| - | |
251 |
| - | |
252 |
| - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
253 | 150 |
| |
254 | 151 |
| |
255 | 152 |
| |
256 | 153 |
| |
257 | 154 |
| |
258 | 155 |
| |
259 | 156 |
| |
260 |
| - | |
261 |
| - | |
262 |
| - | |
| 157 | + | |
263 | 158 |
| |
| 159 | + | |
264 | 160 |
| |
265 | 161 |
| |
266 | 162 |
| |
267 | 163 |
| |
268 |
| - | |
269 |
| - | |
270 |
| - | |
271 |
| - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
272 | 168 |
| |
273 | 169 |
| |
274 | 170 |
| |
275 | 171 |
| |
276 | 172 |
| |
277 | 173 |
| |
278 | 174 |
| |
279 |
| - | |
280 |
| - | |
281 |
| - | |
| 175 | + | |
282 | 176 |
| |
| 177 | + | |
283 | 178 |
| |
284 | 179 |
| |
285 | 180 |
| |
286 | 181 |
| |
287 |
| - | |
288 |
| - | |
289 |
| - | |
290 |
| - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
291 | 186 |
| |
292 | 187 |
| |
293 | 188 |
| |
294 | 189 |
| |
295 | 190 |
| |
296 | 191 |
| |
297 | 192 |
| |
298 |
| - | |
299 |
| - | |
300 |
| - | |
| 193 | + | |
301 | 194 |
| |
| 195 | + | |
302 | 196 |
| |
303 | 197 |
| |
304 | 198 |
| |
305 | 199 |
| |
306 |
| - | |
307 |
| - | |
308 |
| - | |
309 |
| - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
310 | 204 |
| |
311 | 205 |
| |
312 | 206 |
|
0 commit comments
Comments
(0)