Commit d761f53
* gh-146287: use signed type for HMAC digest size to prevent unsigned wrapping
Change _hashlib_hmac_digest_size() return type from unsigned int to int
so that a hypothetical negative return from EVP_MD_size() is not
silently wrapped to a large positive value. Add an explicit check for
negative digest_size in the legacy OpenSSL path, and use SystemError
(not ValueError) since these conditions indicate internal invariant
violations. Also add debug-build asserts to EVP_get_block_size and
EVP_get_digest_size documenting that the hash context is always
initialized.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
1 parent cef334f commit d761f53
1 file changed
+11
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1006 | 1006 | | |
1007 | 1007 | | |
1008 | 1008 | | |
| 1009 | + | |
1009 | 1010 | | |
1010 | 1011 | | |
1011 | 1012 | | |
| |||
1014 | 1015 | | |
1015 | 1016 | | |
1016 | 1017 | | |
| 1018 | + | |
1017 | 1019 | | |
1018 | 1020 | | |
1019 | 1021 | | |
| |||
2200 | 2202 | | |
2201 | 2203 | | |
2202 | 2204 | | |
2203 | | - | |
| 2205 | + | |
2204 | 2206 | | |
2205 | 2207 | | |
2206 | 2208 | | |
| |||
2215 | 2217 | | |
2216 | 2218 | | |
2217 | 2219 | | |
2218 | | - | |
2219 | 2220 | | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
2220 | 2225 | | |
2221 | 2226 | | |
2222 | 2227 | | |
2223 | | - | |
| 2228 | + | |
2224 | 2229 | | |
2225 | 2230 | | |
2226 | | - | |
| 2231 | + | |
2227 | 2232 | | |
2228 | 2233 | | |
2229 | 2234 | | |
| |||
2321 | 2326 | | |
2322 | 2327 | | |
2323 | 2328 | | |
2324 | | - | |
| 2329 | + | |
2325 | 2330 | | |
2326 | 2331 | | |
2327 | 2332 | | |
| |||
2386 | 2391 | | |
2387 | 2392 | | |
2388 | 2393 | | |
2389 | | - | |
| 2394 | + | |
2390 | 2395 | | |
2391 | 2396 | | |
2392 | 2397 | | |
| |||
0 commit comments