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