| 阶段一 | Extract(salt, IKM) → PRK |
|---|---|
| 阶段二 | Expand(PRK, info, L) → OKM |
| 适用输入 | 已具一定熵的共享秘密、DH 输出 |
| 不适用 | 低熵口令(应先跑慢散列) |
Python 示例(cryptography)
Python 示例(cryptography)
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
okm = HKDF(algorithm=hashes.SHA256(), length=32, salt=None, info=b'enc-key').derive(shared_secret)TLS 1.3 的密钥调度使用 HKDF-Expand-Label,把握手上下文(Transcript-Hash)作为输入,实现每条记录密钥的独立派生。