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

Better support for generic PKEYs #119

Closed
wants to merge 12 commits into from

Commits on Mar 23, 2017

  1. pkey: avoid unnecessary cache of rb_intern()

    rb_intern() with a string literal caches the result. This is unnecessary
    for init functions.
    rhenium committed Mar 23, 2017
    Configuration menu
    Copy the full SHA
    7eff12d View commit details
    Browse the repository at this point in the history
  2. pkey: assume generic PKey types contain private components

    The EVP interface cannot tell whether if a pkey contains the private
    components or not. Assume it has, if the object does not respond to
    'private?'.
    rhenium committed Mar 23, 2017
    Configuration menu
    Copy the full SHA
    d1e2932 View commit details
    Browse the repository at this point in the history
  3. pkey: simplify ossl_pkey_new()

    ossl_{rsa,dsa,dh,ec}_new() called from this function are not used
    anywhere else. Inline them into pkey_new0() and reduce code
    duplication.
    rhenium committed Mar 23, 2017
    Configuration menu
    Copy the full SHA
    860ebe6 View commit details
    Browse the repository at this point in the history
  4. pkey: remove {rsa,dsa,dh,ec}_instance()

    Merge the code into the callers. They are used only once or twice.
    
    In fact, they are inconsistent and not useful - they are expected to
    return Qfalse on failure, but actually also raise NoMemoryError if a
    Ruby object allocation fails. This potentially causes memory leaks.
    rhenium committed Mar 23, 2017
    Configuration menu
    Copy the full SHA
    0342c79 View commit details
    Browse the repository at this point in the history
  5. pkey: add support for PKCS ruby#8 key serialization

    OpenSSL::PKey::PKey#private_to_der, #private_to_pem are added to the
    generic PKey class. They serialize the private key to PKCS ruby#8
    {Encrypted,}PrivateKeyInfo format, in DER- and PEM- encoding,
    respectively. For symmetry, also add #public_to_der and #public_to_pem
    that serialize the public key into X.509 SubjectPublicKeyInfo format.
    
    OpenSSL::PKey.read now reads DER-encoded PKCS ruby#8 keys as well as the
    "raw" private keys. PEM-encoded PKCS ruby#8 keys have been already handled
    by PEM_read_bio_PrivateKey().
    rhenium committed Mar 23, 2017
    Configuration menu
    Copy the full SHA
    4ce54a5 View commit details
    Browse the repository at this point in the history
  6. pkey: parse PEM-encoded DHParameter format

    Try PEM_read_bio_Parameters() in OpenSSL::PKey.read.
    rhenium committed Mar 23, 2017
    Configuration menu
    Copy the full SHA
    3322537 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    0d3130e View commit details
    Browse the repository at this point in the history
  8. pkey: refactor reading PEM or DER encoded keys code

    Let each class' initialize method use the same code as
    OpenSSL::PKey.read for loading a key from String.
    rhenium committed Mar 23, 2017
    Configuration menu
    Copy the full SHA
    c5a46d1 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    9527641 View commit details
    Browse the repository at this point in the history
  10. pkey: add OpenSSL::PKey::PKey#derive

    Add OpenSSL::PKey::PKey#derive as the wrapper for EVP_PKEY_CTX_derive().
    This is useful for pkey types that we don't have dedicated classes, such
    as X25519.
    rhenium committed Mar 23, 2017
    Configuration menu
    Copy the full SHA
    f8ecd42 View commit details
    Browse the repository at this point in the history
  11. pkey: implement DH#compute_key and EC#dh_compute_key in Ruby

    Use the new OpenSSL::PKey::PKey#derive instead of the raw
    {EC,}DH_compute_key(), mainly to reduce amount of the C code.
    rhenium committed Mar 23, 2017
    Configuration menu
    Copy the full SHA
    9516f9b View commit details
    Browse the repository at this point in the history
  12. pkey: add OpenSSL::PKey::PKey.generate_parameters and .generate_key

    Add two methods to create a PKey using the EVP interface. This can be
    useful for PKey types we don't have a dedicated class.
    rhenium committed Mar 23, 2017
    Configuration menu
    Copy the full SHA
    07653ef View commit details
    Browse the repository at this point in the history