keystoneclient.middleware package¶
Submodules¶
keystoneclient.middleware.auth_token module¶
keystoneclient.middleware.memcache_crypt module¶
Utilities for memcache encryption and integrity check.
Data should be serialized before entering these functions. Encryption has a dependency on the pycrypto. If pycrypto is not available, CryptoUnavailableError will be raised.
This module will not be called unless signing or encryption is enabled in the config. It will always validate signatures, and will decrypt data if encryption is enabled. It is not valid to mix protection modes.
Bases: exceptions.Exception
raise when Python Crypto module is not available.
- exception keystoneclient.middleware.memcache_crypt.DecryptError¶
Bases: exceptions.Exception
raise when unable to decrypt encrypted data.
- exception keystoneclient.middleware.memcache_crypt.InvalidMacError¶
Bases: exceptions.Exception
raise when unable to verify MACed data.
This usually indicates that data had been expectedly modified in memcache.
- keystoneclient.middleware.memcache_crypt.assert_crypto_availability(f)¶
Ensure Crypto module is available.
- keystoneclient.middleware.memcache_crypt.constant_time_compare(first, second)¶
Returns True if both string inputs are equal, otherwise False.
This function should take a constant amount of time regardless of how many characters in the strings match.
- keystoneclient.middleware.memcache_crypt.decrypt_data(*args, **kwds)¶
Decrypt the data with the given secret key.
- keystoneclient.middleware.memcache_crypt.derive_keys(token, secret, strategy)¶
Derives keys for MAC and ENCRYPTION from the user-provided secret. The resulting keys should be passed to the protect and unprotect functions.
As suggested by NIST Special Publication 800-108, this uses the first 128 bits from the sha384 KDF for the obscured cache key value, the second 128 bits for the message authentication key and the remaining 128 bits for the encryption key.
This approach is faster than computing a separate hmac as the KDF for each desired key.
- keystoneclient.middleware.memcache_crypt.encrypt_data(*args, **kwds)¶
Encrypt the data with the given secret key.
Padding is n bytes of the value n, where 1 <= n <= blocksize.
- keystoneclient.middleware.memcache_crypt.get_cache_key(keys)¶
Given keys generated by derive_keys(), returns a base64 encoded value suitable for use as a cache key in memcached.
- keystoneclient.middleware.memcache_crypt.protect_data(keys, data)¶
Given keys and serialized data, returns an appropriately protected string suitable for storage in the cache.
- keystoneclient.middleware.memcache_crypt.sign_data(key, data)¶
Sign the data using the defined function and the derived key.
- keystoneclient.middleware.memcache_crypt.unprotect_data(keys, signed_data)¶
Given keys and cached string data, verifies the signature, decrypts if necessary, and returns the original serialized data.