From f10928f92636ee67f7b5ef3737523f428fb5ca00 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 9 Oct 2023 09:41:01 -0400 Subject: [PATCH] crypto: use X509_ALGOR accessors instead of reaching into X509_ALGOR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While the struct is still public in OpenSSL, there is a (somewhat inconvenient) accessor. Use it to remain compatible if it becomes opaque in the future. PR-URL: https://github.com/nodejs/node/pull/50057 Reviewed-By: Ben Noordhuis Reviewed-By: Tobias Nießen --- src/crypto/crypto_rsa.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/crypto/crypto_rsa.cc b/src/crypto/crypto_rsa.cc index 3f8499457cf107..f222ab9cf5ccbc 100644 --- a/src/crypto/crypto_rsa.cc +++ b/src/crypto/crypto_rsa.cc @@ -577,7 +577,9 @@ Maybe GetRsaKeyDetail( int64_t salt_length = 20; if (params->hashAlgorithm != nullptr) { - hash_nid = OBJ_obj2nid(params->hashAlgorithm->algorithm); + const ASN1_OBJECT* hash_obj; + X509_ALGOR_get0(&hash_obj, nullptr, nullptr, params->hashAlgorithm); + hash_nid = OBJ_obj2nid(hash_obj); } if (target @@ -590,9 +592,13 @@ Maybe GetRsaKeyDetail( } if (params->maskGenAlgorithm != nullptr) { - mgf_nid = OBJ_obj2nid(params->maskGenAlgorithm->algorithm); + const ASN1_OBJECT* mgf_obj; + X509_ALGOR_get0(&mgf_obj, nullptr, nullptr, params->maskGenAlgorithm); + mgf_nid = OBJ_obj2nid(mgf_obj); if (mgf_nid == NID_mgf1) { - mgf1_hash_nid = OBJ_obj2nid(params->maskHash->algorithm); + const ASN1_OBJECT* mgf1_hash_obj; + X509_ALGOR_get0(&mgf1_hash_obj, nullptr, nullptr, params->maskHash); + mgf1_hash_nid = OBJ_obj2nid(mgf1_hash_obj); } }