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