summaryrefslogtreecommitdiff
path: root/nova/crypto.py
diff options
context:
space:
mode:
authorSean Dague <sean@dague.net>2016-05-10 11:39:11 -0400
committerCorey Wright <corey.wright@rackspace.com>2016-05-10 12:01:22 -0500
commit6b1293fd6f5bcb35f317f36c540f543b1192928c (patch)
tree71ba6348eeafdba6e838e01dbe289d4704a5fe58 /nova/crypto.py
parentc05b338f163e0bafbe564c6c7c593b819f2f2eac (diff)
downloadnova-6b1293fd6f5bcb35f317f36c540f543b1192928c.tar.gz
Drop paramiko < 2 compat code
This drops the paramiko < 2 compatibility code so we only need to support one major version. Depends-On: I2369638282b4fefccd8484a5039fcfa9795069a7 (global requirements change) Change-Id: Ife4df9e64299e1182d77d568d1deed5ec3b608b3 Closes-Bug: #1483132
Diffstat (limited to 'nova/crypto.py')
-rw-r--r--nova/crypto.py33
1 files changed, 1 insertions, 32 deletions
diff --git a/nova/crypto.py b/nova/crypto.py
index 4db8ce02cb..f0b4e4ebb9 100644
--- a/nova/crypto.py
+++ b/nova/crypto.py
@@ -128,39 +128,8 @@ def generate_x509_fingerprint(pem_key):
'Error message: %s') % ex)
-def generate_key(bits):
- """Generate a paramiko RSAKey"""
- # NOTE(dims): pycryptodome has changed the signature of the RSA.generate
- # call. specifically progress_func has been dropped. paramiko still uses
- # pycrypto. However some projects like latest pysaml2 have switched from
- # pycrypto to pycryptodome as pycrypto seems to have been abandoned.
- # paramiko project has started transition to pycryptodome as well but
- # there is no release yet with that support. So at the moment depending on
- # which version of pysaml2 is installed, Nova is likely to break. So we
- # call "RSA.generate(bits)" which works on both pycrypto and pycryptodome
- # and then wrap it into a paramiko.RSAKey
- #
- # NOTE(coreywright): Paramiko 2 avoids this conundrum by migrating from
- # PyCrypto/PyCryptodome to cryptography.
- #
- # TODO(coreywright): When Paramiko constraint is upgraded to 2.x, then
- # remove this abstraction and replace the call to this function with a call
- # to `paramiko.RSAKey.generate(bits)`.
-
- if paramiko.__version_info__[0] == 2:
- key = paramiko.RSAKey.generate(bits)
- else: # paramiko 1.x
- from Crypto.PublicKey import RSA
- rsa = RSA.generate(bits)
- key = paramiko.RSAKey(vals=(rsa.e, rsa.n))
- key.d = rsa.d
- key.p = rsa.p
- key.q = rsa.q
- return key
-
-
def generate_key_pair(bits=2048):
- key = generate_key(bits)
+ key = paramiko.RSAKey.generate(bits)
keyout = six.StringIO()
key.write_private_key(keyout)
private_key = keyout.getvalue()