Repository navigation
Commit fd700e4
[3.14] gh-161383: Fix inverted FIPS property query in _hashlib
In FIPS mode, usedforsecurity worked the wrong way round:
usedforsecurity=False MD5 was refused, usedforsecurity=True MD5 was
allowed, and hashlib.md5() fell back to the built-in _md5 without any
error.
disable_fips_property() returns 1 for usedforsecurity=False, but
py_digest_by_name() uses 'fips' as "1 = strict FIPS lookup". main
inverts the value with "!"; the 3.14 backport of gh-149816 (GH-160006)
lost it. Invert it after the -1 error check.
Tests:
- Add a FIPS-only test: MD5 must work with usedforsecurity=False and be
refused with usedforsecurity=True.
- Copy check_file_digest() from main (gh-136547). The 3.14 version
checks hashlib.new(name), which works through the built-in MD5, and
then also calls _hashlib.openssl_md5, which FIPS refuses. With only
the C fix, test_case_md5_* fail in FIPS mode. The main version skips
each blocked constructor.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>1 parent 6e88927 commit fd700e4
3 files changed
Lines changed: 31 additions & 7 deletions
File tree
- Lib/test
- Misc/NEWS.d/next/Library
- Modules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
280 | 292 | | |
281 | 293 | | |
282 | 294 | | |
| |||
512 | 524 | | |
513 | 525 | | |
514 | 526 | | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
522 | 538 | | |
523 | 539 | | |
524 | 540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
424 | 427 | | |
425 | 428 | | |
426 | 429 | | |
| |||
0 commit comments