Section 19.1.11

Synthetic initialization vector (SIV) and misuse resistance

Full name: Synthetic initialization vector (SIV); built on the block cipher of the Advanced Encryption Standard (AES), it is called AES-SIV.

Definition

SIV (synthetic initialization vector) is a form of authenticated encryption §5.16, which hides a message and detects any change, whose initialization vector (the per-message starting value of encryption) is computed from the message. A keyed pseudorandom function §15.1 maps the associated data (authenticated but unencrypted inputs) and the plaintext to a 16-byte value that serves as both tag and starting counter. Misuse resistance follows: if a nonce §5.18 (a value meant for one use per key) repeats, authenticity survives and only exact repeats of a whole input show. RFC 5297 defines it.

The idea

Ordinary authenticated encryption takes a nonce, a value that must never repeat under one key, and usually encrypts with counter mode §15.5: it combines the message by bitwise XOR (exclusive or) with a keystream, a pseudorandom byte sequence fixed by the key and the nonce. Real systems do repeat nonces: a device loses its message counter in a power cut, or a virtual machine §2.3 restored from a snapshot reuses its last nonces. A repeated nonce repeats the keystream, the XOR of the two ciphertexts then equals the XOR of the two plaintexts, and knowing one plaintext reveals the other. In some modes the repetition also lets an attacker forge tags.

SIV lets each message choose its own starting value. It first computes the tag as a pseudorandom function (a keyed function whose outputs look random to anyone without the key) of everything being protected, the nonce included, and then uses the tag as the initial counter of counter mode. Inputs that differ anywhere get unrelated tags and so unrelated keystreams, whether or not the nonce repeated. Only an input identical in every part gives the same ciphertext, and that ciphertext tells an observer only that the input was repeated. The price is a second pass: the whole plaintext must be read before encryption can begin.

How it works

AES-SIV, as RFC 5297 defines it, has these inputs and this output:

Encryption:

  1. Tag. Compute VV with the function that RFC 5297 calls S2V, keyed with K1K_1. S2V applies CMAC §15.7 (cipher-based message authentication code), a message authentication code §5.7 built from AES, to a 16-byte block of zeros and to each AiA_i separately. It folds these results together by XOR, doubling the running value before each fold. Doubling is a one-bit left shift followed, when the bit shifted out is 1, by an XOR with a fixed constant; it makes the order of the strings matter. Then S2V combines the running value with the plaintext and applies one final CMAC. A plaintext of 16 bytes or more has the running value combined by XOR into its last 16 bytes; a shorter plaintext is padded to 16 bytes and combined by XOR with the running value doubled once more.

  2. Counter. Copy VV to QQ and clear bit 63 and bit 31, counting the rightmost bit as bit 0, so that an implementation may increment the counter with ordinary 32-bit or 64-bit addition.

  3. Encrypt. Encrypt QQ, Q+1Q + 1, Q+2Q + 2 and so on with AES under K2K_2, and combine the resulting keystream with PP by XOR to get CC.

  4. Output V‖CV \mathbin{\Vert} C.

Decryption takes the first 16 bytes as VV, forms QQ and the keystream as above, and recovers a candidate plaintext from CC. It recomputes S2V over the associated data the receiver holds and the candidate. If the result equals VV, checked with a constant-time comparison §4.33, it returns the plaintext; otherwise it returns FAIL\mathrm{FAIL} and releases nothing of the candidate.

With a nonce among the associated data, AES-SIV is nonce-based authenticated encryption. Without one, it is deterministic authenticated encryption §19.1.10, which RFC 5297 offers for key wrapping §19.1.12. A later design, AES-GCM-SIV (GCM stands for Galois/Counter Mode), defined in RFC 8452 [436], applies the same idea with a fast polynomial hash in place of CMAC.

Worked example

This is the deterministic example of RFC 5297, Appendix A.1, in hexadecimal, with one associated-data string and no nonce:

K1K_1 = fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0
K2K_2 = f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
A1A_1 = the 24 bytes 10, 11, and so on up to 27
PP = 112233445566778899aabbccddee, 14 bytes

S2V under K1K_1:

  1. The CMAC of 16 zero bytes is 0e04dfafc1efbf040140582859bf073a.

  2. Its first byte 0e is below 80, so its leftmost bit is 0 and doubling is a plain left shift: 1c09bf5f83df7e080280b050b37e0e74.

  3. The CMAC of A1A_1 is f1f922b7f5193ce64ff80cb47d93f23b. Combined by XOR with the doubled value, it gives edf09de876c642ee4d78bce4ceedfc4f.

  4. The plaintext is shorter than 16 bytes, so the running value is doubled again. Its first byte ed is above 80, so its leftmost bit is 1, and after the shift the last byte is combined by XOR with the constant 87: 4f shifts to 9e, and 9e XOR 87 = 19. The result is dbe13bd0ed8c85dc9af179c99ddbf819.

  5. Padding the plaintext with the byte 80 and then zero bytes up to 16 bytes gives
    112233445566778899aabbccddee8000.
    Its XOR with the doubled value is cac30894b8eaf254035bc20540357819.

  6. The final CMAC of that block is VV = 85632d07c6e8f37f950acd320a2ecc93.

Counter. Number the bytes of VV from 0 at the left. Bit 63 is the leftmost bit of byte 8, and bit 31 is the leftmost bit of byte 12. Byte 8 is 95, binary 10010101; clearing its leftmost bit gives 00010101, which is 15. Byte 12 is 0a, binary 00001010, whose leftmost bit is already 0. So QQ = 85632d07c6e8f37f150acd320a2ecc93.

Encryption. The 14-byte plaintext needs one 16-byte keystream block. AES under K2K_2 turns QQ into 51e218d2c5a2ab8c4345c4a623b2f08f. Its first 14 bytes are combined by XOR with PP: the first byte gives 11 XOR 51 = 40, the second 22 XOR e2 = c0, and so on, so CC = 40c02b9690c4dc04daef7f6afe5c. The last 2 keystream bytes are discarded.

The output V‖CV \mathbin{\Vert} C is 16+14=3016 + 14 = 30 bytes and equals the output printed in RFC 5297. Encrypting the same A1A_1 and PP again gives the same 30 bytes, and that equality is all an observer learns. A receiver whose A1A_1 differs in one bit recomputes a different S2V value, except with negligible probability, and gets FAIL\mathrm{FAIL}.

Stated precisely

Let EK2E_{K_2} be AES encryption under K2K_2, ⊕\oplus bitwise XOR, ∧\wedge bitwise AND, |P||P| the length of PP in bits, and firstℓ(X)\mathrm{first}_{\ell}(X) the first ℓ\ell bits of XX. Let mask\mathrm{mask} be the 128-bit value whose bits are all 1 except bit 63 and bit 31, where bit 0 is the rightmost bit. RFC 5297 defines V=S2V(K1,A1,…,An,P),Q=V∧mask,C=P⊕first|P|(EK2(Q)‖EK2(Q+1)‖EK2(Q+2)‖⋯),Z=V‖C,\begin{aligned} V &= \mathrm{S2V}(K_1, A_1, \dots, A_n, P), \\ Q &= V \wedge \mathrm{mask}, \\ C &= P \oplus \mathrm{first}_{|P|}\bigl(E_{K_2}(Q) \mathbin{\Vert} E_{K_2}(Q+1) \mathbin{\Vert} E_{K_2}(Q+2) \mathbin{\Vert} \cdots\bigr), \\ Z &= V \mathbin{\Vert} C, \end{aligned} where Q+iQ + i is addition modulo 21282^{128} and ZZ is the output. Decryption recomputes PP from ZZ and returns it only if S2V(K1,A1,…,An,P)=V\mathrm{S2V}(K_1, A_1, \dots, A_n, P) = V; otherwise it returns FAIL\mathrm{FAIL}.

Three assumptions carry the guarantees.

  1. A secret, uniformly random key KK, whose halves are used for nothing else.

  2. AES is a pseudorandom permutation §15.2: under a secret random key, no feasible computation tells AES apart from a randomly chosen permutation of 128-bit blocks.

  3. Bounded use: at most 126 associated-data strings per message, because the proof of S2V covers at most 127 strings and the plaintext is one of them, and a bounded number of messages per key, for which RFC 5297 recommends at most 2482^{48}.

If all three hold, RFC 5297, citing the proof of Rogaway and Shrimpton presented at the Eurocrypt 2006 conference [435], states three guarantees.

Misuse resistance names this behavior under nonce repetition. No deterministic computation can reveal less, since identical inputs must give identical outputs.

Limits and common mistakes

Misuse resistance does not mean that nonce reuse leaks nothing: identical inputs still give identical outputs, an equality leakage that the entry on deterministic authenticated encryption works out.

Usage limits remain. By the birthday bound §5.6, two different inputs get the same or overlapping counter ranges with a probability that grows with the square of the number of messages, and an overlap reuses keystream across different plaintexts. RFC 5297 therefore recommends at most 2482^{48} messages per key.

SIV is two-pass: no ciphertext comes out before the whole plaintext has been read, which costs memory or a second read on a device with little RAM.

SIV does not stop replay, since a recorded output decrypts correctly when sent again, and it does not decide authorization §1.7.

Use the specified construction exactly. A home-made variant, such as one key used in both roles or fields joined into one string without lengths, falls outside the proof. Side channels §1.29, leaked keys and faulty implementations are outside the guarantee as well.

Questions answered

Does misuse resistant mean nonce reuse leaks nothing?

No. Misuse resistance, the property of SIV (synthetic initialization vector) authenticated encryption such as AES-SIV, which is built on the Advanced Encryption Standard, means that a repeated nonce does far less damage than in ordinary modes, not that it does none. When a nonce repeats, authenticity is unaffected, but if the key, the nonce, the associated data and the plaintext are all identical, the ciphertext is identical too, so an observer learns that the same message was encrypted again. Inputs that differ anywhere still give unrelated ciphertexts, and no deterministic computation can hide more, since identical inputs must give identical outputs.

Ordinary designs built on counter mode fail far worse: a repeated nonce repeats the keystream and exposes the exclusive or of the two plaintexts. Per-key usage limits, replay protection and authorization remain the job of the rest of the system.

Related entries: Deterministic authenticated encryption and equality leakage (§19.1.10), Authenticated encryption (AEAD) (§5.16), Cipher-based MAC (CMAC) (§15.7), Counter mode (CTR) (§15.5). Further reading: [48, 153, 435, 436].