[前][次][番号順一覧][スレッド一覧]

ruby-changes:70369

From: Kazuki <ko1@a...>
Date: Tue, 21 Dec 2021 00:11:37 +0900 (JST)
Subject: [ruby-changes:70369] ac757b218c (master): [ruby/openssl] pkey: use EVP_PKEY_CTX_new_from_name() on OpenSSL 3.0

https://git.ruby-lang.org/ruby.git/commit/?id=ac757b218c

From ac757b218c66569be6789144b149d6d798c72d98 Mon Sep 17 00:00:00 2001
From: Kazuki Yamaguchi <k@r...>
Date: Mon, 12 Apr 2021 10:43:46 +0900
Subject: [ruby/openssl] 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.

https://github.com/ruby/openssl/commit/d6535d13d1
---
 ext/openssl/ossl_pkey.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c
index 09d45d85ca8..2a4835a28d0 100644
--- a/ext/openssl/ossl_pkey.c
+++ b/ext/openssl/ossl_pkey.c
@@ -316,6 +316,11 @@ pkey_generate(int argc, VALUE *argv, VALUE self, int genparam) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkey.c#L316
             ossl_raise(ePKeyError, "EVP_PKEY_CTX_new");
     }
     else {
+#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+        ctx = EVP_PKEY_CTX_new_from_name(NULL, StringValueCStr(alg), NULL);
+        if (!ctx)
+            ossl_raise(ePKeyError, "EVP_PKEY_CTX_new_from_name");
+#else
         const EVP_PKEY_ASN1_METHOD *ameth;
         ENGINE *tmpeng;
         int pkey_id;
@@ -334,6 +339,7 @@ pkey_generate(int argc, VALUE *argv, VALUE self, int genparam) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_pkey.c#L339
         ctx = EVP_PKEY_CTX_new_id(pkey_id, NULL/* engine */);
         if (!ctx)
             ossl_raise(ePKeyError, "EVP_PKEY_CTX_new_id");
+#endif
     }
 
     if (genparam && EVP_PKEY_paramgen_init(ctx) <= 0) {
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]