@sebastienrousseau/crypto-lib 0.0.34 → 0.0.36
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 +17 -2
- package/dist/accel/index.d.ts +5 -4
- package/dist/accel/index.d.ts.map +1 -1
- package/dist/accel/index.js +5 -5
- package/dist/accel/kdf-backend.d.ts +13 -0
- package/dist/accel/kdf-backend.d.ts.map +1 -0
- package/dist/accel/kdf-backend.js +81 -0
- package/dist/accel/native-pqc-bridge.d.ts.map +1 -1
- package/dist/accel/native-pqc-bridge.js +12 -52
- package/dist/accel/pq-backend.d.ts +3652 -0
- package/dist/accel/pq-backend.d.ts.map +1 -0
- package/dist/accel/pq-backend.js +215 -0
- package/dist/accel/runtime.d.ts +3 -0
- package/dist/accel/runtime.d.ts.map +1 -0
- package/dist/accel/runtime.js +9 -0
- package/dist/accel/wasm-bridge.d.ts.map +1 -1
- package/dist/accel/wasm-bridge.js +14 -13
- package/dist/accel/webcrypto-bridge.d.ts.map +1 -1
- package/dist/accel/webcrypto-bridge.js +14 -13
- package/dist/accel/webcrypto-modern.d.ts.map +1 -1
- package/dist/accel/webcrypto-modern.js +15 -14
- package/dist/accel/worker-pool.d.ts +18 -0
- package/dist/accel/worker-pool.d.ts.map +1 -1
- package/dist/accel/worker-pool.js +113 -37
- package/dist/bin/cryptolib.d.ts +7 -4
- package/dist/bin/cryptolib.d.ts.map +1 -1
- package/dist/bin/cryptolib.js +6 -6
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +2 -1
- package/dist/encoding.d.ts +10 -0
- package/dist/encoding.d.ts.map +1 -0
- package/dist/encoding.js +84 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +20 -1
- package/dist/high-level/key-wrap.d.ts.map +1 -1
- package/dist/high-level/key-wrap.js +12 -17
- package/dist/high-level/multi-recipient.d.ts.map +1 -1
- package/dist/high-level/multi-recipient.js +15 -28
- package/dist/high-level/password-encrypt.d.ts.map +1 -1
- package/dist/high-level/password-encrypt.js +11 -11
- package/dist/high-level/sealedbox.d.ts.map +1 -1
- package/dist/high-level/sealedbox.js +16 -28
- package/dist/high-level/secretbox.d.ts.map +1 -1
- package/dist/high-level/secretbox.js +11 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/key/keystore.d.ts.map +1 -1
- package/dist/key/keystore.js +2 -1
- package/dist/keys/keygen.d.ts.map +1 -1
- package/dist/keys/keygen.js +13 -14
- package/dist/keys/keyring.d.ts.map +1 -1
- package/dist/keys/keyring.js +4 -2
- package/dist/keys/serialize.d.ts.map +1 -1
- package/dist/keys/serialize.js +18 -16
- package/dist/lib/decrypt.d.ts.map +1 -1
- package/dist/lib/decrypt.js +2 -1
- package/dist/lib/generate.d.ts +2 -1
- package/dist/lib/generate.d.ts.map +1 -1
- package/dist/lib/generate.js +7 -6
- package/dist/lib/key-output.d.ts +4 -1
- package/dist/lib/key-output.d.ts.map +1 -1
- package/dist/lib/key-output.js +2 -2
- package/dist/lib/reformat.d.ts +2 -1
- package/dist/lib/reformat.d.ts.map +1 -1
- package/dist/lib/reformat.js +2 -2
- package/dist/lib/revoke.d.ts +2 -1
- package/dist/lib/revoke.d.ts.map +1 -1
- package/dist/lib/revoke.js +2 -2
- package/dist/lib/verify.d.ts +6 -2
- package/dist/lib/verify.d.ts.map +1 -1
- package/dist/lib/verify.js +28 -9
- package/dist/modern/aead.d.ts.map +1 -1
- package/dist/modern/aead.js +11 -10
- package/dist/modern/aes.d.ts.map +1 -1
- package/dist/modern/aes.js +10 -9
- package/dist/modern/cost-limits.d.ts.map +1 -1
- package/dist/modern/cost-limits.js +3 -2
- package/dist/modern/curves.d.ts +10 -5
- package/dist/modern/curves.d.ts.map +1 -1
- package/dist/modern/curves.js +43 -36
- package/dist/modern/ecdh.d.ts +2 -1
- package/dist/modern/ecdh.d.ts.map +1 -1
- package/dist/modern/ecdh.js +10 -9
- package/dist/modern/fn-dsa.d.ts.map +1 -1
- package/dist/modern/fn-dsa.js +9 -8
- package/dist/modern/hash.d.ts.map +1 -1
- package/dist/modern/hash.js +5 -3
- package/dist/modern/hpke-xwing.d.ts +10 -0
- package/dist/modern/hpke-xwing.d.ts.map +1 -0
- package/dist/modern/hpke-xwing.js +26 -0
- package/dist/modern/hpke.d.ts +1 -1
- package/dist/modern/hpke.d.ts.map +1 -1
- package/dist/modern/hpke.js +60 -28
- package/dist/modern/hybrid-combiner.d.ts +20 -0
- package/dist/modern/hybrid-combiner.d.ts.map +1 -0
- package/dist/modern/hybrid-combiner.js +79 -0
- package/dist/modern/index.d.ts +10 -10
- package/dist/modern/index.d.ts.map +1 -1
- package/dist/modern/index.js +17 -7
- package/dist/modern/kdf.d.ts.map +1 -1
- package/dist/modern/kdf.js +12 -12
- package/dist/modern/mac.d.ts +1 -0
- package/dist/modern/mac.d.ts.map +1 -1
- package/dist/modern/mac.js +24 -15
- package/dist/modern/password.d.ts.map +1 -1
- package/dist/modern/password.js +19 -18
- package/dist/modern/pq-hash-sign.d.ts.map +1 -1
- package/dist/modern/pq-hash-sign.js +23 -22
- package/dist/modern/pq-kem.d.ts +8 -0
- package/dist/modern/pq-kem.d.ts.map +1 -1
- package/dist/modern/pq-kem.js +71 -79
- package/dist/modern/pq-sign.d.ts +9 -2
- package/dist/modern/pq-sign.d.ts.map +1 -1
- package/dist/modern/pq-sign.js +60 -23
- package/dist/modern/pq.d.ts +0 -17
- package/dist/modern/pq.d.ts.map +1 -1
- package/dist/modern/pq.js +15 -43
- package/dist/modern/signing.d.ts +2 -1
- package/dist/modern/signing.d.ts.map +1 -1
- package/dist/modern/signing.js +14 -13
- package/dist/protocols/iso20022.d.ts.map +1 -1
- package/dist/protocols/iso20022.js +12 -6
- package/dist/protocols/opaque/ksf.js +2 -2
- package/dist/protocols/opaque/suite.d.ts +1 -8
- package/dist/protocols/opaque/suite.d.ts.map +1 -1
- package/dist/protocols/opaque/suite.js +5 -10
- package/dist/protocols/pqxdh.d.ts +9 -2
- package/dist/protocols/pqxdh.d.ts.map +1 -1
- package/dist/protocols/pqxdh.js +99 -94
- package/dist/protocols/ratchet.d.ts.map +1 -1
- package/dist/protocols/ratchet.js +14 -15
- package/dist/protocols/threshold.d.ts.map +1 -1
- package/dist/protocols/threshold.js +16 -15
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +26 -0
- package/dist/streaming/chunks.d.ts +40 -0
- package/dist/streaming/chunks.d.ts.map +1 -0
- package/dist/streaming/chunks.js +173 -0
- package/dist/streaming/stream-aead.d.ts +9 -0
- package/dist/streaming/stream-aead.d.ts.map +1 -1
- package/dist/streaming/stream-aead.js +33 -82
- package/dist/streaming/stream-hash.d.ts.map +1 -1
- package/dist/streaming/stream-hash.js +6 -4
- package/dist/streaming/stream-multi-pq-aead.d.ts +12 -0
- package/dist/streaming/stream-multi-pq-aead.d.ts.map +1 -1
- package/dist/streaming/stream-multi-pq-aead.js +90 -147
- package/dist/streaming/stream-pq-aead.d.ts +7 -3
- package/dist/streaming/stream-pq-aead.d.ts.map +1 -1
- package/dist/streaming/stream-pq-aead.js +34 -114
- package/dist/streaming/web-streams.d.ts +5 -2
- package/dist/streaming/web-streams.d.ts.map +1 -1
- package/dist/streaming/web-streams.js +90 -151
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +13 -0
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/key-rotation.d.ts.map +1 -1
- package/dist/tokens/key-rotation.js +4 -2
- package/dist/tokens/paseto.d.ts +2 -0
- package/dist/tokens/paseto.d.ts.map +1 -1
- package/dist/tokens/paseto.js +56 -29
- package/dist/types/types.d.ts +1 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +3 -2
- package/package.json +12 -2
- package/dist/config/config.d.ts +0 -8
- package/dist/config/config.d.ts.map +0 -1
- package/dist/config/config.js +0 -13
- package/dist/key/key.d.ts +0 -10
- package/dist/key/key.d.ts.map +0 -1
- package/dist/key/key.js +0 -25
package/README.md
CHANGED
|
@@ -108,12 +108,12 @@ Crypto Service provides a complete cryptography stack across 14 specialized pack
|
|
|
108
108
|
|
|
109
109
|
| Package | Role | Description |
|
|
110
110
|
| :---------------------------------------------------------------------------------------------------------------------------------------- | :--------------- | :----------------------------------------------------------------------------------------------------------------------------- |
|
|
111
|
-
| [`@sebastienrousseau/crypto-api`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-api) | API
|
|
111
|
+
| [`@sebastienrousseau/crypto-api`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-api) | API docs | Postman collection types and a Postman-to-Markdown converter; the server's API contract is its OpenAPI document. |
|
|
112
112
|
| [`@sebastienrousseau/crypto-benchmarks`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-benchmarks) | Benchmarks | Benchmarks comparing classical and post-quantum cryptography: ops/sec, latency and throughput. |
|
|
113
113
|
| [`@sebastienrousseau/crypto-cbom`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-cbom) | CBOM | Cryptographic Bill of Materials generator and auditor (CycloneDX 1.6, SPDX 3.0). |
|
|
114
114
|
| [`@sebastienrousseau/crypto-cli`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-cli) | Terminal CLI | Command-line interface: hashing, key generation, encryption, signing, HPKE, Argon2id and CBOM scans, with an interactive menu. |
|
|
115
115
|
| [`@sebastienrousseau/crypto-edge`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-edge) | Edge Runtime | Edge-runtime cryptographic operations using the Web Crypto API, optimized for Cloudflare Workers, Vercel Edge, and Deno. |
|
|
116
|
-
| [`@sebastienrousseau/crypto-kms`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-kms) | Cloud KMS | Unified KMS interface: AWS KMS and local providers
|
|
116
|
+
| [`@sebastienrousseau/crypto-kms`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-kms) | Cloud KMS | Unified KMS interface: AWS KMS, Google Cloud KMS, Vault Transit and local providers; Azure is a stub. |
|
|
117
117
|
| **[`@sebastienrousseau/crypto-lib`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-lib)** _(this package)_ | **Core Library** | **Core library: post-quantum ML-KEM, ML-DSA and SLH-DSA, plus classical, modern and OpenPGP cryptography for TypeScript.** |
|
|
118
118
|
| [`@sebastienrousseau/crypto-lsp`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-lsp) | IDE Analysis | Language server that flags weak and quantum-vulnerable cryptography in the editor, with quick fixes. |
|
|
119
119
|
| [`@sebastienrousseau/crypto-mcp`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-mcp) | AI Agents | Model Context Protocol server exposing cryptography tools to AI assistants and agents. |
|
|
@@ -143,6 +143,21 @@ SLH-DSA) are first-class citizens, not add-ons, and hybrid
|
|
|
143
143
|
constructions combine classical and PQ algorithms so security holds
|
|
144
144
|
even if one family breaks.
|
|
145
145
|
|
|
146
|
+
On Node.js 24.7 and later, ML-KEM, ML-DSA and SLH-DSA run in the
|
|
147
|
+
runtime's own OpenSSL 3.5 instead: measured on an Apple A18 Pro with
|
|
148
|
+
Node.js 24.21, ML-KEM-768 encapsulation is about 7 times faster,
|
|
149
|
+
ML-DSA-65 signing about 20 times and SLH-DSA-SHA2-128f signing about 6
|
|
150
|
+
times. Keys, ciphertexts and signatures are the same raw bytes as
|
|
151
|
+
noble's, so data made on one runtime works on another, and noble still
|
|
152
|
+
runs in browsers, edge runtimes and older Node.js. `nativeAlgorithms()`
|
|
153
|
+
in `@sebastienrousseau/crypto-lib/accel` lists what runs natively.
|
|
154
|
+
|
|
155
|
+
In a browser, import from the `./modern`, `./high-level`, `./keys`,
|
|
156
|
+
`./streaming`, `./protocols` and `./tokens` subpaths: they use no
|
|
157
|
+
Node.js API (each is bundled for the browser and run in Chrome in
|
|
158
|
+
testing). The main entry also loads the OpenPGP API and the file
|
|
159
|
+
keystore, and `./accel` the worker pool, which need Node.js.
|
|
160
|
+
|
|
146
161
|
Two API layers serve different needs: a unified `crypto.*` namespace
|
|
147
162
|
for common tasks, and granular per-module imports for full control
|
|
148
163
|
and tree-shaking. Both layers use the same underlying noble
|
package/dist/accel/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { isWebCryptoAvailable, webCryptoAesGcmEncrypt, webCryptoAesGcmDecrypt, webCryptoHash, } from "./webcrypto-bridge";
|
|
2
2
|
export type { WebCryptoHashAlgorithm, WebCryptoAesGcmEncryptOptions, WebCryptoAesGcmEncryptResult, WebCryptoAesGcmDecryptOptions, WebCryptoAesGcmDecryptResult, WebCryptoHashOptions, WebCryptoHashResult, } from "./webcrypto-bridge";
|
|
3
|
-
export { WorkerPool } from "./worker-pool";
|
|
3
|
+
export { WorkerPool, WorkerPoolBusyError, WorkerTaskTimeoutError, } from "./worker-pool";
|
|
4
4
|
export type { WorkerPoolOptions, WorkerTask } from "./worker-pool";
|
|
5
|
-
export { detectWasmBackend, wasmHash, wasmAeadEncrypt, wasmAeadDecrypt,
|
|
5
|
+
export { detectWasmBackend, wasmHash, wasmAeadEncrypt, wasmAeadDecrypt, } from "./wasm-bridge";
|
|
6
6
|
export type { WasmBackend, WasmHashAlgorithm, WasmHashOptions, WasmHashResult, WasmAeadEncryptOptions, WasmAeadEncryptResult, WasmAeadDecryptResult, } from "./wasm-bridge";
|
|
7
|
-
export { hasNativePqc,
|
|
7
|
+
export { hasNativePqc, pqcBackend, bridgedMlKemKeygen, bridgedMlKemEncapsulate, bridgedMlKemDecapsulate, } from "./native-pqc-bridge";
|
|
8
|
+
export { nativeAlgorithms } from "./pq-backend";
|
|
8
9
|
export type { PqcBackend, NativeMlKemLevel, BridgedMlKemKeygenResult, BridgedMlKemEncapsulateResult, } from "./native-pqc-bridge";
|
|
9
|
-
export { detectModernWebCrypto,
|
|
10
|
+
export { detectModernWebCrypto, modernChaCha20Encrypt, modernChaCha20Decrypt, modernSha3Hash, } from "./webcrypto-modern";
|
|
10
11
|
export type { WebCryptoModernSupport, ModernSha3Algorithm, ModernChaCha20EncryptOptions, ModernAeadResult, ModernChaCha20DecryptOptions, ModernChaCha20DecryptResult, ModernSha3HashOptions, ModernSha3HashResult, } from "./webcrypto-modern";
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/accel/index.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,GACd,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,sBAAsB,EACtB,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,EAC7B,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/accel/index.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,GACd,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,sBAAsB,EACtB,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,EAC7B,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,4BAA4B,EAC5B,gBAAgB,EAChB,4BAA4B,EAC5B,2BAA2B,EAC3B,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
|
package/dist/accel/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.modernSha3Hash = exports.modernChaCha20Decrypt = exports.modernChaCha20Encrypt = exports.
|
|
3
|
+
exports.modernSha3Hash = exports.modernChaCha20Decrypt = exports.modernChaCha20Encrypt = exports.detectModernWebCrypto = exports.nativeAlgorithms = exports.bridgedMlKemDecapsulate = exports.bridgedMlKemEncapsulate = exports.bridgedMlKemKeygen = exports.pqcBackend = exports.hasNativePqc = exports.wasmAeadDecrypt = exports.wasmAeadEncrypt = exports.wasmHash = exports.detectWasmBackend = exports.WorkerTaskTimeoutError = exports.WorkerPoolBusyError = exports.WorkerPool = exports.webCryptoHash = exports.webCryptoAesGcmDecrypt = exports.webCryptoAesGcmEncrypt = exports.isWebCryptoAvailable = void 0;
|
|
4
4
|
var webcrypto_bridge_1 = require("./webcrypto-bridge");
|
|
5
5
|
Object.defineProperty(exports, "isWebCryptoAvailable", { enumerable: true, get: function () { return webcrypto_bridge_1.isWebCryptoAvailable; } });
|
|
6
6
|
Object.defineProperty(exports, "webCryptoAesGcmEncrypt", { enumerable: true, get: function () { return webcrypto_bridge_1.webCryptoAesGcmEncrypt; } });
|
|
@@ -8,23 +8,23 @@ Object.defineProperty(exports, "webCryptoAesGcmDecrypt", { enumerable: true, get
|
|
|
8
8
|
Object.defineProperty(exports, "webCryptoHash", { enumerable: true, get: function () { return webcrypto_bridge_1.webCryptoHash; } });
|
|
9
9
|
var worker_pool_1 = require("./worker-pool");
|
|
10
10
|
Object.defineProperty(exports, "WorkerPool", { enumerable: true, get: function () { return worker_pool_1.WorkerPool; } });
|
|
11
|
+
Object.defineProperty(exports, "WorkerPoolBusyError", { enumerable: true, get: function () { return worker_pool_1.WorkerPoolBusyError; } });
|
|
12
|
+
Object.defineProperty(exports, "WorkerTaskTimeoutError", { enumerable: true, get: function () { return worker_pool_1.WorkerTaskTimeoutError; } });
|
|
11
13
|
var wasm_bridge_1 = require("./wasm-bridge");
|
|
12
14
|
Object.defineProperty(exports, "detectWasmBackend", { enumerable: true, get: function () { return wasm_bridge_1.detectWasmBackend; } });
|
|
13
15
|
Object.defineProperty(exports, "wasmHash", { enumerable: true, get: function () { return wasm_bridge_1.wasmHash; } });
|
|
14
16
|
Object.defineProperty(exports, "wasmAeadEncrypt", { enumerable: true, get: function () { return wasm_bridge_1.wasmAeadEncrypt; } });
|
|
15
17
|
Object.defineProperty(exports, "wasmAeadDecrypt", { enumerable: true, get: function () { return wasm_bridge_1.wasmAeadDecrypt; } });
|
|
16
|
-
Object.defineProperty(exports, "_resetWasmDetection", { enumerable: true, get: function () { return wasm_bridge_1._resetWasmDetection; } });
|
|
17
18
|
var native_pqc_bridge_1 = require("./native-pqc-bridge");
|
|
18
19
|
Object.defineProperty(exports, "hasNativePqc", { enumerable: true, get: function () { return native_pqc_bridge_1.hasNativePqc; } });
|
|
19
|
-
Object.defineProperty(exports, "resetNativePqcCache", { enumerable: true, get: function () { return native_pqc_bridge_1.resetNativePqcCache; } });
|
|
20
|
-
Object.defineProperty(exports, "_forceNativePqcDetected", { enumerable: true, get: function () { return native_pqc_bridge_1._forceNativePqcDetected; } });
|
|
21
20
|
Object.defineProperty(exports, "pqcBackend", { enumerable: true, get: function () { return native_pqc_bridge_1.pqcBackend; } });
|
|
22
21
|
Object.defineProperty(exports, "bridgedMlKemKeygen", { enumerable: true, get: function () { return native_pqc_bridge_1.bridgedMlKemKeygen; } });
|
|
23
22
|
Object.defineProperty(exports, "bridgedMlKemEncapsulate", { enumerable: true, get: function () { return native_pqc_bridge_1.bridgedMlKemEncapsulate; } });
|
|
24
23
|
Object.defineProperty(exports, "bridgedMlKemDecapsulate", { enumerable: true, get: function () { return native_pqc_bridge_1.bridgedMlKemDecapsulate; } });
|
|
24
|
+
var pq_backend_1 = require("./pq-backend");
|
|
25
|
+
Object.defineProperty(exports, "nativeAlgorithms", { enumerable: true, get: function () { return pq_backend_1.nativeAlgorithms; } });
|
|
25
26
|
var webcrypto_modern_1 = require("./webcrypto-modern");
|
|
26
27
|
Object.defineProperty(exports, "detectModernWebCrypto", { enumerable: true, get: function () { return webcrypto_modern_1.detectModernWebCrypto; } });
|
|
27
|
-
Object.defineProperty(exports, "_resetModernWebCryptoDetection", { enumerable: true, get: function () { return webcrypto_modern_1._resetModernWebCryptoDetection; } });
|
|
28
28
|
Object.defineProperty(exports, "modernChaCha20Encrypt", { enumerable: true, get: function () { return webcrypto_modern_1.modernChaCha20Encrypt; } });
|
|
29
29
|
Object.defineProperty(exports, "modernChaCha20Decrypt", { enumerable: true, get: function () { return webcrypto_modern_1.modernChaCha20Decrypt; } });
|
|
30
30
|
Object.defineProperty(exports, "modernSha3Hash", { enumerable: true, get: function () { return webcrypto_modern_1.modernSha3Hash; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { argon2id as nobleArgon2id } from "@noble/hashes/argon2.js";
|
|
2
|
+
import { pbkdf2 as noblePbkdf2 } from "@noble/hashes/pbkdf2.js";
|
|
3
|
+
import { scrypt as nobleScrypt } from "@noble/hashes/scrypt.js";
|
|
4
|
+
export type Input = string | Uint8Array;
|
|
5
|
+
export declare function nativeKdfFallbacks(): number;
|
|
6
|
+
export type Argon2Opts = Parameters<typeof nobleArgon2id>[2];
|
|
7
|
+
export type Argon2Fn = (password: Input, salt: Input, opts: Argon2Opts) => Uint8Array;
|
|
8
|
+
export declare const argon2id: Argon2Fn;
|
|
9
|
+
export declare const argon2i: Argon2Fn;
|
|
10
|
+
export declare const argon2d: Argon2Fn;
|
|
11
|
+
export declare const scrypt: typeof nobleScrypt;
|
|
12
|
+
export declare const pbkdf2: typeof noblePbkdf2;
|
|
13
|
+
//# sourceMappingURL=kdf-backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kdf-backend.d.ts","sourceRoot":"","sources":["../../src/accel/kdf-backend.ts"],"names":[],"mappings":"AAmBA,OAAO,EAGL,QAAQ,IAAI,aAAa,EAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAQhE,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,UAAU,CAAC;AAMxC,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAsBD,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAG7D,MAAM,MAAM,QAAQ,GAAG,CACrB,QAAQ,EAAE,KAAK,EACf,IAAI,EAAE,KAAK,EACX,IAAI,EAAE,UAAU,KACb,UAAU,CAAC;AA6ChB,eAAO,MAAM,QAAQ,UAAoC,CAAC;AAE1D,eAAO,MAAM,OAAO,UAAkC,CAAC;AAEvD,eAAO,MAAM,OAAO,UAAkC,CAAC;AAQvD,eAAO,MAAM,MAAM,EAAE,OAAO,WAczB,CAAC;AAYJ,eAAO,MAAM,MAAM,EAAE,OAAO,WAiB3B,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pbkdf2 = exports.scrypt = exports.argon2d = exports.argon2i = exports.argon2id = void 0;
|
|
4
|
+
exports.nativeKdfFallbacks = nativeKdfFallbacks;
|
|
5
|
+
const argon2_js_1 = require("@noble/hashes/argon2.js");
|
|
6
|
+
const pbkdf2_js_1 = require("@noble/hashes/pbkdf2.js");
|
|
7
|
+
const scrypt_js_1 = require("@noble/hashes/scrypt.js");
|
|
8
|
+
const sha2_js_1 = require("@noble/hashes/sha2.js");
|
|
9
|
+
const runtime_1 = require("./runtime");
|
|
10
|
+
const nodeCrypto = (0, runtime_1.runtimeCrypto)();
|
|
11
|
+
let fallbacks = 0;
|
|
12
|
+
function nativeKdfFallbacks() {
|
|
13
|
+
return fallbacks;
|
|
14
|
+
}
|
|
15
|
+
function nativeOr(fast, slow) {
|
|
16
|
+
if (fast) {
|
|
17
|
+
try {
|
|
18
|
+
return fast();
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
fallbacks += 1;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return slow();
|
|
25
|
+
}
|
|
26
|
+
function only(opts, allowed) {
|
|
27
|
+
return Object.keys(opts).every((key) => allowed.includes(key));
|
|
28
|
+
}
|
|
29
|
+
function argon2Costs(opts) {
|
|
30
|
+
const { t, m, p, dkLen } = (opts ?? {});
|
|
31
|
+
const costs = [t, m, p, dkLen ?? 32];
|
|
32
|
+
if (!only(opts ?? {}, ["t", "m", "p", "dkLen"]))
|
|
33
|
+
return undefined;
|
|
34
|
+
if (!costs.every((n) => typeof n === "number"))
|
|
35
|
+
return undefined;
|
|
36
|
+
const [passes, memory, parallelism, tagLength] = costs;
|
|
37
|
+
return {
|
|
38
|
+
passes: passes,
|
|
39
|
+
memory: memory,
|
|
40
|
+
parallelism: parallelism,
|
|
41
|
+
tagLength: tagLength,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function argon2(variant, noble) {
|
|
45
|
+
return (password, salt, opts) => {
|
|
46
|
+
const costs = argon2Costs(opts);
|
|
47
|
+
return nativeOr(nodeCrypto?.argon2Sync && costs
|
|
48
|
+
? () => new Uint8Array(nodeCrypto.argon2Sync(variant, {
|
|
49
|
+
message: password,
|
|
50
|
+
nonce: salt,
|
|
51
|
+
...costs,
|
|
52
|
+
}))
|
|
53
|
+
: undefined, () => noble(password, salt, opts));
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
exports.argon2id = argon2("argon2id", argon2_js_1.argon2id);
|
|
57
|
+
exports.argon2i = argon2("argon2i", argon2_js_1.argon2i);
|
|
58
|
+
exports.argon2d = argon2("argon2d", argon2_js_1.argon2d);
|
|
59
|
+
const SCRYPT_MAXMEM = 1024 ** 3;
|
|
60
|
+
const scrypt = (password, salt, opts) => nativeOr(nodeCrypto && only(opts, ["N", "r", "p", "dkLen", "maxmem"])
|
|
61
|
+
? () => new Uint8Array(nodeCrypto.scryptSync(password, salt, opts.dkLen ?? 32, {
|
|
62
|
+
N: opts.N,
|
|
63
|
+
r: opts.r,
|
|
64
|
+
p: opts.p,
|
|
65
|
+
maxmem: opts.maxmem ?? SCRYPT_MAXMEM,
|
|
66
|
+
}))
|
|
67
|
+
: undefined, () => (0, scrypt_js_1.scrypt)(password, salt, opts));
|
|
68
|
+
exports.scrypt = scrypt;
|
|
69
|
+
const DIGESTS = new Map([
|
|
70
|
+
[sha2_js_1.sha256, "sha256"],
|
|
71
|
+
[sha2_js_1.sha384, "sha384"],
|
|
72
|
+
[sha2_js_1.sha512, "sha512"],
|
|
73
|
+
]);
|
|
74
|
+
const pbkdf2 = (hash, password, salt, opts) => {
|
|
75
|
+
const digest = DIGESTS.get(hash);
|
|
76
|
+
return nativeOr(nodeCrypto && digest && only(opts, ["c", "dkLen"])
|
|
77
|
+
? () => new Uint8Array(nodeCrypto.pbkdf2Sync(password, salt, opts.c, opts.dkLen ?? 32, digest))
|
|
78
|
+
: undefined, () => (0, pbkdf2_js_1.pbkdf2)(hash, password, salt, opts));
|
|
79
|
+
};
|
|
80
|
+
exports.pbkdf2 = pbkdf2;
|
|
81
|
+
//# sourceMappingURL=kdf-backend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-pqc-bridge.d.ts","sourceRoot":"","sources":["../../src/accel/native-pqc-bridge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"native-pqc-bridge.d.ts","sourceRoot":"","sources":["../../src/accel/native-pqc-bridge.ts"],"names":[],"mappings":"AAqCA,wBAAgB,YAAY,IAAI,OAAO,CAOtC;AAUD,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAUD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE5D;AAGD,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;AAU5C,wBAAgB,UAAU,IAAI,UAAU,CAEvC;AAKD,MAAM,MAAM,gBAAgB,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;AAGhD,MAAM,WAAW,wBAAwB;IAEvC,SAAS,EAAE,UAAU,CAAC;IAEtB,SAAS,EAAE,UAAU,CAAC;CACvB;AAGD,MAAM,WAAW,6BAA6B;IAE5C,UAAU,EAAE,UAAU,CAAC;IAEvB,YAAY,EAAE,UAAU,CAAC;CAC1B;AAuCD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,gBAAgB,GACtB,wBAAwB,CAI1B;AAgBD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,gBAAgB,EACvB,SAAS,EAAE,UAAU,GACpB,6BAA6B,CAI/B;AAiBD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,gBAAgB,EACvB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,UAAU,GACpB,UAAU,CAIZ"}
|
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.hasNativePqc = hasNativePqc;
|
|
37
4
|
exports.resetNativePqcCache = resetNativePqcCache;
|
|
@@ -40,21 +7,14 @@ exports.pqcBackend = pqcBackend;
|
|
|
40
7
|
exports.bridgedMlKemKeygen = bridgedMlKemKeygen;
|
|
41
8
|
exports.bridgedMlKemEncapsulate = bridgedMlKemEncapsulate;
|
|
42
9
|
exports.bridgedMlKemDecapsulate = bridgedMlKemDecapsulate;
|
|
43
|
-
const
|
|
44
|
-
const
|
|
10
|
+
const pq_backend_1 = require("./pq-backend");
|
|
11
|
+
const errors_1 = require("../errors");
|
|
45
12
|
let _nativePqcDetected;
|
|
46
13
|
function hasNativePqc() {
|
|
47
14
|
if (_nativePqcDetected !== undefined)
|
|
48
15
|
return _nativePqcDetected;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
_nativePqcDetected =
|
|
52
|
-
typeof c.encapsulate === "function" &&
|
|
53
|
-
typeof c.decapsulate === "function";
|
|
54
|
-
}
|
|
55
|
-
catch {
|
|
56
|
-
_nativePqcDetected = false;
|
|
57
|
-
}
|
|
16
|
+
const native = (0, pq_backend_1.nativeAlgorithms)();
|
|
17
|
+
_nativePqcDetected = ["ml-kem-512", "ml-kem-768", "ml-kem-1024"].every((name) => native.includes(name));
|
|
58
18
|
return _nativePqcDetected;
|
|
59
19
|
}
|
|
60
20
|
function resetNativePqcCache() {
|
|
@@ -69,32 +29,32 @@ function pqcBackend() {
|
|
|
69
29
|
const VALID_LEVELS = new Set([512, 768, 1024]);
|
|
70
30
|
function assertLevel(level) {
|
|
71
31
|
if (!VALID_LEVELS.has(level)) {
|
|
72
|
-
throw new
|
|
32
|
+
throw new errors_1.CryptoError(`Unsupported ML-KEM level: ${level}. Supported: 512, 768, 1024`, errors_1.CryptoErrorCode.UNSUPPORTED_ALGORITHM);
|
|
73
33
|
}
|
|
74
34
|
}
|
|
75
|
-
function
|
|
35
|
+
function getKem(level) {
|
|
76
36
|
switch (level) {
|
|
77
37
|
case 512:
|
|
78
|
-
return
|
|
38
|
+
return pq_backend_1.ml_kem512;
|
|
79
39
|
case 768:
|
|
80
|
-
return
|
|
40
|
+
return pq_backend_1.ml_kem768;
|
|
81
41
|
case 1024:
|
|
82
|
-
return
|
|
42
|
+
return pq_backend_1.ml_kem1024;
|
|
83
43
|
}
|
|
84
44
|
}
|
|
85
45
|
function bridgedMlKemKeygen(level) {
|
|
86
46
|
assertLevel(level);
|
|
87
|
-
const kem =
|
|
47
|
+
const kem = getKem(level);
|
|
88
48
|
return kem.keygen();
|
|
89
49
|
}
|
|
90
50
|
function bridgedMlKemEncapsulate(level, publicKey) {
|
|
91
51
|
assertLevel(level);
|
|
92
|
-
const kem =
|
|
52
|
+
const kem = getKem(level);
|
|
93
53
|
return kem.encapsulate(publicKey);
|
|
94
54
|
}
|
|
95
55
|
function bridgedMlKemDecapsulate(level, cipherText, secretKey) {
|
|
96
56
|
assertLevel(level);
|
|
97
|
-
const kem =
|
|
57
|
+
const kem = getKem(level);
|
|
98
58
|
return kem.decapsulate(cipherText, secretKey);
|
|
99
59
|
}
|
|
100
60
|
//# sourceMappingURL=native-pqc-bridge.js.map
|