Synss / python-mbedtls

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

pk.get_supported_curves raise `ValueError: b'x25519' is not a valid Curve` #45

Closed marianhlavac closed 2 years ago

marianhlavac commented 3 years ago

Bug report

Description

Calling pk.get_supported_curves() raises following error

Traceback (most recent call last):
  File "minimal-example.py", line 3, in <module>
    print(pk.get_supported_curves())
  File "src/mbedtls/pk.pyx", line 116, in mbedtls.pk.get_supported_curves
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/enum.py", line 384, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/enum.py", line 702, in __new__
    raise ve_exc
ValueError: b'x25519' is not a valid Curve

Environment

macOS 10.15.7 Python 3.9.6 mbedtls 2.27.0 installed via brew

Minimal demo of the problem

from mbedtls import pk

print(pk.get_supported_curves())
marianhlavac commented 3 years ago

This bug prevents any use of pk.ECC.* functions, as they often call get_supported_curves internally.

marianhlavac commented 3 years ago

Tried downgrading mbedtls to 2.26.0, didn't help.

Synss commented 3 years ago

Hi Marián,

Could you try again with 2.16? It would be too much work for me to support anything but LTS versions from upstream and the library is not tested with anything else.

I do not use brew but if you need help to install the library from source, feel free to use

These scripts should work on MacOS.

Cheers, Mathias

marianhlavac commented 3 years ago

I can confirm that downgrading to 2.16.9 works. Thanks for your help.

Can you update README file and specify, that the 2.16 is the latest supported version? It would be a solution for #46 , at least for now. Homebrew on macOS consider 3.0.0 as the latest, other users might have the same problem.