Skip to content

openssl unsupported hash type blake2s error after building cpython 3.11.1 with openssl #101148

Closed
@nanaceba

Description

@nanaceba

Bug report

We are building and linking cpython with OpenSSL_1_1_1l using --with-openssl. Everything was working fine from 3.8.0 to 3.10.5 python. After we build 3.11.1 with same openssl version using same build code we start seeing code for hash not found error when trying to use pip

 ~/test/bin ./python3.11 -m pip install pytest
ERROR:root:code for hash blake2b was not found.
Traceback (most recent call last):
  File "/Users/eugene.sevostianov/test/lib/python3.11/hashlib.py", line 307, in <module>
    globals()[__func_name] = __get_hash(__func_name)
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eugene.sevostianov/test/lib/python3.11/hashlib.py", line 129, in __get_openssl_constructor
    return __get_builtin_constructor(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eugene.sevostianov/test/lib/python3.11/hashlib.py", line 123, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type blake2b
ERROR:root:code for hash blake2s was not found.
Traceback (most recent call last):
  File "/Users/eugene.sevostianov/test/lib/python3.11/hashlib.py", line 307, in <module>
    globals()[__func_name] = __get_hash(__func_name)
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eugene.sevostianov/test/lib/python3.11/hashlib.py", line 129, in __get_openssl_constructor
    return __get_builtin_constructor(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eugene.sevostianov/test/lib/python3.11/hashlib.py", line 123, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type blake2s
Collecting pytest
  Using cached pytest-7.2.1-py3-none-any.whl (317 kB)
Collecting attrs>=19.2.0
  Using cached attrs-22.2.0-py3-none-any.whl (60 kB)
Collecting iniconfig
  Using cached iniconfig-2.0.0-py3-none-any.whl (5.9 kB)
Collecting packaging
  Using cached packaging-23.0-py3-none-any.whl (42 kB)
Collecting pluggy<2.0,>=0.12
  Using cached pluggy-1.0.0-py2.py3-none-any.whl (13 kB)
Installing collected packages: pluggy, packaging, iniconfig, attrs, pytest
Successfully installed attrs-22.2.0 iniconfig-2.0.0 packaging-23.0 pluggy-1.0.0 pytest-7.2.1

Also blake2s is printed as available

 ~/test1/bin ./python3
Python 3.11.1 (tags/v3.11.1-dirty:a7a450f, Jan 27 2023, 20:43:46) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
ERROR:root:code for hash blake2b was not found.
Traceback (most recent call last):
  File "/Users/eugene.sevostianov/test1/lib/python3.11/hashlib.py", line 307, in <module>
    globals()[__func_name] = __get_hash(__func_name)
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eugene.sevostianov/test1/lib/python3.11/hashlib.py", line 129, in __get_openssl_constructor
    return __get_builtin_constructor(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eugene.sevostianov/test1/lib/python3.11/hashlib.py", line 123, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type blake2b
ERROR:root:code for hash blake2s was not found.
Traceback (most recent call last):
  File "/Users/eugene.sevostianov/test1/lib/python3.11/hashlib.py", line 307, in <module>
    globals()[__func_name] = __get_hash(__func_name)
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eugene.sevostianov/test1/lib/python3.11/hashlib.py", line 129, in __get_openssl_constructor
    return __get_builtin_constructor(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eugene.sevostianov/test1/lib/python3.11/hashlib.py", line 123, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type blake2s
>>> print(hashlib.algorithms_available)
{'md5', 'sha3_256', 'blake2s', 'sha256', 'whirlpool', 'ripemd160', 'sha512_256', 'sha3_512', 'md4', 'sha512', 'sha512_224', 'mdc2', 'sha224', 'shake_256', 'sha384', 'sha1', 'blake2b', 'sha3_384', 'shake_128', 'sm3', 'sha3_224', 'md5-sha1'}

We configure and build openssl as static library and build cpython with static lib.

            ssl_builder.run_in_build(
                ("perl", "../source/Configure", f"darwin64-{ssl_builder.flavor}-cc", "no-shared",
                 f"--prefix={ssl_builder.install_dir}",
                 f"--openssldir={ssl_builder.install_dir}",
                 ), build_env=BuildEnv(cflags=(macos_version_flag,),
                                       ldflags=(macos_version_flag,)).get_modified_with_private_deps())

we build 2 versions of open ssl lib for arm and x64 and then lipo them, and feed that fat static library to python.
python configure

    config_cmd = ("bash", "../source/configure",
                  f"--prefix={cpython_builder.install_dir}",
                  f"--with-openssl={lipo_ssl_root}")

Can't find out what I am missing.

Your environment

  • CPython versions tested on: 3.11.1
  • Operating system and architecture: 13.1 mac os, arm64 m1 mac

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixesbuildThe build process and cross-buildtopic-SSLtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions