components/python/keystoneclient/patches/nopycrypto.patch
changeset 5405 66fd59fecd68
parent 3998 5bd484384122
equal deleted inserted replaced
5404:55e409ba4e72 5405:66fd59fecd68
     1 In-house removal of PyCrypto dependency in keystoneclient. This patch
     1 In-house removal of PyCrypto dependency in keystoneclient. This patch
     2 is Solaris-specific and not suitable for upstream.
     2 is Solaris-specific and not suitable for upstream.
     3 
     3 
     4 --- python-keystoneclient-1.0.0/keystoneclient/middleware/memcache_crypt.py.~1~	2014-12-18 09:37:35.000000000 -0800
     4 --- python-keystoneclient-1.3.0/keystoneclient/middleware/memcache_crypt.py.~1~	2015-03-25 14:00:24.000000000 -0600
     5 +++ python-keystoneclient-1.0.0/keystoneclient/middleware/memcache_crypt.py	2015-01-31 23:38:16.649757111 -0800
     5 +++ python-keystoneclient-1.3.0/keystoneclient/middleware/memcache_crypt.py	2015-04-27 17:29:37.082689412 -0600
     6 @@ -17,7 +17,7 @@
     6 @@ -17,7 +17,7 @@
     7  Utilities for memcache encryption and integrity check.
     7  Utilities for memcache encryption and integrity check.
     8  
     8  
     9  Data should be serialized before entering these functions. Encryption
     9  Data should be serialized before entering these functions. Encryption
    10 -has a dependency on the pycrypto. If pycrypto is not available,
    10 -has a dependency on the pycrypto. If pycrypto is not available,
    23 +    from M2Crypto.EVP import Cipher
    23 +    from M2Crypto.EVP import Cipher
    24 +    AES = Cipher
    24 +    AES = Cipher
    25  except ImportError:
    25  except ImportError:
    26      AES = None
    26      AES = None
    27  
    27  
    28 @@ -72,6 +73,13 @@ class CryptoUnavailableError(Exception):
    28 @@ -72,6 +73,12 @@ class CryptoUnavailableError(Exception):
    29      pass
    29      pass
    30  
    30  
    31  
    31  
    32 +class InvalidKeyLength(Exception):
    32 +class InvalidKeyLength(Exception):
    33 +    """raise when AES key length is an invalid value.
    33 +    """raise when AES key length is an invalid value.
    34 +
    34 +
    35 +    """
    35 +    """
    36 +    pass
    36 +    pass
    37 +
    37 +
    38 +
       
    39  def assert_crypto_availability(f):
    38  def assert_crypto_availability(f):
    40      """Ensure Crypto module is available."""
    39      """Ensure Crypto module is available."""
    41  
    40  
    42 @@ -131,31 +139,44 @@ def sign_data(key, data):
    41 @@ -131,31 +138,44 @@ def sign_data(key, data):
    43      return base64.b64encode(mac)
    42      return base64.b64encode(mac)
    44  
    43  
    45  
    44  
    46 +def _key_to_alg(key):
    45 +def _key_to_alg(key):
    47 +    """Return a M2Crypto-compatible AES-CBC algorithm name given a key."""
    46 +    """Return a M2Crypto-compatible AES-CBC algorithm name given a key."""