Support Public Key Algorithms in Crypto Module#80
Support Public Key Algorithms in Crypto Module#80InfoHunter wants to merge 19 commits intoTongsuo-Project:mainfrom
Conversation
|
Tongsuo will fail for sure since its adaptor is not implemented yet |
| prime: Option<u8>, | ||
| size: Option<RSAKeySize>, | ||
| ) -> Result<Self, RvError> { | ||
| return Ok( |
| let mut ctx = match PkeyCtx::new(&key) { | ||
| Ok(ctx) => ctx, | ||
| Err(_e) => return Err(RvError::ErrCryptoPKeyInternalError), | ||
| }; |
There was a problem hiding this comment.
let mut ctx = PkeyCtx::new(&key).map_err(|_| RvError::ErrCryptoPKeyInternalError)?;
| let rsa = match Rsa::generate(bits) { | ||
| Ok(r) => r, | ||
| Err(_e) => return Err(RvError::ErrCryptoPKeyRSAKeyGenFailed), | ||
| }; |
There was a problem hiding this comment.
let rsa = Rsa::generate(bits).map_err(|_| RvError::ErrCryptoPKeyRSAKeyGenFailed)?;
| let pkey = match PKey::from_rsa(rsa) { | ||
| Ok(r) => r, | ||
| Err(_e) => return Err(RvError::ErrCryptoPKeyRSAKeyGenFailed), | ||
| }; |
There was a problem hiding this comment.
let pkey = PKey::from_rsa(rsa).map_err(|_| RvError::ErrCryptoPKeyRSAKeyGenFailed)?;
| match ctx.verify_init() { | ||
| Ok(_ret) => {}, | ||
| Err(_e) => return Err(RvError::ErrCryptoPKeyVerifyInitFailed), | ||
| } |
| let valid = match ctx.verify(data, sig) { | ||
| Ok(ret) => ret, | ||
| Err(_e) => return Err(RvError::ErrCryptoPKeyVerifyFailed), | ||
| }; |
| #[cfg(feature = "crypto_adaptor_tongsuo")] | ||
| #[test] | ||
| fn test_sm2_keygen() { | ||
| assert_eq!(1, 1); |
There was a problem hiding this comment.
SM2 is not to be supported in this PR. rust-tongsuo should support SM2 first.
| #[cfg(feature = "crypto_adaptor_tongsuo")] | ||
| #[test] | ||
| fn test_sm2_sign_decrypt() { | ||
| assert_eq!(1, 1); |
| #[cfg(feature = "crypto_adaptor_tongsuo")] | ||
| #[test] | ||
| fn test_sm2_encrypt_decrypt() { | ||
| assert_eq!(1, 1); |
There was a problem hiding this comment.
This not implemented in the underlying rust-tongsuo crate, so it's not implemented yet.
|
Paul Yang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Algorithms may vary for different crypto adaptor: