Skip to content

hashlib.md5 doesn't work when FIPS is enabled #580

@henry2004y

Description

@henry2004y

Similar to this issue, while importing yt 4.4.0, I encountered the following error on Pleiades, a cluster managed by NASA:

Python 3.12.10 (main, Apr 22 2025, 18:32:49) [GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home1/hzhou4/swbuild/Python-3.12.10/lib/python3.12/site-packages/yt/__init__.py", line 12, in <module>
    import yt.units as units
  File "/home1/hzhou4/swbuild/Python-3.12.10/lib/python3.12/site-packages/yt/units/__init__.py", line 1, in <module>
    from unyt.array import (
  File "/home1/hzhou4/swbuild/Python-3.12.10/lib/python3.12/site-packages/unyt/__init__.py", line 38, in <module>
    from unyt import physical_constants, unit_symbols
  File "/home1/hzhou4/swbuild/Python-3.12.10/lib/python3.12/site-packages/unyt/physical_constants.py", line 22, in <module>
    _add_constants(globals(), registry=_default_unit_registry)
  File "/home1/hzhou4/swbuild/Python-3.12.10/lib/python3.12/site-packages/unyt/unit_systems.py", line 91, in add_constants
    namespace[name] = quan.in_base(unit_system=registry.unit_system)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home1/hzhou4/swbuild/Python-3.12.10/lib/python3.12/site-packages/unyt/array.py", line 1044, in in_base
    conv_data = _check_em_conversion(
                ^^^^^^^^^^^^^^^^^^^^^
  File "/home1/hzhou4/swbuild/Python-3.12.10/lib/python3.12/site-packages/unyt/unit_object.py", line 312, in __hash__
    return int(self.registry.unit_system_id, 16) ^ hash(self.expr)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home1/hzhou4/swbuild/Python-3.12.10/lib/python3.12/site-packages/unyt/unit_registry.py", line 96, in unit_system_id
    m = md5()
        ^^^^^
ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS

The following workaround seems to fix the problem:

m = md5(usedforsecurity=False)

However, in yt it seems there are more places calling md5().

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions