forked from nodejs/node
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrypto_hkdf.h
65 lines (50 loc) · 1.61 KB
/
crypto_hkdf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef SRC_CRYPTO_CRYPTO_HKDF_H_
#define SRC_CRYPTO_CRYPTO_HKDF_H_
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#include "async_wrap.h"
#include "base_object.h"
#include "crypto/crypto_keys.h"
#include "crypto/crypto_util.h"
#include "v8.h"
namespace node {
namespace crypto {
static constexpr size_t kMaxDigestMultiplier = 255;
struct HKDFConfig final : public MemoryRetainer {
CryptoJobMode mode;
size_t length;
const EVP_MD* digest;
std::shared_ptr<KeyObjectData> key;
ByteSource salt;
ByteSource info;
HKDFConfig() = default;
explicit HKDFConfig(HKDFConfig&& other) noexcept;
HKDFConfig& operator=(HKDFConfig&& other) noexcept;
void MemoryInfo(MemoryTracker* tracker) const override;
SET_MEMORY_INFO_NAME(HKDFConfig)
SET_SELF_SIZE(HKDFConfig)
};
struct HKDFTraits final {
using AdditionalParameters = HKDFConfig;
static constexpr const char* JobName = "HKDFJob";
static constexpr AsyncWrap::ProviderType Provider =
AsyncWrap::PROVIDER_DERIVEBITSREQUEST;
static v8::Maybe<bool> AdditionalConfig(
CryptoJobMode mode,
const v8::FunctionCallbackInfo<v8::Value>& args,
unsigned int offset,
HKDFConfig* params);
static bool DeriveBits(
Environment* env,
const HKDFConfig& params,
ByteSource* out);
static v8::Maybe<bool> EncodeOutput(
Environment* env,
const HKDFConfig& params,
ByteSource* out,
v8::Local<v8::Value>* result);
};
using HKDFJob = DeriveBitsJob<HKDFTraits>;
} // namespace crypto
} // namespace node
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#endif // SRC_CRYPTO_CRYPTO_HKDF_H_