Add cryptography >= 39.0.0 support

The cryptography release 39.0.0 added a new parameter to the
backend.load_pem_private_key and backend.load_der_private_key
that's required. This patch uses the serialization method to load keys
because there the new parameter is optional.

https://cryptography.io/en/latest/changelog/#v39-0-0

This patch fixes the tests test_encrypt_decrypt_asymmetric
This commit is contained in:
Daniel Garcia Moreno 2023-01-26 13:07:54 +01:00 committed by arp102
parent 0a3e39143f
commit 652d5cab67
1 changed files with 6 additions and 6 deletions

View File

@ -929,18 +929,18 @@ class CryptographyEngine(api.CryptographicEngine):
"decryption.".format(padding_method) "decryption.".format(padding_method)
) )
backend = default_backend()
try: try:
private_key = backend.load_der_private_key( private_key = serialization.load_der_private_key(
decryption_key, decryption_key,
None password=None,
backend=default_backend()
) )
except Exception: except Exception:
try: try:
private_key = backend.load_pem_private_key( private_key = serialization.load_pem_private_key(
decryption_key, decryption_key,
None password=None,
backend=default_backend()
) )
except Exception: except Exception:
raise exceptions.CryptographicFailure( raise exceptions.CryptographicFailure(