Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit aa582fd

Browse files
sam-githubnornagon
authored andcommitted
[cherry-pick] 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/node#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 803f35c commit aa582fd

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
@@ -1756,21 +1756,18 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
17561756
CHECK_NULL(pub);
17571757
}
17581758
1759-
if (EC_GROUP_get_asn1_flag(group) != 0) {
1759+
const int nid = EC_GROUP_get_curve_name(group);
1760+
if (nid != 0) {
17601761
// Curve is well-known, get its OID and NIST nick-name (if it has one).
17611762
1762-
int nid = EC_GROUP_get_curve_name(group);
1763-
if (nid != 0) {
1764-
if (const char* sn = OBJ_nid2sn(nid)) {
1765-
info->Set(context, env->asn1curve_string(),
1766-
OneByteString(env->isolate(), sn)).FromJust();
1767-
}
1763+
if (const char* sn = OBJ_nid2sn(nid)) {
1764+
info->Set(context, env->asn1curve_string(),
1765+
OneByteString(env->isolate(), sn)).FromJust();
17681766
}
1769-
if (nid != 0) {
1770-
if (const char* nist = EC_curve_nid2nist(nid)) {
1771-
info->Set(context, env->nistcurve_string(),
1772-
OneByteString(env->isolate(), nist)).FromJust();
1773-
}
1767+
1768+
if (const char* nist = EC_curve_nid2nist(nid)) {
1769+
info->Set(context, env->nistcurve_string(),
1770+
OneByteString(env->isolate(), nist)).FromJust();
17741771
}
17751772
} else {
17761773
// Unnamed curves can be described by their mathematical properties,

0 commit comments

Comments
 (0)