Files
libsmx/src/lib.rs
T
huangxt 7c159343f8 发布 v0.3.0:rustls CryptoProvider 支持
新增功能:
- rustls CryptoProvider:完整 rustls 0.23.x 支持
  - SM3 Hash/Context trait 实现
  - SM3 HMAC trait 实现
  - SM4-GCM/CCM AEAD 密码套件
  - SM2 ECDHE 密钥交换
  - SM2 签名/验签算法
- SM3 流式 HMAC(HmacSm3)
- SM2 SPKI DER 编码
- SM2 DEFAULT_ID 常量

文档更新:
- README 依赖版本更新为 0.3
- CHANGELOG 添加 v0.3.0 变更记录
- SECURITY 更新版本支持表
2026-03-09 10:13:09 +08:00

67 lines
1.7 KiB
Rust

//! # 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 |
#![no_std]
#![forbid(unsafe_code)]
#![warn(missing_docs, rust_2018_idioms)]
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
pub mod error;
pub mod sm2;
pub mod sm3;
pub mod sm4;
pub mod sm9;
#[cfg(feature = "alloc")]
pub mod bls;
pub mod fpe;
#[cfg(feature = "rustls-provider")]
pub mod rustls_provider;