@encharm/cws 4.5.1 → 4.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -5
- package/binding.gyp +1 -1
- package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Info.plist +20 -0
- package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Resources/DWARF/cws_darwin_arm64_node115.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Resources/Relocations/aarch64/cws_darwin_arm64_node115.node.yml +931 -0
- package/dist/bindings/cws_darwin_arm64_node127.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Info.plist +20 -0
- package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Resources/DWARF/cws_darwin_arm64_node127.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Resources/Relocations/aarch64/cws_darwin_arm64_node127.node.yml +931 -0
- package/dist/bindings/cws_darwin_arm64_node137.node +0 -0
- package/dist/bindings/cws_linux_x64_node137.node +0 -0
- package/dist/bindings/cws_win32_x64_node137.node +0 -0
- package/package.json +1 -1
- package/src/Addon.h +6 -1
- package/src/headers/24/acorn_version.h +6 -0
- package/src/headers/24/addon_permission.h +31 -0
- package/src/headers/24/agent.h +195 -0
- package/src/headers/24/aliased_buffer-inl.h +244 -0
- package/src/headers/24/aliased_buffer.h +206 -0
- package/src/headers/24/aliased_struct-inl.h +54 -0
- package/src/headers/24/aliased_struct.h +63 -0
- package/src/headers/24/amaro_version.h +6 -0
- package/src/headers/24/application.h +165 -0
- package/src/headers/24/async_context_frame.h +33 -0
- package/src/headers/24/async_wrap-inl.h +96 -0
- package/src/headers/24/async_wrap.h +244 -0
- package/src/headers/24/base_object-inl.h +330 -0
- package/src/headers/24/base_object.h +338 -0
- package/src/headers/24/base_object_types.h +74 -0
- package/src/headers/24/bindingdata.h +272 -0
- package/src/headers/24/blob_serializer_deserializer-inl.h +385 -0
- package/src/headers/24/blob_serializer_deserializer.h +132 -0
- package/src/headers/24/callback_queue-inl.h +97 -0
- package/src/headers/24/callback_queue.h +79 -0
- package/src/headers/24/cares_wrap.h +447 -0
- package/src/headers/24/child_process_permission.h +31 -0
- package/src/headers/24/cid.h +127 -0
- package/src/headers/24/cjs_module_lexer_version.h +6 -0
- package/src/headers/24/cleanup_queue-inl.h +36 -0
- package/src/headers/24/cleanup_queue.h +79 -0
- package/src/headers/24/compile_cache.h +113 -0
- package/src/headers/24/connect_wrap.h +26 -0
- package/src/headers/24/connection_wrap.h +30 -0
- package/src/headers/24/cppgc_helpers-inl.h +65 -0
- package/src/headers/24/cppgc_helpers.h +162 -0
- package/src/headers/24/crypto/crypto_aes.h +97 -0
- package/src/headers/24/crypto/crypto_argon2.h +86 -0
- package/src/headers/24/crypto/crypto_bio.h +193 -0
- package/src/headers/24/crypto/crypto_chacha20_poly1305.h +64 -0
- package/src/headers/24/crypto/crypto_cipher.h +281 -0
- package/src/headers/24/crypto/crypto_clienthello-inl.h +90 -0
- package/src/headers/24/crypto/crypto_clienthello.h +131 -0
- package/src/headers/24/crypto/crypto_common.h +48 -0
- package/src/headers/24/crypto/crypto_context.h +171 -0
- package/src/headers/24/crypto/crypto_dh.h +126 -0
- package/src/headers/24/crypto/crypto_dsa.h +50 -0
- package/src/headers/24/crypto/crypto_ec.h +163 -0
- package/src/headers/24/crypto/crypto_hash.h +89 -0
- package/src/headers/24/crypto/crypto_hkdf.h +61 -0
- package/src/headers/24/crypto/crypto_hmac.h +92 -0
- package/src/headers/24/crypto/crypto_kem.h +113 -0
- package/src/headers/24/crypto/crypto_keygen.h +290 -0
- package/src/headers/24/crypto/crypto_keys.h +392 -0
- package/src/headers/24/crypto/crypto_ml_dsa.h +21 -0
- package/src/headers/24/crypto/crypto_pbkdf2.h +74 -0
- package/src/headers/24/crypto/crypto_random.h +124 -0
- package/src/headers/24/crypto/crypto_rsa.h +136 -0
- package/src/headers/24/crypto/crypto_scrypt.h +85 -0
- package/src/headers/24/crypto/crypto_sig.h +156 -0
- package/src/headers/24/crypto/crypto_spkac.h +21 -0
- package/src/headers/24/crypto/crypto_timing.h +20 -0
- package/src/headers/24/crypto/crypto_tls.h +309 -0
- package/src/headers/24/crypto/crypto_util.h +598 -0
- package/src/headers/24/crypto/crypto_x509.h +140 -0
- package/src/headers/24/data.h +148 -0
- package/src/headers/24/debug_utils-inl.h +232 -0
- package/src/headers/24/debug_utils.h +193 -0
- package/src/headers/24/defs.h +254 -0
- package/src/headers/24/diagnosticfilename-inl.h +33 -0
- package/src/headers/24/embedded_data.h +17 -0
- package/src/headers/24/encoding_binding.h +60 -0
- package/src/headers/24/endpoint.h +421 -0
- package/src/headers/24/env-inl.h +935 -0
- package/src/headers/24/env.h +1257 -0
- package/src/headers/24/env_properties.h +561 -0
- package/src/headers/24/fs_permission.h +167 -0
- package/src/headers/24/handle_wrap.h +123 -0
- package/src/headers/24/histogram-inl.h +107 -0
- package/src/headers/24/histogram.h +279 -0
- package/src/headers/24/http3.h +44 -0
- package/src/headers/24/inspector_agent.h +165 -0
- package/src/headers/24/inspector_io.h +78 -0
- package/src/headers/24/inspector_permission.h +31 -0
- package/src/headers/24/inspector_profiler.h +149 -0
- package/src/headers/24/inspector_socket.h +60 -0
- package/src/headers/24/inspector_socket_server.h +110 -0
- package/src/headers/24/io_agent.h +30 -0
- package/src/headers/24/js_native_api.h +615 -0
- package/src/headers/24/js_native_api_types.h +211 -0
- package/src/headers/24/js_native_api_v8.h +485 -0
- package/src/headers/24/js_native_api_v8_internals.h +45 -0
- package/src/headers/24/js_stream.h +52 -0
- package/src/headers/24/json_parser.h +40 -0
- package/src/headers/24/json_utils.h +172 -0
- package/src/headers/24/logstream.h +81 -0
- package/src/headers/24/main_thread_interface.h +116 -0
- package/src/headers/24/memory_tracker-inl.h +454 -0
- package/src/headers/24/memory_tracker.h +333 -0
- package/src/headers/24/module_wrap.h +229 -0
- package/src/headers/24/ncrypto.h +1625 -0
- package/src/headers/24/network_agent.h +118 -0
- package/src/headers/24/network_inspector.h +45 -0
- package/src/headers/24/network_resource_manager.h +29 -0
- package/src/headers/24/node.h +1620 -0
- package/src/headers/24/node_api.h +269 -0
- package/src/headers/24/node_api_internals.h +46 -0
- package/src/headers/24/node_api_types.h +52 -0
- package/src/headers/24/node_binding.h +163 -0
- package/src/headers/24/node_blob.h +159 -0
- package/src/headers/24/node_bob-inl.h +36 -0
- package/src/headers/24/node_bob.h +107 -0
- package/src/headers/24/node_buffer.h +92 -0
- package/src/headers/24/node_builtins.h +223 -0
- package/src/headers/24/node_config_file.h +65 -0
- package/src/headers/24/node_constants.h +82 -0
- package/src/headers/24/node_context_data.h +168 -0
- package/src/headers/24/node_contextify.h +261 -0
- package/src/headers/24/node_crypto.h +62 -0
- package/src/headers/24/node_debug.h +25 -0
- package/src/headers/24/node_dir.h +52 -0
- package/src/headers/24/node_dotenv.h +45 -0
- package/src/headers/24/node_errors.h +391 -0
- package/src/headers/24/node_exit_code.h +54 -0
- package/src/headers/24/node_external_reference.h +167 -0
- package/src/headers/24/node_file-inl.h +412 -0
- package/src/headers/24/node_file.h +540 -0
- package/src/headers/24/node_http2.h +1175 -0
- package/src/headers/24/node_http2_state.h +159 -0
- package/src/headers/24/node_http_common-inl.h +198 -0
- package/src/headers/24/node_http_common.h +535 -0
- package/src/headers/24/node_i18n.h +132 -0
- package/src/headers/24/node_internals.h +476 -0
- package/src/headers/24/node_json.h +24 -0
- package/src/headers/24/node_large_page.h +34 -0
- package/src/headers/24/node_locks.h +180 -0
- package/src/headers/24/node_main_instance.h +67 -0
- package/src/headers/24/node_mem-inl.h +112 -0
- package/src/headers/24/node_mem.h +45 -0
- package/src/headers/24/node_messaging.h +389 -0
- package/src/headers/24/node_metadata.h +164 -0
- package/src/headers/24/node_modules.h +93 -0
- package/src/headers/24/node_mutex.h +323 -0
- package/src/headers/24/node_object_wrap.h +132 -0
- package/src/headers/24/node_options-inl.h +524 -0
- package/src/headers/24/node_options.h +682 -0
- package/src/headers/24/node_perf.h +166 -0
- package/src/headers/24/node_perf_common.h +102 -0
- package/src/headers/24/node_platform.h +286 -0
- package/src/headers/24/node_process-inl.h +26 -0
- package/src/headers/24/node_process.h +111 -0
- package/src/headers/24/node_realm-inl.h +153 -0
- package/src/headers/24/node_realm.h +236 -0
- package/src/headers/24/node_report.h +43 -0
- package/src/headers/24/node_revert.h +82 -0
- package/src/headers/24/node_root_certs.h +3546 -0
- package/src/headers/24/node_sea.h +74 -0
- package/src/headers/24/node_shadow_realm.h +46 -0
- package/src/headers/24/node_snapshot_builder.h +57 -0
- package/src/headers/24/node_snapshotable.h +174 -0
- package/src/headers/24/node_sockaddr-inl.h +257 -0
- package/src/headers/24/node_sockaddr.h +394 -0
- package/src/headers/24/node_sqlite.h +270 -0
- package/src/headers/24/node_stat_watcher.h +73 -0
- package/src/headers/24/node_string.h +101 -0
- package/src/headers/24/node_task_runner.h +92 -0
- package/src/headers/24/node_threadsafe_cow-inl.h +54 -0
- package/src/headers/24/node_threadsafe_cow.h +105 -0
- package/src/headers/24/node_trace_buffer.h +83 -0
- package/src/headers/24/node_trace_writer.h +75 -0
- package/src/headers/24/node_union_bytes.h +81 -0
- package/src/headers/24/node_url.h +101 -0
- package/src/headers/24/node_url_pattern.h +118 -0
- package/src/headers/24/node_v8.h +77 -0
- package/src/headers/24/node_v8_platform-inl.h +185 -0
- package/src/headers/24/node_version.h +110 -0
- package/src/headers/24/node_wasi.h +185 -0
- package/src/headers/24/node_wasm_web_api.h +55 -0
- package/src/headers/24/node_watchdog.h +154 -0
- package/src/headers/24/node_webstorage.h +60 -0
- package/src/headers/24/node_worker.h +159 -0
- package/src/headers/24/packet.h +155 -0
- package/src/headers/24/path.h +33 -0
- package/src/headers/24/permission/addon_permission.h +31 -0
- package/src/headers/24/permission/child_process_permission.h +31 -0
- package/src/headers/24/permission/fs_permission.h +167 -0
- package/src/headers/24/permission/inspector_permission.h +31 -0
- package/src/headers/24/permission/permission.h +100 -0
- package/src/headers/24/permission/permission_base.h +65 -0
- package/src/headers/24/permission/wasi_permission.h +31 -0
- package/src/headers/24/permission/worker_permission.h +31 -0
- package/src/headers/24/permission.h +100 -0
- package/src/headers/24/permission_base.h +65 -0
- package/src/headers/24/pipe_wrap.h +80 -0
- package/src/headers/24/preferredaddress.h +72 -0
- package/src/headers/24/protocol_helper.h +27 -0
- package/src/headers/24/queue.h +306 -0
- package/src/headers/24/req_wrap-inl.h +176 -0
- package/src/headers/24/req_wrap.h +79 -0
- package/src/headers/24/runtime_agent.h +41 -0
- package/src/headers/24/session.h +528 -0
- package/src/headers/24/sessionticket.h +108 -0
- package/src/headers/24/spawn_sync.h +243 -0
- package/src/headers/24/stream_base-inl.h +173 -0
- package/src/headers/24/stream_base.h +478 -0
- package/src/headers/24/stream_pipe.h +76 -0
- package/src/headers/24/stream_wrap.h +132 -0
- package/src/headers/24/streams.h +370 -0
- package/src/headers/24/string_bytes.h +109 -0
- package/src/headers/24/string_decoder-inl.h +31 -0
- package/src/headers/24/string_decoder.h +49 -0
- package/src/headers/24/target_agent.h +75 -0
- package/src/headers/24/tcp_wrap.h +105 -0
- package/src/headers/24/threadpoolwork-inl.h +70 -0
- package/src/headers/24/timer_wrap-inl.h +32 -0
- package/src/headers/24/timer_wrap.h +87 -0
- package/src/headers/24/timers.h +75 -0
- package/src/headers/24/tlscontext.h +228 -0
- package/src/headers/24/tokens.h +256 -0
- package/src/headers/24/trace_event.h +722 -0
- package/src/headers/24/trace_event_common.h +1109 -0
- package/src/headers/24/traced_value.h +129 -0
- package/src/headers/24/tracing/agent.h +195 -0
- package/src/headers/24/tracing/trace_event.h +722 -0
- package/src/headers/24/tracing_agent.h +43 -0
- package/src/headers/24/transportparams.h +166 -0
- package/src/headers/24/tty_wrap.h +65 -0
- package/src/headers/24/udp_wrap.h +230 -0
- package/src/headers/24/undici_version.h +6 -0
- package/src/headers/24/util-inl.h +711 -0
- package/src/headers/24/util.h +1016 -0
- package/src/headers/24/v8-external-memory-accounter.h +60 -0
- package/src/headers/24/v8-fast-api-calls.h +819 -0
- package/src/headers/24/v8-inspector.h +426 -0
- package/src/headers/24/wasi_permission.h +31 -0
- package/src/headers/24/worker_agent.h +40 -0
- package/src/headers/24/worker_inspector.h +124 -0
- package/src/headers/24/worker_permission.h +31 -0
- package/src/headers/24/zlib_version.h +6 -0
|
@@ -0,0 +1,89 @@
|
|
|
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 "base_object.h"
|
|
7
|
+
#include "crypto/crypto_keys.h"
|
|
8
|
+
#include "crypto/crypto_util.h"
|
|
9
|
+
#include "env.h"
|
|
10
|
+
#include "memory_tracker.h"
|
|
11
|
+
#include "v8.h"
|
|
12
|
+
|
|
13
|
+
namespace node {
|
|
14
|
+
namespace crypto {
|
|
15
|
+
class Hash final : public BaseObject {
|
|
16
|
+
public:
|
|
17
|
+
static void Initialize(Environment* env, v8::Local<v8::Object> target);
|
|
18
|
+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
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
|
+
static void GetCachedAliases(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
29
|
+
static void OneShotDigest(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
30
|
+
|
|
31
|
+
protected:
|
|
32
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
33
|
+
static void HashUpdate(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
34
|
+
static void HashDigest(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
35
|
+
|
|
36
|
+
Hash(Environment* env, v8::Local<v8::Object> wrap);
|
|
37
|
+
|
|
38
|
+
private:
|
|
39
|
+
ncrypto::EVPMDCtxPointer mdctx_{};
|
|
40
|
+
unsigned int md_len_ = 0;
|
|
41
|
+
ByteSource digest_;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
struct HashConfig final : public MemoryRetainer {
|
|
45
|
+
CryptoJobMode mode;
|
|
46
|
+
ByteSource in;
|
|
47
|
+
const EVP_MD* digest;
|
|
48
|
+
unsigned int length;
|
|
49
|
+
|
|
50
|
+
HashConfig() = default;
|
|
51
|
+
|
|
52
|
+
explicit HashConfig(HashConfig&& other) noexcept;
|
|
53
|
+
|
|
54
|
+
HashConfig& operator=(HashConfig&& other) noexcept;
|
|
55
|
+
|
|
56
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
57
|
+
SET_MEMORY_INFO_NAME(HashConfig)
|
|
58
|
+
SET_SELF_SIZE(HashConfig)
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
struct HashTraits final {
|
|
62
|
+
using AdditionalParameters = HashConfig;
|
|
63
|
+
static constexpr const char* JobName = "HashJob";
|
|
64
|
+
static constexpr AsyncWrap::ProviderType Provider =
|
|
65
|
+
AsyncWrap::PROVIDER_HASHREQUEST;
|
|
66
|
+
|
|
67
|
+
static v8::Maybe<void> AdditionalConfig(
|
|
68
|
+
CryptoJobMode mode,
|
|
69
|
+
const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
70
|
+
unsigned int offset,
|
|
71
|
+
HashConfig* params);
|
|
72
|
+
|
|
73
|
+
static bool DeriveBits(Environment* env,
|
|
74
|
+
const HashConfig& params,
|
|
75
|
+
ByteSource* out,
|
|
76
|
+
CryptoJobMode mode);
|
|
77
|
+
|
|
78
|
+
static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env,
|
|
79
|
+
const HashConfig& params,
|
|
80
|
+
ByteSource* out);
|
|
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_
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#ifndef SRC_CRYPTO_CRYPTO_HKDF_H_
|
|
2
|
+
#define SRC_CRYPTO_CRYPTO_HKDF_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "async_wrap.h"
|
|
7
|
+
#include "base_object.h"
|
|
8
|
+
#include "crypto/crypto_keys.h"
|
|
9
|
+
#include "crypto/crypto_util.h"
|
|
10
|
+
#include "v8.h"
|
|
11
|
+
|
|
12
|
+
namespace node {
|
|
13
|
+
namespace crypto {
|
|
14
|
+
struct HKDFConfig final : public MemoryRetainer {
|
|
15
|
+
CryptoJobMode mode;
|
|
16
|
+
size_t length;
|
|
17
|
+
ncrypto::Digest digest;
|
|
18
|
+
KeyObjectData key;
|
|
19
|
+
ByteSource salt;
|
|
20
|
+
ByteSource info;
|
|
21
|
+
|
|
22
|
+
HKDFConfig() = default;
|
|
23
|
+
|
|
24
|
+
explicit HKDFConfig(HKDFConfig&& other) noexcept;
|
|
25
|
+
|
|
26
|
+
HKDFConfig& operator=(HKDFConfig&& other) noexcept;
|
|
27
|
+
|
|
28
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
29
|
+
SET_MEMORY_INFO_NAME(HKDFConfig)
|
|
30
|
+
SET_SELF_SIZE(HKDFConfig)
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
struct HKDFTraits final {
|
|
34
|
+
using AdditionalParameters = HKDFConfig;
|
|
35
|
+
static constexpr const char* JobName = "HKDFJob";
|
|
36
|
+
static constexpr AsyncWrap::ProviderType Provider =
|
|
37
|
+
AsyncWrap::PROVIDER_DERIVEBITSREQUEST;
|
|
38
|
+
|
|
39
|
+
static v8::Maybe<void> AdditionalConfig(
|
|
40
|
+
CryptoJobMode mode,
|
|
41
|
+
const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
42
|
+
unsigned int offset,
|
|
43
|
+
HKDFConfig* params);
|
|
44
|
+
|
|
45
|
+
static bool DeriveBits(Environment* env,
|
|
46
|
+
const HKDFConfig& params,
|
|
47
|
+
ByteSource* out,
|
|
48
|
+
CryptoJobMode mode);
|
|
49
|
+
|
|
50
|
+
static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env,
|
|
51
|
+
const HKDFConfig& params,
|
|
52
|
+
ByteSource* out);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
using HKDFJob = DeriveBitsJob<HKDFTraits>;
|
|
56
|
+
|
|
57
|
+
} // namespace crypto
|
|
58
|
+
} // namespace node
|
|
59
|
+
|
|
60
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
61
|
+
#endif // SRC_CRYPTO_CRYPTO_HKDF_H_
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#ifndef SRC_CRYPTO_CRYPTO_HMAC_H_
|
|
2
|
+
#define SRC_CRYPTO_CRYPTO_HMAC_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "base_object.h"
|
|
7
|
+
#include "crypto/crypto_keys.h"
|
|
8
|
+
#include "crypto/crypto_sig.h"
|
|
9
|
+
#include "crypto/crypto_util.h"
|
|
10
|
+
#include "env.h"
|
|
11
|
+
#include "memory_tracker.h"
|
|
12
|
+
#include "v8.h"
|
|
13
|
+
|
|
14
|
+
namespace node {
|
|
15
|
+
namespace crypto {
|
|
16
|
+
class Hmac : public BaseObject {
|
|
17
|
+
public:
|
|
18
|
+
static void Initialize(Environment* env, v8::Local<v8::Object> target);
|
|
19
|
+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
20
|
+
|
|
21
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
22
|
+
SET_MEMORY_INFO_NAME(Hmac)
|
|
23
|
+
SET_SELF_SIZE(Hmac)
|
|
24
|
+
|
|
25
|
+
protected:
|
|
26
|
+
void HmacInit(const char* hash_type, const char* key, int key_len);
|
|
27
|
+
bool HmacUpdate(const char* data, size_t len);
|
|
28
|
+
|
|
29
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
30
|
+
static void HmacInit(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
31
|
+
static void HmacUpdate(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
32
|
+
static void HmacDigest(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
33
|
+
|
|
34
|
+
Hmac(Environment* env, v8::Local<v8::Object> wrap);
|
|
35
|
+
|
|
36
|
+
static void Sign(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
37
|
+
|
|
38
|
+
private:
|
|
39
|
+
ncrypto::HMACCtxPointer ctx_;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
struct HmacConfig final : public MemoryRetainer {
|
|
43
|
+
CryptoJobMode job_mode;
|
|
44
|
+
SignConfiguration::Mode mode;
|
|
45
|
+
KeyObjectData key;
|
|
46
|
+
ByteSource data;
|
|
47
|
+
ByteSource signature;
|
|
48
|
+
ncrypto::Digest digest;
|
|
49
|
+
|
|
50
|
+
HmacConfig() = default;
|
|
51
|
+
|
|
52
|
+
explicit HmacConfig(HmacConfig&& other) noexcept;
|
|
53
|
+
|
|
54
|
+
HmacConfig& operator=(HmacConfig&& other) noexcept;
|
|
55
|
+
|
|
56
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
57
|
+
SET_MEMORY_INFO_NAME(HmacConfig)
|
|
58
|
+
SET_SELF_SIZE(HmacConfig)
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
struct HmacTraits final {
|
|
62
|
+
using AdditionalParameters = HmacConfig;
|
|
63
|
+
static constexpr const char* JobName = "HmacJob";
|
|
64
|
+
|
|
65
|
+
// TODO(@jasnell): Sign request vs. Verify request
|
|
66
|
+
|
|
67
|
+
static constexpr AsyncWrap::ProviderType Provider =
|
|
68
|
+
AsyncWrap::PROVIDER_SIGNREQUEST;
|
|
69
|
+
|
|
70
|
+
static v8::Maybe<void> AdditionalConfig(
|
|
71
|
+
CryptoJobMode mode,
|
|
72
|
+
const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
73
|
+
unsigned int offset,
|
|
74
|
+
HmacConfig* params);
|
|
75
|
+
|
|
76
|
+
static bool DeriveBits(Environment* env,
|
|
77
|
+
const HmacConfig& params,
|
|
78
|
+
ByteSource* out,
|
|
79
|
+
CryptoJobMode mode);
|
|
80
|
+
|
|
81
|
+
static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env,
|
|
82
|
+
const HmacConfig& params,
|
|
83
|
+
ByteSource* out);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
using HmacJob = DeriveBitsJob<HmacTraits>;
|
|
87
|
+
|
|
88
|
+
} // namespace crypto
|
|
89
|
+
} // namespace node
|
|
90
|
+
|
|
91
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
92
|
+
#endif // SRC_CRYPTO_CRYPTO_HMAC_H_
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#ifndef SRC_CRYPTO_CRYPTO_KEM_H_
|
|
2
|
+
#define SRC_CRYPTO_CRYPTO_KEM_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "base_object.h"
|
|
7
|
+
#include "crypto/crypto_keys.h"
|
|
8
|
+
#include "crypto/crypto_util.h"
|
|
9
|
+
#include "env.h"
|
|
10
|
+
#include "memory_tracker.h"
|
|
11
|
+
#include "node_external_reference.h"
|
|
12
|
+
|
|
13
|
+
#if OPENSSL_VERSION_MAJOR >= 3
|
|
14
|
+
|
|
15
|
+
namespace node {
|
|
16
|
+
namespace crypto {
|
|
17
|
+
|
|
18
|
+
enum class KEMMode { Encapsulate, Decapsulate };
|
|
19
|
+
|
|
20
|
+
struct KEMConfiguration final : public MemoryRetainer {
|
|
21
|
+
CryptoJobMode job_mode;
|
|
22
|
+
KEMMode mode;
|
|
23
|
+
KeyObjectData key;
|
|
24
|
+
ByteSource ciphertext;
|
|
25
|
+
|
|
26
|
+
KEMConfiguration() = default;
|
|
27
|
+
explicit KEMConfiguration(KEMConfiguration&& other) noexcept;
|
|
28
|
+
KEMConfiguration& operator=(KEMConfiguration&& other) noexcept;
|
|
29
|
+
|
|
30
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
31
|
+
SET_MEMORY_INFO_NAME(KEMConfiguration)
|
|
32
|
+
SET_SELF_SIZE(KEMConfiguration)
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
struct KEMEncapsulateTraits final {
|
|
36
|
+
using AdditionalParameters = KEMConfiguration;
|
|
37
|
+
static constexpr const char* JobName = "KEMEncapsulateJob";
|
|
38
|
+
|
|
39
|
+
static constexpr AsyncWrap::ProviderType Provider =
|
|
40
|
+
AsyncWrap::PROVIDER_DERIVEBITSREQUEST;
|
|
41
|
+
|
|
42
|
+
static v8::Maybe<void> AdditionalConfig(
|
|
43
|
+
CryptoJobMode mode,
|
|
44
|
+
const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
45
|
+
unsigned int offset,
|
|
46
|
+
KEMConfiguration* params);
|
|
47
|
+
|
|
48
|
+
static bool DeriveBits(Environment* env,
|
|
49
|
+
const KEMConfiguration& params,
|
|
50
|
+
ByteSource* out,
|
|
51
|
+
CryptoJobMode mode);
|
|
52
|
+
|
|
53
|
+
static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env,
|
|
54
|
+
const KEMConfiguration& params,
|
|
55
|
+
ByteSource* out);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
struct KEMDecapsulateTraits final {
|
|
59
|
+
using AdditionalParameters = KEMConfiguration;
|
|
60
|
+
static constexpr const char* JobName = "KEMDecapsulateJob";
|
|
61
|
+
|
|
62
|
+
static constexpr AsyncWrap::ProviderType Provider =
|
|
63
|
+
AsyncWrap::PROVIDER_DERIVEBITSREQUEST;
|
|
64
|
+
|
|
65
|
+
static v8::Maybe<void> AdditionalConfig(
|
|
66
|
+
CryptoJobMode mode,
|
|
67
|
+
const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
68
|
+
unsigned int offset,
|
|
69
|
+
KEMConfiguration* params);
|
|
70
|
+
|
|
71
|
+
static bool DeriveBits(Environment* env,
|
|
72
|
+
const KEMConfiguration& params,
|
|
73
|
+
ByteSource* out,
|
|
74
|
+
CryptoJobMode mode);
|
|
75
|
+
|
|
76
|
+
static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env,
|
|
77
|
+
const KEMConfiguration& params,
|
|
78
|
+
ByteSource* out);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
using KEMEncapsulateJob = DeriveBitsJob<KEMEncapsulateTraits>;
|
|
82
|
+
using KEMDecapsulateJob = DeriveBitsJob<KEMDecapsulateTraits>;
|
|
83
|
+
|
|
84
|
+
void InitializeKEM(Environment* env, v8::Local<v8::Object> target);
|
|
85
|
+
void RegisterKEMExternalReferences(ExternalReferenceRegistry* registry);
|
|
86
|
+
|
|
87
|
+
namespace KEM {
|
|
88
|
+
void Initialize(Environment* env, v8::Local<v8::Object> target);
|
|
89
|
+
void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
90
|
+
} // namespace KEM
|
|
91
|
+
|
|
92
|
+
} // namespace crypto
|
|
93
|
+
} // namespace node
|
|
94
|
+
|
|
95
|
+
#else
|
|
96
|
+
|
|
97
|
+
// Provide stub implementations when OpenSSL < 3.0
|
|
98
|
+
namespace node {
|
|
99
|
+
namespace crypto {
|
|
100
|
+
namespace KEM {
|
|
101
|
+
inline void Initialize(Environment* env, v8::Local<v8::Object> target) {
|
|
102
|
+
// No-op when OpenSSL < 3.0
|
|
103
|
+
}
|
|
104
|
+
inline void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
|
|
105
|
+
// No-op when OpenSSL < 3.0
|
|
106
|
+
}
|
|
107
|
+
} // namespace KEM
|
|
108
|
+
} // namespace crypto
|
|
109
|
+
} // namespace node
|
|
110
|
+
|
|
111
|
+
#endif
|
|
112
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
113
|
+
#endif // SRC_CRYPTO_CRYPTO_KEM_H_
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
#ifndef SRC_CRYPTO_CRYPTO_KEYGEN_H_
|
|
2
|
+
#define SRC_CRYPTO_CRYPTO_KEYGEN_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "async_wrap.h"
|
|
7
|
+
#include "base_object.h"
|
|
8
|
+
#include "crypto/crypto_keys.h"
|
|
9
|
+
#include "crypto/crypto_util.h"
|
|
10
|
+
#include "env.h"
|
|
11
|
+
#include "memory_tracker.h"
|
|
12
|
+
#include "v8.h"
|
|
13
|
+
|
|
14
|
+
namespace node::crypto {
|
|
15
|
+
namespace Keygen {
|
|
16
|
+
void Initialize(Environment* env, v8::Local<v8::Object> target);
|
|
17
|
+
void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
18
|
+
} // namespace Keygen
|
|
19
|
+
|
|
20
|
+
enum class KeyGenJobStatus {
|
|
21
|
+
OK,
|
|
22
|
+
FAILED
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// A Base CryptoJob for generating secret keys or key pairs.
|
|
26
|
+
// The KeyGenTraits is largely responsible for the details of
|
|
27
|
+
// the implementation, while KeyGenJob handles the common
|
|
28
|
+
// mechanisms.
|
|
29
|
+
template <typename KeyGenTraits>
|
|
30
|
+
class KeyGenJob final : public CryptoJob<KeyGenTraits> {
|
|
31
|
+
public:
|
|
32
|
+
using AdditionalParams = typename KeyGenTraits::AdditionalParameters;
|
|
33
|
+
|
|
34
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|
35
|
+
Environment* env = Environment::GetCurrent(args);
|
|
36
|
+
CHECK(args.IsConstructCall());
|
|
37
|
+
|
|
38
|
+
CryptoJobMode mode = GetCryptoJobMode(args[0]);
|
|
39
|
+
|
|
40
|
+
unsigned int offset = 1;
|
|
41
|
+
|
|
42
|
+
AdditionalParams params;
|
|
43
|
+
if (KeyGenTraits::AdditionalConfig(mode, args, &offset, ¶ms)
|
|
44
|
+
.IsNothing()) {
|
|
45
|
+
// The KeyGenTraits::AdditionalConfig is responsible for
|
|
46
|
+
// calling an appropriate THROW_CRYPTO_* variant reporting
|
|
47
|
+
// whatever error caused initialization to fail.
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
new KeyGenJob<KeyGenTraits>(env, args.This(), mode, std::move(params));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static void Initialize(
|
|
55
|
+
Environment* env,
|
|
56
|
+
v8::Local<v8::Object> target) {
|
|
57
|
+
CryptoJob<KeyGenTraits>::Initialize(New, env, target);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
|
|
61
|
+
CryptoJob<KeyGenTraits>::RegisterExternalReferences(New, registry);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
KeyGenJob(
|
|
65
|
+
Environment* env,
|
|
66
|
+
v8::Local<v8::Object> object,
|
|
67
|
+
CryptoJobMode mode,
|
|
68
|
+
AdditionalParams&& params)
|
|
69
|
+
: CryptoJob<KeyGenTraits>(
|
|
70
|
+
env,
|
|
71
|
+
object,
|
|
72
|
+
KeyGenTraits::Provider,
|
|
73
|
+
mode,
|
|
74
|
+
std::move(params)) {}
|
|
75
|
+
|
|
76
|
+
void DoThreadPoolWork() override {
|
|
77
|
+
AdditionalParams* params = CryptoJob<KeyGenTraits>::params();
|
|
78
|
+
|
|
79
|
+
switch (KeyGenTraits::DoKeyGen(AsyncWrap::env(), params)) {
|
|
80
|
+
case KeyGenJobStatus::OK:
|
|
81
|
+
status_ = KeyGenJobStatus::OK;
|
|
82
|
+
// Success!
|
|
83
|
+
break;
|
|
84
|
+
case KeyGenJobStatus::FAILED: {
|
|
85
|
+
CryptoErrorStore* errors = CryptoJob<KeyGenTraits>::errors();
|
|
86
|
+
errors->Capture();
|
|
87
|
+
if (errors->Empty())
|
|
88
|
+
errors->Insert(NodeCryptoError::KEY_GENERATION_JOB_FAILED);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
v8::Maybe<void> ToResult(v8::Local<v8::Value>* err,
|
|
94
|
+
v8::Local<v8::Value>* result) override {
|
|
95
|
+
Environment* env = AsyncWrap::env();
|
|
96
|
+
CryptoErrorStore* errors = CryptoJob<KeyGenTraits>::errors();
|
|
97
|
+
AdditionalParams* params = CryptoJob<KeyGenTraits>::params();
|
|
98
|
+
|
|
99
|
+
if (status_ == KeyGenJobStatus::OK) {
|
|
100
|
+
v8::TryCatch try_catch(env->isolate());
|
|
101
|
+
if (KeyGenTraits::EncodeKey(env, params).ToLocal(result)) {
|
|
102
|
+
*err = Undefined(env->isolate());
|
|
103
|
+
} else {
|
|
104
|
+
CHECK(try_catch.HasCaught());
|
|
105
|
+
CHECK(try_catch.CanContinue());
|
|
106
|
+
*result = Undefined(env->isolate());
|
|
107
|
+
*err = try_catch.Exception();
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
if (errors->Empty()) errors->Capture();
|
|
111
|
+
CHECK(!errors->Empty());
|
|
112
|
+
*result = Undefined(env->isolate());
|
|
113
|
+
if (!errors->ToException(env).ToLocal(err)) {
|
|
114
|
+
return v8::Nothing<void>();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
CHECK(!result->IsEmpty());
|
|
118
|
+
CHECK(!err->IsEmpty());
|
|
119
|
+
return v8::JustVoid();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
SET_SELF_SIZE(KeyGenJob)
|
|
123
|
+
|
|
124
|
+
private:
|
|
125
|
+
KeyGenJobStatus status_ = KeyGenJobStatus::FAILED;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// A Base KeyGenTraits for Key Pair generation algorithms.
|
|
129
|
+
template <typename KeyPairAlgorithmTraits>
|
|
130
|
+
struct KeyPairGenTraits final {
|
|
131
|
+
using AdditionalParameters =
|
|
132
|
+
typename KeyPairAlgorithmTraits::AdditionalParameters;
|
|
133
|
+
|
|
134
|
+
static const AsyncWrap::ProviderType Provider =
|
|
135
|
+
AsyncWrap::PROVIDER_KEYPAIRGENREQUEST;
|
|
136
|
+
static constexpr const char* JobName = KeyPairAlgorithmTraits::JobName;
|
|
137
|
+
|
|
138
|
+
static v8::Maybe<void> AdditionalConfig(
|
|
139
|
+
CryptoJobMode mode,
|
|
140
|
+
const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
141
|
+
unsigned int* offset,
|
|
142
|
+
AdditionalParameters* params) {
|
|
143
|
+
// Notice that offset is a pointer. Each of the AdditionalConfig,
|
|
144
|
+
// GetPublicKeyEncodingFromJs, and GetPrivateKeyEncodingFromJs
|
|
145
|
+
// functions will update the value of the offset as they successfully
|
|
146
|
+
// process input parameters. This allows each job to have a variable
|
|
147
|
+
// number of input parameters specific to each job type.
|
|
148
|
+
if (KeyPairAlgorithmTraits::AdditionalConfig(mode, args, offset, params)
|
|
149
|
+
.IsNothing() ||
|
|
150
|
+
!KeyObjectData::GetPublicKeyEncodingFromJs(
|
|
151
|
+
args, offset, kKeyContextGenerate)
|
|
152
|
+
.To(¶ms->public_key_encoding) ||
|
|
153
|
+
!KeyObjectData::GetPrivateKeyEncodingFromJs(
|
|
154
|
+
args, offset, kKeyContextGenerate)
|
|
155
|
+
.To(¶ms->private_key_encoding)) {
|
|
156
|
+
return v8::Nothing<void>();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return v8::JustVoid();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static KeyGenJobStatus DoKeyGen(
|
|
163
|
+
Environment* env,
|
|
164
|
+
AdditionalParameters* params) {
|
|
165
|
+
ncrypto::EVPKeyCtxPointer ctx = KeyPairAlgorithmTraits::Setup(params);
|
|
166
|
+
|
|
167
|
+
if (!ctx)
|
|
168
|
+
return KeyGenJobStatus::FAILED;
|
|
169
|
+
|
|
170
|
+
// Generate the key
|
|
171
|
+
EVP_PKEY* pkey = nullptr;
|
|
172
|
+
if (!EVP_PKEY_keygen(ctx.get(), &pkey))
|
|
173
|
+
return KeyGenJobStatus::FAILED;
|
|
174
|
+
|
|
175
|
+
auto data = KeyObjectData::CreateAsymmetric(KeyType::kKeyTypePrivate,
|
|
176
|
+
ncrypto::EVPKeyPointer(pkey));
|
|
177
|
+
if (!data) [[unlikely]]
|
|
178
|
+
return KeyGenJobStatus::FAILED;
|
|
179
|
+
params->key = std::move(data);
|
|
180
|
+
return KeyGenJobStatus::OK;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
static v8::MaybeLocal<v8::Value> EncodeKey(Environment* env,
|
|
184
|
+
AdditionalParameters* params) {
|
|
185
|
+
v8::Local<v8::Value> keys[2];
|
|
186
|
+
if (!params->key.ToEncodedPublicKey(
|
|
187
|
+
env, params->public_key_encoding, &keys[0]) ||
|
|
188
|
+
!params->key.ToEncodedPrivateKey(
|
|
189
|
+
env, params->private_key_encoding, &keys[1])) {
|
|
190
|
+
return {};
|
|
191
|
+
}
|
|
192
|
+
return v8::Array::New(env->isolate(), keys, arraysize(keys));
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
struct SecretKeyGenConfig final : public MemoryRetainer {
|
|
197
|
+
size_t length; // In bytes.
|
|
198
|
+
ByteSource out; // Placeholder for the generated key bytes.
|
|
199
|
+
|
|
200
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
201
|
+
SET_MEMORY_INFO_NAME(SecretKeyGenConfig)
|
|
202
|
+
SET_SELF_SIZE(SecretKeyGenConfig)
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
struct SecretKeyGenTraits final {
|
|
206
|
+
using AdditionalParameters = SecretKeyGenConfig;
|
|
207
|
+
static const AsyncWrap::ProviderType Provider =
|
|
208
|
+
AsyncWrap::PROVIDER_KEYGENREQUEST;
|
|
209
|
+
static constexpr const char* JobName = "SecretKeyGenJob";
|
|
210
|
+
|
|
211
|
+
static v8::Maybe<void> AdditionalConfig(
|
|
212
|
+
CryptoJobMode mode,
|
|
213
|
+
const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
214
|
+
unsigned int* offset,
|
|
215
|
+
SecretKeyGenConfig* params);
|
|
216
|
+
|
|
217
|
+
static KeyGenJobStatus DoKeyGen(
|
|
218
|
+
Environment* env,
|
|
219
|
+
SecretKeyGenConfig* params);
|
|
220
|
+
|
|
221
|
+
static v8::MaybeLocal<v8::Value> EncodeKey(Environment* env,
|
|
222
|
+
SecretKeyGenConfig* params);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
template <typename AlgorithmParams>
|
|
226
|
+
struct KeyPairGenConfig final : public MemoryRetainer {
|
|
227
|
+
ncrypto::EVPKeyPointer::PublicKeyEncodingConfig public_key_encoding;
|
|
228
|
+
ncrypto::EVPKeyPointer::PrivateKeyEncodingConfig private_key_encoding;
|
|
229
|
+
KeyObjectData key;
|
|
230
|
+
AlgorithmParams params;
|
|
231
|
+
|
|
232
|
+
KeyPairGenConfig() = default;
|
|
233
|
+
|
|
234
|
+
explicit KeyPairGenConfig(KeyPairGenConfig&& other) noexcept
|
|
235
|
+
: public_key_encoding(other.public_key_encoding),
|
|
236
|
+
private_key_encoding(
|
|
237
|
+
std::forward<ncrypto::EVPKeyPointer::PrivateKeyEncodingConfig>(
|
|
238
|
+
other.private_key_encoding)),
|
|
239
|
+
key(std::move(other.key)),
|
|
240
|
+
params(std::move(other.params)) {}
|
|
241
|
+
|
|
242
|
+
KeyPairGenConfig& operator=(KeyPairGenConfig&& other) noexcept {
|
|
243
|
+
if (&other == this) return *this;
|
|
244
|
+
this->~KeyPairGenConfig();
|
|
245
|
+
return *new (this) KeyPairGenConfig(std::move(other));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
void MemoryInfo(MemoryTracker* tracker) const override {
|
|
249
|
+
tracker->TrackField("key", key);
|
|
250
|
+
if (private_key_encoding.passphrase.has_value()) {
|
|
251
|
+
auto& passphrase = private_key_encoding.passphrase.value();
|
|
252
|
+
tracker->TrackFieldWithSize("private_key_encoding.passphrase",
|
|
253
|
+
passphrase.size());
|
|
254
|
+
}
|
|
255
|
+
tracker->TrackField("params", params);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
SET_MEMORY_INFO_NAME(KeyPairGenConfig)
|
|
259
|
+
SET_SELF_SIZE(KeyPairGenConfig)
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
struct NidKeyPairParams final : public MemoryRetainer {
|
|
263
|
+
int id;
|
|
264
|
+
SET_NO_MEMORY_INFO()
|
|
265
|
+
SET_MEMORY_INFO_NAME(NidKeyPairParams)
|
|
266
|
+
SET_SELF_SIZE(NidKeyPairParams)
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
using NidKeyPairGenConfig = KeyPairGenConfig<NidKeyPairParams>;
|
|
270
|
+
|
|
271
|
+
struct NidKeyPairGenTraits final {
|
|
272
|
+
using AdditionalParameters = NidKeyPairGenConfig;
|
|
273
|
+
static constexpr const char* JobName = "NidKeyPairGenJob";
|
|
274
|
+
|
|
275
|
+
static ncrypto::EVPKeyCtxPointer Setup(NidKeyPairGenConfig* params);
|
|
276
|
+
|
|
277
|
+
static v8::Maybe<void> AdditionalConfig(
|
|
278
|
+
CryptoJobMode mode,
|
|
279
|
+
const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
280
|
+
unsigned int* offset,
|
|
281
|
+
NidKeyPairGenConfig* params);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
using NidKeyPairGenJob = KeyGenJob<KeyPairGenTraits<NidKeyPairGenTraits>>;
|
|
285
|
+
using SecretKeyGenJob = KeyGenJob<SecretKeyGenTraits>;
|
|
286
|
+
} // namespace node::crypto
|
|
287
|
+
|
|
288
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
289
|
+
#endif // SRC_CRYPTO_CRYPTO_KEYGEN_H_
|
|
290
|
+
|