Skip to content

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.

4 participants