in fxa/crypto.py [0:0]
def bundle(key, namespace, payload):
"""Encrypt a response bundle using the given key."""
# Derive enough key material for HMAC-check and encryption.
size = 32 + len(payload)
key_material = derive_key(key, namespace, size)
# XOR-encrypt the payload using the derived key.
xor_key = key_material[32:]
ciphertext = xor(xor_key, payload)
# Append an HMAC using the derived key.
hmac_key = key_material[:32]
return ciphertext + calculate_hmac(hmac_key, ciphertext)