GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: crypto/crypto_common.h Lines: 4 4 100.0 %
Date: 2022-05-18 04:18:05 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
1389
  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
114
v8::MaybeLocal<v8::Value> GetValidTo(
115
    Environment* env,
116
    X509* cert,
117
    const BIOPointer& bio);
118
119
v8::MaybeLocal<v8::Value> GetValidFrom(
120
    Environment* env,
121
    X509* cert,
122
    const BIOPointer& bio);
123
124
v8::MaybeLocal<v8::Value> GetFingerprintDigest(
125
    Environment* env,
126
    const EVP_MD* method,
127
    X509* cert);
128
129
v8::MaybeLocal<v8::Value> GetKeyUsage(Environment* env, X509* cert);
130
131
v8::MaybeLocal<v8::Value> GetSerialNumber(Environment* env, X509* cert);
132
133
v8::MaybeLocal<v8::Object> GetRawDERCertificate(Environment* env, X509* cert);
134
135
v8::Local<v8::Value> ToV8Value(Environment* env, const BIOPointer& bio);
136
bool SafeX509SubjectAltNamePrint(const BIOPointer& out, X509_EXTENSION* ext);
137
138
v8::MaybeLocal<v8::Value> GetSubject(
139
    Environment* env,
140
    const BIOPointer& bio,
141
    X509* cert);
142
143
v8::MaybeLocal<v8::Value> GetIssuerString(
144
    Environment* env,
145
    const BIOPointer& bio,
146
    X509* cert);
147
148
v8::MaybeLocal<v8::Value> GetSubjectAltNameString(
149
    Environment* env,
150
    const BIOPointer& bio,
151
    X509* cert);
152
153
v8::MaybeLocal<v8::Value> GetInfoAccessString(
154
    Environment* env,
155
    const BIOPointer& bio,
156
    X509* cert);
157
158
}  // namespace crypto
159
}  // namespace node
160
161
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
162
163
#endif  // SRC_CRYPTO_CRYPTO_COMMON_H_