跳到主要内容

7. HKDF 和基于 SHA 的 HMACs (HKDF- and SHA-Based HMACs)

下面给出简要描述, 并指向更完整的描述和代码, 涉及 (1) SHA-based HMACs 和 (2) HMAC-based extract-and-expand key derivation function. HKDF 和 HMAC 都由 Hugo Krawczyk 设计.

7.1. 基于 SHA 的 HMACs (SHA-Based HMACs)

HMAC 是一种使用 hash function 计算 keyed MAC (Message Authentication Code) 的方法, 如 [RFC2104] 所述. 它使用 key 与 input text 混合以生成最终 hash.

下文第 8.3 节还提供 sample code, 用于基于本文所述任一 SHA algorithms 执行 HMAC. [RFC2104] 中的 sample code 是按指定 text size 编写的. 由于 SHA 是按任意数量 bits 定义的, sample HMAC code 被编写为允许 HMAC 的 text input 具有任意数量的 octets 和 bits. 还提供了 fixed-length interface.

7.2. HKDF

HKDF 是一种特定的 Key Derivation Function (KDF), 即以 initial keying material 为输入, 由 KDF 派生出一个或多个 cryptographically strong secret keys 的函数. [RFC5869] 中描述的 HKDF 基于 HMAC.

HKDF 的 sample code 见下文第 8.4 节.