Skip to content

Commit d6535d1

Browse files
committed
pkey: use EVP_PKEY_CTX_new_from_name() on OpenSSL 3.0
Replace EVP_PKEY_CTX_new_id() with the new EVP_PKEY_CTX_new_from_name() which takes the algorithm name in a string instead of in an NID.
1 parent ccdb6f7 commit d6535d1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ext/openssl/ossl_pkey.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ pkey_generate(int argc, VALUE *argv, VALUE self, int genparam)
316316
ossl_raise(ePKeyError, "EVP_PKEY_CTX_new");
317317
}
318318
else {
319+
#if OSSL_OPENSSL_PREREQ(3, 0, 0)
320+
ctx = EVP_PKEY_CTX_new_from_name(NULL, StringValueCStr(alg), NULL);
321+
if (!ctx)
322+
ossl_raise(ePKeyError, "EVP_PKEY_CTX_new_from_name");
323+
#else
319324
const EVP_PKEY_ASN1_METHOD *ameth;
320325
ENGINE *tmpeng;
321326
int pkey_id;
@@ -334,6 +339,7 @@ pkey_generate(int argc, VALUE *argv, VALUE self, int genparam)
334339
ctx = EVP_PKEY_CTX_new_id(pkey_id, NULL/* engine */);
335340
if (!ctx)
336341
ossl_raise(ePKeyError, "EVP_PKEY_CTX_new_id");
342+
#endif
337343
}
338344

339345
if (genparam && EVP_PKEY_paramgen_init(ctx) <= 0) {

0 commit comments

Comments
 (0)