镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Commit 5b93356

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 <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 7d1d261 commit 5b93356

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
@@ -1721,21 +1721,18 @@ static Local<Object> X509ToObject(Environment* env, X509* cert) {
17211721
CHECK_NULL(pub);
17221722
}
17231723

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

1727-
int nid = EC_GROUP_get_curve_name(group);
1728-
if (nid != 0) {
1729-
if (const char* sn = OBJ_nid2sn(nid)) {
1730-
info->Set(context, env->asn1curve_string(),
1731-
OneByteString(env->isolate(), sn)).FromJust();
1732-
}
1728+
if (const char* sn = OBJ_nid2sn(nid)) {
1729+
info->Set(context, env->asn1curve_string(),
1730+
OneByteString(env->isolate(), sn)).FromJust();
17331731
}
1734-
if (nid != 0) {
1735-
if (const char* nist = EC_curve_nid2nist(nid)) {
1736-
info->Set(context, env->nistcurve_string(),
1737-
OneByteString(env->isolate(), nist)).FromJust();
1738-
}
1732+
1733+
if (const char* nist = EC_curve_nid2nist(nid)) {
1734+
info->Set(context, env->nistcurve_string(),
1735+
OneByteString(env->isolate(), nist)).FromJust();
17391736
}
17401737
} else {
17411738
// Unnamed curves can be described by their mathematical properties,

0 commit comments

Comments
 (0)