修复 no_std 测试并升级 MSRV 至 1.83.0
- 修复 cargo test --no-default-features --lib 编译错误 - SM3 测试:移除 alloc 依赖,改用手动十六进制解析 - SM4 modes 测试:添加 #[cfg(feature = "alloc")] - MSRV 升级至 1.83.0(crypto-bigint 0.6.x 的 ConstMontyForm 所需) - 更新 CI 工作流中的 MSRV 版本 - 修正 Cargo.toml 仓库链接
This commit is contained in:
@@ -111,7 +111,7 @@ jobs:
|
|||||||
# Job 3: MSRV 验证(最低支持版本)
|
# Job 3: MSRV 验证(最低支持版本)
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
msrv:
|
msrv:
|
||||||
name: MSRV (1.72.0)
|
name: MSRV (1.83.0)
|
||||||
needs: lint
|
needs: lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -121,7 +121,7 @@ jobs:
|
|||||||
- name: 安装 MSRV 工具链
|
- name: 安装 MSRV 工具链
|
||||||
uses: dtolnay/rust-toolchain@master
|
uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
toolchain: "1.72.0"
|
toolchain: "1.83.0"
|
||||||
|
|
||||||
- name: 缓存 Cargo 编译产物
|
- name: 缓存 Cargo 编译产物
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- SM2 sign: 258 µs, verify: 316 µs
|
- SM2 sign: 258 µs, verify: 316 µs
|
||||||
- SM9 sign: 3.44 ms, verify: 5.50 ms
|
- SM9 sign: 3.44 ms, verify: 5.50 ms
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- MSRV raised to 1.83.0 (required by crypto-bigint 0.6.x for ConstMontyForm constant-time Montgomery arithmetic)
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
||||||
- GCM `gf128_mul`: replaced secret-dependent `if` branches with mask arithmetic
|
- GCM `gf128_mul`: replaced secret-dependent `if` branches with mask arithmetic
|
||||||
|
|||||||
@@ -38,6 +38,10 @@
|
|||||||
- SM2 签名:258 µs,验签:316 µs
|
- SM2 签名:258 µs,验签:316 µs
|
||||||
- SM9 签名:3.44 ms,验签:5.50 ms
|
- SM9 签名:3.44 ms,验签:5.50 ms
|
||||||
|
|
||||||
|
### 变更
|
||||||
|
|
||||||
|
- MSRV 提升至 1.83.0(crypto-bigint 0.6.x 的 ConstMontyForm 常量时间 Montgomery 算术所需)
|
||||||
|
|
||||||
### 安全
|
### 安全
|
||||||
|
|
||||||
- GCM `gf128_mul`:用掩码运算替换依赖秘密的 `if` 分支
|
- GCM `gf128_mul`:用掩码运算替换依赖秘密的 `if` 分支
|
||||||
|
|||||||
+3
-3
@@ -2,12 +2,12 @@
|
|||||||
name = "libsmx"
|
name = "libsmx"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.72.0"
|
rust-version = "1.83.0"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
description = "Pure-Rust, no_std, constant-time SM2/SM3/SM4/SM9 Chinese cryptography (GB/T 32918/32905/32907/38635)"
|
description = "Pure-Rust, no_std, constant-time SM2/SM3/SM4/SM9 Chinese cryptography (GB/T 32918/32905/32907/38635)"
|
||||||
repository = "https://github.com/aspect-building/libsmx"
|
repository = "https://github.com/kintaiW/libsmx"
|
||||||
documentation = "https://docs.rs/libsmx"
|
documentation = "https://docs.rs/libsmx"
|
||||||
homepage = "https://github.com/aspect-building/libsmx"
|
homepage = "https://github.com/kintaiW/libsmx"
|
||||||
categories = ["cryptography", "no-std"]
|
categories = ["cryptography", "no-std"]
|
||||||
keywords = ["sm2", "sm3", "sm4", "sm9", "gmssl"]
|
keywords = ["sm2", "sm3", "sm4", "sm9", "gmssl"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
[](https://docs.rs/libsmx)
|
[](https://docs.rs/libsmx)
|
||||||
[](https://codecov.io/gh/kintaiW/libsmx)
|
[](https://codecov.io/gh/kintaiW/libsmx)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
[](https://blog.rust-lang.org/2023/08/24/Rust-1.72.0.html)
|
[](https://blog.rust-lang.org/2024/11/28/Rust-1.83.0.html)
|
||||||
|
|
||||||
Pure-Rust, `#![no_std]` implementation of Chinese commercial cryptography standards with constant-time operations throughout.
|
Pure-Rust, `#![no_std]` implementation of Chinese commercial cryptography standards with constant-time operations throughout.
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ cargo bench
|
|||||||
|
|
||||||
## MSRV Policy
|
## MSRV Policy
|
||||||
|
|
||||||
The minimum supported Rust version is **1.72.0**. MSRV bumps are treated as minor version changes.
|
The minimum supported Rust version is **1.83.0**. MSRV bumps are treated as minor version changes.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -5,7 +5,7 @@
|
|||||||
[](https://docs.rs/libsmx)
|
[](https://docs.rs/libsmx)
|
||||||
[](https://codecov.io/gh/kintaiW/libsmx)
|
[](https://codecov.io/gh/kintaiW/libsmx)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
[](https://blog.rust-lang.org/2023/08/24/Rust-1.72.0.html)
|
[](https://blog.rust-lang.org/2024/11/28/Rust-1.83.0.html)
|
||||||
|
|
||||||
纯 Rust、`#![no_std]` 实现的中国商用密码算法库,全程常量时间操作。
|
纯 Rust、`#![no_std]` 实现的中国商用密码算法库,全程常量时间操作。
|
||||||
|
|
||||||
@@ -246,7 +246,7 @@ cargo bench
|
|||||||
|
|
||||||
## 最低支持 Rust 版本(MSRV)
|
## 最低支持 Rust 版本(MSRV)
|
||||||
|
|
||||||
最低支持版本为 **Rust 1.72.0**。MSRV 提升视为次版本号变更。
|
最低支持版本为 **Rust 1.83.0**。MSRV 提升视为次版本号变更。
|
||||||
|
|
||||||
## 许可证
|
## 许可证
|
||||||
|
|
||||||
|
|||||||
+16
-5
@@ -265,11 +265,22 @@ mod tests {
|
|||||||
// 辅助:从十六进制字符串构造 [u8; 32]
|
// 辅助:从十六进制字符串构造 [u8; 32]
|
||||||
fn hex_literal(s: &str) -> [u8; 32] {
|
fn hex_literal(s: &str) -> [u8; 32] {
|
||||||
let mut out = [0u8; 32];
|
let mut out = [0u8; 32];
|
||||||
let bytes: alloc::vec::Vec<u8> = (0..s.len())
|
let b = s.as_bytes();
|
||||||
.step_by(2)
|
for i in 0..32 {
|
||||||
.map(|i| u8::from_str_radix(&s[i..i + 2], 16).unwrap())
|
let hi = match b[i * 2] {
|
||||||
.collect();
|
c @ b'0'..=b'9' => c - b'0',
|
||||||
out.copy_from_slice(&bytes);
|
c @ b'a'..=b'f' => c - b'a' + 10,
|
||||||
|
c @ b'A'..=b'F' => c - b'A' + 10,
|
||||||
|
_ => panic!("invalid hex"),
|
||||||
|
};
|
||||||
|
let lo = match b[i * 2 + 1] {
|
||||||
|
c @ b'0'..=b'9' => c - b'0',
|
||||||
|
c @ b'a'..=b'f' => c - b'a' + 10,
|
||||||
|
c @ b'A'..=b'F' => c - b'A' + 10,
|
||||||
|
_ => panic!("invalid hex"),
|
||||||
|
};
|
||||||
|
out[i] = hi << 4 | lo;
|
||||||
|
}
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -654,6 +654,7 @@ pub fn sm4_decrypt_xts(
|
|||||||
// ── 测试 ──────────────────────────────────────────────────────────────────────
|
// ── 测试 ──────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[cfg(feature = "alloc")]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user