| 标准 | RFC 8439 |
|---|---|
| nonce / tag | 96 位 / 128 位 |
| TLS 1.3 套件 | TLS_CHACHA20_POLY1305_SHA256 |
| 优势 | 无 AES-NI 时性能好,便于常量时间实现 |
Python 使用示例
Python 使用示例
from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
import os
key = ChaCha20Poly1305.generate_key()
aead = ChaCha20Poly1305(key)
nonce = os.urandom(12)
ct = aead.encrypt(nonce, b"payload", None)TLS 1.3 部署时常把 ChaCha20-Poly1305 放在 AES-GCM 之后,客户端无 AES 加速或服务端策略偏好时才优先选用。