GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: crypto/crypto_common.h Lines: 4 4 100.0 %
Date: 2022-03-03 04:14:50 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
bool 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 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::Value> GetCipherName(
78
    Environment* env,
79
    const SSLPointer& ssl);
80
81
v8::MaybeLocal<v8::Value> GetCipherStandardName(
82
    Environment* env,
83
    const SSLPointer& ssl);
84
85
v8::MaybeLocal<v8::Value> GetCipherVersion(
86
    Environment* env,
87
    const SSLPointer& ssl);
88
89
v8::MaybeLocal<v8::Object> GetCipherInfo(
90
    Environment* env,
91
    const SSLPointer& ssl);
92
93
v8::MaybeLocal<v8::Object> GetEphemeralKey(
94
    Environment* env,
95
    const SSLPointer& ssl);
96
97
v8::MaybeLocal<v8::Value> GetPeerCert(
98
    Environment* env,
99
    const SSLPointer& ssl,
100
    bool abbreviated = false,
101
    bool is_server = false);
102
103
v8::MaybeLocal<v8::Object> ECPointToBuffer(
104
    Environment* env,
105
    const EC_GROUP* group,
106
    const EC_POINT* point,
107
    point_conversion_form_t form,
108
    const char** error);
109
110
v8::MaybeLocal<v8::Object> X509ToObject(
111
    Environment* env,
112
    X509* cert,
113
    bool names_as_string = false);
114
115
v8::MaybeLocal<v8::Value> GetValidTo(
116
    Environment* env,
117
    X509* cert,
118
    const BIOPointer& bio);
119
120
v8::MaybeLocal<v8::Value> GetValidFrom(
121
    Environment* env,
122
    X509* cert,
123
    const BIOPointer& bio);
124
125
v8::MaybeLocal<v8::Value> GetFingerprintDigest(
126
    Environment* env,
127
    const EVP_MD* method,
128
    X509* cert);
129
130
v8::MaybeLocal<v8::Value> GetKeyUsage(Environment* env, X509* cert);
131
132
v8::MaybeLocal<v8::Value> GetSerialNumber(Environment* env, X509* cert);
133
134
v8::MaybeLocal<v8::Object> GetRawDERCertificate(Environment* env, X509* cert);
135
136
v8::Local<v8::Value> ToV8Value(Environment* env, const BIOPointer& bio);
137
bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext);
138
139
v8::MaybeLocal<v8::Value> GetSubject(
140
    Environment* env,
141
    const BIOPointer& bio,
142
    X509* cert);
143
144
v8::MaybeLocal<v8::Value> GetIssuerString(
145
    Environment* env,
146
    const BIOPointer& bio,
147
    X509* cert);
148
149
v8::MaybeLocal<v8::Value> GetSubjectAltNameString(
150
    Environment* env,
151
    const BIOPointer& bio,
152
    X509* cert);
153
154
v8::MaybeLocal<v8::Value> GetInfoAccessString(
155
    Environment* env,
156
    const BIOPointer& bio,
157
    X509* cert);
158
159
}  // namespace crypto
160
}  // namespace node
161
162
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
163
164
#endif  // SRC_CRYPTO_CRYPTO_COMMON_H_