pub fn encode_with_context(
master_key_bytes: &[u8],
key_id: &str,
plaintext: &[u8],
extra_aad: &[u8],
) -> Vec<u8> ⓘExpand description
Variant of encode that mixes additional bytes into the AEAD AAD.
Used by Encrypt / GenerateDataKey / ReEncrypt to bind the
caller’s EncryptionContext into the ciphertext: a different EC
supplied at decrypt time fails AES-GCM verification, matching real
KMS behavior. When extra_aad is empty the AAD is just key_id,
so blobs produced by callers that don’t pass EC stay byte-compatible
with the original encode output and pre-existing persisted blobs.