← [ BACK_TO_NOTES ]

AEAD(Authenticated Encryption with Associated Data)

AEAD 同时提供 confidentiality 与 ciphertext integrity/authenticity,并允许把 header/metadata 作为 AAD 认证但不加密;安全性高度依赖唯一/正确的 nonce 与完整 tag verification。

#concept #evergreen #crypto

[!info] related notes

AEAD(Authenticated Encryption with Associated Data)

一句话定义

AEAD 是一种消息保护接口:

plaintext + associated data + key + nonce
→ ciphertext + authentication tag

解密端:

ciphertext + associated data + key + nonce + tag
→ plaintext or authentication failure

它同时提供:

  • confidentiality;
  • integrity/authenticity of ciphertext;
  • integrity/authenticity of AAD。

为什么只加密不够

传统只提供 confidentiality 的模式,例如单独 CBC:

plaintext
→ ciphertext

攻击者可能无法看懂明文,但仍可能篡改 ciphertext。

如果系统没有正确 MAC / authentication,解密端可能:

  • 接受被修改的数据;
  • 暴露 padding oracle;
  • 产生不可预测状态。

因此现代协议更倾向:

encrypt + authenticate as one construction

也就是 AEAD。

Associated Data

AAD 是:

需要认证,但不需要保密的数据。

典型:

  • protocol header;
  • message type;
  • sequence number;
  • tenant id;
  • version;
  • routing metadata。

AAD 不会被加密,但任何篡改都会导致 tag verification 失败。

AES-GCM

AES-GCM 是常见 AEAD。

它组合:

  • AES block cipher;
  • counter-mode encryption;
  • Galois-field authentication。

NIST SP 800-38D 明确定义 GCM 为 authenticated encryption with associated data。

ChaCha20-Poly1305

另一个常见 AEAD:

  • ChaCha20:stream cipher;
  • Poly1305:authenticator。

它与 AES-GCM 不同,但暴露类似 AEAD abstraction。

某些没有高效 AES hardware 的平台可能更适合 ChaCha20-Poly1305。

Nonce 是关键安全边界

AEAD 通常要求:

在同一个 key 下 nonce 满足该算法规定的唯一性/随机性要求。

以 GCM 为例,重复 nonce 可能严重破坏:

  • confidentiality;
  • authentication key security;
  • tag forgery resistance。

所以:

AES-GCM + strong key + reused nonce
≠ secure encryption

nonce management 与 key management 同样重要。

Nonce 不等于 Secret

许多 AEAD nonce 并不要求保密。

它可以和 ciphertext 一起存储/传输。

关键是:

  • 格式正确;
  • 长度符合算法;
  • uniqueness / generation policy 正确。

不要因为 nonce 公开就误认为它没有安全意义。

Authentication Tag

tag 必须在输出 plaintext 被应用消费前验证。

错误模式:

decrypt
→ 先使用 plaintext
→ 后验证 tag

正确抽象:

AEAD open()
→ tag valid ? plaintext : failure

应用层不应该接触“未认证明文”。

AEAD 与 HMAC

两种常见设计:

AEAD

encrypt + authenticate 作为一个标准 primitive。

Encrypt-then-MAC

encryption
→ HMAC over ciphertext/metadata

如果协议已经选了成熟 AEAD,通常不需要再随意叠一层 HMAC。

如果自己组合 encryption + MAC,顺序、key separation、覆盖字段都容易出错。

Replay 不由 AEAD 自动解决

AEAD 可以证明:

这条 ciphertext/tag 没被修改。

但同一条合法消息被攻击者重复发送:

replay original valid packet
→ tag still valid

因此 protocol 仍可能需要:

  • sequence number;
  • timestamp;
  • nonce state;
  • replay window;
  • idempotency/state machine。

Key Separation

不要把同一个 secret key 随意同时用于:

  • AES-GCM;
  • HMAC;
  • unrelated protocol;
  • different tenant/context。

现代 protocol 常通过 KDF 派生用途隔离的 subkeys。

TLS 里的 AEAD

TLS 1.3 record protection 只使用 AEAD cipher suites。

握手建立 traffic secrets 后,再派生:

  • traffic key;
  • IV;

用于保护 application records。

详见 TLS 1.3 Key Schedule。

常见误区

AES = AEAD

错误。AES 是 block cipher,AES-GCM 才是具体 AEAD construction。

encrypted = authenticated

错误。confidentiality 不自动提供 integrity。

nonce 是公开的,所以随便重复

错误。是否保密和是否必须唯一是两件事。

tag valid = 这条消息没被 replay

错误。tag 只认证内容与上下文,不自动提供 anti-replay。

学习检查

  1. AEAD 比单纯 encryption 多提供了什么?
  2. AAD 为什么不加密却仍有安全价值?
  3. AES 与 AES-GCM 的层级差异是什么?
  4. GCM nonce reuse 为什么是严重错误?
  5. 为什么 nonce 可以公开但仍必须严格管理?
  6. authentication tag 应在什么时候验证?
  7. 为什么 AEAD 不能自动解决 replay?
  8. TLS 1.3 的 traffic key 与 nonce/IV 为什么通常由 KDF 派生,而不是手工配置?
创建于 2026/9/30 更新于 2026/9/30
Digital Biome
Access

键盘导航

j / k / ↑ / ↓
选择对象
Enter / o
打开选择
/ 或 Ctrl+K
全站搜索
i / f / 1–4
筛选当前列表
g → h / l / p / t / a
首页 / 笔记 / 项目 / 工具 / About
r → 1–9
打开所选对象的关联
u
返回上一页
Esc
关闭浮层 / 取消命令;输入框内清空文本