Skip to content

Commit

Permalink
crypto: use X509_ALGOR accessors instead of reaching into X509_ALGOR
Browse files Browse the repository at this point in the history
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: nodejs#50057
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
davidben authored Oct 9, 2023
1 parent 76004f3 commit f10928f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/crypto/crypto_rsa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,9 @@ Maybe<bool> 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
Expand All @@ -590,9 +592,13 @@ Maybe<bool> 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);
}
}

Expand Down

0 comments on commit f10928f

Please sign in to comment.