Synss / python-mbedtls

Cryptographic library with an mbed TLS back end
MIT License
79 stars 28 forks source link

Incompatibility with mbedtls version 3.0.0 #46

Closed marianhlavac closed 3 years ago

marianhlavac commented 3 years ago

Description

Upgrading mbedtls to latest stable version 3.0.0 causes compatibility issues with python-mbedtls.

Current behavior

Building wheels for package results in error

build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/mpi.c:4343:36: error: implicit declaration of function 'mbedtls_mpi_is_prime' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    __pyx_t_2 = __Pyx_PyInt_From_int(mbedtls_mpi_is_prime((&__pyx_v_self->_ctx), (&mbedtls_ctr_drbg_random), (&__pyx_v_7mbedtls_3mpi___rng->_ctx))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
                                     ^
  build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/mpi.c:4343:36: note: did you mean 'mbedtls_mpi_gen_prime'?
  /usr/local/include/mbedtls/bignum.h:1002:5: note: 'mbedtls_mpi_gen_prime' declared here
  int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int flags,
      ^
  1 error generated.
Full output
❯ env LDFLAGS="-I/usr/local/Cellar/mbedtls/3.0.0/include -L/usr/local/Cellar/mbedtls/3.0.0/lib" pip3 install python-mbedtls --no-cache-dir
Looking in indexes: https://pypi.org/simple, https://pypi%40dronetag.cz:****@pypi.dronetag.cz/
Collecting python-mbedtls
  Downloading python-mbedtls-1.5.1.tar.gz (122 kB)
     |████████████████████████████████| 122 kB 3.3 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Requirement already satisfied: certifi in /usr/local/lib/python3.9/site-packages (from python-mbedtls) (2021.5.30)
Building wheels for collected packages: python-mbedtls
  Building wheel for python-mbedtls (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/python@3.9/bin/python3.9 /usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /var/folders/nr/d4vr6w_97gg039v6gxyfrzkw0000gn/T/tmp9e4wj54w
       cwd: /private/var/folders/nr/d4vr6w_97gg039v6gxyfrzkw0000gn/T/pip-install-ltzuoka5/python-mbedtls_51fd5414c21142678e58258c68a1a045
  Complete output (61 lines):
    loading: '/usr/local/lib/libmbedtls.dylib'
    mbedtls version: mbed TLS 3.0.0
    python-mbedtls version: 1.5.1running bdist_wheel
  running build
  running build_py
  creating build
  creating build/3.9.6
  creating build/3.9.6/lib.macosx-10.15-x86_64-3.9
  creating build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls
  copying src/mbedtls/hashlib.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls
  copying src/mbedtls/__init__.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls
  copying src/mbedtls/secrets.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls
  copying src/mbedtls/hmac.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls
  creating build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls/cipher
  copying src/mbedtls/cipher/ARIA.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls/cipher
  copying src/mbedtls/cipher/ARC4.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls/cipher
  copying src/mbedtls/cipher/AES.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls/cipher
  copying src/mbedtls/cipher/__init__.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls/cipher
  copying src/mbedtls/cipher/DES3.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls/cipher
  copying src/mbedtls/cipher/Camellia.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls/cipher
  copying src/mbedtls/cipher/CHACHA20.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls/cipher
  copying src/mbedtls/cipher/Blowfish.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls/cipher
  copying src/mbedtls/cipher/DES3dbl.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls/cipher
  copying src/mbedtls/cipher/DES.py -> build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls/cipher
  running build_ext
  cythoning src/mbedtls/_platform.pyx to build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/_platform.c
  creating build/3.9.6/temp.macosx-10.15-x86_64-3.9
  creating build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex
  creating build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls
  cythoning src/mbedtls/mpi.pyx to build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/mpi.c
  cythoning src/mbedtls/pk.pyx to build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/pk.c
  cythoning src/mbedtls/tls.pyx to build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/tls.c
  cythoning src/mbedtls/version.pyx to build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/version.c
  cythoning src/mbedtls/_random.pyx to build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/_random.c
  cythoning src/mbedtls/hkdf.pyx to build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/hkdf.c
  cythoning src/mbedtls/x509.pyx to build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/x509.c
  cythoning src/mbedtls/exceptions.pyx to build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/exceptions.c
  cythoning src/mbedtls/_ringbuf.pyx to build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/_ringbuf.c
  cythoning src/mbedtls/_md.pyx to build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/_md.c
  cythoning src/mbedtls/cipher/_cipher.pyx to build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/cipher/_cipher.c
  creating build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/cipher
  building 'mbedtls._platform' extension
  creating build/3.9.6/temp.macosx-10.15-x86_64-3.9/build
  creating build/3.9.6/temp.macosx-10.15-x86_64-3.9/build/3.9.6
  creating build/3.9.6/temp.macosx-10.15-x86_64-3.9/build/3.9.6/temp.macosx-10.15-x86_64-3.9
  creating build/3.9.6/temp.macosx-10.15-x86_64-3.9/build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex
  creating build/3.9.6/temp.macosx-10.15-x86_64-3.9/build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/_platform.c -o build/3.9.6/temp.macosx-10.15-x86_64-3.9/build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/_platform.o
  clang -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/usr/local/Cellar/mbedtls/3.0.0/include -L/usr/local/Cellar/mbedtls/3.0.0/lib build/3.9.6/temp.macosx-10.15-x86_64-3.9/build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/_platform.o -L -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/sqlite/lib -lmbedcrypto -lmbedtls -lmbedx509 -o build/3.9.6/lib.macosx-10.15-x86_64-3.9/mbedtls/_platform.cpython-39-darwin.so
  ld: warning: directory not found for option '-L-L/usr/local/lib'
  building 'mbedtls.mpi' extension
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/mpi.c -o build/3.9.6/temp.macosx-10.15-x86_64-3.9/build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/mpi.o
  build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/mpi.c:4343:36: error: implicit declaration of function 'mbedtls_mpi_is_prime' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    __pyx_t_2 = __Pyx_PyInt_From_int(mbedtls_mpi_is_prime((&__pyx_v_self->_ctx), (&mbedtls_ctr_drbg_random), (&__pyx_v_7mbedtls_3mpi___rng->_ctx))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
                                     ^
  build/3.9.6/temp.macosx-10.15-x86_64-3.9/pyrex/mbedtls/mpi.c:4343:36: note: did you mean 'mbedtls_mpi_gen_prime'?
  /usr/local/include/mbedtls/bignum.h:1002:5: note: 'mbedtls_mpi_gen_prime' declared here
  int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int flags,
      ^
  1 error generated.
  error: command '/usr/bin/clang' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for python-mbedtls
Failed to build python-mbedtls
ERROR: Could not build wheels for python-mbedtls which use PEP 517 and cannot be installed directly

Expected behavior

Passing build or specification of maximum supported mbedtls version in README.md

Environment

macOS 10.15.7 Python 3.9.6 mbedtls 3.0.0 installed via brew

Synss commented 3 years ago

Hi Marián,

Thank you for the report. I plan to support 3.0 in the future but currently, only 2.6 is supported. Pull requests are, however, welcome. Tell me if you plan to work on this, otherwise, I will close this issue.

Regards, Mathias