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

pkey: refactor PEM/DER serialization code #328

Merged
merged 6 commits into from
May 13, 2020

Conversation

rhenium
Copy link
Member

@rhenium rhenium commented Feb 16, 2020

This is split from #119. This Pull Request mainly aims to reduce code duplication.

PKCS #8 formats support has been already merged by #297. I will create another Pull Request for generic pkey operations, including #generate_{key,params}, #derive, and one-shot #sign/#verify.

This probably should be merged after the v2.2.0 release.

@rhenium rhenium added this to the v3.0.0 milestone Feb 19, 2020
@rhenium rhenium force-pushed the ky/pkey-refactor-serialization branch from 23ef86b to 3cfc13b Compare April 22, 2020 12:38
ossl_{rsa,dsa,dh,ec}_new() called from this function are not used
anywhere else. Inline them into pkey_new0() and reduce code
duplication.
Merge the code into the callers so that the wrapping Ruby object is
allocated before the raw key object is allocated. This prevents possible
memory leak on Ruby object allocation failure, and also reduces the
lines of code.
Try PEM_read_bio_Parameters(). Only PEM format is supported at the
moment since corresponding d2i_* functions are not provided by OpenSSL.
Export the flow used by OpenSSL::PKey.read and let the subclasses call
it before attempting other formats.
Add ossl_pkey_export_traditional() and ossl_pkey_export_spki() helper
functions, and use them. This reduces code duplication.
@rhenium rhenium force-pushed the ky/pkey-refactor-serialization branch from 3cfc13b to 56f0d34 Compare May 13, 2020 07:17
@rhenium rhenium merged commit 2cb67d7 into ruby:master May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant