GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: node_crypto.cc Lines: 28 30 93.3 %
Date: 2021-09-20 04:12:42 Branches: 2 6 33.3 %

Line Branch Exec Source
1
// Copyright Joyent, Inc. and other Node contributors.
2
//
3
// Permission is hereby granted, free of charge, to any person obtaining a
4
// copy of this software and associated documentation files (the
5
// "Software"), to deal in the Software without restriction, including
6
// without limitation the rights to use, copy, modify, merge, publish,
7
// distribute, sublicense, and/or sell copies of the Software, and to permit
8
// persons to whom the Software is furnished to do so, subject to the
9
// following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included
12
// in all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22
#include "node_crypto.h"
23
#include "async_wrap-inl.h"
24
#include "debug_utils-inl.h"
25
#include "threadpoolwork-inl.h"
26
#include "memory_tracker-inl.h"
27
#include "v8.h"
28
29
namespace node {
30
31
using v8::Context;
32
using v8::Local;
33
using v8::Object;
34
using v8::TryCatch;
35
using v8::Value;
36
37
namespace crypto {
38
39
4299
void Initialize(Local<Object> target,
40
                Local<Value> unused,
41
                Local<Context> context,
42
                void* priv) {
43
4299
  Environment* env = Environment::GetCurrent(context);
44
45
  static uv_once_t init_once = UV_ONCE_INIT;
46
4299
  TryCatch try_catch{env->isolate()};
47
4299
  uv_once(&init_once, InitCryptoOnce);
48

4299
  if (try_catch.HasCaught() && !try_catch.HasTerminated()) {
49
    try_catch.ReThrow();
50
    return;
51
  }
52
53
4299
  AES::Initialize(env, target);
54
4299
  CipherBase::Initialize(env, target);
55
4299
  DiffieHellman::Initialize(env, target);
56
4299
  DSAAlg::Initialize(env, target);
57
4299
  ECDH::Initialize(env, target);
58
4299
  Hash::Initialize(env, target);
59
4299
  HKDFJob::Initialize(env, target);
60
4299
  Hmac::Initialize(env, target);
61
4299
  Keygen::Initialize(env, target);
62
4299
  Keys::Initialize(env, target);
63
4299
  NativeKeyObject::Initialize(env, target);
64
4299
  PBKDF2Job::Initialize(env, target);
65
4299
  Random::Initialize(env, target);
66
4299
  RSAAlg::Initialize(env, target);
67
4299
  SecureContext::Initialize(env, target);
68
4299
  Sign::Initialize(env, target);
69
4299
  SPKAC::Initialize(env, target);
70
4299
  Timing::Initialize(env, target);
71
4299
  Util::Initialize(env, target);
72
4299
  Verify::Initialize(env, target);
73
4299
  X509Certificate::Initialize(env, target);
74
75
#ifndef OPENSSL_NO_SCRYPT
76
4299
  ScryptJob::Initialize(env, target);
77
#endif
78
}
79
80
}  // namespace crypto
81
}  // namespace node
82
83
4926
NODE_MODULE_CONTEXT_AWARE_INTERNAL(crypto, node::crypto::Initialize)