Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author3nprob <3nprob@3nprob>2021-08-30 09:31:28 +0300
committerTobias Nießen <tniessen@tnie.de>2021-11-10 17:26:28 +0300
commit79d681501d592eceaef104c8ed43856158d8cf1e (patch)
treebab65094b697e4ce56c3bd643e4cf831144d271e /src/crypto
parent5e0dd79a3c111ae62712e22512de5ae18f9bcf9f (diff)
src: add x509.fingerprint512 to crypto module
PR-URL: https://github.com/nodejs/node/pull/39809 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/crypto_common.cc4
-rw-r--r--src/crypto/crypto_x509.cc10
-rw-r--r--src/crypto/crypto_x509.h1
3 files changed, 15 insertions, 0 deletions
diff --git a/src/crypto/crypto_common.cc b/src/crypto/crypto_common.cc
index cc03fddd464..8b3abc6f47c 100644
--- a/src/crypto/crypto_common.cc
+++ b/src/crypto/crypto_common.cc
@@ -1105,6 +1105,10 @@ MaybeLocal<Object> X509ToObject(Environment* env, X509* cert) {
GetFingerprintDigest(env, EVP_sha256(), cert)) ||
!Set<Value>(context,
info,
+ env->fingerprint512_string(),
+ GetFingerprintDigest(env, EVP_sha512(), cert)) ||
+ !Set<Value>(context,
+ info,
env->ext_key_usage_string(),
GetKeyUsage(env, cert)) ||
!Set<Value>(context,
diff --git a/src/crypto/crypto_x509.cc b/src/crypto/crypto_x509.cc
index cb34003c4dd..f2fa18b5b6b 100644
--- a/src/crypto/crypto_x509.cc
+++ b/src/crypto/crypto_x509.cc
@@ -68,6 +68,7 @@ Local<FunctionTemplate> X509Certificate::GetConstructorTemplate(
env->SetProtoMethod(tmpl, "validFrom", ValidFrom);
env->SetProtoMethod(tmpl, "fingerprint", Fingerprint);
env->SetProtoMethod(tmpl, "fingerprint256", Fingerprint256);
+ env->SetProtoMethod(tmpl, "fingerprint512", Fingerprint512);
env->SetProtoMethod(tmpl, "keyUsage", KeyUsage);
env->SetProtoMethod(tmpl, "serialNumber", SerialNumber);
env->SetProtoMethod(tmpl, "pem", Pem);
@@ -268,6 +269,15 @@ void X509Certificate::Fingerprint256(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(ret);
}
+void X509Certificate::Fingerprint512(const FunctionCallbackInfo<Value>& args) {
+ Environment* env = Environment::GetCurrent(args);
+ X509Certificate* cert;
+ ASSIGN_OR_RETURN_UNWRAP(&cert, args.Holder());
+ Local<Value> ret;
+ if (GetFingerprintDigest(env, EVP_sha512(), cert->get()).ToLocal(&ret))
+ args.GetReturnValue().Set(ret);
+}
+
void X509Certificate::KeyUsage(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
X509Certificate* cert;
diff --git a/src/crypto/crypto_x509.h b/src/crypto/crypto_x509.h
index cd7f529b476..751e6e8cf4b 100644
--- a/src/crypto/crypto_x509.h
+++ b/src/crypto/crypto_x509.h
@@ -81,6 +81,7 @@ class X509Certificate : public BaseObject {
static void ValidTo(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Fingerprint(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Fingerprint256(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void Fingerprint512(const v8::FunctionCallbackInfo<v8::Value>& args);
static void KeyUsage(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SerialNumber(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Raw(const v8::FunctionCallbackInfo<v8::Value>& args);