@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.
Files changed (249) hide show
  1. package/README.md +3 -5
  2. package/binding.gyp +1 -1
  3. package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
  4. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Info.plist +20 -0
  5. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Resources/DWARF/cws_darwin_arm64_node115.node +0 -0
  6. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Resources/Relocations/aarch64/cws_darwin_arm64_node115.node.yml +931 -0
  7. package/dist/bindings/cws_darwin_arm64_node127.node +0 -0
  8. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Info.plist +20 -0
  9. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Resources/DWARF/cws_darwin_arm64_node127.node +0 -0
  10. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Resources/Relocations/aarch64/cws_darwin_arm64_node127.node.yml +931 -0
  11. package/dist/bindings/cws_darwin_arm64_node137.node +0 -0
  12. package/dist/bindings/cws_linux_x64_node137.node +0 -0
  13. package/dist/bindings/cws_win32_x64_node137.node +0 -0
  14. package/package.json +1 -1
  15. package/src/Addon.h +6 -1
  16. package/src/headers/24/acorn_version.h +6 -0
  17. package/src/headers/24/addon_permission.h +31 -0
  18. package/src/headers/24/agent.h +195 -0
  19. package/src/headers/24/aliased_buffer-inl.h +244 -0
  20. package/src/headers/24/aliased_buffer.h +206 -0
  21. package/src/headers/24/aliased_struct-inl.h +54 -0
  22. package/src/headers/24/aliased_struct.h +63 -0
  23. package/src/headers/24/amaro_version.h +6 -0
  24. package/src/headers/24/application.h +165 -0
  25. package/src/headers/24/async_context_frame.h +33 -0
  26. package/src/headers/24/async_wrap-inl.h +96 -0
  27. package/src/headers/24/async_wrap.h +244 -0
  28. package/src/headers/24/base_object-inl.h +330 -0
  29. package/src/headers/24/base_object.h +338 -0
  30. package/src/headers/24/base_object_types.h +74 -0
  31. package/src/headers/24/bindingdata.h +272 -0
  32. package/src/headers/24/blob_serializer_deserializer-inl.h +385 -0
  33. package/src/headers/24/blob_serializer_deserializer.h +132 -0
  34. package/src/headers/24/callback_queue-inl.h +97 -0
  35. package/src/headers/24/callback_queue.h +79 -0
  36. package/src/headers/24/cares_wrap.h +447 -0
  37. package/src/headers/24/child_process_permission.h +31 -0
  38. package/src/headers/24/cid.h +127 -0
  39. package/src/headers/24/cjs_module_lexer_version.h +6 -0
  40. package/src/headers/24/cleanup_queue-inl.h +36 -0
  41. package/src/headers/24/cleanup_queue.h +79 -0
  42. package/src/headers/24/compile_cache.h +113 -0
  43. package/src/headers/24/connect_wrap.h +26 -0
  44. package/src/headers/24/connection_wrap.h +30 -0
  45. package/src/headers/24/cppgc_helpers-inl.h +65 -0
  46. package/src/headers/24/cppgc_helpers.h +162 -0
  47. package/src/headers/24/crypto/crypto_aes.h +97 -0
  48. package/src/headers/24/crypto/crypto_argon2.h +86 -0
  49. package/src/headers/24/crypto/crypto_bio.h +193 -0
  50. package/src/headers/24/crypto/crypto_chacha20_poly1305.h +64 -0
  51. package/src/headers/24/crypto/crypto_cipher.h +281 -0
  52. package/src/headers/24/crypto/crypto_clienthello-inl.h +90 -0
  53. package/src/headers/24/crypto/crypto_clienthello.h +131 -0
  54. package/src/headers/24/crypto/crypto_common.h +48 -0
  55. package/src/headers/24/crypto/crypto_context.h +171 -0
  56. package/src/headers/24/crypto/crypto_dh.h +126 -0
  57. package/src/headers/24/crypto/crypto_dsa.h +50 -0
  58. package/src/headers/24/crypto/crypto_ec.h +163 -0
  59. package/src/headers/24/crypto/crypto_hash.h +89 -0
  60. package/src/headers/24/crypto/crypto_hkdf.h +61 -0
  61. package/src/headers/24/crypto/crypto_hmac.h +92 -0
  62. package/src/headers/24/crypto/crypto_kem.h +113 -0
  63. package/src/headers/24/crypto/crypto_keygen.h +290 -0
  64. package/src/headers/24/crypto/crypto_keys.h +392 -0
  65. package/src/headers/24/crypto/crypto_ml_dsa.h +21 -0
  66. package/src/headers/24/crypto/crypto_pbkdf2.h +74 -0
  67. package/src/headers/24/crypto/crypto_random.h +124 -0
  68. package/src/headers/24/crypto/crypto_rsa.h +136 -0
  69. package/src/headers/24/crypto/crypto_scrypt.h +85 -0
  70. package/src/headers/24/crypto/crypto_sig.h +156 -0
  71. package/src/headers/24/crypto/crypto_spkac.h +21 -0
  72. package/src/headers/24/crypto/crypto_timing.h +20 -0
  73. package/src/headers/24/crypto/crypto_tls.h +309 -0
  74. package/src/headers/24/crypto/crypto_util.h +598 -0
  75. package/src/headers/24/crypto/crypto_x509.h +140 -0
  76. package/src/headers/24/data.h +148 -0
  77. package/src/headers/24/debug_utils-inl.h +232 -0
  78. package/src/headers/24/debug_utils.h +193 -0
  79. package/src/headers/24/defs.h +254 -0
  80. package/src/headers/24/diagnosticfilename-inl.h +33 -0
  81. package/src/headers/24/embedded_data.h +17 -0
  82. package/src/headers/24/encoding_binding.h +60 -0
  83. package/src/headers/24/endpoint.h +421 -0
  84. package/src/headers/24/env-inl.h +935 -0
  85. package/src/headers/24/env.h +1257 -0
  86. package/src/headers/24/env_properties.h +561 -0
  87. package/src/headers/24/fs_permission.h +167 -0
  88. package/src/headers/24/handle_wrap.h +123 -0
  89. package/src/headers/24/histogram-inl.h +107 -0
  90. package/src/headers/24/histogram.h +279 -0
  91. package/src/headers/24/http3.h +44 -0
  92. package/src/headers/24/inspector_agent.h +165 -0
  93. package/src/headers/24/inspector_io.h +78 -0
  94. package/src/headers/24/inspector_permission.h +31 -0
  95. package/src/headers/24/inspector_profiler.h +149 -0
  96. package/src/headers/24/inspector_socket.h +60 -0
  97. package/src/headers/24/inspector_socket_server.h +110 -0
  98. package/src/headers/24/io_agent.h +30 -0
  99. package/src/headers/24/js_native_api.h +615 -0
  100. package/src/headers/24/js_native_api_types.h +211 -0
  101. package/src/headers/24/js_native_api_v8.h +485 -0
  102. package/src/headers/24/js_native_api_v8_internals.h +45 -0
  103. package/src/headers/24/js_stream.h +52 -0
  104. package/src/headers/24/json_parser.h +40 -0
  105. package/src/headers/24/json_utils.h +172 -0
  106. package/src/headers/24/logstream.h +81 -0
  107. package/src/headers/24/main_thread_interface.h +116 -0
  108. package/src/headers/24/memory_tracker-inl.h +454 -0
  109. package/src/headers/24/memory_tracker.h +333 -0
  110. package/src/headers/24/module_wrap.h +229 -0
  111. package/src/headers/24/ncrypto.h +1625 -0
  112. package/src/headers/24/network_agent.h +118 -0
  113. package/src/headers/24/network_inspector.h +45 -0
  114. package/src/headers/24/network_resource_manager.h +29 -0
  115. package/src/headers/24/node.h +1620 -0
  116. package/src/headers/24/node_api.h +269 -0
  117. package/src/headers/24/node_api_internals.h +46 -0
  118. package/src/headers/24/node_api_types.h +52 -0
  119. package/src/headers/24/node_binding.h +163 -0
  120. package/src/headers/24/node_blob.h +159 -0
  121. package/src/headers/24/node_bob-inl.h +36 -0
  122. package/src/headers/24/node_bob.h +107 -0
  123. package/src/headers/24/node_buffer.h +92 -0
  124. package/src/headers/24/node_builtins.h +223 -0
  125. package/src/headers/24/node_config_file.h +65 -0
  126. package/src/headers/24/node_constants.h +82 -0
  127. package/src/headers/24/node_context_data.h +168 -0
  128. package/src/headers/24/node_contextify.h +261 -0
  129. package/src/headers/24/node_crypto.h +62 -0
  130. package/src/headers/24/node_debug.h +25 -0
  131. package/src/headers/24/node_dir.h +52 -0
  132. package/src/headers/24/node_dotenv.h +45 -0
  133. package/src/headers/24/node_errors.h +391 -0
  134. package/src/headers/24/node_exit_code.h +54 -0
  135. package/src/headers/24/node_external_reference.h +167 -0
  136. package/src/headers/24/node_file-inl.h +412 -0
  137. package/src/headers/24/node_file.h +540 -0
  138. package/src/headers/24/node_http2.h +1175 -0
  139. package/src/headers/24/node_http2_state.h +159 -0
  140. package/src/headers/24/node_http_common-inl.h +198 -0
  141. package/src/headers/24/node_http_common.h +535 -0
  142. package/src/headers/24/node_i18n.h +132 -0
  143. package/src/headers/24/node_internals.h +476 -0
  144. package/src/headers/24/node_json.h +24 -0
  145. package/src/headers/24/node_large_page.h +34 -0
  146. package/src/headers/24/node_locks.h +180 -0
  147. package/src/headers/24/node_main_instance.h +67 -0
  148. package/src/headers/24/node_mem-inl.h +112 -0
  149. package/src/headers/24/node_mem.h +45 -0
  150. package/src/headers/24/node_messaging.h +389 -0
  151. package/src/headers/24/node_metadata.h +164 -0
  152. package/src/headers/24/node_modules.h +93 -0
  153. package/src/headers/24/node_mutex.h +323 -0
  154. package/src/headers/24/node_object_wrap.h +132 -0
  155. package/src/headers/24/node_options-inl.h +524 -0
  156. package/src/headers/24/node_options.h +682 -0
  157. package/src/headers/24/node_perf.h +166 -0
  158. package/src/headers/24/node_perf_common.h +102 -0
  159. package/src/headers/24/node_platform.h +286 -0
  160. package/src/headers/24/node_process-inl.h +26 -0
  161. package/src/headers/24/node_process.h +111 -0
  162. package/src/headers/24/node_realm-inl.h +153 -0
  163. package/src/headers/24/node_realm.h +236 -0
  164. package/src/headers/24/node_report.h +43 -0
  165. package/src/headers/24/node_revert.h +82 -0
  166. package/src/headers/24/node_root_certs.h +3546 -0
  167. package/src/headers/24/node_sea.h +74 -0
  168. package/src/headers/24/node_shadow_realm.h +46 -0
  169. package/src/headers/24/node_snapshot_builder.h +57 -0
  170. package/src/headers/24/node_snapshotable.h +174 -0
  171. package/src/headers/24/node_sockaddr-inl.h +257 -0
  172. package/src/headers/24/node_sockaddr.h +394 -0
  173. package/src/headers/24/node_sqlite.h +270 -0
  174. package/src/headers/24/node_stat_watcher.h +73 -0
  175. package/src/headers/24/node_string.h +101 -0
  176. package/src/headers/24/node_task_runner.h +92 -0
  177. package/src/headers/24/node_threadsafe_cow-inl.h +54 -0
  178. package/src/headers/24/node_threadsafe_cow.h +105 -0
  179. package/src/headers/24/node_trace_buffer.h +83 -0
  180. package/src/headers/24/node_trace_writer.h +75 -0
  181. package/src/headers/24/node_union_bytes.h +81 -0
  182. package/src/headers/24/node_url.h +101 -0
  183. package/src/headers/24/node_url_pattern.h +118 -0
  184. package/src/headers/24/node_v8.h +77 -0
  185. package/src/headers/24/node_v8_platform-inl.h +185 -0
  186. package/src/headers/24/node_version.h +110 -0
  187. package/src/headers/24/node_wasi.h +185 -0
  188. package/src/headers/24/node_wasm_web_api.h +55 -0
  189. package/src/headers/24/node_watchdog.h +154 -0
  190. package/src/headers/24/node_webstorage.h +60 -0
  191. package/src/headers/24/node_worker.h +159 -0
  192. package/src/headers/24/packet.h +155 -0
  193. package/src/headers/24/path.h +33 -0
  194. package/src/headers/24/permission/addon_permission.h +31 -0
  195. package/src/headers/24/permission/child_process_permission.h +31 -0
  196. package/src/headers/24/permission/fs_permission.h +167 -0
  197. package/src/headers/24/permission/inspector_permission.h +31 -0
  198. package/src/headers/24/permission/permission.h +100 -0
  199. package/src/headers/24/permission/permission_base.h +65 -0
  200. package/src/headers/24/permission/wasi_permission.h +31 -0
  201. package/src/headers/24/permission/worker_permission.h +31 -0
  202. package/src/headers/24/permission.h +100 -0
  203. package/src/headers/24/permission_base.h +65 -0
  204. package/src/headers/24/pipe_wrap.h +80 -0
  205. package/src/headers/24/preferredaddress.h +72 -0
  206. package/src/headers/24/protocol_helper.h +27 -0
  207. package/src/headers/24/queue.h +306 -0
  208. package/src/headers/24/req_wrap-inl.h +176 -0
  209. package/src/headers/24/req_wrap.h +79 -0
  210. package/src/headers/24/runtime_agent.h +41 -0
  211. package/src/headers/24/session.h +528 -0
  212. package/src/headers/24/sessionticket.h +108 -0
  213. package/src/headers/24/spawn_sync.h +243 -0
  214. package/src/headers/24/stream_base-inl.h +173 -0
  215. package/src/headers/24/stream_base.h +478 -0
  216. package/src/headers/24/stream_pipe.h +76 -0
  217. package/src/headers/24/stream_wrap.h +132 -0
  218. package/src/headers/24/streams.h +370 -0
  219. package/src/headers/24/string_bytes.h +109 -0
  220. package/src/headers/24/string_decoder-inl.h +31 -0
  221. package/src/headers/24/string_decoder.h +49 -0
  222. package/src/headers/24/target_agent.h +75 -0
  223. package/src/headers/24/tcp_wrap.h +105 -0
  224. package/src/headers/24/threadpoolwork-inl.h +70 -0
  225. package/src/headers/24/timer_wrap-inl.h +32 -0
  226. package/src/headers/24/timer_wrap.h +87 -0
  227. package/src/headers/24/timers.h +75 -0
  228. package/src/headers/24/tlscontext.h +228 -0
  229. package/src/headers/24/tokens.h +256 -0
  230. package/src/headers/24/trace_event.h +722 -0
  231. package/src/headers/24/trace_event_common.h +1109 -0
  232. package/src/headers/24/traced_value.h +129 -0
  233. package/src/headers/24/tracing/agent.h +195 -0
  234. package/src/headers/24/tracing/trace_event.h +722 -0
  235. package/src/headers/24/tracing_agent.h +43 -0
  236. package/src/headers/24/transportparams.h +166 -0
  237. package/src/headers/24/tty_wrap.h +65 -0
  238. package/src/headers/24/udp_wrap.h +230 -0
  239. package/src/headers/24/undici_version.h +6 -0
  240. package/src/headers/24/util-inl.h +711 -0
  241. package/src/headers/24/util.h +1016 -0
  242. package/src/headers/24/v8-external-memory-accounter.h +60 -0
  243. package/src/headers/24/v8-fast-api-calls.h +819 -0
  244. package/src/headers/24/v8-inspector.h +426 -0
  245. package/src/headers/24/wasi_permission.h +31 -0
  246. package/src/headers/24/worker_agent.h +40 -0
  247. package/src/headers/24/worker_inspector.h +124 -0
  248. package/src/headers/24/worker_permission.h +31 -0
  249. package/src/headers/24/zlib_version.h +6 -0
@@ -0,0 +1,131 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ #ifndef SRC_CRYPTO_CRYPTO_CLIENTHELLO_H_
23
+ #define SRC_CRYPTO_CRYPTO_CLIENTHELLO_H_
24
+
25
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
+
27
+ #include <cstddef> // size_t
28
+ #include <cstdint>
29
+
30
+ namespace node {
31
+ namespace crypto {
32
+ // Parse the client hello so we can do async session resumption. OpenSSL's
33
+ // session resumption uses synchronous callbacks, see SSL_CTX_sess_set_get_cb
34
+ // and get_session_cb.
35
+ //
36
+ // TLS1.3 handshakes masquerade as TLS1.2 session resumption, and to do this,
37
+ // they always include a session_id in the ClientHello, making up a bogus value
38
+ // if necessary. The parser can't know if its a bogus id, and will cause a
39
+ // 'newSession' event to be emitted. This should do no harm, the id won't be
40
+ // found, and the handshake will continue.
41
+ class ClientHelloParser {
42
+ public:
43
+ inline ClientHelloParser();
44
+
45
+ class ClientHello {
46
+ public:
47
+ inline uint8_t session_size() const { return session_size_; }
48
+ inline const uint8_t* session_id() const { return session_id_; }
49
+ inline bool has_ticket() const { return has_ticket_; }
50
+ inline uint8_t servername_size() const { return servername_size_; }
51
+ inline const uint8_t* servername() const { return servername_; }
52
+
53
+ private:
54
+ uint8_t session_size_;
55
+ const uint8_t* session_id_;
56
+ bool has_ticket_;
57
+ uint8_t servername_size_;
58
+ const uint8_t* servername_;
59
+
60
+ friend class ClientHelloParser;
61
+ };
62
+
63
+ typedef void (*OnHelloCb)(void* arg, const ClientHello& hello);
64
+ typedef void (*OnEndCb)(void* arg);
65
+
66
+ void Parse(const uint8_t* data, size_t avail);
67
+
68
+ inline void Reset();
69
+ inline void Start(OnHelloCb onhello_cb, OnEndCb onend_cb, void* cb_arg);
70
+ inline void End();
71
+ inline bool IsPaused() const;
72
+ inline bool IsEnded() const;
73
+
74
+ private:
75
+ static const size_t kMaxTLSFrameLen = 16 * 1024 + 5;
76
+ static const size_t kMaxSSLExFrameLen = 32 * 1024;
77
+ static const uint8_t kServernameHostname = 0;
78
+ static const size_t kMinStatusRequestSize = 5;
79
+
80
+ enum ParseState {
81
+ kWaiting,
82
+ kTLSHeader,
83
+ kPaused,
84
+ kEnded
85
+ };
86
+
87
+ enum FrameType {
88
+ kChangeCipherSpec = 20,
89
+ kAlert = 21,
90
+ kHandshake = 22,
91
+ kApplicationData = 23,
92
+ kOther = 255
93
+ };
94
+
95
+ enum HandshakeType {
96
+ kClientHello = 1
97
+ };
98
+
99
+ enum ExtensionType {
100
+ kServerName = 0,
101
+ kTLSSessionTicket = 35
102
+ };
103
+
104
+ bool ParseRecordHeader(const uint8_t* data, size_t avail);
105
+ void ParseHeader(const uint8_t* data, size_t avail);
106
+ void ParseExtension(const uint16_t type,
107
+ const uint8_t* data,
108
+ size_t len);
109
+ bool ParseTLSClientHello(const uint8_t* data, size_t avail);
110
+
111
+ ParseState state_;
112
+ OnHelloCb onhello_cb_;
113
+ OnEndCb onend_cb_;
114
+ void* cb_arg_;
115
+ size_t frame_len_ = 0;
116
+ size_t body_offset_ = 0;
117
+ size_t extension_offset_ = 0;
118
+ uint8_t session_size_ = 0;
119
+ const uint8_t* session_id_ = nullptr;
120
+ uint16_t servername_size_ = 0;
121
+ const uint8_t* servername_ = nullptr;
122
+ uint16_t tls_ticket_size_ = -1;
123
+ const uint8_t* tls_ticket_ = nullptr;
124
+ };
125
+
126
+ } // namespace crypto
127
+ } // namespace node
128
+
129
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
130
+
131
+ #endif // SRC_CRYPTO_CRYPTO_CLIENTHELLO_H_
@@ -0,0 +1,48 @@
1
+ #ifndef SRC_CRYPTO_CRYPTO_COMMON_H_
2
+ #define SRC_CRYPTO_CRYPTO_COMMON_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include <openssl/ssl.h>
7
+ #include <openssl/x509v3.h>
8
+ #include "ncrypto.h"
9
+ #include "node_crypto.h"
10
+ #include "v8.h"
11
+
12
+ #include <string>
13
+
14
+ namespace node {
15
+ namespace crypto {
16
+
17
+ ncrypto::SSLSessionPointer GetTLSSession(const unsigned char* buf,
18
+ size_t length);
19
+
20
+ v8::MaybeLocal<v8::Value> GetValidationErrorReason(Environment* env, int err);
21
+
22
+ v8::MaybeLocal<v8::Value> GetValidationErrorCode(Environment* env, int err);
23
+
24
+ v8::MaybeLocal<v8::Value> GetCert(Environment* env,
25
+ const ncrypto::SSLPointer& ssl);
26
+
27
+ v8::MaybeLocal<v8::Object> GetCipherInfo(Environment* env,
28
+ const ncrypto::SSLPointer& ssl);
29
+
30
+ v8::MaybeLocal<v8::Object> GetEphemeralKey(Environment* env,
31
+ const ncrypto::SSLPointer& ssl);
32
+
33
+ v8::MaybeLocal<v8::Value> GetPeerCert(Environment* env,
34
+ const ncrypto::SSLPointer& ssl,
35
+ bool abbreviated = false,
36
+ bool is_server = false);
37
+
38
+ v8::MaybeLocal<v8::Object> ECPointToBuffer(Environment* env,
39
+ const EC_GROUP* group,
40
+ const EC_POINT* point,
41
+ point_conversion_form_t form);
42
+
43
+ } // namespace crypto
44
+ } // namespace node
45
+
46
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
47
+
48
+ #endif // SRC_CRYPTO_CRYPTO_COMMON_H_
@@ -0,0 +1,171 @@
1
+ #ifndef SRC_CRYPTO_CRYPTO_CONTEXT_H_
2
+ #define SRC_CRYPTO_CRYPTO_CONTEXT_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
+ // A maxVersion of 0 means "any", but OpenSSL may support TLS versions that
16
+ // Node.js doesn't, so pin the max to what we do support.
17
+ constexpr int kMaxSupportedVersion = TLS1_3_VERSION;
18
+
19
+ void GetRootCertificates(
20
+ const v8::FunctionCallbackInfo<v8::Value>& args);
21
+
22
+ X509_STORE* NewRootCertStore();
23
+
24
+ X509_STORE* GetOrCreateRootCertStore();
25
+
26
+ ncrypto::BIOPointer LoadBIO(Environment* env, v8::Local<v8::Value> v);
27
+
28
+ class SecureContext final : public BaseObject {
29
+ public:
30
+ using GetSessionCb = SSL_SESSION* (*)(SSL*, const unsigned char*, int, int*);
31
+ using KeylogCb = void (*)(const SSL*, const char*);
32
+ using NewSessionCb = int (*)(SSL*, SSL_SESSION*);
33
+ using SelectSNIContextCb = int (*)(SSL*, int*, void*);
34
+
35
+ ~SecureContext() override;
36
+
37
+ static bool HasInstance(Environment* env, const v8::Local<v8::Value>& value);
38
+ static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
39
+ Environment* env);
40
+ static void Initialize(Environment* env, v8::Local<v8::Object> target);
41
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
42
+ static SecureContext* Create(Environment* env);
43
+
44
+ const ncrypto::SSLCtxPointer& ctx() const { return ctx_; }
45
+
46
+ // Non-const ctx() that allows for non-default initialization of
47
+ // the SecureContext.
48
+ ncrypto::SSLCtxPointer& ctx() { return ctx_; }
49
+
50
+ ncrypto::SSLPointer CreateSSL();
51
+
52
+ void SetGetSessionCallback(GetSessionCb cb);
53
+ void SetKeylogCallback(KeylogCb cb);
54
+ void SetNewSessionCallback(NewSessionCb cb);
55
+ void SetSelectSNIContextCallback(SelectSNIContextCb cb);
56
+
57
+ inline const ncrypto::X509Pointer& issuer() const { return issuer_; }
58
+ inline const ncrypto::X509Pointer& cert() const { return cert_; }
59
+
60
+ v8::Maybe<void> AddCert(Environment* env, ncrypto::BIOPointer&& bio);
61
+ v8::Maybe<void> SetCRL(Environment* env, const ncrypto::BIOPointer& bio);
62
+ v8::Maybe<void> UseKey(Environment* env, const KeyObjectData& key);
63
+
64
+ void SetCACert(const ncrypto::BIOPointer& bio);
65
+ void SetRootCerts();
66
+
67
+ void SetX509StoreFlag(unsigned long flags); // NOLINT(runtime/int)
68
+ X509_STORE* GetCertStoreOwnedByThisSecureContext();
69
+
70
+ // TODO(joyeecheung): track the memory used by OpenSSL types
71
+ SET_NO_MEMORY_INFO()
72
+ SET_MEMORY_INFO_NAME(SecureContext)
73
+ SET_SELF_SIZE(SecureContext)
74
+
75
+ static const int kMaxSessionSize = 10 * 1024;
76
+
77
+ // See TicketKeyCallback
78
+ static const int kTicketKeyReturnIndex = 0;
79
+ static const int kTicketKeyHMACIndex = 1;
80
+ static const int kTicketKeyAESIndex = 2;
81
+ static const int kTicketKeyNameIndex = 3;
82
+ static const int kTicketKeyIVIndex = 4;
83
+
84
+ protected:
85
+ // OpenSSL structures are opaque. This is sizeof(SSL_CTX) for OpenSSL 1.1.1b:
86
+ static const int64_t kExternalSize = 1024;
87
+
88
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
89
+ static void Init(const v8::FunctionCallbackInfo<v8::Value>& args);
90
+ static void SetKey(const v8::FunctionCallbackInfo<v8::Value>& args);
91
+ #ifndef OPENSSL_NO_ENGINE
92
+ static void SetEngineKey(const v8::FunctionCallbackInfo<v8::Value>& args);
93
+ #endif // !OPENSSL_NO_ENGINE
94
+ static void SetCert(const v8::FunctionCallbackInfo<v8::Value>& args);
95
+ static void AddCACert(const v8::FunctionCallbackInfo<v8::Value>& args);
96
+ static void SetAllowPartialTrustChain(
97
+ const v8::FunctionCallbackInfo<v8::Value>& args);
98
+ static void AddCRL(const v8::FunctionCallbackInfo<v8::Value>& args);
99
+ static void AddRootCerts(const v8::FunctionCallbackInfo<v8::Value>& args);
100
+ static void SetCipherSuites(const v8::FunctionCallbackInfo<v8::Value>& args);
101
+ static void SetCiphers(const v8::FunctionCallbackInfo<v8::Value>& args);
102
+ static void SetSigalgs(const v8::FunctionCallbackInfo<v8::Value>& args);
103
+ static void SetECDHCurve(const v8::FunctionCallbackInfo<v8::Value>& args);
104
+ static void SetDHParam(const v8::FunctionCallbackInfo<v8::Value>& args);
105
+ static void SetOptions(const v8::FunctionCallbackInfo<v8::Value>& args);
106
+ static void SetSessionIdContext(
107
+ const v8::FunctionCallbackInfo<v8::Value>& args);
108
+ static void SetSessionTimeout(
109
+ const v8::FunctionCallbackInfo<v8::Value>& args);
110
+ static void SetMinProto(const v8::FunctionCallbackInfo<v8::Value>& args);
111
+ static void SetMaxProto(const v8::FunctionCallbackInfo<v8::Value>& args);
112
+ static void GetMinProto(const v8::FunctionCallbackInfo<v8::Value>& args);
113
+ static void GetMaxProto(const v8::FunctionCallbackInfo<v8::Value>& args);
114
+ static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
115
+ static void LoadPKCS12(const v8::FunctionCallbackInfo<v8::Value>& args);
116
+ #ifndef OPENSSL_NO_ENGINE
117
+ static void SetClientCertEngine(
118
+ const v8::FunctionCallbackInfo<v8::Value>& args);
119
+ #endif // !OPENSSL_NO_ENGINE
120
+ static void GetTicketKeys(const v8::FunctionCallbackInfo<v8::Value>& args);
121
+ static void SetTicketKeys(const v8::FunctionCallbackInfo<v8::Value>& args);
122
+ static void EnableTicketKeyCallback(
123
+ const v8::FunctionCallbackInfo<v8::Value>& args);
124
+ static void CtxGetter(const v8::FunctionCallbackInfo<v8::Value>& info);
125
+
126
+ template <bool primary>
127
+ static void GetCertificate(const v8::FunctionCallbackInfo<v8::Value>& args);
128
+
129
+ static int TicketKeyCallback(SSL* ssl,
130
+ unsigned char* name,
131
+ unsigned char* iv,
132
+ EVP_CIPHER_CTX* ectx,
133
+ HMAC_CTX* hctx,
134
+ int enc);
135
+
136
+ static int TicketCompatibilityCallback(SSL* ssl,
137
+ unsigned char* name,
138
+ unsigned char* iv,
139
+ EVP_CIPHER_CTX* ectx,
140
+ HMAC_CTX* hctx,
141
+ int enc);
142
+
143
+ SecureContext(Environment* env, v8::Local<v8::Object> wrap);
144
+ void Reset();
145
+
146
+ private:
147
+ ncrypto::SSLCtxPointer ctx_;
148
+ ncrypto::X509Pointer cert_;
149
+ ncrypto::X509Pointer issuer_;
150
+ // Non-owning cache for SSL_CTX_get_cert_store(ctx_.get())
151
+ X509_STORE* own_cert_store_cache_ = nullptr;
152
+ #ifndef OPENSSL_NO_ENGINE
153
+ bool client_cert_engine_provided_ = false;
154
+ ncrypto::EnginePointer private_key_engine_;
155
+ #endif // !OPENSSL_NO_ENGINE
156
+
157
+ unsigned char ticket_key_name_[16];
158
+ unsigned char ticket_key_aes_[16];
159
+ unsigned char ticket_key_hmac_[16];
160
+ };
161
+
162
+ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx,
163
+ ncrypto::BIOPointer&& in,
164
+ ncrypto::X509Pointer* cert,
165
+ ncrypto::X509Pointer* issuer);
166
+
167
+ } // namespace crypto
168
+ } // namespace node
169
+
170
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
171
+ #endif // SRC_CRYPTO_CRYPTO_CONTEXT_H_
@@ -0,0 +1,126 @@
1
+ #ifndef SRC_CRYPTO_CRYPTO_DH_H_
2
+ #define SRC_CRYPTO_CRYPTO_DH_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "crypto/crypto_keys.h"
7
+ #include "crypto/crypto_keygen.h"
8
+ #include "crypto/crypto_util.h"
9
+ #include "env.h"
10
+ #include "memory_tracker.h"
11
+ #include "v8.h"
12
+
13
+ #include <variant>
14
+
15
+ namespace node {
16
+ namespace crypto {
17
+ class DiffieHellman final : public BaseObject {
18
+ public:
19
+ static void Initialize(Environment* env, v8::Local<v8::Object> target);
20
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
21
+
22
+ DiffieHellman(Environment* env,
23
+ v8::Local<v8::Object> wrap,
24
+ ncrypto::DHPointer dh);
25
+ operator ncrypto::DHPointer&() { return dh_; }
26
+
27
+ void MemoryInfo(MemoryTracker* tracker) const override;
28
+ SET_MEMORY_INFO_NAME(DiffieHellman)
29
+ SET_SELF_SIZE(DiffieHellman)
30
+
31
+ private:
32
+ ncrypto::DHPointer dh_;
33
+ };
34
+
35
+ struct DhKeyPairParams final : public MemoryRetainer {
36
+ // Diffie-Hellman can either generate keys using a fixed prime, or by first
37
+ // generating a random prime of a given size (in bits). Only one of both
38
+ // options may be specified.
39
+ std::variant<ncrypto::BignumPointer, int> prime;
40
+ unsigned int generator;
41
+ SET_NO_MEMORY_INFO()
42
+ SET_MEMORY_INFO_NAME(DhKeyPairParams)
43
+ SET_SELF_SIZE(DhKeyPairParams)
44
+ };
45
+
46
+ using DhKeyPairGenConfig = KeyPairGenConfig<DhKeyPairParams>;
47
+
48
+ struct DhKeyGenTraits final {
49
+ using AdditionalParameters = DhKeyPairGenConfig;
50
+ static constexpr const char* JobName = "DhKeyPairGenJob";
51
+
52
+ static ncrypto::EVPKeyCtxPointer Setup(DhKeyPairGenConfig* params);
53
+
54
+ static v8::Maybe<void> AdditionalConfig(
55
+ CryptoJobMode mode,
56
+ const v8::FunctionCallbackInfo<v8::Value>& args,
57
+ unsigned int* offset,
58
+ DhKeyPairGenConfig* params);
59
+ };
60
+
61
+ using DHKeyPairGenJob = KeyGenJob<KeyPairGenTraits<DhKeyGenTraits>>;
62
+
63
+ struct DHKeyExportConfig final : public MemoryRetainer {
64
+ SET_NO_MEMORY_INFO()
65
+ SET_MEMORY_INFO_NAME(DHKeyExportConfig)
66
+ SET_SELF_SIZE(DHKeyExportConfig)
67
+ };
68
+
69
+ struct DHKeyExportTraits final {
70
+ static constexpr const char* JobName = "DHKeyExportJob";
71
+ using AdditionalParameters = DHKeyExportConfig;
72
+
73
+ static v8::Maybe<void> AdditionalConfig(
74
+ const v8::FunctionCallbackInfo<v8::Value>& args,
75
+ unsigned int offset,
76
+ DHKeyExportConfig* config);
77
+
78
+ static WebCryptoKeyExportStatus DoExport(const KeyObjectData& key_data,
79
+ WebCryptoKeyFormat format,
80
+ const DHKeyExportConfig& params,
81
+ ByteSource* out);
82
+ };
83
+
84
+ using DHKeyExportJob = KeyExportJob<DHKeyExportTraits>;
85
+
86
+ struct DHBitsConfig final : public MemoryRetainer {
87
+ KeyObjectData private_key;
88
+ KeyObjectData public_key;
89
+ SET_NO_MEMORY_INFO()
90
+ SET_MEMORY_INFO_NAME(DHBitsConfig)
91
+ SET_SELF_SIZE(DHBitsConfig)
92
+ };
93
+
94
+ struct DHBitsTraits final {
95
+ using AdditionalParameters = DHBitsConfig;
96
+ static constexpr const char* JobName = "DHBitsJob";
97
+ static constexpr AsyncWrap::ProviderType Provider =
98
+ AsyncWrap::PROVIDER_DERIVEBITSREQUEST;
99
+
100
+ static v8::Maybe<void> AdditionalConfig(
101
+ CryptoJobMode mode,
102
+ const v8::FunctionCallbackInfo<v8::Value>& args,
103
+ unsigned int offset,
104
+ DHBitsConfig* params);
105
+
106
+ static bool DeriveBits(Environment* env,
107
+ const DHBitsConfig& params,
108
+ ByteSource* out_,
109
+ CryptoJobMode mode);
110
+
111
+ static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env,
112
+ const DHBitsConfig& params,
113
+ ByteSource* out);
114
+ };
115
+
116
+ using DHBitsJob = DeriveBitsJob<DHBitsTraits>;
117
+
118
+ bool GetDhKeyDetail(Environment* env,
119
+ const KeyObjectData& key,
120
+ v8::Local<v8::Object> target);
121
+
122
+ } // namespace crypto
123
+ } // namespace node
124
+
125
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
126
+ #endif // SRC_CRYPTO_CRYPTO_DH_H_
@@ -0,0 +1,50 @@
1
+ #ifndef SRC_CRYPTO_CRYPTO_DSA_H_
2
+ #define SRC_CRYPTO_CRYPTO_DSA_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "crypto/crypto_keys.h"
7
+ #include "crypto/crypto_keygen.h"
8
+ #include "crypto/crypto_util.h"
9
+ #include "env.h"
10
+ #include "memory_tracker.h"
11
+ #include "v8.h"
12
+
13
+ namespace node::crypto {
14
+ struct DsaKeyPairParams final : public MemoryRetainer {
15
+ unsigned int modulus_bits;
16
+ int divisor_bits;
17
+ SET_NO_MEMORY_INFO()
18
+ SET_MEMORY_INFO_NAME(DsaKeyPairParams)
19
+ SET_SELF_SIZE(DsaKeyPairParams)
20
+ };
21
+
22
+ using DsaKeyPairGenConfig = KeyPairGenConfig<DsaKeyPairParams>;
23
+
24
+ struct DsaKeyGenTraits final {
25
+ using AdditionalParameters = DsaKeyPairGenConfig;
26
+ static constexpr const char* JobName = "DsaKeyPairGenJob";
27
+
28
+ static ncrypto::EVPKeyCtxPointer Setup(DsaKeyPairGenConfig* params);
29
+
30
+ static v8::Maybe<void> AdditionalConfig(
31
+ CryptoJobMode mode,
32
+ const v8::FunctionCallbackInfo<v8::Value>& args,
33
+ unsigned int* offset,
34
+ DsaKeyPairGenConfig* params);
35
+ };
36
+
37
+ using DsaKeyPairGenJob = KeyGenJob<KeyPairGenTraits<DsaKeyGenTraits>>;
38
+
39
+ bool GetDsaKeyDetail(Environment* env,
40
+ const KeyObjectData& key,
41
+ v8::Local<v8::Object> target);
42
+
43
+ namespace DSAAlg {
44
+ void Initialize(Environment* env, v8::Local<v8::Object> target);
45
+ void RegisterExternalReferences(ExternalReferenceRegistry* registry);
46
+ } // namespace DSAAlg
47
+ } // namespace node::crypto
48
+
49
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
50
+ #endif // SRC_CRYPTO_CRYPTO_DSA_H_
@@ -0,0 +1,163 @@
1
+ #ifndef SRC_CRYPTO_CRYPTO_EC_H_
2
+ #define SRC_CRYPTO_CRYPTO_EC_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_keygen.h"
9
+ #include "crypto/crypto_keys.h"
10
+ #include "crypto/crypto_util.h"
11
+ #include "env.h"
12
+ #include "memory_tracker.h"
13
+ #include "node_internals.h"
14
+ #include "v8.h"
15
+
16
+ namespace node {
17
+ namespace crypto {
18
+
19
+ class ECDH final : public BaseObject {
20
+ public:
21
+ ~ECDH() override = default;
22
+
23
+ static void Initialize(Environment* env, v8::Local<v8::Object> target);
24
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
25
+
26
+ static ncrypto::ECPointPointer BufferToPoint(Environment* env,
27
+ const EC_GROUP* group,
28
+ v8::Local<v8::Value> buf);
29
+
30
+ void MemoryInfo(MemoryTracker* tracker) const override;
31
+ SET_MEMORY_INFO_NAME(ECDH)
32
+ SET_SELF_SIZE(ECDH)
33
+
34
+ static void ConvertKey(const v8::FunctionCallbackInfo<v8::Value>& args);
35
+
36
+ static void GetCurves(const v8::FunctionCallbackInfo<v8::Value>& args);
37
+
38
+ protected:
39
+ ECDH(Environment* env,
40
+ v8::Local<v8::Object> wrap,
41
+ ncrypto::ECKeyPointer&& key);
42
+
43
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
44
+ static void GenerateKeys(const v8::FunctionCallbackInfo<v8::Value>& args);
45
+ static void ComputeSecret(const v8::FunctionCallbackInfo<v8::Value>& args);
46
+ static void GetPrivateKey(const v8::FunctionCallbackInfo<v8::Value>& args);
47
+ static void SetPrivateKey(const v8::FunctionCallbackInfo<v8::Value>& args);
48
+ static void GetPublicKey(const v8::FunctionCallbackInfo<v8::Value>& args);
49
+ static void SetPublicKey(const v8::FunctionCallbackInfo<v8::Value>& args);
50
+
51
+ bool IsKeyPairValid();
52
+ bool IsKeyValidForCurve(const ncrypto::BignumPointer& private_key);
53
+
54
+ ncrypto::ECKeyPointer key_;
55
+ const EC_GROUP* group_;
56
+ };
57
+
58
+ struct ECDHBitsConfig final : public MemoryRetainer {
59
+ int id_;
60
+ KeyObjectData private_;
61
+ KeyObjectData public_;
62
+
63
+ void MemoryInfo(MemoryTracker* tracker) const override;
64
+ SET_MEMORY_INFO_NAME(ECDHBitsConfig)
65
+ SET_SELF_SIZE(ECDHBitsConfig)
66
+ };
67
+
68
+ struct ECDHBitsTraits final {
69
+ using AdditionalParameters = ECDHBitsConfig;
70
+ static constexpr const char* JobName = "ECDHBitsJob";
71
+ static constexpr AsyncWrap::ProviderType Provider =
72
+ AsyncWrap::PROVIDER_DERIVEBITSREQUEST;
73
+
74
+ static v8::Maybe<void> AdditionalConfig(
75
+ CryptoJobMode mode,
76
+ const v8::FunctionCallbackInfo<v8::Value>& args,
77
+ unsigned int offset,
78
+ ECDHBitsConfig* params);
79
+
80
+ static bool DeriveBits(Environment* env,
81
+ const ECDHBitsConfig& params,
82
+ ByteSource* out_,
83
+ CryptoJobMode mode);
84
+
85
+ static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env,
86
+ const ECDHBitsConfig& params,
87
+ ByteSource* out);
88
+ };
89
+
90
+ using ECDHBitsJob = DeriveBitsJob<ECDHBitsTraits>;
91
+
92
+ struct EcKeyPairParams final : public MemoryRetainer {
93
+ int curve_nid;
94
+ int param_encoding;
95
+ SET_NO_MEMORY_INFO()
96
+ SET_MEMORY_INFO_NAME(EcKeyPairParams)
97
+ SET_SELF_SIZE(EcKeyPairParams)
98
+ };
99
+
100
+ using EcKeyPairGenConfig = KeyPairGenConfig<EcKeyPairParams>;
101
+
102
+ struct EcKeyGenTraits final {
103
+ using AdditionalParameters = EcKeyPairGenConfig;
104
+ static constexpr const char* JobName = "EcKeyPairGenJob";
105
+
106
+ static ncrypto::EVPKeyCtxPointer Setup(EcKeyPairGenConfig* params);
107
+
108
+ static v8::Maybe<void> AdditionalConfig(
109
+ CryptoJobMode mode,
110
+ const v8::FunctionCallbackInfo<v8::Value>& args,
111
+ unsigned int* offset,
112
+ EcKeyPairGenConfig* params);
113
+ };
114
+
115
+ using ECKeyPairGenJob = KeyGenJob<KeyPairGenTraits<EcKeyGenTraits>>;
116
+
117
+ // There is currently no additional information that the
118
+ // ECKeyExport needs to collect, but we need to provide
119
+ // the base struct anyway.
120
+ struct ECKeyExportConfig final : public MemoryRetainer {
121
+ SET_NO_MEMORY_INFO()
122
+ SET_MEMORY_INFO_NAME(ECKeyExportConfig)
123
+ SET_SELF_SIZE(ECKeyExportConfig)
124
+ };
125
+
126
+ struct ECKeyExportTraits final {
127
+ static constexpr const char* JobName = "ECKeyExportJob";
128
+ using AdditionalParameters = ECKeyExportConfig;
129
+
130
+ static v8::Maybe<void> AdditionalConfig(
131
+ const v8::FunctionCallbackInfo<v8::Value>& args,
132
+ unsigned int offset,
133
+ ECKeyExportConfig* config);
134
+
135
+ static WebCryptoKeyExportStatus DoExport(const KeyObjectData& key_data,
136
+ WebCryptoKeyFormat format,
137
+ const ECKeyExportConfig& params,
138
+ ByteSource* out);
139
+ };
140
+
141
+ using ECKeyExportJob = KeyExportJob<ECKeyExportTraits>;
142
+
143
+ bool ExportJWKEcKey(Environment* env,
144
+ const KeyObjectData& key,
145
+ v8::Local<v8::Object> target);
146
+
147
+ bool ExportJWKEdKey(Environment* env,
148
+ const KeyObjectData& key,
149
+ v8::Local<v8::Object> target);
150
+
151
+ KeyObjectData ImportJWKEcKey(Environment* env,
152
+ v8::Local<v8::Object> jwk,
153
+ const v8::FunctionCallbackInfo<v8::Value>& args,
154
+ unsigned int offset);
155
+
156
+ bool GetEcKeyDetail(Environment* env,
157
+ const KeyObjectData& key,
158
+ v8::Local<v8::Object> target);
159
+ } // namespace crypto
160
+ } // namespace node
161
+
162
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
163
+ #endif // SRC_CRYPTO_CRYPTO_EC_H_