summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/crypto/hash.ts
AgeCommit message (Collapse)Author
2024-08-07feat(ext/node): rewrite crypto keys (#24463)Luca Casonato
This completely rewrites how we handle key material in ext/node. Changes in this PR: - **Signing** - RSA - RSA-PSS ๐Ÿ†• - DSA ๐Ÿ†• - EC - ED25519 ๐Ÿ†• - **Verifying** - RSA - RSA-PSS ๐Ÿ†• - DSA ๐Ÿ†• - EC ๐Ÿ†• - ED25519 ๐Ÿ†• - **Private key import** - Passphrase encrypted private keys ๐Ÿ†• - RSA - PEM - DER (PKCS#1) ๐Ÿ†• - DER (PKCS#8) ๐Ÿ†• - RSA-PSS - PEM - DER (PKCS#1) ๐Ÿ†• - DER (PKCS#8) ๐Ÿ†• - DSA ๐Ÿ†• - EC - PEM - DER (SEC1) ๐Ÿ†• - DER (PKCS#8) ๐Ÿ†• - X25519 ๐Ÿ†• - ED25519 ๐Ÿ†• - DH - **Public key import** - RSA - PEM - DER (PKCS#1) ๐Ÿ†• - DER (PKCS#8) ๐Ÿ†• - RSA-PSS ๐Ÿ†• - DSA ๐Ÿ†• - EC ๐Ÿ†• - X25519 ๐Ÿ†• - ED25519 ๐Ÿ†• - DH ๐Ÿ†• - **Private key export** - RSA ๐Ÿ†• - DSA ๐Ÿ†• - EC ๐Ÿ†• - X25519 ๐Ÿ†• - ED25519 ๐Ÿ†• - DH ๐Ÿ†• - **Public key export** - RSA - DSA ๐Ÿ†• - EC ๐Ÿ†• - X25519 ๐Ÿ†• - ED25519 ๐Ÿ†• - DH ๐Ÿ†• - **Key pair generation** - Overhauled, but supported APIs unchanged This PR adds a lot of new individual functionality. But most importantly because of the new key material representation, it is now trivial to add new algorithms (as shown by this PR). Now, when adding a new algorithm, it is also widely supported - for example previously we supported ED25519 key pair generation, but we could not import, export, sign or verify with ED25519. We can now do all of those things.
2024-06-24fix(ext/node): rewrite crypto.Hash (#24302)Luca Casonato
Changes in this PR: - Added new fixed size hash algorithms (blake2b512, blake2s256, sha512-224, sha512-256, sha3-224, sha3-256, sha3-384, sha3-512, sm3) - Added variable size hash algorithms (the concept), with the algorithms shake128 and shake256 - Use cppgc instead of resources for the hasher - Enable Node's crypto.Hash tests and fix found bugs
2024-01-29refactor: migrate 'ext/node' extension to virtual ops module (#22157)Bartek Iwaล„czuk
Follow up to https://github.com/denoland/deno/pull/22135
2024-01-10refactor: use `core.ensureFastOps()` (#21888)Kenta Moriuchi
2024-01-01chore: update copyright to 2024 (#21753)David Sherret
2023-07-02refactor: rename built-in node modules from ext:deno_node/ to node: (#19680)Bartek Iwaล„czuk
Closes https://github.com/denoland/deno/issues/19510
2023-06-27chore(ext/node): disable prefer-primordials on a per-file basis (#19553)Kenta Moriuchi
2023-06-27test(ext/node): port crypto_test.ts from deno_std (#19561)Felipe Baltor
2023-04-25fix(ext/node): fix hash.flush (#18818)Yoshiya Hinosawa
2023-03-28fix(ext/node): implement crypto.Sign (RSA/PEM/SHA{224,256,384,512}) (#18471)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-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-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-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): 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-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>