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
//! # libsmx
//!
//! Production-grade implementation of Chinese commercial cryptography standards:
//!
//! - **SM2** — Elliptic Curve Public Key Cryptography (GB/T 32918.1-5)
//! - **SM3** — Cryptographic Hash Algorithm (GB/T 32905)
//! - **SM4** — Block Cipher Algorithm (GB/T 32907)
//! - **SM9** — Identity-Based Cryptographic Algorithm (GB/T 38635.1-2)
//!
//! ## Features
//!
//! - `no_std` compatible (requires `alloc` feature for SM2/SM9 operations)
//! - Constant-time operations via [`subtle`](https://docs.rs/subtle)
//! - Automatic key zeroization via [`zeroize`](https://docs.rs/zeroize)
//! - All implementations validated against official GB/T test vectors
//!
//! ## Quick Start
//!
//! ```rust
//! use libsmx::sm3::Sm3Hasher;
//!
//! let mut h = Sm3Hasher::new();
//! h.update(b"hello world");
//! let digest = h.finalize();
//! assert_eq!(digest.len(), 32);
//! ```
//!
//! ## Security Notice
//!
//! This library uses constant-time operations throughout to prevent timing
//! side-channel attacks. Private keys are zeroized on drop. However, this
//! library has **not** been independently audited. Use in production at your
//! own risk.
//!
//! ## Standards Compliance
//!
//! | Algorithm | Standard |
//! |-----------|----------|
//! | SM2 | GB/T 32918.1-5-2016 |
//! | SM3 | GB/T 32905-2016 |
//! | SM4 | GB/T 32907-2016 |
//! | SM9 | GB/T 38635.1-2-2020 |
extern crate alloc;
extern crate std;