def _decrypt_data(self, session_data): """Bas64, decipher, then un-serialize the data for the session dict""" if self.encrypt_key: try: nonce = session_data[:8] encrypt_key = crypto.generateCryptoKeys( self.encrypt_key, self.validate_key + nonce, 1) payload = b64decode(session_data[8:]) data = crypto.aesDecrypt(payload, encrypt_key) except: # As much as I hate a bare except, we get some insane errors # here that get tossed when crypto fails, so we raise the # 'right' exception if self.invalidate_corrupt: return None else: raise try: return util.pickle.loads(data) except: if self.invalidate_corrupt: return None else: raise else: data = b64decode(session_data) return util.pickle.loads(data)
def _decrypt_data(self, session_data): """Bas64, decipher, then un-serialize the data for the session dict""" if self.encrypt_key: try: nonce = session_data[:8] encrypt_key = crypto.generateCryptoKeys(self.encrypt_key, self.validate_key + nonce, 1) payload = b64decode(session_data[8:]) data = crypto.aesDecrypt(payload, encrypt_key) except: # As much as I hate a bare except, we get some insane errors # here that get tossed when crypto fails, so we raise the # 'right' exception if self.invalidate_corrupt: return None else: raise try: return util.pickle.loads(data) except: if self.invalidate_corrupt: return None else: raise else: data = b64decode(session_data) return util.pickle.loads(data)
def _decrypt_data(self): """Bas64, decipher, then un-serialize the data for the session dict""" if self.encrypt_key: nonce = self.cookie[self.key].value[:8] encrypt_key = crypto.generateCryptoKeys(self.encrypt_key, self.validate_key + nonce, 1) payload = b64decode(self.cookie[self.key].value[8:]) data = crypto.aesDecrypt(payload, encrypt_key) return pickle.loads(data) else: data = b64decode(self.cookie[self.key].value) return pickle.loads(data)
def _decrypt_data(self, session_data): """Bas64, decipher, then un-serialize the data for the session dict""" if self.encrypt_key: __, nonce_b64len = self.encrypt_nonce_size nonce = session_data[:nonce_b64len] encrypt_key = crypto.generateCryptoKeys(self.encrypt_key, self.validate_key + nonce, 1) payload = b64decode(session_data[nonce_b64len:]) data = crypto.aesDecrypt(payload, encrypt_key) else: data = b64decode(session_data) return self.serializer.loads(data)