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

Parsing rsa::pkcs1v15::Signature from DER bit string #449

Open
zhengyao-lin opened this issue Sep 30, 2024 · 3 comments
Open

Parsing rsa::pkcs1v15::Signature from DER bit string #449

zhengyao-lin opened this issue Sep 30, 2024 · 3 comments

Comments

@zhengyao-lin
Copy link

Hello! I'm trying to use this crate for verifying RSA PKCS1 signatures in X.509 certificates.

What's the best way to parse a DER BitString and get a rsa::pkcs1v15::Signature out of it? I see that there is impl SignatureBitStringEncoding for Signature to output bit string, but there doesn't seem to be anything for the inverse.

Thank you!

@tarcieri
Copy link
Member

What type is the BIT STRING represented as? Do you need to parse it first? Does it have a DER header?

@zhengyao-lin
Copy link
Author

zhengyao-lin commented Sep 30, 2024

Right now it’s a DER BIT STRING (with tag and length), but I can tweak it if needed.

@tarcieri
Copy link
Member

You can use der::asn1::BitStringRef to parse it, and as_bytes() to obtain &[u8].

In the next release we can add a TryFrom<BitStringRef<'_>> impl.

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

2 participants