@encharm/cws 4.5.3 → 4.6.0
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/CHANGELOG.md +9 -0
- package/CLAUDE.md +81 -0
- package/README.md +10 -3
- package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node127.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node137.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node147.node +0 -0
- package/dist/bindings/cws_linux_arm64_node115.node +0 -0
- package/dist/bindings/cws_linux_arm64_node127.node +0 -0
- package/dist/bindings/cws_linux_arm64_node137.node +0 -0
- package/dist/bindings/cws_linux_arm64_node147.node +0 -0
- package/dist/bindings/cws_linux_x64_node115.node +0 -0
- package/dist/bindings/cws_linux_x64_node127.node +0 -0
- package/dist/bindings/cws_linux_x64_node137.node +0 -0
- package/dist/bindings/cws_linux_x64_node147.node +0 -0
- package/dist/bindings/cws_win32_x64_node115.node +0 -0
- package/dist/bindings/cws_win32_x64_node127.node +0 -0
- package/dist/bindings/cws_win32_x64_node137.node +0 -0
- package/dist/bindings/cws_win32_x64_node147.node +0 -0
- package/package.json +1 -1
- package/src/Addon.cpp +2 -1
- package/src/Addon.h +70 -14
- package/src/Hub.h +1 -0
- package/src/Networking.h +11 -0
- package/src/Socket.h +201 -6
- package/src/WebSocket.cpp +4 -1
- package/src/cSNode.cpp +2 -0
- package/src/cSNode.h +4 -0
- package/src/headers/26/acorn_version.h +6 -0
- package/src/headers/26/aliased_buffer-inl.h +264 -0
- package/src/headers/26/aliased_buffer.h +205 -0
- package/src/headers/26/aliased_struct-inl.h +143 -0
- package/src/headers/26/aliased_struct.h +248 -0
- package/src/headers/26/amaro_version.h +6 -0
- package/src/headers/26/async_context_frame.h +33 -0
- package/src/headers/26/async_wrap-inl.h +123 -0
- package/src/headers/26/async_wrap.h +254 -0
- package/src/headers/26/base_object-inl.h +333 -0
- package/src/headers/26/base_object.h +339 -0
- package/src/headers/26/base_object_types.h +76 -0
- package/src/headers/26/blob_serializer_deserializer-inl.h +385 -0
- package/src/headers/26/blob_serializer_deserializer.h +142 -0
- package/src/headers/26/builtin_info.h +57 -0
- package/src/headers/26/callback_queue-inl.h +97 -0
- package/src/headers/26/callback_queue.h +79 -0
- package/src/headers/26/cares_wrap.h +475 -0
- package/src/headers/26/cleanup_queue-inl.h +36 -0
- package/src/headers/26/cleanup_queue.h +79 -0
- package/src/headers/26/compile_cache.h +134 -0
- package/src/headers/26/connect_wrap.h +26 -0
- package/src/headers/26/connection_wrap.h +30 -0
- package/src/headers/26/cppgc_helpers-inl.h +69 -0
- package/src/headers/26/cppgc_helpers.h +162 -0
- package/src/headers/26/crypto/crypto_aes.h +107 -0
- package/src/headers/26/crypto/crypto_argon2.h +88 -0
- package/src/headers/26/crypto/crypto_bio.h +193 -0
- package/src/headers/26/crypto/crypto_chacha20_poly1305.h +62 -0
- package/src/headers/26/crypto/crypto_cipher.h +291 -0
- package/src/headers/26/crypto/crypto_common.h +48 -0
- package/src/headers/26/crypto/crypto_context.h +219 -0
- package/src/headers/26/crypto/crypto_dh.h +104 -0
- package/src/headers/26/crypto/crypto_dsa.h +50 -0
- package/src/headers/26/crypto/crypto_ec.h +102 -0
- package/src/headers/26/crypto/crypto_hash.h +157 -0
- package/src/headers/26/crypto/crypto_hkdf.h +62 -0
- package/src/headers/26/crypto/crypto_hmac.h +92 -0
- package/src/headers/26/crypto/crypto_kem.h +131 -0
- package/src/headers/26/crypto/crypto_keygen.h +382 -0
- package/src/headers/26/crypto/crypto_keys.h +366 -0
- package/src/headers/26/crypto/crypto_kmac.h +79 -0
- package/src/headers/26/crypto/crypto_pbkdf2.h +76 -0
- package/src/headers/26/crypto/crypto_pqc.h +39 -0
- package/src/headers/26/crypto/crypto_random.h +127 -0
- package/src/headers/26/crypto/crypto_rsa.h +108 -0
- package/src/headers/26/crypto/crypto_scrypt.h +85 -0
- package/src/headers/26/crypto/crypto_sig.h +159 -0
- package/src/headers/26/crypto/crypto_spkac.h +21 -0
- package/src/headers/26/crypto/crypto_timing.h +20 -0
- package/src/headers/26/crypto/crypto_tls.h +342 -0
- package/src/headers/26/crypto/crypto_turboshake.h +105 -0
- package/src/headers/26/crypto/crypto_util.h +775 -0
- package/src/headers/26/crypto/crypto_x509.h +140 -0
- package/src/headers/26/dataqueue/queue.h +311 -0
- package/src/headers/26/debug_utils-inl.h +291 -0
- package/src/headers/26/debug_utils.h +200 -0
- package/src/headers/26/diagnosticfilename-inl.h +33 -0
- package/src/headers/26/embedded_data.h +17 -0
- package/src/headers/26/encoding_binding.h +59 -0
- package/src/headers/26/env-inl.h +956 -0
- package/src/headers/26/env.h +1294 -0
- package/src/headers/26/env_properties.h +562 -0
- package/src/headers/26/ffi/data.h +30 -0
- package/src/headers/26/ffi/fast.h +96 -0
- package/src/headers/26/ffi/jit_memory.h +26 -0
- package/src/headers/26/ffi/types.h +99 -0
- package/src/headers/26/handle_wrap.h +123 -0
- package/src/headers/26/histogram-inl.h +211 -0
- package/src/headers/26/histogram.h +474 -0
- package/src/headers/26/inspector/dom_storage_agent.h +68 -0
- package/src/headers/26/inspector/inspector_object_utils.h +38 -0
- package/src/headers/26/inspector/io_agent.h +30 -0
- package/src/headers/26/inspector/main_thread_interface.h +116 -0
- package/src/headers/26/inspector/network_agent.h +110 -0
- package/src/headers/26/inspector/network_inspector.h +45 -0
- package/src/headers/26/inspector/network_requests_buffer.h +195 -0
- package/src/headers/26/inspector/network_resource_manager.h +29 -0
- package/src/headers/26/inspector/node_json.h +24 -0
- package/src/headers/26/inspector/node_string.h +101 -0
- package/src/headers/26/inspector/notification_emitter.h +38 -0
- package/src/headers/26/inspector/protocol_helper.h +27 -0
- package/src/headers/26/inspector/runtime_agent.h +41 -0
- package/src/headers/26/inspector/storage_agent.h +33 -0
- package/src/headers/26/inspector/target_agent.h +59 -0
- package/src/headers/26/inspector/target_manager.h +70 -0
- package/src/headers/26/inspector/tracing_agent.h +43 -0
- package/src/headers/26/inspector/worker_agent.h +40 -0
- package/src/headers/26/inspector/worker_inspector.h +124 -0
- package/src/headers/26/inspector_agent.h +168 -0
- package/src/headers/26/inspector_io.h +78 -0
- package/src/headers/26/inspector_profiler.h +149 -0
- package/src/headers/26/inspector_socket.h +60 -0
- package/src/headers/26/inspector_socket_server.h +110 -0
- package/src/headers/26/js_native_api.h +634 -0
- package/src/headers/26/js_native_api_types.h +244 -0
- package/src/headers/26/js_native_api_v8.h +485 -0
- package/src/headers/26/js_native_api_v8_internals.h +45 -0
- package/src/headers/26/js_stream.h +57 -0
- package/src/headers/26/json_utils.h +172 -0
- package/src/headers/26/large_pages/node_large_page.h +34 -0
- package/src/headers/26/lru_cache-inl.h +69 -0
- package/src/headers/26/memory_tracker-inl.h +461 -0
- package/src/headers/26/memory_tracker.h +341 -0
- package/src/headers/26/module_wrap.h +231 -0
- package/src/headers/26/ncrypto.h +2008 -0
- package/src/headers/26/node.h +1693 -0
- package/src/headers/26/node_api.h +265 -0
- package/src/headers/26/node_api_internals.h +48 -0
- package/src/headers/26/node_api_types.h +58 -0
- package/src/headers/26/node_binding.h +170 -0
- package/src/headers/26/node_blob.h +160 -0
- package/src/headers/26/node_bob-inl.h +36 -0
- package/src/headers/26/node_bob.h +107 -0
- package/src/headers/26/node_buffer.h +92 -0
- package/src/headers/26/node_builtins.h +239 -0
- package/src/headers/26/node_concepts.h +46 -0
- package/src/headers/26/node_config_file.h +77 -0
- package/src/headers/26/node_constants.h +82 -0
- package/src/headers/26/node_context_data.h +171 -0
- package/src/headers/26/node_contextify.h +261 -0
- package/src/headers/26/node_crypto.h +66 -0
- package/src/headers/26/node_debug.h +30 -0
- package/src/headers/26/node_diagnostics_channel.h +121 -0
- package/src/headers/26/node_dir.h +52 -0
- package/src/headers/26/node_dotenv.h +45 -0
- package/src/headers/26/node_errors.h +378 -0
- package/src/headers/26/node_exit_code.h +54 -0
- package/src/headers/26/node_external_reference.h +171 -0
- package/src/headers/26/node_ffi.h +212 -0
- package/src/headers/26/node_file-inl.h +421 -0
- package/src/headers/26/node_file.h +561 -0
- package/src/headers/26/node_file_utils.h +39 -0
- package/src/headers/26/node_hash.h +212 -0
- package/src/headers/26/node_http2.h +1202 -0
- package/src/headers/26/node_http2_state.h +159 -0
- package/src/headers/26/node_http_common-inl.h +199 -0
- package/src/headers/26/node_http_common.h +535 -0
- package/src/headers/26/node_i18n.h +132 -0
- package/src/headers/26/node_internals.h +485 -0
- package/src/headers/26/node_locks.h +184 -0
- package/src/headers/26/node_main_instance.h +67 -0
- package/src/headers/26/node_mem-inl.h +113 -0
- package/src/headers/26/node_mem.h +45 -0
- package/src/headers/26/node_messaging.h +389 -0
- package/src/headers/26/node_metadata.h +172 -0
- package/src/headers/26/node_modules.h +102 -0
- package/src/headers/26/node_mutex.h +323 -0
- package/src/headers/26/node_object_wrap.h +145 -0
- package/src/headers/26/node_options-inl.h +524 -0
- package/src/headers/26/node_options.h +710 -0
- package/src/headers/26/node_perf.h +167 -0
- package/src/headers/26/node_perf_common.h +103 -0
- package/src/headers/26/node_platform.h +290 -0
- package/src/headers/26/node_process-inl.h +26 -0
- package/src/headers/26/node_process.h +112 -0
- package/src/headers/26/node_profiling.h +38 -0
- package/src/headers/26/node_realm-inl.h +156 -0
- package/src/headers/26/node_realm.h +236 -0
- package/src/headers/26/node_report.h +43 -0
- package/src/headers/26/node_revert.h +82 -0
- package/src/headers/26/node_root_certs.h +2937 -0
- package/src/headers/26/node_sea.h +101 -0
- package/src/headers/26/node_shadow_realm.h +46 -0
- package/src/headers/26/node_snapshot_builder.h +57 -0
- package/src/headers/26/node_snapshotable.h +167 -0
- package/src/headers/26/node_sockaddr-inl.h +248 -0
- package/src/headers/26/node_sockaddr.h +459 -0
- package/src/headers/26/node_sqlite.h +607 -0
- package/src/headers/26/node_stat_watcher.h +73 -0
- package/src/headers/26/node_task_runner.h +92 -0
- package/src/headers/26/node_threadsafe_cow-inl.h +54 -0
- package/src/headers/26/node_threadsafe_cow.h +105 -0
- package/src/headers/26/node_union_bytes.h +81 -0
- package/src/headers/26/node_url.h +101 -0
- package/src/headers/26/node_url_pattern.h +118 -0
- package/src/headers/26/node_v8.h +78 -0
- package/src/headers/26/node_v8_embedder.h +26 -0
- package/src/headers/26/node_v8_platform-inl.h +96 -0
- package/src/headers/26/node_version.h +116 -0
- package/src/headers/26/node_wasi.h +184 -0
- package/src/headers/26/node_wasm_web_api.h +55 -0
- package/src/headers/26/node_watchdog.h +164 -0
- package/src/headers/26/node_webstorage.h +62 -0
- package/src/headers/26/node_worker.h +162 -0
- package/src/headers/26/path.h +36 -0
- package/src/headers/26/permission/boolean_permission.h +50 -0
- package/src/headers/26/permission/fs_permission.h +192 -0
- package/src/headers/26/permission/permission.h +155 -0
- package/src/headers/26/permission/permission_base.h +79 -0
- package/src/headers/26/pipe_wrap.h +80 -0
- package/src/headers/26/quic/application.h +279 -0
- package/src/headers/26/quic/arena.h +373 -0
- package/src/headers/26/quic/bindingdata.h +440 -0
- package/src/headers/26/quic/cid.h +127 -0
- package/src/headers/26/quic/data.h +358 -0
- package/src/headers/26/quic/defs.h +417 -0
- package/src/headers/26/quic/endpoint.h +519 -0
- package/src/headers/26/quic/guard.h +5 -0
- package/src/headers/26/quic/http3.h +25 -0
- package/src/headers/26/quic/packet.h +166 -0
- package/src/headers/26/quic/preferredaddress.h +72 -0
- package/src/headers/26/quic/session.h +770 -0
- package/src/headers/26/quic/session_manager.h +107 -0
- package/src/headers/26/quic/sessionticket.h +110 -0
- package/src/headers/26/quic/streams.h +518 -0
- package/src/headers/26/quic/tlscontext.h +353 -0
- package/src/headers/26/quic/tokens.h +263 -0
- package/src/headers/26/quic/transportparams.h +184 -0
- package/src/headers/26/req_wrap-inl.h +175 -0
- package/src/headers/26/req_wrap.h +79 -0
- package/src/headers/26/spawn_sync.h +243 -0
- package/src/headers/26/stream_base-inl.h +170 -0
- package/src/headers/26/stream_base.h +487 -0
- package/src/headers/26/stream_pipe.h +76 -0
- package/src/headers/26/stream_wrap.h +137 -0
- package/src/headers/26/string_bytes.h +114 -0
- package/src/headers/26/string_decoder-inl.h +31 -0
- package/src/headers/26/string_decoder.h +49 -0
- package/src/headers/26/tcp_wrap.h +138 -0
- package/src/headers/26/threadpoolwork-inl.h +70 -0
- package/src/headers/26/timer_wrap-inl.h +32 -0
- package/src/headers/26/timer_wrap.h +87 -0
- package/src/headers/26/timers.h +70 -0
- package/src/headers/26/tracing/agent.h +125 -0
- package/src/headers/26/tracing/agent_legacy.h +146 -0
- package/src/headers/26/tracing/agent_perfetto.h +145 -0
- package/src/headers/26/tracing/node_trace_buffer.h +91 -0
- package/src/headers/26/tracing/node_trace_writer.h +79 -0
- package/src/headers/26/tracing/trace_event.h +27 -0
- package/src/headers/26/tracing/trace_event_helper.h +40 -0
- package/src/headers/26/tracing/trace_event_legacy.h +1113 -0
- package/src/headers/26/tracing/trace_event_legacy_inl.h +711 -0
- package/src/headers/26/tracing/trace_event_perfetto.h +47 -0
- package/src/headers/26/tracing/traced_value.h +167 -0
- package/src/headers/26/tty_wrap.h +65 -0
- package/src/headers/26/udp_wrap.h +231 -0
- package/src/headers/26/undici_version.h +6 -0
- package/src/headers/26/util-inl.h +788 -0
- package/src/headers/26/util.h +1207 -0
- package/src/headers/26/v8-cpp-heap-external.h +56 -0
- package/src/headers/26/v8-external-memory-accounter.h +60 -0
- package/src/headers/26/v8-fast-api-calls.h +784 -0
- package/src/headers/26/v8-inspector-protocol.h +13 -0
- package/src/headers/26/v8-inspector.h +458 -0
- package/src/headers/26/v8-metrics.h +273 -0
- package/src/headers/26/v8-trace-categories.h +28 -0
- package/src/headers/26/v8-unwinder-state.h +30 -0
- package/src/headers/26/v8-util.h +549 -0
- package/src/headers/26/v8-value-serializer-version.h +24 -0
- package/src/headers/26/v8-version-string.h +38 -0
- package/src/headers/26/v8-wasm-trap-handler-posix.h +31 -0
- package/src/headers/26/v8-wasm-trap-handler-win.h +28 -0
- package/src/headers/26/zlib_version.h +6 -0
- package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Info.plist +0 -20
- 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 +0 -931
- package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Info.plist +0 -20
- 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 +0 -931
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#ifndef SRC_CRYPTO_CRYPTO_RSA_H_
|
|
2
|
+
#define SRC_CRYPTO_CRYPTO_RSA_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "crypto/crypto_cipher.h"
|
|
7
|
+
#include "crypto/crypto_keygen.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 {
|
|
15
|
+
namespace crypto {
|
|
16
|
+
enum RSAKeyVariant {
|
|
17
|
+
kKeyVariantRSA_SSA_PKCS1_v1_5,
|
|
18
|
+
kKeyVariantRSA_PSS,
|
|
19
|
+
kKeyVariantRSA_OAEP
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
struct RsaKeyPairParams final : public MemoryRetainer {
|
|
23
|
+
RSAKeyVariant variant;
|
|
24
|
+
unsigned int modulus_bits;
|
|
25
|
+
unsigned int exponent;
|
|
26
|
+
|
|
27
|
+
// The following options are used for RSA-PSS. If any of them are set, a
|
|
28
|
+
// RSASSA-PSS-params sequence will be added to the key.
|
|
29
|
+
ncrypto::Digest md = nullptr;
|
|
30
|
+
ncrypto::Digest mgf1_md = nullptr;
|
|
31
|
+
int saltlen = -1;
|
|
32
|
+
|
|
33
|
+
SET_NO_MEMORY_INFO()
|
|
34
|
+
SET_MEMORY_INFO_NAME(RsaKeyPairParams)
|
|
35
|
+
SET_SELF_SIZE(RsaKeyPairParams)
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
using RsaKeyPairGenConfig = KeyPairGenConfig<RsaKeyPairParams>;
|
|
39
|
+
|
|
40
|
+
struct RsaKeyGenTraits final {
|
|
41
|
+
using AdditionalParameters = RsaKeyPairGenConfig;
|
|
42
|
+
static constexpr const char* JobName = "RsaKeyPairGenJob";
|
|
43
|
+
|
|
44
|
+
static ncrypto::EVPKeyCtxPointer Setup(RsaKeyPairGenConfig* params);
|
|
45
|
+
|
|
46
|
+
static v8::Maybe<void> AdditionalConfig(
|
|
47
|
+
CryptoJobMode mode,
|
|
48
|
+
const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
49
|
+
unsigned int* offset,
|
|
50
|
+
RsaKeyPairGenConfig* params);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
using RSAKeyPairGenJob = KeyGenJob<KeyPairGenTraits<RsaKeyGenTraits>>;
|
|
54
|
+
|
|
55
|
+
struct RSACipherConfig final : public MemoryRetainer {
|
|
56
|
+
ByteSource label;
|
|
57
|
+
int padding = 0;
|
|
58
|
+
ncrypto::Digest digest;
|
|
59
|
+
|
|
60
|
+
RSACipherConfig() = default;
|
|
61
|
+
|
|
62
|
+
RSACipherConfig(RSACipherConfig&& other) noexcept;
|
|
63
|
+
|
|
64
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
65
|
+
SET_MEMORY_INFO_NAME(RSACipherConfig)
|
|
66
|
+
SET_SELF_SIZE(RSACipherConfig)
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
struct RSACipherTraits final {
|
|
70
|
+
static constexpr const char* JobName = "RSACipherJob";
|
|
71
|
+
using AdditionalParameters = RSACipherConfig;
|
|
72
|
+
|
|
73
|
+
static v8::Maybe<void> AdditionalConfig(
|
|
74
|
+
CryptoJobMode mode,
|
|
75
|
+
const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
76
|
+
unsigned int offset,
|
|
77
|
+
WebCryptoCipherMode cipher_mode,
|
|
78
|
+
RSACipherConfig* config);
|
|
79
|
+
|
|
80
|
+
static WebCryptoCipherStatus DoCipher(Environment* env,
|
|
81
|
+
const KeyObjectData& key_data,
|
|
82
|
+
WebCryptoCipherMode cipher_mode,
|
|
83
|
+
const RSACipherConfig& params,
|
|
84
|
+
const ByteSource& in,
|
|
85
|
+
ByteSource* out);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
using RSACipherJob = CipherJob<RSACipherTraits>;
|
|
89
|
+
|
|
90
|
+
bool ExportJWKRsaKey(Environment* env,
|
|
91
|
+
const KeyObjectData& key,
|
|
92
|
+
v8::Local<v8::Object> target);
|
|
93
|
+
|
|
94
|
+
KeyObjectData ImportJWKRsaKey(Environment* env, v8::Local<v8::Object> jwk);
|
|
95
|
+
|
|
96
|
+
bool GetRsaKeyDetail(Environment* env,
|
|
97
|
+
const KeyObjectData& key,
|
|
98
|
+
v8::Local<v8::Object> target);
|
|
99
|
+
|
|
100
|
+
namespace RSAAlg {
|
|
101
|
+
void Initialize(Environment* env, v8::Local<v8::Object> target);
|
|
102
|
+
void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
103
|
+
} // namespace RSAAlg
|
|
104
|
+
} // namespace crypto
|
|
105
|
+
} // namespace node
|
|
106
|
+
|
|
107
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
108
|
+
#endif // SRC_CRYPTO_CRYPTO_RSA_H_
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#ifndef SRC_CRYPTO_CRYPTO_SCRYPT_H_
|
|
2
|
+
#define SRC_CRYPTO_CRYPTO_SCRYPT_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "crypto/crypto_util.h"
|
|
7
|
+
#include "env.h"
|
|
8
|
+
#include "memory_tracker.h"
|
|
9
|
+
#include "v8.h"
|
|
10
|
+
|
|
11
|
+
namespace node {
|
|
12
|
+
namespace crypto {
|
|
13
|
+
#ifndef OPENSSL_NO_SCRYPT
|
|
14
|
+
|
|
15
|
+
// Scrypt is a password-based key derivation algorithm
|
|
16
|
+
// defined in https://tools.ietf.org/html/rfc7914
|
|
17
|
+
|
|
18
|
+
// It takes as input a password, a salt value, and a
|
|
19
|
+
// handful of additional parameters that control the
|
|
20
|
+
// cost of the operation. In this case, the higher
|
|
21
|
+
// the cost, the better the result. The length parameter
|
|
22
|
+
// defines the number of bytes that are generated.
|
|
23
|
+
|
|
24
|
+
// The salt must be as random as possible and should be
|
|
25
|
+
// at least 16 bytes in length.
|
|
26
|
+
|
|
27
|
+
struct ScryptConfig final : public MemoryRetainer {
|
|
28
|
+
ByteSource pass;
|
|
29
|
+
ByteSource salt;
|
|
30
|
+
uint32_t N;
|
|
31
|
+
uint32_t r;
|
|
32
|
+
uint32_t p;
|
|
33
|
+
uint64_t maxmem;
|
|
34
|
+
int32_t length;
|
|
35
|
+
|
|
36
|
+
ScryptConfig() = default;
|
|
37
|
+
|
|
38
|
+
explicit ScryptConfig(ScryptConfig&& other) noexcept;
|
|
39
|
+
|
|
40
|
+
ScryptConfig& operator=(ScryptConfig&& other) noexcept;
|
|
41
|
+
|
|
42
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
43
|
+
SET_MEMORY_INFO_NAME(ScryptConfig)
|
|
44
|
+
SET_SELF_SIZE(ScryptConfig)
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
struct ScryptTraits final {
|
|
48
|
+
using AdditionalParameters = ScryptConfig;
|
|
49
|
+
static constexpr const char* JobName = "ScryptJob";
|
|
50
|
+
static constexpr AsyncWrap::ProviderType Provider =
|
|
51
|
+
AsyncWrap::PROVIDER_SCRYPTREQUEST;
|
|
52
|
+
|
|
53
|
+
static v8::Maybe<void> AdditionalConfig(
|
|
54
|
+
CryptoJobMode mode,
|
|
55
|
+
const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
56
|
+
unsigned int offset,
|
|
57
|
+
ScryptConfig* params);
|
|
58
|
+
|
|
59
|
+
static bool DeriveBits(Environment* env,
|
|
60
|
+
const ScryptConfig& params,
|
|
61
|
+
ByteSource* out,
|
|
62
|
+
CryptoJobMode mode,
|
|
63
|
+
CryptoErrorStore* errors);
|
|
64
|
+
|
|
65
|
+
static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env,
|
|
66
|
+
const ScryptConfig& params,
|
|
67
|
+
ByteSource* out);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
using ScryptJob = DeriveBitsJob<ScryptTraits>;
|
|
71
|
+
|
|
72
|
+
#else
|
|
73
|
+
// If there is no Scrypt support, ScryptJob becomes a non-op
|
|
74
|
+
struct ScryptJob {
|
|
75
|
+
static void Initialize(
|
|
76
|
+
Environment* env,
|
|
77
|
+
v8::Local<v8::Object> target) {}
|
|
78
|
+
};
|
|
79
|
+
#endif // !OPENSSL_NO_SCRYPT
|
|
80
|
+
|
|
81
|
+
} // namespace crypto
|
|
82
|
+
} // namespace node
|
|
83
|
+
|
|
84
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
85
|
+
#endif // SRC_CRYPTO_CRYPTO_SCRYPT_H_
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#ifndef SRC_CRYPTO_CRYPTO_SIG_H_
|
|
2
|
+
#define SRC_CRYPTO_CRYPTO_SIG_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
|
+
|
|
12
|
+
namespace node {
|
|
13
|
+
namespace crypto {
|
|
14
|
+
static const unsigned int kNoDsaSignature = static_cast<unsigned int>(-1);
|
|
15
|
+
|
|
16
|
+
enum class DSASigEnc { DER, P1363, Invalid };
|
|
17
|
+
|
|
18
|
+
class SignBase : public BaseObject {
|
|
19
|
+
public:
|
|
20
|
+
enum class Error {
|
|
21
|
+
Ok,
|
|
22
|
+
UnknownDigest,
|
|
23
|
+
Init,
|
|
24
|
+
NotInitialised,
|
|
25
|
+
Update,
|
|
26
|
+
PrivateKey,
|
|
27
|
+
PublicKey,
|
|
28
|
+
MalformedSignature,
|
|
29
|
+
ContextUnsupported,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
SignBase(Environment* env, v8::Local<v8::Object> wrap);
|
|
33
|
+
|
|
34
|
+
Error Init(const char* digest);
|
|
35
|
+
Error Update(const char* data, size_t len);
|
|
36
|
+
|
|
37
|
+
// TODO(joyeecheung): track the memory used by OpenSSL types
|
|
38
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
39
|
+
SET_MEMORY_INFO_NAME(SignBase)
|
|
40
|
+
SET_SELF_SIZE(SignBase)
|
|
41
|
+
|
|
42
|
+
protected:
|
|
43
|
+
ncrypto::EVPMDCtxPointer mdctx_;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
class Sign final : public SignBase {
|
|
47
|
+
public:
|
|
48
|
+
static void Initialize(Environment* env, v8::Local<v8::Object> target);
|
|
49
|
+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
50
|
+
|
|
51
|
+
struct SignResult {
|
|
52
|
+
Error error;
|
|
53
|
+
std::unique_ptr<v8::BackingStore> signature;
|
|
54
|
+
|
|
55
|
+
inline explicit SignResult(
|
|
56
|
+
Error err, std::unique_ptr<v8::BackingStore>&& sig = nullptr)
|
|
57
|
+
: error(err), signature(std::move(sig)) {}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
SignResult SignFinal(const ncrypto::EVPKeyPointer& pkey,
|
|
61
|
+
int padding,
|
|
62
|
+
std::optional<int> saltlen,
|
|
63
|
+
DSASigEnc dsa_sig_enc);
|
|
64
|
+
|
|
65
|
+
static void SignSync(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
66
|
+
|
|
67
|
+
protected:
|
|
68
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
69
|
+
static void SignInit(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
70
|
+
static void SignUpdate(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
71
|
+
static void SignFinal(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
72
|
+
|
|
73
|
+
Sign(Environment* env, v8::Local<v8::Object> wrap);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
class Verify final : public SignBase {
|
|
77
|
+
public:
|
|
78
|
+
static void Initialize(Environment* env, v8::Local<v8::Object> target);
|
|
79
|
+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
80
|
+
|
|
81
|
+
Error VerifyFinal(const ncrypto::EVPKeyPointer& key,
|
|
82
|
+
const ByteSource& sig,
|
|
83
|
+
int padding,
|
|
84
|
+
std::optional<int> saltlen,
|
|
85
|
+
bool* verify_result);
|
|
86
|
+
|
|
87
|
+
static void VerifySync(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
88
|
+
|
|
89
|
+
protected:
|
|
90
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
91
|
+
static void VerifyInit(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
92
|
+
static void VerifyUpdate(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
93
|
+
static void VerifyFinal(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
94
|
+
|
|
95
|
+
Verify(Environment* env, v8::Local<v8::Object> wrap);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
struct SignConfiguration final : public MemoryRetainer {
|
|
99
|
+
enum class Mode { Sign, Verify };
|
|
100
|
+
enum Flags {
|
|
101
|
+
kHasNone = 0,
|
|
102
|
+
kHasSaltLength = 1,
|
|
103
|
+
kHasPadding = 2,
|
|
104
|
+
kHasContextString = 4
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
Mode mode;
|
|
108
|
+
KeyObjectData key;
|
|
109
|
+
ByteSource data;
|
|
110
|
+
ByteSource signature;
|
|
111
|
+
ncrypto::Digest digest;
|
|
112
|
+
int flags = SignConfiguration::kHasNone;
|
|
113
|
+
int padding = 0;
|
|
114
|
+
int salt_length = 0;
|
|
115
|
+
DSASigEnc dsa_encoding = DSASigEnc::DER;
|
|
116
|
+
ByteSource context_string;
|
|
117
|
+
|
|
118
|
+
SignConfiguration() = default;
|
|
119
|
+
|
|
120
|
+
explicit SignConfiguration(SignConfiguration&& other) noexcept;
|
|
121
|
+
|
|
122
|
+
SignConfiguration& operator=(SignConfiguration&& other) noexcept;
|
|
123
|
+
|
|
124
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
125
|
+
SET_MEMORY_INFO_NAME(SignConfiguration)
|
|
126
|
+
SET_SELF_SIZE(SignConfiguration)
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
struct SignTraits final {
|
|
130
|
+
using AdditionalParameters = SignConfiguration;
|
|
131
|
+
static constexpr const char* JobName = "SignJob";
|
|
132
|
+
|
|
133
|
+
static constexpr AsyncWrap::ProviderType Provider =
|
|
134
|
+
AsyncWrap::PROVIDER_SIGNREQUEST;
|
|
135
|
+
|
|
136
|
+
static v8::Maybe<void> AdditionalConfig(
|
|
137
|
+
CryptoJobMode mode,
|
|
138
|
+
const v8::FunctionCallbackInfo<v8::Value>& args,
|
|
139
|
+
unsigned int offset,
|
|
140
|
+
SignConfiguration* params);
|
|
141
|
+
|
|
142
|
+
static bool DeriveBits(Environment* env,
|
|
143
|
+
const SignConfiguration& params,
|
|
144
|
+
ByteSource* out,
|
|
145
|
+
CryptoJobMode mode,
|
|
146
|
+
CryptoErrorStore* errors);
|
|
147
|
+
|
|
148
|
+
static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env,
|
|
149
|
+
const SignConfiguration& params,
|
|
150
|
+
ByteSource* out);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
using SignJob = DeriveBitsJob<SignTraits>;
|
|
154
|
+
|
|
155
|
+
} // namespace crypto
|
|
156
|
+
} // namespace node
|
|
157
|
+
|
|
158
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
159
|
+
#endif // SRC_CRYPTO_CRYPTO_SIG_H_
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#ifndef SRC_CRYPTO_CRYPTO_SPKAC_H_
|
|
2
|
+
#define SRC_CRYPTO_CRYPTO_SPKAC_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "env.h"
|
|
7
|
+
#include "v8.h"
|
|
8
|
+
|
|
9
|
+
#include <openssl/evp.h>
|
|
10
|
+
|
|
11
|
+
namespace node {
|
|
12
|
+
namespace crypto {
|
|
13
|
+
namespace SPKAC {
|
|
14
|
+
void Initialize(Environment* env, v8::Local<v8::Object>);
|
|
15
|
+
void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
16
|
+
} // namespace SPKAC
|
|
17
|
+
} // namespace crypto
|
|
18
|
+
} // namespace node
|
|
19
|
+
|
|
20
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
21
|
+
#endif // SRC_CRYPTO_CRYPTO_SPKAC_H_
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#ifndef SRC_CRYPTO_CRYPTO_TIMING_H_
|
|
2
|
+
#define SRC_CRYPTO_CRYPTO_TIMING_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "env.h"
|
|
7
|
+
#include "v8.h"
|
|
8
|
+
|
|
9
|
+
namespace node {
|
|
10
|
+
namespace crypto {
|
|
11
|
+
namespace Timing {
|
|
12
|
+
void Initialize(Environment* env, v8::Local<v8::Object> target);
|
|
13
|
+
void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
14
|
+
} // namespace Timing
|
|
15
|
+
} // namespace crypto
|
|
16
|
+
} // namespace node
|
|
17
|
+
|
|
18
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
19
|
+
|
|
20
|
+
#endif // SRC_CRYPTO_CRYPTO_TIMING_H_
|