Skip to content

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

@mgorny

Description

@mgorny

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-SSLtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions