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_x509.h Lines: 7 14 50.0 %
Date: 2021-01-16 04:10:54 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_CRYPTO_CRYPTO_X509_H_
2
#define SRC_CRYPTO_CRYPTO_X509_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "base_object.h"
7
#include "crypto/crypto_util.h"
8
#include "env.h"
9
#include "memory_tracker.h"
10
#include "node_worker.h"
11
#include "v8.h"
12
13
namespace node {
14
namespace crypto {
15
16
// The ManagedX509 class is essentially a smart pointer for
17
// X509 objects that allows an X509Certificate instance to
18
// be cloned at the JS level while pointing at the same
19
// underlying X509 instance.
20
4
class ManagedX509 : public MemoryRetainer {
21
 public:
22
  ManagedX509() = default;
23
  explicit ManagedX509(X509Pointer&& cert);
24
  ManagedX509(const ManagedX509& that);
25
  ManagedX509& operator=(const ManagedX509& that);
26
27
  operator bool() const { return !!cert_; }
28
33
  X509* get() const { return cert_.get(); }
29
30
  void MemoryInfo(MemoryTracker* tracker) const override;
31
  SET_MEMORY_INFO_NAME(ManagedX509)
32
  SET_SELF_SIZE(ManagedX509)
33
34
 private:
35
  X509Pointer cert_;
36
};
37
38
6
class X509Certificate : public BaseObject {
39
 public:
40
  enum class GetPeerCertificateFlag {
41
    ABBREVIATED,
42
    SERVER
43
  };
44
45
  static void Initialize(Environment* env, v8::Local<v8::Object> target);
46
  static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
47
      Environment* env);
48
  static bool HasInstance(Environment* env, v8::Local<v8::Object> object);
49
50
  static v8::MaybeLocal<v8::Object> New(
51
      Environment* env,
52
      X509Pointer cert);
53
54
  static v8::MaybeLocal<v8::Object> New(
55
      Environment* env,
56
      std::shared_ptr<ManagedX509> cert);
57
58
  static v8::MaybeLocal<v8::Object> GetCert(
59
      Environment* env,
60
      const SSLPointer& ssl);
61
62
  static v8::MaybeLocal<v8::Object> GetPeerCert(
63
      Environment* env,
64
      const SSLPointer& ssl,
65
      GetPeerCertificateFlag flag);
66
67
  static v8::Local<v8::Object> Wrap(
68
      Environment* env,
69
      v8::Local<v8::Object> object,
70
      X509Pointer cert);
71
72
  static void Parse(const v8::FunctionCallbackInfo<v8::Value>& args);
73
  static void Subject(const v8::FunctionCallbackInfo<v8::Value>& args);
74
  static void SubjectAltName(const v8::FunctionCallbackInfo<v8::Value>& args);
75
  static void Issuer(const v8::FunctionCallbackInfo<v8::Value>& args);
76
  static void InfoAccess(const v8::FunctionCallbackInfo<v8::Value>& args);
77
  static void ValidFrom(const v8::FunctionCallbackInfo<v8::Value>& args);
78
  static void ValidTo(const v8::FunctionCallbackInfo<v8::Value>& args);
79
  static void Fingerprint(const v8::FunctionCallbackInfo<v8::Value>& args);
80
  static void Fingerprint256(const v8::FunctionCallbackInfo<v8::Value>& args);
81
  static void KeyUsage(const v8::FunctionCallbackInfo<v8::Value>& args);
82
  static void SerialNumber(const v8::FunctionCallbackInfo<v8::Value>& args);
83
  static void Raw(const v8::FunctionCallbackInfo<v8::Value>& args);
84
  static void PublicKey(const v8::FunctionCallbackInfo<v8::Value>& args);
85
  static void Pem(const v8::FunctionCallbackInfo<v8::Value>& args);
86
  static void CheckCA(const v8::FunctionCallbackInfo<v8::Value>& args);
87
  static void CheckHost(const v8::FunctionCallbackInfo<v8::Value>& args);
88
  static void CheckEmail(const v8::FunctionCallbackInfo<v8::Value>& args);
89
  static void CheckIP(const v8::FunctionCallbackInfo<v8::Value>& args);
90
  static void CheckIssued(const v8::FunctionCallbackInfo<v8::Value>& args);
91
  static void CheckPrivateKey(const v8::FunctionCallbackInfo<v8::Value>& args);
92
  static void Verify(const v8::FunctionCallbackInfo<v8::Value>& args);
93
  static void ToLegacy(const v8::FunctionCallbackInfo<v8::Value>& args);
94
95
33
  X509* get() { return cert_->get(); }
96
97
  void MemoryInfo(MemoryTracker* tracker) const override;
98
  SET_MEMORY_INFO_NAME(X509Certificate);
99
  SET_SELF_SIZE(X509Certificate);
100
101
2
  class X509CertificateTransferData : public worker::TransferData {
102
   public:
103
1
    explicit X509CertificateTransferData(
104
        const std::shared_ptr<ManagedX509>& data)
105
1
        : data_(data) {}
106
107
    BaseObjectPtr<BaseObject> Deserialize(
108
        Environment* env,
109
        v8::Local<v8::Context> context,
110
        std::unique_ptr<worker::TransferData> self) override;
111
112
    SET_MEMORY_INFO_NAME(X509CertificateTransferData)
113
    SET_SELF_SIZE(X509CertificateTransferData)
114
    SET_NO_MEMORY_INFO()
115
116
   private:
117
    std::shared_ptr<ManagedX509> data_;
118
  };
119
120
  BaseObject::TransferMode GetTransferMode() const override;
121
  std::unique_ptr<worker::TransferData> CloneForMessaging() const override;
122
123
 private:
124
  X509Certificate(
125
      Environment* env,
126
      v8::Local<v8::Object> object,
127
      std::shared_ptr<ManagedX509> cert);
128
129
  std::shared_ptr<ManagedX509> cert_;
130
};
131
132
}  // namespace crypto
133
}  // namespace node
134
135
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
136
#endif  // SRC_CRYPTO_CRYPTO_X509_H_