We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I had a problem with signature verification. I narrowed problem down to the following test:
#[test] fn test_signing_verifying() { use rsa::{ pkcs1v15::{Signature, SigningKey, VerifyingKey}, sha2::Sha256, signature::{RandomizedSigner, SignatureEncoding, Verifier}, RsaPrivateKey, }; const BIT_SIZE: usize = 2048; let mut rng = rand::thread_rng(); let private_key = RsaPrivateKey::new(&mut rng, BIT_SIZE).expect("failed to generate a key"); let signing_key = SigningKey::<Sha256>::new(private_key.clone()); let public_key = private_key.to_public_key(); let verifying_key: VerifyingKey<Sha256> = public_key.into(); let data = vec![123u8; 255]; let signature = signing_key.sign_with_rng(&mut rng, &data).to_bytes(); let signature = signature.as_ref(); let Ok(signature) = Signature::try_from(signature) else { panic!("Failed to convert back to signature") }; let is_valid = verifying_key.verify(&data, &signature).is_ok(); assert!(is_valid); }
It fails. However if I change lines
let signing_key = SigningKey::<Sha256>::new(private_key.clone()); let public_key = private_key.to_public_key(); let verifying_key: VerifyingKey<Sha256> = public_key.into();
to
let signing_key = SigningKey::<Sha256>::new(private_key.clone()); let verifying_key: VerifyingKey<Sha256> = signing_key.verifying_key();
It works. Very unintuitive. Reason for this From trait implementation which uses new_unprefixed instead of new. https://docs.rs/rsa/latest/src/rsa/pkcs1v15/verifying_key.rs.html#163-170
new_unprefixed
In the docs to new_unprefixed it even says that you most likely wanna use new. So I consider this being a bug.
new
The text was updated successfully, but these errors were encountered:
Dup of #341
Sorry, something went wrong.
No branches or pull requests
I had a problem with signature verification. I narrowed problem down to the following test:
It fails. However if I change lines
to
It works. Very unintuitive. Reason for this From trait implementation which uses
new_unprefixed
instead of new. https://docs.rs/rsa/latest/src/rsa/pkcs1v15/verifying_key.rs.html#163-170In the docs to
new_unprefixed
it even says that you most likely wanna usenew
. So I consider this being a bug.The text was updated successfully, but these errors were encountered: