Skip to content

Commit

Permalink
pkey: assume a pkey always has public key components on OpenSSL 3.0
Browse files Browse the repository at this point in the history
Do not check the key components in this way because they are not
necessarily accessible in this way.
  • Loading branch information
rhenium committed Nov 3, 2021
1 parent de5277e commit 78a8eeb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ext/openssl/ossl_pkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,19 @@ ossl_pkey_s_generate_key(int argc, VALUE *argv, VALUE self)
return pkey_generate(argc, argv, self, 0);
}

/*
* TODO: There is no convenient way to check the presence of public key
* components on OpenSSL 3.0. But since keys are immutable on 3.0, pkeys without
* these should only be created by OpenSSL::PKey.generate_parameters or by
* parsing DER-/PEM-encoded string. We would need another flag for that.
*/
void
ossl_pkey_check_public_key(const EVP_PKEY *pkey)
{
#if OSSL_OPENSSL_PREREQ(3, 0, 0)
if (EVP_PKEY_missing_parameters(pkey))
ossl_raise(ePKeyError, "parameters missing");
#else
void *ptr;
const BIGNUM *n, *e, *pubkey;

Expand Down Expand Up @@ -471,6 +481,7 @@ ossl_pkey_check_public_key(const EVP_PKEY *pkey)
return;
}
ossl_raise(ePKeyError, "public key missing");
#endif
}

EVP_PKEY *
Expand Down

0 comments on commit 78a8eeb

Please sign in to comment.