01-nopycrypto.patch revision 5403
5403N/A--- glance-2015.1.2/glance/common/crypt.py.~1~ 2015-10-13 09:38:23.000000000 -0700
5403N/A+++ glance-2015.1.2/glance/common/crypt.py 2016-01-24 16:48:24.788282369 -0800
5403N/A@@ -20,14 +20,30 @@ Routines for URL-safe encrypting/decrypt
2521N/A-from Crypto.Cipher import AES
2521N/A-from Crypto.Random import random
5403N/A+from glance.common import exception
5403N/A+from M2Crypto.EVP import Cipher
2521N/A+ raise exception.Invalid(msg)
2521N/A- sr = random.StrongRandom()
2521N/A- pad = ''.join(chr(sr.randint(1, 0xFF)) for i in range(pad_length - 1))
2521N/A- init_vector = Random.get_random_bytes(16)
2521N/A- padded = cypher.encrypt(pad(str(plaintext)))
2521N/A+ init_vector = os.urandom(16)
2521N/A+ padded = cipher.update(str(plaintext))
2521N/A+ padded = padded + cipher.final()
2521N/A return base64.urlsafe_b64encode(init_vector + padded)
2521N/A ciphertext = base64.urlsafe_b64decode(str(ciphertext))
2521N/A- padded = cypher.decrypt(ciphertext[16:])
2521N/A- return padded[:padded.rfind(chr(0))]
2521N/A+ padded = cipher.update(ciphertext[16:])
2521N/A+ padded = padded + cipher.final()