summaryrefslogtreecommitdiffhomepage
path: root/paramiko/kex_curve25519.py
diff options
context:
space:
mode:
Diffstat (limited to 'paramiko/kex_curve25519.py')
-rw-r--r--paramiko/kex_curve25519.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/paramiko/kex_curve25519.py b/paramiko/kex_curve25519.py
index 60fb2c7a..b092afae 100644
--- a/paramiko/kex_curve25519.py
+++ b/paramiko/kex_curve25519.py
@@ -1,6 +1,7 @@
import binascii
import hashlib
+from cryptography.exceptions import UnsupportedAlgorithm
from cryptography.hazmat.primitives import constant_time, serialization
from cryptography.hazmat.primitives.asymmetric.x25519 import (
X25519PrivateKey, X25519PublicKey
@@ -19,6 +20,14 @@ class KexCurve25519(object):
self.transport = transport
self.key = None
+ def is_available(self):
+ try:
+ X25519PrivateKey.generate()
+ except UnsupportedAlgorithm:
+ return False
+ else:
+ return True
+
def _perform_exchange(self, peer_key):
secret = self.key.exchange(peer_key)
if constant_time.bytes_eq(secret, b"\x00" * 32):