Skip to content

Commit 966a05f

Browse files
sam-githubrefack
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: nodejs#25345 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent fea4525 commit 966a05f

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

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)