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_hash.h Lines: 3 7 42.9 %
Date: 2021-04-24 04:15:50 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_CRYPTO_CRYPTO_HASH_H_
2
#define SRC_CRYPTO_CRYPTO_HASH_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "crypto/crypto_keys.h"
7
#include "crypto/crypto_util.h"
8
#include "allocated_buffer.h"
9
#include "base_object.h"
10
#include "env.h"
11
#include "memory_tracker.h"
12
#include "v8.h"
13
14
namespace node {
15
namespace crypto {
16
48802
class Hash final : public BaseObject {
17
 public:
18
  static void Initialize(Environment* env, v8::Local<v8::Object> target);
19
20
  void MemoryInfo(MemoryTracker* tracker) const override;
21
  SET_MEMORY_INFO_NAME(Hash)
22
  SET_SELF_SIZE(Hash)
23
24
  bool HashInit(const EVP_MD* md, v8::Maybe<unsigned int> xof_md_len);
25
  bool HashUpdate(const char* data, size_t len);
26
27
  static void GetHashes(const v8::FunctionCallbackInfo<v8::Value>& args);
28
29
 protected:
30
  static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
31
  static void HashUpdate(const v8::FunctionCallbackInfo<v8::Value>& args);
32
  static void HashDigest(const v8::FunctionCallbackInfo<v8::Value>& args);
33
34
  Hash(Environment* env, v8::Local<v8::Object> wrap);
35
36
 private:
37
  EVPMDPointer mdctx_ {};
38
  unsigned int md_len_ = 0;
39
  ByteSource digest_;
40
};
41
42
147
struct HashConfig final : public MemoryRetainer {
43
  CryptoJobMode mode;
44
  ByteSource in;
45
  const EVP_MD* digest;
46
  unsigned int length;
47
48
74
  HashConfig() = default;
49
50
  explicit HashConfig(HashConfig&& other) noexcept;
51
52
  HashConfig& operator=(HashConfig&& other) noexcept;
53
54
  void MemoryInfo(MemoryTracker* tracker) const override;
55
  SET_MEMORY_INFO_NAME(HashConfig);
56
  SET_SELF_SIZE(HashConfig);
57
};
58
59
struct HashTraits final {
60
  using AdditionalParameters = HashConfig;
61
  static constexpr const char* JobName = "HashJob";
62
  static constexpr AsyncWrap::ProviderType Provider =
63
      AsyncWrap::PROVIDER_HASHREQUEST;
64
65
  static v8::Maybe<bool> AdditionalConfig(
66
      CryptoJobMode mode,
67
      const v8::FunctionCallbackInfo<v8::Value>& args,
68
      unsigned int offset,
69
      HashConfig* params);
70
71
  static bool DeriveBits(
72
      Environment* env,
73
      const HashConfig& params,
74
      ByteSource* out);
75
76
  static v8::Maybe<bool> EncodeOutput(
77
      Environment* env,
78
      const HashConfig& params,
79
      ByteSource* out,
80
      v8::Local<v8::Value>* result);
81
};
82
83
using HashJob = DeriveBitsJob<HashTraits>;
84
85
}  // namespace crypto
86
}  // namespace node
87
88
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
89
#endif  // SRC_CRYPTO_CRYPTO_HASH_H_