跳到主要内容
uencoder

ChaCha20

ChaCha20 是 Daniel Bernstein 设计的流密码,基于 ARX(加-轮-异或)操作,常与 Poly1305 组成 AEAD,是 AES-GCM 的高性能替代。

用途

在缺乏 AES 硬件加速的平台上提供高速且常时安全的加密,避免 AES 的时序侧信道。

机制

基于 Salsa20 改进,20 轮 quarter-round 操作。状态为 4×4 矩阵(常量、密钥、计数器、nonce)。每轮对列与对角线执行 add-rotate-xor。输出密钥流与明文异或。

用例

  • TLS 1.3 默认密码套件之一
  • WireGuard VPN 隧道
  • Google 服务器加密
  • 移动端加密

示例

  • 输入
    key=256bit, nonce=96bit, counter
    输出
    keystream

    Combined with Poly1305 as AEAD

常见错误

Nonce reuse replays the keystream
Use a unique nonce per message (e.g., a counter)

相关词条

相关工具

参考链接