GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — `hashlib`: `usedforsecurity` works the wrong way round in FIPS mode in 3.14.10 · Issue #161383 · python/cpython Closed as duplicate Closed as duplicate Copy link Labels type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug reportBug description:In 3.14.10, when OpenSSL runs in FIPS mode,
Because 3.14.9 and earlier work correctly. CauseThe bug was introduced when the fix for gh-149816 was backported to 3.14 (GH-160006, commit 3d2f1b2). In int fips = disable_fips_property(py_ht); if (fips == -1) { goto finally; }
PY_EVP_MD **cached = fips ? &entry->evp : &entry->evp_nosecurity; ... fresh = PY_EVP_MD_fetch(entry->ossl_name, fips ? NULL : "-fips"); So the value needs to be inverted. int fips = !disable_fips_property(py_ht); In 3.14 the backport kept a Affected: 3.14.10 and the current How to reproduceYou need OpenSSL 3 in FIPS mode as described above, so that import hashlib, _hashlib print("fips mode:", _hashlib.get_fips_mode()) def t(label, f): try: f() print("ok ", label) except Exception as e: print("ERROR ", label, "->", type(e).__name__, e) t("openssl_md5(usedforsecurity=False) [must work]", lambda: _hashlib.openssl_md5(b"x", usedforsecurity=False)) t("openssl_md5(usedforsecurity=True) [must be refused]", lambda: _hashlib.openssl_md5(b"x", usedforsecurity=True)) t("new('md5', usedforsecurity=True) [must be refused]", lambda: _hashlib.new("md5", b"x", usedforsecurity=True)) t("new('md5', usedforsecurity=False) [must work]", lambda: _hashlib.new("md5", b"x", usedforsecurity=False)) print("hashlib.md5 module:", hashlib.md5.__module__) t("hashlib.md5() (default usedforsecurity=True) [must be refused]", lambda: hashlib.md5(b"x")) Actual output (unmodified Expected output (the same build with the fix; 3.14.8 behaves the same way): Why the tests did not catch itCI does not run in FIPS mode. Proposed fixInvert CPython versions tested on:3.14 Operating systems tested on:Linux Linked PRsActivity
MetadataMetadataAssigneesLabelstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |