Section 19.1.6

Authenticated key exchange and transcript binding

Definition

Authenticated key exchange (AKE) is a protocol in which two parties agree on a secret key and each obtains proof of who the other is, so that the key is shared with the intended party and nobody else. The transcript is the exact sequence of messages exchanged, including both identities. Transcript binding means that the proofs of identity and the derived keys are computed from the whole transcript, so that two parties whose views of the exchange differ in any byte do not both accept the same key.

The idea

Diffie–Hellman key agreement §19.1.4, in which two parties each send a public value and compute a shared secret, gives each party a secret shared with somebody. It does not say with whom. A key is useful only together with its label: this key is for talking to Bob. An exchange can go wrong in two ways. An attacker in the middle can end up knowing the keys. Or the keys can stay secret while a label is wrong, so that one party attributes everything it receives to the wrong sender. Authenticated key exchange has to rule out both.

The intuition for transcript binding is a signed contract. Two people who each sign only the last page can be given different first pages. If each signs a fingerprint of the entire text, any difference between the two copies makes the signatures fail to match. In a key exchange the text is the transcript, the fingerprint is a cryptographic hash §5.1 (a short fixed-length value computed from the text, such that finding two texts with the same value is infeasible), and the keys themselves are computed from that fingerprint as well. The comparison stops being accurate in one respect: people check a contract afterwards, while a protocol must detect a mismatch itself, before any key is used.

How it works

Protocols differ in detail. A common pattern, which version 1.3 of Transport Layer Security (TLS), the Internet protocol that protects connections between clients and servers, follows when both sides authenticate with certificates, has five parts.

  1. Exchange. Each party sends a fresh Diffie–Hellman public value and its identity. The identity can come as a certificate: a statement, signed by an authority that both parties trust, that a public key belongs to a named party.

  2. Record. Each party keeps the exact bytes of every message sent and received, in order, and computes a cryptographic hash of them, called the transcript hash.

  3. Authenticate. Each party signs the transcript hash with its long-term private key. The other party verifies the digital signature §5.14 against its own transcript hash, using the public key in the certificate.

  4. Confirm. Each party sends a message authentication code §5.7 (MAC), a short keyed check value, computed over the transcript hash with a key derived from the Diffie–Hellman shared secret. A correct MAC shows that the signer also holds the fresh secret.

  5. Derive. The session keys, the keys that protect the messages of this one connection, come from a key derivation function §5.20 (KDF), an algorithm §14.1 that turns a secret value into keys, whose inputs are the shared secret and the transcript hash.

The signature ties an identity to this run of the protocol. The MAC ties that identity to the key. The derivation ties the key to everything both sides saw. Where the two parties already share a key in advance, a MAC under that key can take the place of the signatures. TLS calls the party that starts the exchange the client and the other party the server. TLS 1.3 also has a one-way form in which only the server proves its identity: the client then knows with whom it shares the keys, and the server does not know who the client is.

Worked example

The numbers are far too small to be secure. Two parties, Alice and Bob, run Diffie–Hellman key agreement with whole numbers modulo 23, that is, reduced to their remainders after division by 23, and with the public element 2. Alice sends the public value 8, Bob sends 13, and both compute the shared secret 12. In this first protocol each party signs only the two public values, and the session key is derived from the shared secret alone.

Eve is a legitimate user with a certificate of Eve’s own. She lets the two public values pass unchanged.

  1. Bob sends Bob’s certificate and a signature over the values 13 and 8. Alice verifies the signature and records: key for Bob.

  2. Alice sends Alice’s certificate and a signature over the values 8 and 13. Eve removes both and puts in their place Eve’s own certificate and Eve’s own signature over 8 and 13. She can sign them because they are public.

  3. Bob verifies Eve’s signature, which is valid, and records: key for Eve.

Alice and Bob hold the same key. In a group of real size Eve cannot learn it, and the attack does not need it. Suppose that Bob is a bank. When Alice sends an encrypted instruction to pay in 100 units, Bob credits them to Eve.

Now bind the transcript. Each party writes down who it believes the two parties are and what was sent, and hashes that text with SHA-256 §5.2 (Secure Hash Algorithm with a 256-bit output). Alice’s transcript is the 38 bytes

initiator=alice;responder=bob;A=8;B=13

and its hash is

1a5c885ac96a9f7b00c401bdbaeb333361684a8e09626b3fefed4502052b8770

After Eve’s substitution, Bob’s transcript is the 36 bytes

initiator=eve;responder=bob;A=8;B=13

and its hash is

572a3f10fbc488f175d966df05ae277f41ee90120e20e944ac071e37d4f1f975

Each party derives a 16-byte session key with HKDF §5.21 (HMAC-based Extract-and-Expand Key Derivation Function, where HMAC is the hash-based message authentication code) using SHA-256. HKDF takes a secret input, an optional random value called the salt §5.19 and a label called info. Here the secret input is the shared secret, the single byte 0x0c, no salt is used, and the info label is the transcript hash. Alice obtains b6fe53d1ad6e999456b47f52dfba738d. Bob obtains 6fd6886b1a130a3fbc499cb2c11c499f. The keys differ, so Bob cannot decrypt Alice’s instruction, and nothing is credited to anyone. With an empty info label both would have obtained the same key, ee2314da08b0bacefba86de43669579f. In a full protocol the mismatch shows even earlier, because the MAC that Alice sends over Alice’s transcript hash does not verify against Bob’s.

Stated precisely

RFC 8446, which defines TLS 1.3 [325], lists the properties that its opening exchange, called the handshake, should provide as an authenticated key exchange against an attacker who has complete control of the network. At the end, each party outputs its view of three things: the session keys, the cryptographic parameters and the identities of the two parties. The main requirements are these.

An unknown-key-share attack breaks peer authentication and leaves secrecy intact.

These properties depend on all of the following conditions. Each long-term private key is known to its owner alone. Each party can check that a public key really belongs to the named peer, through a certificate or because the key was installed in advance. Signatures and MACs cannot be forged without the key. The hash function has collision resistance §5.5, meaning that nobody can find two different inputs with the same hash. The Diffie–Hellman problem §19.1.3 is hard in the group in use. And the transcript is encoded so that two different sequences of messages never give the same bytes.

Limits and common mistakes

A transcript hash alone authenticates nothing. Anyone who sees the messages can compute it. It becomes evidence only when a signature or a MAC is computed over it with a key that the attacker does not have.

Binding covers only what is in the transcript. An identity, an option or a message that is left out, or that is encoded ambiguously, can differ between the two parties without being noticed.

The identity that is bound must be the identity the application acts on. If the exchange binds a public key but the application credits an account named in some other, unprotected field, the attack remains.

A key that is authenticated and confirmed shows who holds it. It does not show that the holder is allowed to request a particular operation, which is a matter of authorization §1.7, or that an operation was carried out.

Authentication rests on the long-term private keys. Whoever steals one can impersonate its owner in later exchanges.

Questions answered

What is an unknown-key-share attack?

An unknown-key-share attack makes two honest parties share a key while one of them is wrong about whom it shares the key with. In the definition by Simon Blake-Wilson and Alfred Menezes [523], one party, Alice, believes that it shares a key with a second party, Bob, which is true, while Bob believes that it shares that key with a third party, Eve. Eve does not learn the key and cannot read the traffic. The damage is misattribution: Bob treats what Alice sends as coming from Eve, so a payment or a command sent by Alice is attributed to Eve.

The attack is possible when the identities are not bound to the key. In the simplest case each party signs only the public values of a key exchange, and Eve, a legitimate user, replaces Alice’s signature with Eve’s own signature over the same public values. The attack differs from a man-in-the-middle attack §7.26, in which the attacker shares one key with each party and reads everything.

Three measures are used against it, and one protocol can combine them. Each party signs the identity of the intended receiver along with its own identity and the public values. Both identities are fed into the key derivation, so that parties who disagree about an identity derive different keys; NIST Special Publication 800-56A recommends this. And each party sends a message authentication code (MAC), a short keyed check value, over the whole transcript of the exchange, both identities included. The MAC is keyed from the shared secret, so Eve cannot compute it.

Related entries: Authentication coverage (§5.41), Key confirmation versus application confirmation (§5.42), Domain separation (§5.22), Authorization (§1.7), Diffie–Hellman key agreement (§19.1.4), Authentication (§1.6), Digital signature (§5.14), Key compromise impersonation (§5.35). Further reading: [9, 152, 325, 523].