summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/crypto
AgeCommit message (Collapse)Author
2023-05-01refactor: migrate async ops to generated wrappers (#18937)Bartek Iwańczuk
Migrates some of existing async ops to generated wrappers introduced in https://github.com/denoland/deno/pull/18887. As a result "core.opAsync2" was removed. I will follow up with more PRs that migrate all the async ops to generated wrappers.
2023-04-27feat(node/crypto): Elliptic Curve Diffie-Hellman (ECDH) support (#18832)Levente Kurusa
- ECDH class - crypto.createECDH() - Supported curves: - secp256k1 - prime256v1 / secp256r1 - secp384r1 - secp224r1 Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-04-27fix(ext/node): prime generation (#18861)Divy Srivastava
Towards https://github.com/denoland/deno/issues/18455 `safe`, `add` and `rem` options are not implemented because there is no rust crate that provides this functionality (except rust-openssl maybe) and its just not clear if this API is used widely.
2023-04-25fix(ext/node): fix hash.flush (#18818)Yoshiya Hinosawa
2023-04-19fix(ext/node): implement asymmetric keygen (#18651)Divy Srivastava
Towards #18455 This commit implements the keypair generation for asymmetric keys for the `generateKeyPair` API. See how key material is managed in this implementation: https://www.notion.so/denolandinc/node-crypto-design-99fc33f568d24e47a5e4b36002c5325d?pvs=4 Private and public key encoding depend on `KeyObject#export` which is not implemented. I've also skipped ED448 and X448 since we need a crate for that in WebCrypto too.
2023-04-19fix(ext/node): add crypto.sign|verify methods (#18765)Yoshiya Hinosawa
2023-04-18refactor(node/crypto): scrypt polyfill to rust (#18746)Levente Kurusa
2023-04-18fix(ext/node): implement crypto.createVerify (#18703)Yoshiya Hinosawa
2023-04-12refactor(node/crypto): port polyfill to Rust for randomInt, randomFill, ↵Levente Kurusa
randomFillSync (#18658) Pretty much as per the title, I'd welcome some feedback especially around the array/buffer handling in the two randomFill functions.
2023-04-07fix(ext/node): add X509Certificate (#18625)Divy Srivastava
Towards #18455
2023-04-06fix(ext/node): implement hkdf-expand (#18612)Divy Srivastava
Towards https://github.com/denoland/deno/issues/18455
2023-04-06fix(ext/node): add symmetric keygen (#18609)Divy Srivastava
Towards #18455
2023-03-31perf(ext/websocket): use opAsync2 to avoid spread deopt (#18525)Divy Srivastava
This commit adds a new core API `opAsync2` to call an async op with atmost 2 arguments. Spread argument iterators has a pretty big perf hit when calling ops. | name | avg msg/sec/core | | --- | --- | | 1.32.1 | `127820.750000` | | #18506 | `140079.000000` | | #18506 + #18509 | `150104.250000` | | #18506 + #18509 + this | `157340.000000` |
2023-03-28fix(ext/node): implement crypto.Sign (RSA/PEM/SHA{224,256,384,512}) (#18471)Yoshiya Hinosawa
2023-03-28feat(ext/node): add `crypto.checkPrime` API (#18465)Divy Srivastava
Towards #18455 This commit implements `checkPrimeSync` and `checkPrime` in node:crypto using the Miller-Rabin primality test (fun fact: it actually is a test for composite numbers) It first compares the candidate against many known small primes and if not, proceeds to run the Miller-Rabin primality test. http://nickle.org/examples/miller-rabin.5c used as reference implementation.
2023-03-28chore(ext/node): port pbkdf2 to Rust (#18470)Divy Srivastava
Towards #18455
2023-03-25fix(ext/node): add aes-128-ecb algorithm support (#18412)Yoshiya Hinosawa
2023-03-24feat(ext/node): implement crypto.createSecretKey (#18413)Divy Srivastava
This commit adds the `crypto.createSecretKey` API. Key management: This follows the same approach as our WebCrypto CryptoKey impl where we use WeakMap for storing key material and a handle is passed around, such that (only internal) JS can access the key material and we don't have to explicitly close a Rust resource. As a result, `createHmac` now accepts a secret KeyObject. Closes https://github.com/denoland/deno/issues/17844
2023-03-24fix(ext/node): make cipher/decipher transform stream (#18408)Yoshiya Hinosawa
2023-03-18fix(ext/node): add createDecipheriv (#18245)Yoshiya Hinosawa
2023-03-16fix(ext/node): resource leak in createHmac (#18229)Divy Srivastava
This commit fixes https://github.com/denoland/deno/issues/18140. Verified that test fails on `main`.
2023-03-14fix(ext/node): add crypto.createCipheriv (#18091)Yoshiya Hinosawa
2023-03-14chore(ext/node): copy internal/crypto/types.ts from std (#18156)Yoshiya Hinosawa
2023-03-08refactor: rename InternalModuleLoader to ExtModuleLoader, use ext: scheme ↵Bartek Iwańczuk
for snapshotted modules (#18041) This commit renames "deno_core::InternalModuleLoader" to "ExtModuleLoader" and changes the specifiers used by the modules loaded from this loader to "ext:". "internal:" scheme was really ambiguous and it's more characters than "ext:", which should result in slightly smaller snapshot size. Closes https://github.com/denoland/deno/issues/18020
2023-03-06fix(ext/node): remove unused _hex module (#18045)Divy Srivastava
2023-03-06perf(ext/node): improve createHash performance (#18033)Divy Srivastava
``` > deno run -A ../test.mjs cpu: unknown runtime: deno 1.31.1 (aarch64-apple-darwin) benchmark time (avg) (min … max) p75 p99 p995 ------------------------------------------------- ----------------------------- 2.22 µs/iter (2.2 µs … 2.28 µs) 2.22 µs 2.28 µs 2.28 µs > target/release/deno run -A test.mjs cpu: unknown runtime: deno 1.31.1 (aarch64-apple-darwin) benchmark time (avg) (min … max) p75 p99 p995 ------------------------------------------------- ----------------------------- 864.9 ns/iter (825.05 ns … 1.22 µs) 864.93 ns 1.22 µs 1.22 µs ```
2023-03-05refactor(core): InternalModuleLoader checks if all files were used (#18005)Bartek Iwańczuk
This commit changes "InternalModuleLoader" from "deno_core" to store a list of used modules during snapshotting. If a module was not used during snapshotting "InternalModuleLoader" will panic in its "Drop" handler signaling to the embedder that they made a mistake somewhere.
2023-03-05refactor(core): include_js_files! 'dir' option doesn't change specifiers ↵Bartek Iwańczuk
(#18019) This commit changes "include_js_files!" macro from "deno_core" in a way that "dir" option doesn't cause specifiers to be rewritten to include it. Example: ``` include_js_files! { dir "js", "hello.js", } ``` The above definition required embedders to use: `import ... from "internal:<ext_name>/js/hello.js"`. But with this change, the "js" directory in which the files are stored is an implementation detail, which for embedders results in: `import ... from "internal:<ext_name>/hello.js"`. The directory the files are stored in, is an implementation detail and in some cases might result in a significant size difference for the snapshot. As an example, in "deno_node" extension, we store the source code in "polyfills" directory; which resulted in each specifier to look like "internal:deno_node/polyfills/<module_name>", but with this change it's "internal:deno_node/<module_name>". Given that "deno_node" has over 100 files, many of them having several import specifiers to the same extension, this change removes 10 characters from each import specifier.
2023-02-20perf: use ops for node:crypto ciphers (#17819)Divy Srivastava
Towards #17809
2023-02-15feat: wire up ext/node to the Node compatibility layer (#17785)Bartek Iwańczuk
This PR changes Node.js/npm compatibility layer to use polyfills for built-in Node.js embedded in the snapshot (that are coming from "ext/node" extension). As a result loading `std/node`, either from "https://deno.land/std@<latest>/" or from "DENO_NODE_COMPAT_URL" env variable were removed. All code that is imported via "npm:" specifiers now uses code embedded in the snapshot. Several fixes were applied to various modules in "ext/node" to make tests pass. --------- Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
2023-02-14feat(ext/node): embed std/node into the snapshot (#17724)Bartek Iwańczuk
This commit moves "deno_std/node" in "ext/node" crate. The code is transpiled and snapshotted during the build process. During the first pass a minimal amount of work was done to create the snapshot, a lot of code in "ext/node" depends on presence of "Deno" global. This code will be gradually fixed in the follow up PRs to migrate it to import relevant APIs from "internal:" modules. Currently the code from snapshot is not used in any way, and all Node/npm compatibility still uses code from "https://deno.land/std/node" (or from the location specified by "DENO_NODE_COMPAT_URL"). This will also be handled in a follow up PRs. --------- Co-authored-by: crowlkats <crowlkats@toaxl.com> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com> Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>