in fxa/crypto.py [0:0]
def unbundle(key, namespace, payload):
"""Decrypt a response bundle using the given key."""
# Split off the last 32 bytes, they're the HMAC.
ciphertext = payload[:-32]
expected_hmac = payload[-32:]
# Derive enough key material for HMAC-check and decryption.
size = 32 + len(ciphertext)
key_material = derive_key(key, namespace, size)
# Check the HMAC using the derived key.
hmac_key = key_material[:32]
verify_hmac(hmac_key, ciphertext, expected_hmac)
# XOR-decrypt the ciphertext using the derived key.
xor_key = key_material[32:]
return xor(xor_key, ciphertext)