Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashlib.algorithms_available doesn't account for backends loaded dynamically at runtime #92874

Open
mgorny opened this issue May 17, 2022 · 2 comments
Labels
topic-SSL type-bug An unexpected behavior, bug, or error

Comments

@mgorny
Copy link
Contributor

mgorny commented May 17, 2022

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 1b6acaa backported, 3.9.12
  • Operating system and architecture: Gentoo Linux amd64
  • OpenSSL version: 3.0.3
@mgorny mgorny added the type-bug An unexpected behavior, bug, or error label May 17, 2022
@jakirkham
Copy link

This looks very similar to issue ( #92876 ). Should one of these be closed? Or am I missing some difference between these?

@mgorny
Copy link
Contributor Author

mgorny commented Oct 29, 2022

No, not really. Solving #92876 would somewhat avoid one particular example but the issue would persist if one of the libraries loaded yet another provider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-SSL type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants