Section 19.1.9

Associated data in authenticated encryption

Definition

Associated data is the input of authenticated encryption §5.16 that is protected against change but not hidden. In AEAD (authenticated encryption with associated data), encryption takes a key, a nonce §5.18 (a value never reused with that key), the plaintext and the associated data; it encrypts the plaintext and attaches a tag computed from all of these inputs. Decryption needs the same associated data and fails if one bit of it differs. The plaintext is hidden and protected; the associated data is only protected. It is also called additional authenticated data (AAD).

Where it fits

Main entry: Authenticated encryption (AEAD) (§5.16).

The AEAD entry gives the full interface and its guarantees. Associated data serves two kinds of bytes. Some must stay readable, such as a header that the receiver reads to decide where a message goes or which key opens it. Others are never sent, because sender and receiver both know them already, such as the receiver’s identity or the protocol version; putting them into the associated data binds the message to them at no cost in message size.

The operation type says what the receiver should do with the plaintext; the key role says what a key is for, such as encrypting telemetry or checking firmware. Take a message with a 1-byte header, 0x01 for a temperature report or 0x02 for a replacement key, followed by 16 encrypted bytes and a tag. If the header is outside the AEAD inputs, an attacker changes 0x01 to 0x02. Decryption still succeeds, because nothing it checks has changed, and the receiver installs the 16 decrypted bytes of a temperature report as its new key. Those bytes hold a reading and a time, which the attacker may well guess. With the header in the associated data, the changed header makes decryption fail. In the same way, an unbound key role lets a key delivered for encrypting telemetry be installed as the key that checks firmware, so whoever learns the telemetry key can approve firmware.

The receiver should supply the associated data it expects, not copy it from the message. A receiver that waits for a replacement key but copies the header into the associated data accepts a genuine temperature report, header 0x01 included, and may treat it as the key it was waiting for. When the associated data holds several fields, encode them so that two different field lists never give the same bytes, for example with fixed widths or a length before each variable field (prefix-free encoding §15.38). The nonce needs no place in the associated data, because AEAD authenticates it already.

Limits and common mistakes

Associated data is not encrypted, so nothing secret belongs in it. A field that is in neither the plaintext nor the associated data is not protected at all.

Binding is not freshness. A recorded message replayed with its own associated data decrypts correctly again; a counter in the associated data helps only if the receiver checks that the counter is new (replay attack §1.26). Binding is not authorization §1.7 either: a correctly bound request still needs a decision that the sender may make it.

Questions answered

Why include operation type and key role?

Include the operation type and the key role in the associated data because they decide what the receiver does with the decrypted bytes, and every input that decides the receiver’s action must be protected against change. In AEAD (authenticated encryption with associated data), the associated data is the input that is authenticated but not encrypted, and decryption fails if it differs by one bit from what the sender used.

Without the operation type, an attacker can relabel a message, for example turn a temperature report into a key replacement, and decryption still succeeds because ciphertext and tag are unchanged. Without the key role, a key delivered for one purpose can be installed for another, which breaks key separation §5.23, the rule that each key serves exactly one purpose. With both in the associated data, the receiver supplies the operation and role it expects, and a ciphertext made for any other operation or role fails to decrypt. The associated data does not hide these values, and it neither stops replay nor decides authorization.

Related entries: Authentication coverage (§5.41), Domain separation (§5.22), Serialization (§4.28), Key separation (§5.23). Further reading: [67].