Skip to content

Commit 51aabfb

Browse files
anrossiguhetier
andauthored
Document Stateless Retry Key Generation (#5258)
Co-authored-by: Guillaume Hetier <[email protected]>
1 parent 92f6736 commit 51aabfb

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

docs/api/QUIC_STATELESS_RETRY_CONFIG.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,48 @@ Changing `RotationMs`, `Algorithm`, or `Secret` will invalidate all retry tokens
4545
All servers deployed in a cluster and sharing the secret must have their clocks synchronized within `RotationMs` of UTC.
4646
A server whose clock is ahead of UTC may produce a retry token that other servers in that deployment are unable to validate.
4747

48+
## Stateless Retry key Generation Algorithm
49+
50+
The stateless retry key is generated from the above configuration parameters using the [SP800-108 rev. 1 CTR-HMAC KDF](https://csrc.nist.gov/pubs/sp/800/108/r1/upd1/final) algorithm with SHA256.
51+
Where:
52+
53+
*K_in* is the `Secret` provided above.
54+
55+
*Label* is the string "QUIC Stateless Retry Key" without the terminating NULL character.
56+
57+
*Context* is the UNIX epoch timestamp in milliseconds, as an 8-byte signed integer in little-endian format, divided by `RotationMs`, rounded down.
58+
59+
*L* is the same as the key length for the `Algorithm`.
60+
61+
### Example 1 - AES-GCM 256
62+
63+
Variable | Value
64+
---------|-------
65+
`Secret` | 0x3edc6b5b8f7aadbd713732b482b8f979286e1ea3b8f8f99c30c884cfe3349b83
66+
`SecretLength` | 32
67+
`RotationMs` | 30000
68+
`Algorithm` | **QUIC_AEAD_ALGORITHM_AES_256_GCM**
69+
The UNIX epoch timestamp | 1752112221
70+
71+
Therefore, *Context* = timestamp / `RotationMs` = `1752112221 / 30000` = 58403.
72+
73+
The generated key should be the following value : 0x8135A3ACD2FB4B2B6D7CDD9C36ACB0A182F725F52C641F4A1F21AB53CD63F9B1.
74+
75+
### Example 2 - AES-GCM 128
76+
77+
Variable | Value
78+
---------|-------
79+
`Secret` | 0x5ddd79f7b33f1f4a6dd57c34a8eec42e
80+
`SecretLength` | 16
81+
`RotationMs` | 30000
82+
`Algorithm` | **QUIC_AEAD_ALGORITHM_AES_128_GCM**
83+
The UNIX epoch timestamp | 1752112221
84+
85+
Therefore, *Context* = timestamp / `RotationMs` = `1752112221 / 30000` = 58403.
86+
87+
The generated key should be the following value: 0x44B08A21DC20D6297328C6B356354502
88+
89+
4890
# See Also
4991

50-
[Settings](../Settings.md)<br>
92+
[Settings](../Settings.md)<br>

0 commit comments

Comments
 (0)