GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: crypto/crypto_common.h Lines: 4 4 100.0 %
Date: 2022-06-10 04:15:47 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_CRYPTO_CRYPTO_COMMON_H_
2
#define SRC_CRYPTO_CRYPTO_COMMON_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "node_crypto.h"
7
#include "v8.h"
8
#include <openssl/ssl.h>
9
#include <openssl/x509v3.h>
10
11
#include <string>
12
13
namespace node {
14
namespace crypto {
15
16
struct StackOfX509Deleter {
17
1391
  void operator()(STACK_OF(X509)* p) const { sk_X509_pop_free(p, X509_free); }
18
};
19
using StackOfX509 = std::unique_ptr<STACK_OF(X509), StackOfX509Deleter>;
20
21
struct StackOfXASN1Deleter {
22
9
  void operator()(STACK_OF(ASN1_OBJECT)* p) const {
23
9
    sk_ASN1_OBJECT_pop_free(p, ASN1_OBJECT_free);
24
9
  }
25
};
26
using StackOfASN1 = std::unique_ptr<STACK_OF(ASN1_OBJECT), StackOfXASN1Deleter>;
27
28
X509Pointer SSL_CTX_get_issuer(SSL_CTX* ctx, X509* cert);
29
30
void LogSecret(
31
    const SSLPointer& ssl,
32
    const char* name,
33
    const unsigned char* secret,
34
    size_t secretlen);
35
36
bool SetALPN(const SSLPointer& ssl, const std::string& alpn);
37
38
bool SetALPN(const SSLPointer& ssl, v8::Local<v8::Value> alpn);
39
40
v8::MaybeLocal<v8::Value> GetSSLOCSPResponse(
41
    Environment* env,
42
    SSL* ssl,
43
    v8::Local<v8::Value> default_value);
44
45
bool SetTLSSession(
46
    const SSLPointer& ssl,
47
    const SSLSessionPointer& session);
48
49
SSLSessionPointer GetTLSSession(const unsigned char* buf, size_t length);
50
51
long VerifyPeerCertificate(  // NOLINT(runtime/int)
52
    const SSLPointer& ssl,
53
    long def = X509_V_ERR_UNSPECIFIED);  // NOLINT(runtime/int)
54
55
bool UseSNIContext(const SSLPointer& ssl, BaseObjectPtr<SecureContext> context);
56
57
const char* GetClientHelloALPN(const SSLPointer& ssl);
58
59
const char* GetClientHelloServerName(const SSLPointer& ssl);
60
61
const char* GetServerName(SSL* ssl);
62
63
v8::MaybeLocal<v8::Array> GetClientHelloCiphers(
64
    Environment* env,
65
    const SSLPointer& ssl);
66
67
bool SetGroups(SecureContext* sc, const char* groups);
68
69
const char* X509ErrorCode(long err);  // NOLINT(runtime/int)
70
71
v8::MaybeLocal<v8::Value> GetValidationErrorReason(Environment* env, int err);
72
73
v8::MaybeLocal<v8::Value> GetValidationErrorCode(Environment* env, int err);
74
75
v8::MaybeLocal<v8::Value> GetCert(Environment* env, const SSLPointer& ssl);
76
77
v8::MaybeLocal<v8::Object> GetCipherInfo(
78
    Environment* env,
79
    const SSLPointer& ssl);
80
81
v8::MaybeLocal<v8::Object> GetEphemeralKey(
82
    Environment* env,
83
    const SSLPointer& ssl);
84
85
v8::MaybeLocal<v8::Value> GetPeerCert(
86
    Environment* env,
87
    const SSLPointer& ssl,
88
    bool abbreviated = false,
89
    bool is_server = false);
90
91
v8::MaybeLocal<v8::Object> ECPointToBuffer(
92
    Environment* env,
93
    const EC_GROUP* group,
94
    const EC_POINT* point,
95
    point_conversion_form_t form,
96
    const char** error);
97
98
v8::MaybeLocal<v8::Object> X509ToObject(
99
    Environment* env,
100
    X509* cert);
101
102
v8::MaybeLocal<v8::Value> GetValidTo(
103
    Environment* env,
104
    X509* cert,
105
    const BIOPointer& bio);
106
107
v8::MaybeLocal<v8::Value> GetValidFrom(
108
    Environment* env,
109
    X509* cert,
110
    const BIOPointer& bio);
111
112
v8::MaybeLocal<v8::Value> GetFingerprintDigest(
113
    Environment* env,
114
    const EVP_MD* method,
115
    X509* cert);
116
117
v8::MaybeLocal<v8::Value> GetKeyUsage(Environment* env, X509* cert);
118
119
v8::MaybeLocal<v8::Value> GetSerialNumber(Environment* env, X509* cert);
120
121
v8::MaybeLocal<v8::Object> GetRawDERCertificate(Environment* env, X509* cert);
122
123
v8::Local<v8::Value> ToV8Value(Environment* env, const BIOPointer& bio);
124
bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext);
125
126
v8::MaybeLocal<v8::Value> GetSubject(
127
    Environment* env,
128
    const BIOPointer& bio,
129
    X509* cert);
130
131
v8::MaybeLocal<v8::Value> GetIssuerString(
132
    Environment* env,
133
    const BIOPointer& bio,
134
    X509* cert);
135
136
v8::MaybeLocal<v8::Value> GetSubjectAltNameString(
137
    Environment* env,
138
    const BIOPointer& bio,
139
    X509* cert);
140
141
v8::MaybeLocal<v8::Value> GetInfoAccessString(
142
    Environment* env,
143
    const BIOPointer& bio,
144
    X509* cert);
145
146
}  // namespace crypto
147
}  // namespace node
148
149
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
150
151
#endif  // SRC_CRYPTO_CRYPTO_COMMON_H_