GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: crypto/crypto_common.h Lines: 4 4 100.0 %
Date: 2022-02-10 04:15:21 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
1387
  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
int SSL_CTX_get_issuer(SSL_CTX* ctx, X509* cert, X509** issuer);
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 unsigned char* buf,
48
    size_t length);
49
50
bool SetTLSSession(
51
    const SSLPointer& ssl,
52
    const SSLSessionPointer& session);
53
54
SSLSessionPointer GetTLSSession(v8::Local<v8::Value> val);
55
56
SSLSessionPointer GetTLSSession(const unsigned char* buf, size_t length);
57
58
long VerifyPeerCertificate(  // NOLINT(runtime/int)
59
    const SSLPointer& ssl,
60
    long def = X509_V_ERR_UNSPECIFIED);  // NOLINT(runtime/int)
61
62
int UseSNIContext(const SSLPointer& ssl, BaseObjectPtr<SecureContext> context);
63
64
const char* GetClientHelloALPN(const SSLPointer& ssl);
65
66
const char* GetClientHelloServerName(const SSLPointer& ssl);
67
68
const char* GetServerName(SSL* ssl);
69
70
v8::MaybeLocal<v8::Array> GetClientHelloCiphers(
71
    Environment* env,
72
    const SSLPointer& ssl);
73
74
bool SetGroups(SecureContext* sc, const char* groups);
75
76
const char* X509ErrorCode(long err);  // NOLINT(runtime/int)
77
78
v8::MaybeLocal<v8::Value> GetValidationErrorReason(Environment* env, int err);
79
80
v8::MaybeLocal<v8::Value> GetValidationErrorCode(Environment* env, int err);
81
82
v8::MaybeLocal<v8::Value> GetCert(Environment* env, const SSLPointer& ssl);
83
84
v8::MaybeLocal<v8::Value> GetCipherName(
85
    Environment* env,
86
    const SSLPointer& ssl);
87
88
v8::MaybeLocal<v8::Value> GetCipherStandardName(
89
    Environment* env,
90
    const SSLPointer& ssl);
91
92
v8::MaybeLocal<v8::Value> GetCipherVersion(
93
    Environment* env,
94
    const SSLPointer& ssl);
95
96
v8::MaybeLocal<v8::Object> GetCipherInfo(
97
    Environment* env,
98
    const SSLPointer& ssl);
99
100
v8::MaybeLocal<v8::Object> GetEphemeralKey(
101
    Environment* env,
102
    const SSLPointer& ssl);
103
104
v8::MaybeLocal<v8::Value> GetPeerCert(
105
    Environment* env,
106
    const SSLPointer& ssl,
107
    bool abbreviated = false,
108
    bool is_server = false);
109
110
v8::MaybeLocal<v8::Object> ECPointToBuffer(
111
    Environment* env,
112
    const EC_GROUP* group,
113
    const EC_POINT* point,
114
    point_conversion_form_t form,
115
    const char** error);
116
117
v8::MaybeLocal<v8::Object> X509ToObject(
118
    Environment* env,
119
    X509* cert,
120
    bool names_as_string = false);
121
122
v8::MaybeLocal<v8::Value> GetValidTo(
123
    Environment* env,
124
    X509* cert,
125
    const BIOPointer& bio);
126
127
v8::MaybeLocal<v8::Value> GetValidFrom(
128
    Environment* env,
129
    X509* cert,
130
    const BIOPointer& bio);
131
132
v8::MaybeLocal<v8::Value> GetFingerprintDigest(
133
    Environment* env,
134
    const EVP_MD* method,
135
    X509* cert);
136
137
v8::MaybeLocal<v8::Value> GetKeyUsage(Environment* env, X509* cert);
138
139
v8::MaybeLocal<v8::Value> GetSerialNumber(Environment* env, X509* cert);
140
141
v8::MaybeLocal<v8::Object> GetRawDERCertificate(Environment* env, X509* cert);
142
143
v8::Local<v8::Value> ToV8Value(Environment* env, const BIOPointer& bio);
144
bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext);
145
146
v8::MaybeLocal<v8::Value> GetSubject(
147
    Environment* env,
148
    const BIOPointer& bio,
149
    X509* cert);
150
151
v8::MaybeLocal<v8::Value> GetIssuerString(
152
    Environment* env,
153
    const BIOPointer& bio,
154
    X509* cert);
155
156
v8::MaybeLocal<v8::Value> GetSubjectAltNameString(
157
    Environment* env,
158
    const BIOPointer& bio,
159
    X509* cert);
160
161
v8::MaybeLocal<v8::Value> GetInfoAccessString(
162
    Environment* env,
163
    const BIOPointer& bio,
164
    X509* cert);
165
166
}  // namespace crypto
167
}  // namespace node
168
169
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
170
171
#endif  // SRC_CRYPTO_CRYPTO_COMMON_H_