Skip to content

Commit

Permalink
Add cryptography >= 39.0.0 support
Browse files Browse the repository at this point in the history
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
  • Loading branch information
danigm authored and arp102 committed Jan 30, 2023
1 parent 0a3e391 commit 652d5ca
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions kmip/services/server/crypto/engine.py
Expand Up @@ -929,18 +929,18 @@ def _decrypt_asymmetric(
"decryption.".format(padding_method)
)

backend = default_backend()

try:
private_key = backend.load_der_private_key(
private_key = serialization.load_der_private_key(
decryption_key,
None
password=None,
backend=default_backend()
)
except Exception:
try:
private_key = backend.load_pem_private_key(
private_key = serialization.load_pem_private_key(
decryption_key,
None
password=None,
backend=default_backend()
)
except Exception:
raise exceptions.CryptographicFailure(
Expand Down

0 comments on commit 652d5ca

Please sign in to comment.