-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The oaep padding is not compatiable to other lib. #57
Comments
|
@dignifiedquire Thanks for rapidly reply. I thought is the sha1 issue. But I cant figure out how to use sha1 in this crate. use rsa::{PublicKey, RSAPublicKey, RSAPrivateKey, PaddingScheme};
use rand::rngs::OsRng;
use sha1::Sha1;
pub fn encrypt_(key: &[u8], plaintext: &[u8]) -> Vec<u8> {
let mut rng = OsRng;
let data = plaintext;
let public_key = RSAPublicKey::from_pkcs8(key).expect("get private key error");
// pkcs#1 padding
// let padding = PaddingScheme::new_pkcs1v15_encrypt();
let padding = PaddingScheme::new_oaep::<Sha1>();
let enc_data = public_key.encrypt(&mut rng, padding, &data[..]).expect("failed to decrypt");
enc_data
} I tried this, but it complain. And I cant find out what other than |
@tarcieri Thanks. But I do need to interact with some legacy code. Is there any way I can use this lib to achieve? |
@wenjoy what is the issue you are encountering with passing |
@dignifiedquire I got this error:
But the link you post inspired me to check the dependencies, then I solved it! Thanks so much @dignifiedquire ! That's the thing. Previously my dependencies likes this:
after compare with this lib's , I found it should be this:
Now it works like a charm. But I have to say why its name so weird. Just following Anyway, thanks again @dignifiedquire. |
@wenjoy |
glad to hear it is working now @wenjoy |
@newpavlov Now that does make sense. Thanks buddy. |
I try to use this crate to encrypt data and decrypt use node's
crypto
and this online tool.this is my example code:
then try to decrypt by
crypto
then I got this error
error:04099079:rsa routines:RSA_padding_check_PKCS1_OAEP_mgf1:oaep decoding error
here is my
private.pem
and
public.pem
and I also tried on this online tool. still no lucky.
but if:
crypto
then decrypt with this online tool. it works.So I can infer that it's the oaep padding lead to incompatible.
The text was updated successfully, but these errors were encountered: