修复 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:
huangxt
2026-03-07 20:38:34 +08:00
parent a7eaf413d9
commit f369ae61de
8 changed files with 34 additions and 14 deletions
+16 -5
View File
@@ -265,11 +265,22 @@ mod tests {
// 辅助:从十六进制字符串构造 [u8; 32]
fn hex_literal(s: &str) -> [u8; 32] {
let mut out = [0u8; 32];
let bytes: alloc::vec::Vec<u8> = (0..s.len())
.step_by(2)
.map(|i| u8::from_str_radix(&s[i..i + 2], 16).unwrap())
.collect();
out.copy_from_slice(&bytes);
let b = s.as_bytes();
for i in 0..32 {
let hi = match b[i * 2] {
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"),
};
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
}
}