GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/crypto/crypto_context.h Lines: 3 4 75.0 %
Date: 2020-11-20 19:51:53 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_CRYPTO_CRYPTO_CONTEXT_H_
2
#define SRC_CRYPTO_CRYPTO_CONTEXT_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "crypto/crypto_util.h"
7
#include "base_object.h"
8
#include "env.h"
9
#include "memory_tracker.h"
10
#include "v8.h"
11
12
namespace node {
13
namespace crypto {
14
// A maxVersion of 0 means "any", but OpenSSL may support TLS versions that
15
// Node.js doesn't, so pin the max to what we do support.
16
constexpr int kMaxSupportedVersion = TLS1_3_VERSION;
17
18
void GetRootCertificates(
19
    const v8::FunctionCallbackInfo<v8::Value>& args);
20
21
void IsExtraRootCertsFileLoaded(
22
    const v8::FunctionCallbackInfo<v8::Value>& args);
23
24
X509_STORE* NewRootCertStore();
25
26
class SecureContext final : public BaseObject {
27
 public:
28
  using GetSessionCb = SSL_SESSION* (*)(SSL*, const unsigned char*, int, int*);
29
  using KeylogCb = void (*)(const SSL*, const char*);
30
  using NewSessionCb = int (*)(SSL*, SSL_SESSION*);
31
  using SelectSNIContextCb = int (*)(SSL*, int*, void*);
32
33
  ~SecureContext() override;
34
35
  static void Initialize(Environment* env, v8::Local<v8::Object> target);
36
37
  SSL_CTX* operator*() const { return ctx_.get(); }
38
39
  SSL_CTX* ssl_ctx() const { return ctx_.get(); }
40
41
  SSLPointer CreateSSL();
42
43
  void SetGetSessionCallback(GetSessionCb cb);
44
  void SetKeylogCallback(KeylogCb cb);
45
  void SetNewSessionCallback(NewSessionCb cb);
46
  void SetSelectSNIContextCallback(SelectSNIContextCb cb);
47
48
  // TODO(joyeecheung): track the memory used by OpenSSL types
49
1
  SET_NO_MEMORY_INFO()
50
1
  SET_MEMORY_INFO_NAME(SecureContext)
51
1
  SET_SELF_SIZE(SecureContext)
52
53
  SSLCtxPointer ctx_;
54
  X509Pointer cert_;
55
  X509Pointer issuer_;
56
#ifndef OPENSSL_NO_ENGINE
57
  bool client_cert_engine_provided_ = false;
58
  EnginePointer private_key_engine_;
59
#endif  // !OPENSSL_NO_ENGINE
60
61
  static const int kMaxSessionSize = 10 * 1024;
62
63
  // See TicketKeyCallback
64
  static const int kTicketKeyReturnIndex = 0;
65
  static const int kTicketKeyHMACIndex = 1;
66
  static const int kTicketKeyAESIndex = 2;
67
  static const int kTicketKeyNameIndex = 3;
68
  static const int kTicketKeyIVIndex = 4;
69
70
  unsigned char ticket_key_name_[16];
71
  unsigned char ticket_key_aes_[16];
72
  unsigned char ticket_key_hmac_[16];
73
74
 protected:
75
  // OpenSSL structures are opaque. This is sizeof(SSL_CTX) for OpenSSL 1.1.1b:
76
  static const int64_t kExternalSize = 1024;
77
78
  static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
79
  static void Init(const v8::FunctionCallbackInfo<v8::Value>& args);
80
  static void SetKey(const v8::FunctionCallbackInfo<v8::Value>& args);
81
#ifndef OPENSSL_NO_ENGINE
82
  static void SetEngineKey(const v8::FunctionCallbackInfo<v8::Value>& args);
83
#endif  // !OPENSSL_NO_ENGINE
84
  static void SetCert(const v8::FunctionCallbackInfo<v8::Value>& args);
85
  static void AddCACert(const v8::FunctionCallbackInfo<v8::Value>& args);
86
  static void AddCRL(const v8::FunctionCallbackInfo<v8::Value>& args);
87
  static void AddRootCerts(const v8::FunctionCallbackInfo<v8::Value>& args);
88
  static void SetCipherSuites(const v8::FunctionCallbackInfo<v8::Value>& args);
89
  static void SetCiphers(const v8::FunctionCallbackInfo<v8::Value>& args);
90
  static void SetSigalgs(const v8::FunctionCallbackInfo<v8::Value>& args);
91
  static void SetECDHCurve(const v8::FunctionCallbackInfo<v8::Value>& args);
92
  static void SetDHParam(const v8::FunctionCallbackInfo<v8::Value>& args);
93
  static void SetOptions(const v8::FunctionCallbackInfo<v8::Value>& args);
94
  static void SetSessionIdContext(
95
      const v8::FunctionCallbackInfo<v8::Value>& args);
96
  static void SetSessionTimeout(
97
      const v8::FunctionCallbackInfo<v8::Value>& args);
98
  static void SetMinProto(const v8::FunctionCallbackInfo<v8::Value>& args);
99
  static void SetMaxProto(const v8::FunctionCallbackInfo<v8::Value>& args);
100
  static void GetMinProto(const v8::FunctionCallbackInfo<v8::Value>& args);
101
  static void GetMaxProto(const v8::FunctionCallbackInfo<v8::Value>& args);
102
  static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
103
  static void LoadPKCS12(const v8::FunctionCallbackInfo<v8::Value>& args);
104
#ifndef OPENSSL_NO_ENGINE
105
  static void SetClientCertEngine(
106
      const v8::FunctionCallbackInfo<v8::Value>& args);
107
#endif  // !OPENSSL_NO_ENGINE
108
  static void GetTicketKeys(const v8::FunctionCallbackInfo<v8::Value>& args);
109
  static void SetTicketKeys(const v8::FunctionCallbackInfo<v8::Value>& args);
110
  static void SetFreeListLength(
111
      const v8::FunctionCallbackInfo<v8::Value>& args);
112
  static void EnableTicketKeyCallback(
113
      const v8::FunctionCallbackInfo<v8::Value>& args);
114
  static void CtxGetter(const v8::FunctionCallbackInfo<v8::Value>& info);
115
116
  template <bool primary>
117
  static void GetCertificate(const v8::FunctionCallbackInfo<v8::Value>& args);
118
119
  static int TicketKeyCallback(SSL* ssl,
120
                               unsigned char* name,
121
                               unsigned char* iv,
122
                               EVP_CIPHER_CTX* ectx,
123
                               HMAC_CTX* hctx,
124
                               int enc);
125
126
  static int TicketCompatibilityCallback(SSL* ssl,
127
                                         unsigned char* name,
128
                                         unsigned char* iv,
129
                                         EVP_CIPHER_CTX* ectx,
130
                                         HMAC_CTX* hctx,
131
                                         int enc);
132
133
  SecureContext(Environment* env, v8::Local<v8::Object> wrap);
134
  void Reset();
135
};
136
137
}  // namespace crypto
138
}  // namespace node
139
140
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
141
#endif  // SRC_CRYPTO_CRYPTO_CONTEXT_H_