Skip to content

pkey: use high level EVP interface to generate parameters and keys - #397

Merged
rhenium merged 5 commits into
ruby:masterfrom
rhenium:ky/pkey-refactor-generate
Apr 4, 2021
Merged

rhenium merged 5 commits into
ruby:masterfrom
rhenium:ky/pkey-refactor-generate

Conversation

@rhenium

@rhenium rhenium commented Aug 21, 2020

Copy link
Copy Markdown
Member

This pull request updates key/parameters generation methods of OpenSSL::PKey::{RSA,DSA,DH} (in other words, all but EC).

This is part of #369 (OpenSSL 3.0 support).


pkey/dh: use high level EVP interface to generate parameters and keys

Implement PKey::DH.new(size, gen), PKey::DH.generate(size, gen), and
PKey::DH#generate_key! using OpenSSL::PKey.generate_parameters and
.generate_key instead of the low level DH functions.

Note that the EVP interface can enforce additional restrictions - for
example, DH key shorter than 2048 bits is no longer supported by
default in OpenSSL 3.0. The test code is updated as such.


pkey/rsa: use high level EVP interface to generate parameters and keys

Implement PKey::RSA.new(size, exponent) and PKey::RSA.generate using
OpenSSL::PKey.generate_key instead of the low level RSA functions.


pkey/dsa: use high level EVP interface to generate parameters and keys

Implement PKey::DSA.new(size) and PKey::DSA.generate using
OpenSSL::PKey.generate_parameters and .generate_key instead of the low
level DSA functions.

@rhenium
rhenium force-pushed the ky/pkey-refactor-generate branch from 8c6f515 to 1b71851 Compare April 4, 2021 14:46
rhenium added 5 commits April 5, 2021 00:41
rb_thread_call_without_gvl() can be interrupted, but it may be able to
resume the operation. Call rb_thread_check_ints() to see if it raises
an exception or not.
Implement PKey::DH.new(size, gen), PKey::DH.generate(size, gen), and
PKey::DH#generate_key! using PKey.generate_parameters and .generate_key
instead of the low level DH functions.

Note that the EVP interface can enforce additional restrictions - for
example, DH key shorter than 2048 bits is no longer accepted by default
in OpenSSL 3.0. The test code is updated accordingly.
Implement PKey::RSA.new(size, exponent) and PKey::RSA.generate using
OpenSSL::PKey.generate_key instead of the low level RSA functions.
Implement PKey::DSA.new(size) and PKey::DSA.generate using
OpenSSL::PKey.generate_parameters and .generate_key instead of the low
level DSA functions.
The previous series of commits re-implemented key generation with the
low level API with the EVP API. The BN_GENCB-based callback function is
no longer used.
@rhenium
rhenium force-pushed the ky/pkey-refactor-generate branch from 1b71851 to 81027b7 Compare April 4, 2021 15:43
@rhenium
rhenium merged commit d172036 into ruby:master Apr 4, 2021
@rhenium rhenium mentioned this pull request Apr 13, 2021
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.

1 participant