Skip to content
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

pkcs1 crate has no examples, no obvious way of using #1611

Open
kornelski opened this issue Nov 27, 2024 · 1 comment
Open

pkcs1 crate has no examples, no obvious way of using #1611

kornelski opened this issue Nov 27, 2024 · 1 comment

Comments

@kornelski
Copy link
Contributor

The docs for pkcs1 have no examples how to use the crate to decode an RsaPrivateKey.

The crate has a DecodeRsaPrivateKey trait, but pkcs1::RsaPrivateKey does not implement it? (or if it does, then only indirectly via a blanket impl on a pkcs8 feature in another crate???)

This seems very weird. Is that a mistake? Why is the type and trait in the same crate if they don't work together?

The only apparent way of creating pkcs1::RsaPrivateKey is via TryFrom<&[u8]> implementation, which is not mentioned anywhere, and the impl itself has zero documentation, so it needs diving into the crate's source code to discover it takes DER.

It's weird that the pkcs1 crate has a pem Cargo feature, and describes possibility of using PEM format, but as far as I can tell, PEM decoding is not supported by the crate.

@kornelski
Copy link
Contributor Author

The actual working implementation of pkcs1::DecodeRsaPrivateKey is not in this crate, only in the rsa crate, and rsa::RsaPrivateKey is a different type than pkcs1::RsaPrivateKey! In the pkcs8 crate, the equivalent of RsaPrivateKey is called PrivateKeyInfo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant