附录 A. 数据包保护示例
本附录给出 packet protection 的样例, 用于展示如何从 TLS secret 派生 QUIC 使用的 key、IV、header protection key 和 key update secret, 以及如何对 Initial packet、Retry packet 和 short header packet 应用保护.
示例首先列出从 secret 通过 HKDF-Expand-Label 派生出的值, 然后展示客户端 Initial packet 和服务器 Initial packet 的构造过程. 这些示例包括 packet number、nonce、未保护 header、payload 明文、payload 密文、header protection sample、mask 以及最终受保护 packet.
Retry 示例展示了 Retry integrity tag 的计算方式, 其中完整性检查覆盖客户端选择的原始 Destination Connection ID, 但该值不直接出现在最终 Retry packet 中.
ChaCha20-Poly1305 short header 示例展示了使用 AEAD_CHACHA20_POLY1305 时的最小 packet 保护流程. 示例说明如何用 application write secret 派生 key、IV、header protection key 和后续 key update secret, 并展示 payload 加密和 header protection 的结果.