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_pbkdf2.h Lines: 4 4 100.0 %
Date: 2021-04-28 04:12:15 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_CRYPTO_CRYPTO_PBKDF2_H_
2
#define SRC_CRYPTO_CRYPTO_PBKDF2_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "crypto/crypto_util.h"
7
#include "async_wrap.h"
8
#include "env.h"
9
#include "memory_tracker.h"
10
#include "v8.h"
11
12
namespace node {
13
namespace crypto {
14
// PBKDF2 is a pseudo-random key derivation scheme defined
15
// in https://tools.ietf.org/html/rfc8018
16
//
17
// The algorithm takes as input a password and salt
18
// (both of which may, but should not be zero-length),
19
// a number of iterations, a hash digest algorithm, and
20
// an output length.
21
//
22
// The salt should be as unique as possible, and should
23
// be at least 16 bytes in length.
24
//
25
// The iteration count should be as high as possible.
26
27
349
struct PBKDF2Config final : public MemoryRetainer {
28
  CryptoJobMode mode;
29
  ByteSource pass;
30
  ByteSource salt;
31
  int32_t iterations;
32
  int32_t length;
33
  const EVP_MD* digest = nullptr;
34
35
176
  PBKDF2Config() = default;
36
37
  explicit PBKDF2Config(PBKDF2Config&& other) noexcept;
38
39
  PBKDF2Config& operator=(PBKDF2Config&& other) noexcept;
40
41
  void MemoryInfo(MemoryTracker* tracker) const override;
42
1
  SET_MEMORY_INFO_NAME(PBKDF2Config);
43
1
  SET_SELF_SIZE(PBKDF2Config);
44
};
45
46
struct PBKDF2Traits final {
47
  using AdditionalParameters = PBKDF2Config;
48
  static constexpr const char* JobName = "PBKDF2Job";
49
  static constexpr AsyncWrap::ProviderType Provider =
50
      AsyncWrap::PROVIDER_PBKDF2REQUEST;
51
52
  static v8::Maybe<bool> AdditionalConfig(
53
      CryptoJobMode mode,
54
      const v8::FunctionCallbackInfo<v8::Value>& args,
55
      unsigned int offset,
56
      PBKDF2Config* params);
57
58
  static bool DeriveBits(
59
      Environment* env,
60
      const PBKDF2Config& params,
61
      ByteSource* out);
62
63
  static v8::Maybe<bool> EncodeOutput(
64
      Environment* env,
65
      const PBKDF2Config& params,
66
      ByteSource* out,
67
      v8::Local<v8::Value>* result);
68
};
69
70
using PBKDF2Job = DeriveBitsJob<PBKDF2Traits>;
71
72
}  // namespace crypto
73
}  // namespace node
74
75
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
76
#endif  // SRC_CRYPTO_CRYPTO_PBKDF2_H_