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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! In-crate streaming primitive traits.
//!
//! v0.3 W5 ships a small **in-crate** trait surface — [`Hash`],
//! [`Mac`], [`BlockCipher`] — that the SM3 / HMAC-SM3 / SM4
//! implementations all satisfy. Per Q7.3 / Q7.10, `RustCrypto`
//! trait fit (`digest::Digest`, `digest::Mac`,
//! `cipher::BlockEncrypt`/`BlockDecrypt`) is **deferred to v0.4**
//! behind an opt-in feature flag. v0.3 stays `no_std` +
//! zero-runtime-deps.
//!
//! # Posture
//!
//! These traits exist for ergonomic generic-over-our-types wiring,
//! NOT as bound-on-public-API constraints. Don't take `T: Hash` on
//! a public function — that would be a v1.0 `SemVer` surface.
//! Implementations of these traits on types in this crate are
//! additive; consumers can opt in if they want.
//!
//! # Lifecycle
//!
//! All three traits use the same shape:
//!
//! - `new()` (or `new(key)` for `Mac` / `BlockCipher`) constructs a
//! fresh instance.
//! - `update(&mut self, &[u8])` absorbs input bytes (where applicable).
//! - `finalize(self) -> Self::Output` consumes the instance and
//! produces the result (digest, MAC, or ciphertext).
//!
//! `BlockCipher` is shape-different: it operates per-block via
//! `encrypt_block` / `decrypt_block` rather than a streaming
//! update/finalize. Higher-level streaming modes (CBC, CTR) compose
//! on top.
/// A streaming hash function.
/// A streaming MAC (message authentication code).