diff options
-rw-r--r-- | paramiko/pkey.py | 16 | ||||
-rw-r--r-- | paramiko/transport.py | 16 |
2 files changed, 30 insertions, 2 deletions
diff --git a/paramiko/pkey.py b/paramiko/pkey.py index ef371002..f0b2d6d4 100644 --- a/paramiko/pkey.py +++ b/paramiko/pkey.py @@ -43,6 +43,20 @@ from paramiko.ssh_exception import SSHException, PasswordRequiredException from paramiko.message import Message +# TripleDES is moving from `cryptography.hazmat.primitives.ciphers.algorithms` +# in cryptography>=43.0.0 to `cryptography.hazmat.decrepit.ciphers.algorithms` +# It will be removed from `cryptography.hazmat.primitives.ciphers.algorithms` +# in cryptography==48.0.0. +# +# Source References: +# - https://github.com/pyca/cryptography/commit/722a6393e61b3ac +# - https://github.com/pyca/cryptography/pull/11407/files +try: + from cryptography.hazmat.decrepit.ciphers.algorithms import TripleDES +except ImportError: + from cryptography.hazmat.primitives.ciphers.algorithms import TripleDES + + OPENSSH_AUTH_MAGIC = b"openssh-key-v1\x00" @@ -97,7 +111,7 @@ class PKey: "mode": modes.CBC, }, "DES-EDE3-CBC": { - "cipher": algorithms.TripleDES, + "cipher": TripleDES, "keysize": 24, "blocksize": 8, "mode": modes.CBC, diff --git a/paramiko/transport.py b/paramiko/transport.py index 14a26333..bd938635 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -120,6 +120,20 @@ from paramiko.util import ( ) +# TripleDES is moving from `cryptography.hazmat.primitives.ciphers.algorithms` +# in cryptography>=43.0.0 to `cryptography.hazmat.decrepit.ciphers.algorithms` +# It will be removed from `cryptography.hazmat.primitives.ciphers.algorithms` +# in cryptography==48.0.0. +# +# Source References: +# - https://github.com/pyca/cryptography/commit/722a6393e61b3ac +# - https://github.com/pyca/cryptography/pull/11407/files +try: + from cryptography.hazmat.decrepit.ciphers.algorithms import TripleDES +except ImportError: + from cryptography.hazmat.primitives.ciphers.algorithms import TripleDES + + # for thread cleanup _active_threads = [] @@ -255,7 +269,7 @@ class Transport(threading.Thread, ClosingContextManager): "key-size": 32, }, "3des-cbc": { - "class": algorithms.TripleDES, + "class": TripleDES, "mode": modes.CBC, "block-size": 8, "key-size": 24, |