-
Notifications
You must be signed in to change notification settings - Fork 156
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
Is RSA PSS key loading from PKCS#8 supported? #422
Comments
If it's truly a PSS key, try using I agree that should probably be If you can make that change locally and add a Not sure if you can post the private key in question or not but that would be helpful in figuring out what's going wrong as well. If you can't post the private key (totally understandable), |
Hi @tarcieri, thanks for the answer. Private key is example key from RFC 9421 https://www.rfc-editor.org/rfc/rfc9421.html#name-example-rsa-pss-key Here is output of
You mean update sample code above to something like this? rsa::pss::SigningKey::from_pkcs8_pem(RSA_2048_PEM_EXAMPLE) I believe I also tried it this way: let pk = PrivateKeyInfo::try_from(bytes.as_slice()).unwrap(); // same as in sample in the first message
let rsa_key = RsaPrivateKey::try_from(pk); // <-- Err(PublicKey(OidUnknown { oid: ObjectIdentifier(1.2.840.113549.1.1.1) }))
let signing_key = rsa::pss::SigningKey::<Sha512>::new(rsa_key.unwrap()); |
Indeed you're right, we don't have a To the extent we support that OID at all, it's in the signature encoding itself: https://github.com/RustCrypto/RSA/blob/7341cd0/src/pss.rs#L243 cc @lumag |
Hmm, let me take a look. |
@tarcieri Could not check it in actual project yet as there is dependencies version conflict, but code extracted to separate workspace works with as expected with the recent commit e54fb7d and Thank you folks for the prompt response and fix. |
As noted in RustCrypto/RSA#422, we're not returning the actual "unknown OID" encountered in these cases, but the expected one, which makes it hard to debug mismatches.
As noted in RustCrypto/RSA#422, we're not returning the actual "unknown OID" encountered in these cases, but the expected one, which makes it hard to debug mismatches.
As noted in RustCrypto/RSA#422, we're not returning the actual "unknown OID" encountered in these cases, but the expected one, which makes it hard to debug mismatches.
Hi,
Are RSA PSS keys supported in
rsa
crate for loading fromPKCS#8
? Documentation has that small greyish checkbox for "PSS: Sign & Verify" bullet (though it is not clear what does it mean as there is no any legend) plus https://docs.rs/rsa/latest/rsa/index.html#pkcs8-rsa-key-encoding mentions related traits, so I assumed it is supported. But maybe I was a bit too hasty in that assumption.If those are supported what is the right way to load RSA PSS private key?
Context
I am trying to load private key https://www.rfc-editor.org/rfc/rfc9421.html#name-example-rsa-pss-key
Test code is:
Output is:
My understanding is that
.10
is OID forrsassa-pss
, while.1
isrsaEncryption
.Validation fails here https://github.com/RustCrypto/RSA/blob/master/src/encoding.rs#L15-L23
pkcs1::ALGORITHM_OID
comes from https://github.com/RustCrypto/formats/blob/master/pkcs1/src/lib.rs#L55 where it is defined as1.2.840.113549.1.1.1
.Not really related but...
I believe error message "public key error: unknown/unsupported algorithm OID: 1.2.840.113549.1.1.1" is misleading as code https://github.com/RustCrypto/RSA/blob/master/src/encoding.rs#L16 asserts that oid is equal to
pkcs1::ALGORITHM_OID
.And
spki
's code isplus "public key" itself in that message does not look right to me.
The text was updated successfully, but these errors were encountered: