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

Add function to parse RSA public key in PKCS1 format #11

Merged
merged 2 commits into from
May 24, 2023

Conversation

emtammaru
Copy link
Owner

There's several different ways to do this in different versions of openssl. In openssl v3, it can be done with PEM_read_RSA_PUBKEY and EVP_PKEY_get_bn_param. To support v1, I had to go digging a little further. There's an alternate function d2i_RSAPublicKey_bio, but it doesn't work for our specific format. The function d2i_RSA_PUBKEY_bio is specifically for parsing keys in PKC#1 container which is what we need.

I generated the testdata for the unit test with the following commands:

openssl genrsa -out rsa.private 1024
openssl rsa -in rsa.private -out rsa.public -pubout -outform DER

@emtammaru emtammaru requested a review from jeanniekidd May 24, 2023 19:49
@adrifern48 adrifern48 self-requested a review May 24, 2023 19:57
@emtammaru emtammaru merged commit 60a54cf into master May 24, 2023
@emtammaru emtammaru deleted the parse-rsa-pub-key branch May 24, 2023 21:45
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

Successfully merging this pull request may close these issues.

3 participants