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