20. DHCP 消息的认证 (Authentication of DHCP Messages)
本文档为 DHCP 消息认证定义了两种安全机制: (1) 使用 IPsec 对服务器与中继代理之间发送的消息进行认证和加密, (2) 防止恶意 DHCP 服务器发送 Reconfigure 消息而导致客户端配置错误.
20.1. 服务器与中继代理之间发送消息的安全性 (Security of Messages Sent Between Servers and Relay Agents)
交换消息的中继代理和服务器可以按照 [RFC8213] 中的详细说明使用 IPsec.
20.2. DHCP 认证概述 (Summary of DHCP Authentication)
DHCP 消息的认证通过使用 Authentication option 完成 (见 Section 21.11). Authentication option 中携带的认证信息可用于可靠地识别 DHCP 消息的来源, 并确认 DHCP 消息的内容未被篡改.
Authentication option 为多种认证协议提供了框架. 其中一种协议 RKAP 定义于 Section 20.4. 未来定义的其他协议将在单独的文档中规定.
任何 DHCP 消息禁止包含多个 Authentication option.
Authentication option 中的 protocol 字段用于标识生成该选项所携带认证信息的具体协议. algorithm 字段用于标识认证协议内的具体算法; 例如, algorithm 字段指定用于在 Authentication option 中生成 Message Authentication Code (MAC) 的哈希算法. RDM 字段用于指定 replay detection 字段中使用的重放检测类型.
20.3. 重放检测 (Replay Detection)
Authentication option 的 RDM 字段 (见 Section 21.11) 决定 replay detection 字段中使用的重放检测类型.
如果 RDM 字段包含 0x00, replay detection 字段必须设置为严格单调递增的 64-bit 无符号整数值 (modulo 2^64). 使用这种技术可以降低重放攻击的风险. 所有 Authentication option 协议都必须支持此方法. 一种选择是使用 64-bit NTP 时间戳格式 [RFC5905].
接收到 RDM 字段设置为 0x00 的消息时, 客户端必须将其 replay detection 字段与同一服务器先前发送的值进行比较 (基于 Server Identifier option; 见 Section 21.3), 只有在接收到的值更大时才接受该消息, 并将其记录为新的值. 如果这是客户端第一次处理某服务器发送的 Authentication option, 客户端必须记录 replay detection 值并跳过 replay detection 检查.
支持 reconfigure 机制的服务器必须确保 replay detection 值在重启之间得到保留. 如果未这样做, 客户端可能会拒绝服务器发送的 Reconfigure 消息, 从而实际上使 reconfigure 机制失效.
20.4. Reconfiguration Key Authentication Protocol (RKAP)
RKAP 用于防止恶意 DHCP 服务器发送 Reconfigure 消息而导致客户端配置错误. 在此协议中, DHCP 服务器会在 DHCP 消息的初始交换中向客户端发送 Reconfigure Key. 客户端记录该 Reconfigure Key, 用于认证随后来自该服务器的 Reconfigure 消息. 随后, 服务器会在后续 Reconfigure 消息中包含一个根据 Reconfigure Key 计算得到的 Hashed Message Authentication Code (HMAC).
从服务器发送到客户端的 Reconfigure Key, 以及后续 Reconfigure 消息中的 HMAC, 都作为 Authentication option 中的认证信息携带 (见 Section 21.11). 认证信息的格式在下一节中定义.
只有当客户端和服务器已经协商使用 Reconfigure 消息时, 才使用 RKAP (由服务器发起).
20.4.1. RKAP 中 Authentication option 的使用 (Use of the Authentication Option in RKAP)
对于 RKAP, Authentication option (见 Section 21.11) 中的以下字段设置如下:
-
protocol: 3
-
algorithm: 1
-
RDM: 0
RKAP 的认证信息格式如下:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Value (128 bits) |
+-+-+-+-+-+-+-+-+ |
. .
. .
. +-+-+-+-+-+-+-+-+
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
图 11: RKAP 认证信息 (RKAP Authentication Information)
Type: 此选项中携带的 Value 字段的数据类型:
-
Reconfigure Key value (用于 Reply 消息).
-
消息的 HMAC-MD5 digest (用于 Reconfigure 消息).
一个 1-octet 字段.
Value: 由 Type 字段定义的数据. 一个 16-octet 字段.
20.4.2. RKAP 的服务器注意事项 (Server Considerations for RKAP)
服务器会在 Request/Reply, Solicit/Reply 或 Information-request/Reply 消息交换期间为客户端选择 Reconfigure Key. 服务器记录该 Reconfigure Key, 并在 Reply 消息的 Authentication option (见 Section 21.11) 中将该密钥发送给客户端.
Reconfigure Key 长度为 128 bits, 并且必须是密码学强度足够高, 难以预测的随机数或伪随机数.
为了为 Reconfigure 消息提供认证, 服务器按照服务器选择的 RDM 选择一个 replay detection 值, 并使用该客户端的 Reconfigure Key 计算 Reconfigure 消息的 HMAC-MD5. 服务器对整个 DHCP Reconfigure 消息计算 HMAC-MD5, 包括 Authentication option; 在计算 HMAC-MD5 时, Authentication option 中的 HMAC-MD5 字段设置为 0. 服务器将 HMAC-MD5 放入发送给客户端的 Reconfigure 消息中所包含 Authentication option 的 authentication information 字段.
20.4.3. RKAP 的客户端注意事项 (Client Considerations for RKAP)
客户端会在服务器的初始 Reply 消息中的 Authentication option (见 Section 21.11) 内收到来自服务器的 Reconfigure Key. 客户端记录该 Reconfigure Key, 用于认证后续 Reconfigure 消息.
为了认证 Reconfigure 消息, 客户端使用从服务器收到的 Reconfigure Key 对 Reconfigure 消息计算 HMAC-MD5, 并在计算时用零替代 HMAC-MD5 字段. 如果计算得到的 HMAC-MD5 与 Authentication option 中的值匹配, 客户端接受该 Reconfigure 消息.