libsm
libsm copied to clipboard
A Rust Library of China's Standards of Encryption Algorithms (SM2/3/4)
#37
我发现ecc.rs的创建点乘表table1和table2时,采用了lazy_static方法,这种方法在被第一次调用时会展开,这步大概需要3~5秒的时间,这里可以直接把两个表512个点(大概2M)写入到文件中,可以显著提高第一次调用该方法的效率
pr #45 and issues #37 both mention that loading gmul_table from disk is an elegant way. In this pr, I modify the g_table function, introduced Serde crate to serialize the...
You can use this crates in WebAssembly. Currently, you only need to add dependencies: ```toml # Cargo.toml getrandom = { version = "^0.2", features = ["js"] } ``` See [getrandom#WebAssembly...
`pub fn decrypt(&self, cipher: &[u8]) -> Sm2Result` 方法 转 c_1_point 时,如果遇到异常能否“透传”出来? 最好 `let c_1_point = self.curve.bytes_to_point(c_1_bytes).unwrap();` 这里可以不要直接 unwrap(), 能把这里的异常也 return 出来。 现在,这里面的 `Sm2Error::InvalidPublic` `Sm2Error::NotOnCurve` 等,外层好像没法处理。
为了将Sm3Hash用于[hmac](https://docs.rs/hmac)库,需要实现[digest](https://docs.rs/digest)中的相关trait: 
SM4-CTR can be optimized by utilizing AES-NI. 代码参考 [Tongsuo](https://github.com/Tongsuo-Project/Tongsuo) 项目实现,迁移到 rust 语言 [参考代码](https://github.com/Tongsuo-Project/Tongsuo/pull/356/files) 此功能基于 Markku-Juhani O. Saarinen 的理论:[sm4ni](https://github.com/mjosaarinen/sm4ni)
1.配置: [dependencies] libsm="0.6.0" 2. 然后在main.rs中调用的时候 use libsm::sm2::signature::{Pubkey, Seckey, SigCtx, Signature}; fn main() { let ctx = SigCtx::new(); let (pk, sk) = ctx.new_keypair(); } **报错信息如下** error[E0308]: mismatched types --> src/main.rs:4:9 |...