"TypeError: Expected instance of hashes.HashAlgorithm." when using cryptography>=41.0.0
hoelsner opened this issue · 1 comments
hoelsner commented
Hello,
I updated to cryptograpy 41.0.0
which breaks django-cryptography
for me with the following exception (together with django 4.1.9 and python3.11):
File "/home/vscode/.local/lib/python3.11/site-packages/django_cryptography/fields.py", line 9, in <module>
from django_cryptography.core.signing import SignatureExpired
File "/home/vscode/.local/lib/python3.11/site-packages/django_cryptography/core/signing.py", line 23, in <module>
from ..utils.crypto import constant_time_compare, salted_hmac
File "/home/vscode/.local/lib/python3.11/site-packages/django_cryptography/utils/crypto.py", line 12, in <module>
from ..conf import CryptographyConf
File "/home/vscode/.local/lib/python3.11/site-packages/django_cryptography/conf.py", line 9, in <module>
class CryptographyConf(AppConf):
File "/home/vscode/.local/lib/python3.11/site-packages/appconf/base.py", line 73, in __new__
new_class._configure()
File "/home/vscode/.local/lib/python3.11/site-packages/appconf/base.py", line 104, in _configure
cls._meta.configured_data = obj.configure()
^^^^^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/django_cryptography/conf.py", line 34, in configure
self.configured_data['KEY'] = kdf.derive(
^^^^^^^^^^^
File "/home/vscode/.local/lib/python3.11/site-packages/cryptography/hazmat/primitives/kdf/pbkdf2.py", line 53, in derive
return rust_openssl.kdf.derive_pbkdf2_hmac(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Expected instance of hashes.HashAlgorithm.
My Django project uses the following settings:
CRYPTOGRAPHY_BACKEND = cryptography.hazmat.backends.default_backend()
CRYPTOGRAPHY_DIGEST = cryptography.hazmat.primitives.hashes.SHA256
I have tried multiple hash algorithms and different combinations, but I always get this issue. Do you have any ideas on how to fix it? If I downgrade to 40.0.2, it's works again.
Thank you in advance.
Nasjoe commented
Same here