1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Copyright (c) 2026 Kirky.X. All rights reserved.
//! See LICENSE for full license text.
//! HTTP Digest 认证子模块(RFC 7616)。
//!
//! 对应 Digest 认证能力,
//! 基于 `md5` / `sha2` crate 实现摘要认证。
//!
//! - `DigestAlgorithm::default()` 返回 `Sha256`
//! - nonce 格式为 `base64(timestamp:random_uuid)`,validate 时校验时间戳防过期
//! - 支持 `qop=auth` 与 `qop=auth-int`(后者需通过 `validate_with_body` 传入请求体)
//!
//! # 安全说明
//!
//! MD5 算法已被证明存在碰撞攻击,不建议在新系统中使用。
//! 仅在兼容旧客户端时使用 MD5,新系统应使用 SHA256(现为默认值)。
/// Digest 算法枚举。
/// `DigestAlgorithm` 实现块(算法名称、摘要计算、字符串解析)。
/// HTTP Digest 认证工具,封装 RFC 7616 质询生成与响应校验。
///
/// # 示例
///
/// ```
/// #[cfg(feature = "secure-httpdigest")]
/// # {
/// use garrison::secure::httpdigest::HttpDigestAuth;
///
/// let auth = HttpDigestAuth::new("test@realm", "MD5").unwrap();
/// let challenge = auth.challenge();
/// assert!(challenge.starts_with("Digest "));
/// # }
/// ```
/// `HttpDigestAuth` 实现块(质询生成与响应校验)。