hashlib.algorithms_available doesn't account for backends loaded dynamically at runtime
Open
Nobody has claimed this yet.
stdlib
topic-SSL
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
Bug report
If additional OpenSSL backends are loaded at runtime (this happens e.g. when importing PyOpenSSL), the hashlib.algorithms_available doesn't get updated for the newly available hashes.
Trivial reproducer:
>>> import ctypes, hashlib
>>> ctypes.CDLL("libssl.so").OSSL_PROVIDER_load(None, b"legacy")
-1311283920
>>> "md4" in hashlib.algorithms_available
False
>>> hashlib.new("md4")
<md4 _hashlib.HASH object @ 0x7f404308faf0>
Your environment
- CPython versions tested on: 3.11.0b1, 3.10.4 with 1b6acaad9a18b2498386c60f24351ab749061e3a backported, 3.9.12
- Operating system and architecture: Gentoo Linux amd64
- OpenSSL version: 3.0.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the hashlib.algorithms_available and hashlib.new entry points and reproduce the behavior after loading OpenSSL's legacy provider at runtime. Trace how the available-hash set is populated, then verify that hashes exposed by a newly loaded backend appear in algorithms_available while hashlib.new continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cryptography
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100