From 9704e98224403b667b6da2afe5487eb04b3d084f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Thu, 24 Feb 2022 17:36:49 +0000 Subject: [PATCH] src: combine GetCurveASN1Name and GetCurveNistName --- src/crypto/crypto_common.cc | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/crypto/crypto_common.cc b/src/crypto/crypto_common.cc index dce0774e8fa632..22b06cdf62a0a8 100644 --- a/src/crypto/crypto_common.cc +++ b/src/crypto/crypto_common.cc @@ -452,17 +452,11 @@ void AddFingerprintDigest( } } -MaybeLocal GetCurveASN1Name(Environment* env, const int nid) { - const char* nist = OBJ_nid2sn(nid); - return nist != nullptr ? - MaybeLocal(OneByteString(env->isolate(), nist)) : - MaybeLocal(Undefined(env->isolate())); -} - -MaybeLocal GetCurveNistName(Environment* env, const int nid) { - const char* nist = EC_curve_nid2nist(nid); - return nist != nullptr ? - MaybeLocal(OneByteString(env->isolate(), nist)) : +template +MaybeLocal GetCurveName(Environment* env, const int nid) { + const char* name = nid2string(nid); + return name != nullptr ? + MaybeLocal(OneByteString(env->isolate(), name)) : MaybeLocal(Undefined(env->isolate())); } @@ -1413,11 +1407,11 @@ MaybeLocal X509ToObject( if (!Set(context, info, env->asn1curve_string(), - GetCurveASN1Name(env, nid)) || + GetCurveName(env, nid)) || !Set(context, info, env->nistcurve_string(), - GetCurveNistName(env, nid))) { + GetCurveName(env, nid))) { return MaybeLocal(); } } else {