Skip to content

Commit 4a6ec3b

Browse files
sam-githubaddaleax
authored andcommitted
src: check curve ID existence instead of asn flags
Simplify the code. The flag check was in the OpenSSL source, but reading through the docs and source, it is not necessary. Refs: https://github.com/nodejs/node/pull/24358/files#r243099693 PR-URL: #25345 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent bf3cb3f commit 4a6ec3b

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/node_crypto.cc

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,21 +1738,18 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
17381738
CHECK_NULL(pub);
17391739
}
17401740

1741-
if (EC_GROUP_get_asn1_flag(group) != 0) {
1741+
const int nid = EC_GROUP_get_curve_name(group);
1742+
if (nid != 0) {
17421743
// Curve is well-known, get its OID and NIST nick-name (if it has one).
17431744

1744-
int nid = EC_GROUP_get_curve_name(group);
1745-
if (nid != 0) {
1746-
if (const char* sn = OBJ_nid2sn(nid)) {
1747-
info->Set(context, env->asn1curve_string(),
1748-
OneByteString(env->isolate(), sn)).FromJust();
1749-
}
1745+
if (const char* sn = OBJ_nid2sn(nid)) {
1746+
info->Set(context, env->asn1curve_string(),
1747+
OneByteString(env->isolate(), sn)).FromJust();
17501748
}
1751-
if (nid != 0) {
1752-
if (const char* nist = EC_curve_nid2nist(nid)) {
1753-
info->Set(context, env->nistcurve_string(),
1754-
OneByteString(env->isolate(), nist)).FromJust();
1755-
}
1749+
1750+
if (const char* nist = EC_curve_nid2nist(nid)) {
1751+
info->Set(context, env->nistcurve_string(),
1752+
OneByteString(env->isolate(), nist)).FromJust();
17561753
}
17571754
} else {
17581755
// Unnamed curves can be described by their mathematical properties,

0 commit comments

Comments
 (0)