forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5513dc6
committed
Improve error handling of HMAC computations
This is similar tob69aba7, except that this completes the work forHMAC with a new routine called pg_hmac_error() that would provide morecontext about the type of error that happened during a HMAC computation:- The fallback HMAC implementation in hmac.c relies on cryptohashes, soin some code paths it is necessary to return back the error generated bycryptohashes.- For the OpenSSL implementation (hmac_openssl.c), the logic is verysimilar to cryptohash_openssl.c, where the error context comes fromOpenSSL if one of its internal routines failed, with different errorcodes if something internal to hmac_openssl.c failed or was incorrect.Any in-core code paths that use the centralized HMAC interface arerelated to SCRAM, for errors that are unlikely going to happen, withonly SHA-256. It would be possible to see errors when computing someHMACs with MD5 for example and OpenSSL FIPS enabled, and this commitwould help in reporting the correct errors but nothing in core usesthat. So, at the end, no backpatch to v14 is done, at least for now.Errors in SCRAM related to the computation of the server key, storedkey, etc. need to pass down the potential error context string acrossmore layers of their respective call stacks for the frontend and thebackend, so each surrounding routine is adapted for this purpose.Reviewed-by: Sergey ShinderukDiscussion:https://postgr.es/m/Yd0N9tSAIIkFd+qi@paquier.xyz1 parent379a28b commit5513dc6
File tree
10 files changed
+294
-55
lines changed- src
- backend/libpq
- common
- include/common
- interfaces/libpq
- tools/pgindent
10 files changed
+294
-55
lines changedLines changed: 14 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
465 | 465 |
| |
466 | 466 |
| |
467 | 467 |
| |
| 468 | + | |
468 | 469 |
| |
469 | 470 |
| |
470 | 471 |
| |
| |||
482 | 483 |
| |
483 | 484 |
| |
484 | 485 |
| |
485 |
| - | |
| 486 | + | |
| 487 | + | |
486 | 488 |
| |
487 | 489 |
| |
488 | 490 |
| |
| |||
509 | 511 |
| |
510 | 512 |
| |
511 | 513 |
| |
| 514 | + | |
512 | 515 |
| |
513 | 516 |
| |
514 | 517 |
| |
| |||
539 | 542 |
| |
540 | 543 |
| |
541 | 544 |
| |
542 |
| - | |
543 |
| - | |
| 545 | + | |
| 546 | + | |
544 | 547 |
| |
545 |
| - | |
| 548 | + | |
546 | 549 |
| |
547 | 550 |
| |
548 | 551 |
| |
| |||
1113 | 1116 |
| |
1114 | 1117 |
| |
1115 | 1118 |
| |
| 1119 | + | |
1116 | 1120 |
| |
1117 | 1121 |
| |
1118 | 1122 |
| |
| |||
1133 | 1137 |
| |
1134 | 1138 |
| |
1135 | 1139 |
| |
1136 |
| - | |
| 1140 | + | |
| 1141 | + | |
1137 | 1142 |
| |
1138 | 1143 |
| |
1139 | 1144 |
| |
| |||
1143 | 1148 |
| |
1144 | 1149 |
| |
1145 | 1150 |
| |
1146 |
| - | |
1147 |
| - | |
| 1151 | + | |
| 1152 | + | |
1148 | 1153 |
| |
1149 | 1154 |
| |
1150 | 1155 |
| |
| |||
1389 | 1394 |
| |
1390 | 1395 |
| |
1391 | 1396 |
| |
1392 |
| - | |
| 1397 | + | |
| 1398 | + | |
1393 | 1399 |
| |
1394 | 1400 |
| |
1395 | 1401 |
| |
|
Lines changed: 64 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
41 | 49 |
| |
42 | 50 |
| |
43 | 51 |
| |
44 | 52 |
| |
45 | 53 |
| |
| 54 | + | |
| 55 | + | |
46 | 56 |
| |
47 | 57 |
| |
48 | 58 |
| |
| |||
73 | 83 |
| |
74 | 84 |
| |
75 | 85 |
| |
| 86 | + | |
| 87 | + | |
76 | 88 |
| |
77 | 89 |
| |
78 | 90 |
| |
| |||
150 | 162 |
| |
151 | 163 |
| |
152 | 164 |
| |
| 165 | + | |
| 166 | + | |
153 | 167 |
| |
| 168 | + | |
154 | 169 |
| |
155 | 170 |
| |
156 | 171 |
| |
157 | 172 |
| |
158 | 173 |
| |
| 174 | + | |
159 | 175 |
| |
160 | 176 |
| |
161 | 177 |
| |
| |||
164 | 180 |
| |
165 | 181 |
| |
166 | 182 |
| |
| 183 | + | |
| 184 | + | |
167 | 185 |
| |
168 | 186 |
| |
169 | 187 |
| |
| |||
184 | 202 |
| |
185 | 203 |
| |
186 | 204 |
| |
| 205 | + | |
| 206 | + | |
187 | 207 |
| |
188 | 208 |
| |
189 | 209 |
| |
| |||
206 | 226 |
| |
207 | 227 |
| |
208 | 228 |
| |
| 229 | + | |
| 230 | + | |
| 231 | + | |
209 | 232 |
| |
| 233 | + | |
210 | 234 |
| |
211 | 235 |
| |
212 | 236 |
| |
| |||
226 | 250 |
| |
227 | 251 |
| |
228 | 252 |
| |
| 253 | + | |
| 254 | + | |
229 | 255 |
| |
| 256 | + | |
230 | 257 |
| |
231 | 258 |
| |
232 | 259 |
| |
233 | 260 |
| |
| 261 | + | |
| 262 | + | |
234 | 263 |
| |
235 | 264 |
| |
236 | 265 |
| |
| |||
241 | 270 |
| |
242 | 271 |
| |
243 | 272 |
| |
| 273 | + | |
| 274 | + | |
244 | 275 |
| |
245 | 276 |
| |
246 | 277 |
| |
| |||
264 | 295 |
| |
265 | 296 |
| |
266 | 297 |
| |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + |
Lines changed: 90 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
20 | 20 |
| |
21 | 21 |
| |
22 | 22 |
| |
| 23 | + | |
| 24 | + | |
23 | 25 |
| |
24 | 26 |
| |
25 | 27 |
| |
| |||
50 | 52 |
| |
51 | 53 |
| |
52 | 54 |
| |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
53 | 63 |
| |
54 | 64 |
| |
55 | 65 |
| |
56 | 66 |
| |
57 | 67 |
| |
| 68 | + | |
| 69 | + | |
58 | 70 |
| |
59 | 71 |
| |
60 | 72 |
| |
61 | 73 |
| |
62 | 74 |
| |
63 | 75 |
| |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
64 | 89 |
| |
65 | 90 |
| |
66 | 91 |
| |
| |||
78 | 103 |
| |
79 | 104 |
| |
80 | 105 |
| |
| 106 | + | |
| 107 | + | |
81 | 108 |
| |
82 | 109 |
| |
83 | 110 |
| |
| |||
152 | 179 |
| |
153 | 180 |
| |
154 | 181 |
| |
| 182 | + | |
| 183 | + | |
| 184 | + | |
155 | 185 |
| |
| 186 | + | |
156 | 187 |
| |
157 | 188 |
| |
158 | 189 |
| |
| |||
174 | 205 |
| |
175 | 206 |
| |
176 | 207 |
| |
| 208 | + | |
| 209 | + | |
| 210 | + | |
177 | 211 |
| |
| 212 | + | |
178 | 213 |
| |
179 | 214 |
| |
180 | 215 |
| |
| |||
196 | 231 |
| |
197 | 232 |
| |
198 | 233 |
| |
| 234 | + | |
| 235 | + | |
199 | 236 |
| |
| 237 | + | |
200 | 238 |
| |
201 | 239 |
| |
202 | 240 |
| |
| 241 | + | |
| 242 | + | |
203 | 243 |
| |
| 244 | + | |
204 | 245 |
| |
205 | 246 |
| |
206 | 247 |
| |
| 248 | + | |
| 249 | + | |
207 | 250 |
| |
| 251 | + | |
208 | 252 |
| |
209 | 253 |
| |
210 | 254 |
| |
| 255 | + | |
| 256 | + | |
211 | 257 |
| |
| 258 | + | |
212 | 259 |
| |
213 | 260 |
| |
214 | 261 |
| |
| 262 | + | |
| 263 | + | |
215 | 264 |
| |
| 265 | + | |
216 | 266 |
| |
217 | 267 |
| |
218 | 268 |
| |
| 269 | + | |
| 270 | + | |
219 | 271 |
| |
| 272 | + | |
220 | 273 |
| |
221 | 274 |
| |
222 | 275 |
| |
223 | 276 |
| |
224 | 277 |
| |
225 | 278 |
| |
226 | 279 |
| |
| 280 | + | |
| 281 | + | |
| 282 | + | |
227 | 283 |
| |
| 284 | + | |
228 | 285 |
| |
229 | 286 |
| |
230 | 287 |
| |
| |||
252 | 309 |
| |
253 | 310 |
| |
254 | 311 |
| |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + |
0 commit comments
Comments
(0)