Browse Source

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
tags/14.0.0.0b1
Sean Dague 3 years ago
parent
commit
6b1293fd6f
3 changed files with 2 additions and 34 deletions
  1. 1
    32
      nova/crypto.py
  2. 1
    1
      nova/tests/unit/test_crypto.py
  3. 0
    1
      requirements.txt

+ 1
- 32
nova/crypto.py View File

@@ -128,39 +128,8 @@ def generate_x509_fingerprint(pem_key):
128 128
                      'Error message: %s') % ex)
129 129
 
130 130
 
131
-def generate_key(bits):
132
-    """Generate a paramiko RSAKey"""
133
-    # NOTE(dims): pycryptodome has changed the signature of the RSA.generate
134
-    # call. specifically progress_func has been dropped. paramiko still uses
135
-    # pycrypto. However some projects like latest pysaml2 have switched from
136
-    # pycrypto to pycryptodome as pycrypto seems to have been abandoned.
137
-    # paramiko project has started transition to pycryptodome as well but
138
-    # there is no release yet with that support. So at the moment depending on
139
-    # which version of pysaml2 is installed, Nova is likely to break. So we
140
-    # call "RSA.generate(bits)" which works on both pycrypto and pycryptodome
141
-    # and then wrap it into a paramiko.RSAKey
142
-    #
143
-    # NOTE(coreywright): Paramiko 2 avoids this conundrum by migrating from
144
-    # PyCrypto/PyCryptodome to cryptography.
145
-    #
146
-    # TODO(coreywright): When Paramiko constraint is upgraded to 2.x, then
147
-    # remove this abstraction and replace the call to this function with a call
148
-    # to `paramiko.RSAKey.generate(bits)`.
149
-
150
-    if paramiko.__version_info__[0] == 2:
151
-        key = paramiko.RSAKey.generate(bits)
152
-    else:  # paramiko 1.x
153
-        from Crypto.PublicKey import RSA
154
-        rsa = RSA.generate(bits)
155
-        key = paramiko.RSAKey(vals=(rsa.e, rsa.n))
156
-        key.d = rsa.d
157
-        key.p = rsa.p
158
-        key.q = rsa.q
159
-    return key
160
-
161
-
162 131
 def generate_key_pair(bits=2048):
163
-    key = generate_key(bits)
132
+    key = paramiko.RSAKey.generate(bits)
164 133
     keyout = six.StringIO()
165 134
     key.write_private_key(keyout)
166 135
     private_key = keyout.getvalue()

+ 1
- 1
nova/tests/unit/test_crypto.py View File

@@ -362,7 +362,7 @@ class KeyPairTest(test.NoDBTestCase):
362 362
         keyin.seek(0)
363 363
         key = paramiko.RSAKey.from_private_key(keyin)
364 364
 
365
-        with mock.patch.object(crypto, 'generate_key') as mock_generate:
365
+        with mock.patch.object(paramiko.RSAKey, 'generate') as mock_generate:
366 366
             mock_generate.return_value = key
367 367
             (private_key, public_key, fingerprint) = crypto.generate_key_pair()
368 368
             self.assertEqual(self.rsa_pub, public_key)

+ 0
- 1
requirements.txt View File

@@ -13,7 +13,6 @@ lxml>=2.3 # BSD
13 13
 Routes!=2.0,!=2.1,!=2.3.0,>=1.12.3;python_version=='2.7' # MIT
14 14
 Routes!=2.0,!=2.3.0,>=1.12.3;python_version!='2.7' # MIT
15 15
 cryptography!=1.3.0,>=1.0 # BSD/Apache-2.0
16
-pycrypto>=2.6  # Public Domain
17 16
 WebOb>=1.2.3 # MIT
18 17
 greenlet>=0.3.2 # MIT
19 18
 PasteDeploy>=1.5.0 # MIT

Loading…
Cancel
Save