]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
uses os.urandom instead of Crypto.Random for backward compatibility
authorGiulio Fidente <gfidente@redhat.com>
Thu, 11 Apr 2013 15:31:53 +0000 (17:31 +0200)
committerGiulio Fidente <gfidente@redhat.com>
Thu, 11 Apr 2013 15:31:53 +0000 (17:31 +0200)
Crypto.Random has been introduced by pycrypto 2.1 but in RHEL6 and
derivates you will only find pycrypto 2.0.1

Change-Id: Ib601981b0b8fcb5b3e8fc8761ee05adf7f6574fa

heat/common/crypt.py

index 28c11f5343aaf78312829950debb180476ade2a7..81b4c92bcdb1048281f510ea5f16950732437d81 100644 (file)
@@ -15,7 +15,7 @@
 
 import base64
 from Crypto.Cipher import AES
-from Crypto import Random
+from os import urandom
 
 from oslo.config import cfg
 
@@ -36,7 +36,7 @@ logger = logging.getLogger(__name__)
 def encrypt(auth_info):
     if auth_info is None:
         return None
-    iv = Random.new().read(AES.block_size)
+    iv = urandom(AES.block_size)
     cipher = AES.new(cfg.CONF.auth_encryption_key[:32], AES.MODE_CFB, iv)
     res = base64.b64encode(iv + cipher.encrypt(auth_info))
     return res