Skip to content

Commit ccdb6f7

Browse files
committed
pkey: assume a pkey always has public key components on OpenSSL 3.0
OpenSSL 3.0's EVP_PKEY_get0() returns NULL for provider-backed pkeys. This causes segfault because it was supposed to never return NULL before. We can't check the existence of public key components in this way on OpenSSL 3.0. Let's just skip it for now.
1 parent e168df0 commit ccdb6f7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ext/openssl/ossl_pkey.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,19 @@ ossl_pkey_s_generate_key(int argc, VALUE *argv, VALUE self)
429429
return pkey_generate(argc, argv, self, 0);
430430
}
431431

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

@@ -467,6 +477,7 @@ ossl_pkey_check_public_key(const EVP_PKEY *pkey)
467477
return;
468478
}
469479
ossl_raise(ePKeyError, "public key missing");
480+
#endif
470481
}
471482

472483
EVP_PKEY *

0 commit comments

Comments
 (0)