@sebastienrousseau/crypto-lib 0.0.2 → 0.0.7
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 +334 -185
- package/dist/accel/index.d.ts +11 -0
- package/dist/accel/index.d.ts.map +1 -0
- package/dist/accel/index.js +31 -0
- package/dist/accel/native-pqc-bridge.d.ts +18 -0
- package/dist/accel/native-pqc-bridge.d.ts.map +1 -0
- package/dist/accel/native-pqc-bridge.js +100 -0
- package/dist/accel/wasm-bridge.d.ts +35 -0
- package/dist/accel/wasm-bridge.d.ts.map +1 -0
- package/dist/accel/wasm-bridge.js +161 -0
- package/dist/accel/webcrypto-bridge.d.ts +32 -0
- package/dist/accel/webcrypto-bridge.d.ts.map +1 -0
- package/dist/accel/webcrypto-bridge.js +179 -0
- package/dist/accel/webcrypto-modern.d.ts +40 -0
- package/dist/accel/webcrypto-modern.d.ts.map +1 -0
- package/dist/accel/webcrypto-modern.js +213 -0
- package/dist/accel/worker-pool.d.ts +23 -0
- package/dist/accel/worker-pool.d.ts.map +1 -0
- package/dist/accel/worker-pool.js +119 -0
- package/dist/bin/cryptolib.d.ts +25 -0
- package/dist/bin/cryptolib.d.ts.map +1 -0
- package/dist/bin/cryptolib.js +87 -0
- package/dist/config/config.d.ts +8 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +13 -0
- package/dist/crypto.d.ts +43 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +107 -0
- package/dist/enums.d.ts +81 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/enums.js +82 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +22 -0
- package/dist/high-level/index.d.ts +11 -0
- package/dist/high-level/index.d.ts.map +1 -0
- package/dist/high-level/index.js +53 -0
- package/dist/high-level/key-wrap.d.ts +16 -0
- package/dist/high-level/key-wrap.d.ts.map +1 -0
- package/dist/high-level/key-wrap.js +93 -0
- package/dist/high-level/multi-recipient.d.ts +25 -0
- package/dist/high-level/multi-recipient.d.ts.map +1 -0
- package/dist/high-level/multi-recipient.js +122 -0
- package/dist/high-level/password-encrypt.d.ts +14 -0
- package/dist/high-level/password-encrypt.d.ts.map +1 -0
- package/dist/high-level/password-encrypt.js +93 -0
- package/dist/high-level/sealedbox.d.ts +13 -0
- package/dist/high-level/sealedbox.d.ts.map +1 -0
- package/dist/high-level/sealedbox.js +119 -0
- package/dist/high-level/secretbox.d.ts +7 -0
- package/dist/high-level/secretbox.d.ts.map +1 -0
- package/dist/high-level/secretbox.js +54 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -2
- package/dist/key/key.d.ts +10 -0
- package/dist/key/key.d.ts.map +1 -0
- package/dist/key/key.js +25 -0
- package/dist/key/keystore.d.ts +11 -0
- package/dist/key/keystore.d.ts.map +1 -0
- package/dist/key/keystore.js +87 -0
- package/dist/keys/index.d.ts +7 -0
- package/dist/keys/index.d.ts.map +1 -0
- package/dist/keys/index.js +22 -0
- package/dist/keys/keygen.d.ts +16 -0
- package/dist/keys/keygen.d.ts.map +1 -0
- package/dist/keys/keygen.js +128 -0
- package/dist/keys/keyring.d.ts +35 -0
- package/dist/keys/keyring.d.ts.map +1 -0
- package/dist/keys/keyring.js +136 -0
- package/dist/keys/serialize.d.ts +30 -0
- package/dist/keys/serialize.d.ts.map +1 -0
- package/dist/keys/serialize.js +120 -0
- package/dist/lib/decrypt.d.ts +5 -5
- package/dist/lib/decrypt.d.ts.map +1 -1
- package/dist/lib/decrypt.js +49 -39
- package/dist/lib/encrypt.d.ts +2 -5
- package/dist/lib/encrypt.d.ts.map +1 -1
- package/dist/lib/encrypt.js +34 -39
- package/dist/lib/generate.d.ts +2 -11
- package/dist/lib/generate.d.ts.map +1 -1
- package/dist/lib/generate.js +57 -29
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +53 -0
- package/dist/lib/key-output.d.ts +7 -0
- package/dist/lib/key-output.d.ts.map +1 -0
- package/dist/lib/key-output.js +50 -0
- package/dist/lib/reformat.d.ts +9 -0
- package/dist/lib/reformat.d.ts.map +1 -0
- package/dist/lib/reformat.js +67 -0
- package/dist/lib/revoke.d.ts +3 -3
- package/dist/lib/revoke.d.ts.map +1 -1
- package/dist/lib/revoke.js +36 -28
- package/dist/lib/session.d.ts +5 -0
- package/dist/lib/session.d.ts.map +1 -0
- package/dist/lib/session.js +55 -0
- package/dist/lib/sign.d.ts +4 -0
- package/dist/lib/sign.d.ts.map +1 -0
- package/dist/lib/sign.js +63 -0
- package/dist/lib/verify.d.ts +5 -0
- package/dist/lib/verify.d.ts.map +1 -0
- package/dist/lib/verify.js +52 -0
- package/dist/modern/aead.d.ts +17 -0
- package/dist/modern/aead.d.ts.map +1 -0
- package/dist/modern/aead.js +51 -0
- package/dist/modern/aes.d.ts +35 -0
- package/dist/modern/aes.d.ts.map +1 -0
- package/dist/modern/aes.js +82 -0
- package/dist/modern/cost-limits.d.ts +11 -0
- package/dist/modern/cost-limits.d.ts.map +1 -0
- package/dist/modern/cost-limits.js +35 -0
- package/dist/modern/curves.d.ts +86 -0
- package/dist/modern/curves.d.ts.map +1 -0
- package/dist/modern/curves.js +171 -0
- package/dist/modern/ecdh.d.ts +11 -0
- package/dist/modern/ecdh.d.ts.map +1 -0
- package/dist/modern/ecdh.js +28 -0
- package/dist/modern/fn-dsa.d.ts +19 -0
- package/dist/modern/fn-dsa.d.ts.map +1 -0
- package/dist/modern/fn-dsa.js +57 -0
- package/dist/modern/hash.d.ts +13 -0
- package/dist/modern/hash.d.ts.map +1 -0
- package/dist/modern/hash.js +45 -0
- package/dist/modern/hpke.d.ts +47 -0
- package/dist/modern/hpke.d.ts.map +1 -0
- package/dist/modern/hpke.js +207 -0
- package/dist/modern/index.d.ts +40 -0
- package/dist/modern/index.d.ts.map +1 -0
- package/dist/modern/index.js +194 -0
- package/dist/modern/kdf.d.ts +23 -0
- package/dist/modern/kdf.d.ts.map +1 -0
- package/dist/modern/kdf.js +67 -0
- package/dist/modern/mac.d.ts +51 -0
- package/dist/modern/mac.d.ts.map +1 -0
- package/dist/modern/mac.js +119 -0
- package/dist/modern/password.d.ts +40 -0
- package/dist/modern/password.d.ts.map +1 -0
- package/dist/modern/password.js +123 -0
- package/dist/modern/pq-hash-sign.d.ts +18 -0
- package/dist/modern/pq-hash-sign.d.ts.map +1 -0
- package/dist/modern/pq-hash-sign.js +73 -0
- package/dist/modern/pq-kem.d.ts +88 -0
- package/dist/modern/pq-kem.d.ts.map +1 -0
- package/dist/modern/pq-kem.js +270 -0
- package/dist/modern/pq-sign.d.ts +30 -0
- package/dist/modern/pq-sign.d.ts.map +1 -0
- package/dist/modern/pq-sign.js +94 -0
- package/dist/modern/pq.d.ts +38 -0
- package/dist/modern/pq.d.ts.map +1 -0
- package/dist/modern/pq.js +80 -0
- package/dist/modern/signing.d.ts +16 -0
- package/dist/modern/signing.d.ts.map +1 -0
- package/dist/modern/signing.js +34 -0
- package/dist/protocols/index.d.ts +7 -0
- package/dist/protocols/index.d.ts.map +1 -0
- package/dist/protocols/index.js +46 -0
- package/dist/protocols/iso20022.d.ts +51 -0
- package/dist/protocols/iso20022.d.ts.map +1 -0
- package/dist/protocols/iso20022.js +145 -0
- package/dist/protocols/opaque/ake.d.ts +51 -0
- package/dist/protocols/opaque/ake.d.ts.map +1 -0
- package/dist/protocols/opaque/ake.js +102 -0
- package/dist/protocols/opaque/client.d.ts +45 -0
- package/dist/protocols/opaque/client.d.ts.map +1 -0
- package/dist/protocols/opaque/client.js +63 -0
- package/dist/protocols/opaque/config.d.ts +14 -0
- package/dist/protocols/opaque/config.d.ts.map +1 -0
- package/dist/protocols/opaque/config.js +18 -0
- package/dist/protocols/opaque/credentials.d.ts +29 -0
- package/dist/protocols/opaque/credentials.d.ts.map +1 -0
- package/dist/protocols/opaque/credentials.js +61 -0
- package/dist/protocols/opaque/envelope.d.ts +36 -0
- package/dist/protocols/opaque/envelope.d.ts.map +1 -0
- package/dist/protocols/opaque/envelope.js +77 -0
- package/dist/protocols/opaque/ksf.d.ts +15 -0
- package/dist/protocols/opaque/ksf.d.ts.map +1 -0
- package/dist/protocols/opaque/ksf.js +27 -0
- package/dist/protocols/opaque/messages.d.ts +61 -0
- package/dist/protocols/opaque/messages.d.ts.map +1 -0
- package/dist/protocols/opaque/messages.js +94 -0
- package/dist/protocols/opaque/server.d.ts +33 -0
- package/dist/protocols/opaque/server.d.ts.map +1 -0
- package/dist/protocols/opaque/server.js +74 -0
- package/dist/protocols/opaque/suite.d.ts +58 -0
- package/dist/protocols/opaque/suite.d.ts.map +1 -0
- package/dist/protocols/opaque/suite.js +115 -0
- package/dist/protocols/pake.d.ts +14 -0
- package/dist/protocols/pake.d.ts.map +1 -0
- package/dist/protocols/pake.js +33 -0
- package/dist/protocols/pqxdh.d.ts +53 -0
- package/dist/protocols/pqxdh.d.ts.map +1 -0
- package/dist/protocols/pqxdh.js +143 -0
- package/dist/protocols/ratchet.d.ts +52 -0
- package/dist/protocols/ratchet.d.ts.map +1 -0
- package/dist/protocols/ratchet.js +187 -0
- package/dist/protocols/threshold.d.ts +23 -0
- package/dist/protocols/threshold.d.ts.map +1 -0
- package/dist/protocols/threshold.js +191 -0
- package/dist/registry.d.ts +20 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +399 -0
- package/dist/streaming/index.d.ts +7 -0
- package/dist/streaming/index.d.ts.map +1 -0
- package/dist/streaming/index.js +15 -0
- package/dist/streaming/stream-aead.d.ts +17 -0
- package/dist/streaming/stream-aead.d.ts.map +1 -0
- package/dist/streaming/stream-aead.js +125 -0
- package/dist/streaming/stream-hash.d.ts +9 -0
- package/dist/streaming/stream-hash.d.ts.map +1 -0
- package/dist/streaming/stream-hash.js +52 -0
- package/dist/streaming/web-streams.d.ts +17 -0
- package/dist/streaming/web-streams.d.ts.map +1 -0
- package/dist/streaming/web-streams.js +114 -0
- package/dist/tokens/index.d.ts +5 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +15 -0
- package/dist/tokens/key-rotation.d.ts +20 -0
- package/dist/tokens/key-rotation.d.ts.map +1 -0
- package/dist/tokens/key-rotation.js +76 -0
- package/dist/tokens/paseto.d.ts +46 -0
- package/dist/tokens/paseto.d.ts.map +1 -0
- package/dist/tokens/paseto.js +200 -0
- package/dist/types/types.d.ts +57 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +1 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +56 -0
- package/package.json +77 -130
- package/dist/COPYRIGHT +0 -15
- package/dist/Report.txt +0 -72
- package/dist/bin/crypto-lib.d.ts +0 -13
- package/dist/bin/crypto-lib.d.ts.map +0 -1
- package/dist/bin/crypto-lib.js +0 -52
- package/dist/bin/crypto-lib.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/decrypt.js.map +0 -1
- package/dist/lib/encrypt.js.map +0 -1
- package/dist/lib/generate.js.map +0 -1
- package/dist/lib/revoke.js.map +0 -1
- package/dist/package.json +0 -131
- package/dist/types/types.js.map +0 -1
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.hasNativePqc = hasNativePqc;
|
|
37
|
+
exports.resetNativePqcCache = resetNativePqcCache;
|
|
38
|
+
exports._forceNativePqcDetected = _forceNativePqcDetected;
|
|
39
|
+
exports.pqcBackend = pqcBackend;
|
|
40
|
+
exports.bridgedMlKemKeygen = bridgedMlKemKeygen;
|
|
41
|
+
exports.bridgedMlKemEncapsulate = bridgedMlKemEncapsulate;
|
|
42
|
+
exports.bridgedMlKemDecapsulate = bridgedMlKemDecapsulate;
|
|
43
|
+
const ml_kem_js_1 = require("@noble/post-quantum/ml-kem.js");
|
|
44
|
+
const nodeCrypto = __importStar(require("node:crypto"));
|
|
45
|
+
let _nativePqcDetected;
|
|
46
|
+
function hasNativePqc() {
|
|
47
|
+
if (_nativePqcDetected !== undefined)
|
|
48
|
+
return _nativePqcDetected;
|
|
49
|
+
try {
|
|
50
|
+
const c = nodeCrypto;
|
|
51
|
+
_nativePqcDetected =
|
|
52
|
+
typeof c.encapsulate === "function" &&
|
|
53
|
+
typeof c.decapsulate === "function";
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
_nativePqcDetected = false;
|
|
57
|
+
}
|
|
58
|
+
return _nativePqcDetected;
|
|
59
|
+
}
|
|
60
|
+
function resetNativePqcCache() {
|
|
61
|
+
_nativePqcDetected = undefined;
|
|
62
|
+
}
|
|
63
|
+
function _forceNativePqcDetected(value) {
|
|
64
|
+
_nativePqcDetected = value;
|
|
65
|
+
}
|
|
66
|
+
function pqcBackend() {
|
|
67
|
+
return hasNativePqc() ? "native" : "noble";
|
|
68
|
+
}
|
|
69
|
+
const VALID_LEVELS = new Set([512, 768, 1024]);
|
|
70
|
+
function assertLevel(level) {
|
|
71
|
+
if (!VALID_LEVELS.has(level)) {
|
|
72
|
+
throw new Error(`Unsupported ML-KEM level: ${level}. Supported: 512, 768, 1024`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function getNobleKem(level) {
|
|
76
|
+
switch (level) {
|
|
77
|
+
case 512:
|
|
78
|
+
return ml_kem_js_1.ml_kem512;
|
|
79
|
+
case 768:
|
|
80
|
+
return ml_kem_js_1.ml_kem768;
|
|
81
|
+
case 1024:
|
|
82
|
+
return ml_kem_js_1.ml_kem1024;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function bridgedMlKemKeygen(level) {
|
|
86
|
+
assertLevel(level);
|
|
87
|
+
const kem = getNobleKem(level);
|
|
88
|
+
return kem.keygen();
|
|
89
|
+
}
|
|
90
|
+
function bridgedMlKemEncapsulate(level, publicKey) {
|
|
91
|
+
assertLevel(level);
|
|
92
|
+
const kem = getNobleKem(level);
|
|
93
|
+
return kem.encapsulate(publicKey);
|
|
94
|
+
}
|
|
95
|
+
function bridgedMlKemDecapsulate(level, cipherText, secretKey) {
|
|
96
|
+
assertLevel(level);
|
|
97
|
+
const kem = getNobleKem(level);
|
|
98
|
+
return kem.decapsulate(cipherText, secretKey);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=native-pqc-bridge.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type WasmBackend = "wasm-simd" | "wasm" | "js";
|
|
2
|
+
export type WasmHashAlgorithm = "sha256" | "sha512" | "sha3-256" | "sha3-512" | "blake3";
|
|
3
|
+
export interface WasmHashOptions {
|
|
4
|
+
algorithm: WasmHashAlgorithm;
|
|
5
|
+
data: string | Uint8Array;
|
|
6
|
+
encoding?: "hex" | "utf8";
|
|
7
|
+
}
|
|
8
|
+
export interface WasmHashResult {
|
|
9
|
+
digest: string;
|
|
10
|
+
algorithm: WasmHashAlgorithm;
|
|
11
|
+
backend: WasmBackend;
|
|
12
|
+
}
|
|
13
|
+
export interface WasmAeadEncryptOptions {
|
|
14
|
+
key: string | Uint8Array;
|
|
15
|
+
plaintext: string | Uint8Array;
|
|
16
|
+
aad?: Uint8Array;
|
|
17
|
+
}
|
|
18
|
+
export interface WasmAeadEncryptResult {
|
|
19
|
+
ciphertext: string;
|
|
20
|
+
backend: WasmBackend;
|
|
21
|
+
}
|
|
22
|
+
export interface WasmAeadDecryptResult {
|
|
23
|
+
plaintext: Uint8Array;
|
|
24
|
+
backend: WasmBackend;
|
|
25
|
+
}
|
|
26
|
+
export declare function detectWasmBackend(): WasmBackend;
|
|
27
|
+
export declare function _resetWasmDetection(): void;
|
|
28
|
+
export declare function wasmHash(options: WasmHashOptions): WasmHashResult;
|
|
29
|
+
export declare function wasmAeadEncrypt(options: WasmAeadEncryptOptions): WasmAeadEncryptResult;
|
|
30
|
+
export declare function wasmAeadDecrypt(options: {
|
|
31
|
+
key: string | Uint8Array;
|
|
32
|
+
ciphertext: string;
|
|
33
|
+
aad?: Uint8Array;
|
|
34
|
+
}): WasmAeadDecryptResult;
|
|
35
|
+
//# sourceMappingURL=wasm-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm-bridge.d.ts","sourceRoot":"","sources":["../../src/accel/wasm-bridge.ts"],"names":[],"mappings":"AA8BA,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;AAGtD,MAAM,MAAM,iBAAiB,GAC3B,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;AAG3D,MAAM,WAAW,eAAe;IAE9B,SAAS,EAAE,iBAAiB,CAAC;IAE7B,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAE1B,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CAC3B;AAGD,MAAM,WAAW,cAAc;IAE7B,MAAM,EAAE,MAAM,CAAC;IAEf,SAAS,EAAE,iBAAiB,CAAC;IAE7B,OAAO,EAAE,WAAW,CAAC;CACtB;AAGD,MAAM,WAAW,sBAAsB;IAErC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;IAEzB,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC;IAE/B,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB;AAGD,MAAM,WAAW,qBAAqB;IAEpC,UAAU,EAAE,MAAM,CAAC;IAEnB,OAAO,EAAE,WAAW,CAAC;CACtB;AAGD,MAAM,WAAW,qBAAqB;IAEpC,SAAS,EAAE,UAAU,CAAC;IAEtB,OAAO,EAAE,WAAW,CAAC;CACtB;AAoBD,wBAAgB,iBAAiB,IAAI,WAAW,CA0E/C;AASD,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAkDD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,cAAc,CAYjE;AAgBD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,sBAAsB,GAC9B,qBAAqB,CAsBvB;AAWD,wBAAgB,eAAe,CAAC,OAAO,EAAE;IAEvC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;IAEzB,UAAU,EAAE,MAAM,CAAC;IAEnB,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB,GAAG,qBAAqB,CAmBxB"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectWasmBackend = detectWasmBackend;
|
|
4
|
+
exports._resetWasmDetection = _resetWasmDetection;
|
|
5
|
+
exports.wasmHash = wasmHash;
|
|
6
|
+
exports.wasmAeadEncrypt = wasmAeadEncrypt;
|
|
7
|
+
exports.wasmAeadDecrypt = wasmAeadDecrypt;
|
|
8
|
+
const sha2_js_1 = require("@noble/hashes/sha2.js");
|
|
9
|
+
const sha3_js_1 = require("@noble/hashes/sha3.js");
|
|
10
|
+
const blake3_js_1 = require("@noble/hashes/blake3.js");
|
|
11
|
+
const chacha_js_1 = require("@noble/ciphers/chacha.js");
|
|
12
|
+
const utils_js_1 = require("@noble/ciphers/utils.js");
|
|
13
|
+
let cachedBackend;
|
|
14
|
+
function detectWasmBackend() {
|
|
15
|
+
if (cachedBackend !== undefined)
|
|
16
|
+
return cachedBackend;
|
|
17
|
+
const g = globalThis;
|
|
18
|
+
const WA = g["WebAssembly"];
|
|
19
|
+
if (!WA) {
|
|
20
|
+
cachedBackend = "js";
|
|
21
|
+
return cachedBackend;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const simdTest = new Uint8Array([
|
|
25
|
+
0x00,
|
|
26
|
+
0x61,
|
|
27
|
+
0x73,
|
|
28
|
+
0x6d,
|
|
29
|
+
0x01,
|
|
30
|
+
0x00,
|
|
31
|
+
0x00,
|
|
32
|
+
0x00,
|
|
33
|
+
0x01,
|
|
34
|
+
0x05,
|
|
35
|
+
0x01,
|
|
36
|
+
0x60,
|
|
37
|
+
0x00,
|
|
38
|
+
0x01,
|
|
39
|
+
0x7b,
|
|
40
|
+
0x03,
|
|
41
|
+
0x02,
|
|
42
|
+
0x01,
|
|
43
|
+
0x00,
|
|
44
|
+
0x0a,
|
|
45
|
+
0x0a,
|
|
46
|
+
0x01,
|
|
47
|
+
0x08,
|
|
48
|
+
0x00,
|
|
49
|
+
0xfd,
|
|
50
|
+
0x0c,
|
|
51
|
+
0x00,
|
|
52
|
+
0x00,
|
|
53
|
+
0x00,
|
|
54
|
+
0x00,
|
|
55
|
+
0x00,
|
|
56
|
+
0x00,
|
|
57
|
+
0x00,
|
|
58
|
+
0x00,
|
|
59
|
+
0x00,
|
|
60
|
+
0x00,
|
|
61
|
+
0x00,
|
|
62
|
+
0x00,
|
|
63
|
+
0x00,
|
|
64
|
+
0x00,
|
|
65
|
+
0x00,
|
|
66
|
+
0x00,
|
|
67
|
+
0x0b,
|
|
68
|
+
]);
|
|
69
|
+
const mod = new WA.Module(simdTest);
|
|
70
|
+
if (mod) {
|
|
71
|
+
cachedBackend = "wasm-simd";
|
|
72
|
+
return cachedBackend;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
if (typeof WA.Module === "function") {
|
|
77
|
+
cachedBackend = "wasm";
|
|
78
|
+
return cachedBackend;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
cachedBackend = "js";
|
|
82
|
+
return cachedBackend;
|
|
83
|
+
}
|
|
84
|
+
function _resetWasmDetection() {
|
|
85
|
+
cachedBackend = undefined;
|
|
86
|
+
}
|
|
87
|
+
const HEX_RE = /^[0-9a-fA-F]*$/;
|
|
88
|
+
function toBytes(input, encoding = "utf8") {
|
|
89
|
+
if (input instanceof Uint8Array)
|
|
90
|
+
return input;
|
|
91
|
+
if (encoding === "hex") {
|
|
92
|
+
if (!HEX_RE.test(input))
|
|
93
|
+
throw new Error("Invalid hex string");
|
|
94
|
+
return Buffer.from(input, "hex");
|
|
95
|
+
}
|
|
96
|
+
return Buffer.from(input, "utf8");
|
|
97
|
+
}
|
|
98
|
+
function getHashFn(algorithm) {
|
|
99
|
+
switch (algorithm) {
|
|
100
|
+
case "sha256":
|
|
101
|
+
return sha2_js_1.sha256;
|
|
102
|
+
case "sha512":
|
|
103
|
+
return sha2_js_1.sha512;
|
|
104
|
+
case "sha3-256":
|
|
105
|
+
return sha3_js_1.sha3_256;
|
|
106
|
+
case "sha3-512":
|
|
107
|
+
return sha3_js_1.sha3_512;
|
|
108
|
+
case "blake3":
|
|
109
|
+
return blake3_js_1.blake3;
|
|
110
|
+
default:
|
|
111
|
+
throw new Error(`Unsupported hash algorithm: ${algorithm}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function wasmHash(options) {
|
|
115
|
+
const data = toBytes(options.data, options.encoding ?? "utf8");
|
|
116
|
+
const hashFn = getHashFn(options.algorithm);
|
|
117
|
+
const digest = hashFn(data);
|
|
118
|
+
return {
|
|
119
|
+
digest: Buffer.from(digest).toString("hex"),
|
|
120
|
+
algorithm: options.algorithm,
|
|
121
|
+
backend: "js",
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const NONCE_LENGTH = 24;
|
|
125
|
+
function wasmAeadEncrypt(options) {
|
|
126
|
+
const key = toBytes(options.key, "hex");
|
|
127
|
+
if (key.length !== 32) {
|
|
128
|
+
throw new Error(`Key must be 32 bytes (256 bits), got ${key.length}`);
|
|
129
|
+
}
|
|
130
|
+
const plaintext = options.plaintext instanceof Uint8Array
|
|
131
|
+
? options.plaintext
|
|
132
|
+
: Buffer.from(options.plaintext, "utf8");
|
|
133
|
+
const nonce = (0, utils_js_1.randomBytes)(NONCE_LENGTH);
|
|
134
|
+
const cipher = (0, chacha_js_1.xchacha20poly1305)(key, nonce, options.aad);
|
|
135
|
+
const sealed = cipher.encrypt(plaintext);
|
|
136
|
+
const combined = new Uint8Array(NONCE_LENGTH + sealed.length);
|
|
137
|
+
combined.set(nonce);
|
|
138
|
+
combined.set(sealed, NONCE_LENGTH);
|
|
139
|
+
return {
|
|
140
|
+
ciphertext: Buffer.from(combined).toString("base64"),
|
|
141
|
+
backend: "js",
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function wasmAeadDecrypt(options) {
|
|
145
|
+
const key = toBytes(options.key, "hex");
|
|
146
|
+
if (key.length !== 32) {
|
|
147
|
+
throw new Error(`Key must be 32 bytes (256 bits), got ${key.length}`);
|
|
148
|
+
}
|
|
149
|
+
const combined = Buffer.from(options.ciphertext, "base64");
|
|
150
|
+
if (combined.length < NONCE_LENGTH + 16) {
|
|
151
|
+
throw new Error("Ciphertext too short — missing nonce or auth tag");
|
|
152
|
+
}
|
|
153
|
+
const nonce = combined.subarray(0, NONCE_LENGTH);
|
|
154
|
+
const sealed = combined.subarray(NONCE_LENGTH);
|
|
155
|
+
const cipher = (0, chacha_js_1.xchacha20poly1305)(key, nonce, options.aad);
|
|
156
|
+
return {
|
|
157
|
+
plaintext: cipher.decrypt(sealed),
|
|
158
|
+
backend: "js",
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=wasm-bridge.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type WebCryptoHashAlgorithm = "SHA-256" | "SHA-384" | "SHA-512";
|
|
2
|
+
export interface WebCryptoAesGcmEncryptOptions {
|
|
3
|
+
key: string | Uint8Array;
|
|
4
|
+
plaintext: string | Uint8Array;
|
|
5
|
+
aad?: Uint8Array;
|
|
6
|
+
}
|
|
7
|
+
export interface WebCryptoAesGcmEncryptResult {
|
|
8
|
+
ciphertext: string;
|
|
9
|
+
accelerated: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface WebCryptoAesGcmDecryptOptions {
|
|
12
|
+
key: string | Uint8Array;
|
|
13
|
+
ciphertext: string;
|
|
14
|
+
aad?: Uint8Array;
|
|
15
|
+
}
|
|
16
|
+
export interface WebCryptoAesGcmDecryptResult {
|
|
17
|
+
plaintext: Uint8Array;
|
|
18
|
+
accelerated: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface WebCryptoHashOptions {
|
|
21
|
+
algorithm: WebCryptoHashAlgorithm;
|
|
22
|
+
data: string | Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
export interface WebCryptoHashResult {
|
|
25
|
+
digest: string;
|
|
26
|
+
accelerated: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function isWebCryptoAvailable(): boolean;
|
|
29
|
+
export declare function webCryptoAesGcmEncrypt(options: WebCryptoAesGcmEncryptOptions): Promise<WebCryptoAesGcmEncryptResult>;
|
|
30
|
+
export declare function webCryptoAesGcmDecrypt(options: WebCryptoAesGcmDecryptOptions): Promise<WebCryptoAesGcmDecryptResult>;
|
|
31
|
+
export declare function webCryptoHash(options: WebCryptoHashOptions): Promise<WebCryptoHashResult>;
|
|
32
|
+
//# sourceMappingURL=webcrypto-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webcrypto-bridge.d.ts","sourceRoot":"","sources":["../../src/accel/webcrypto-bridge.ts"],"names":[],"mappings":"AAyCA,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAGvE,MAAM,WAAW,6BAA6B;IAE5C,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;IAEzB,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC;IAE/B,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB;AAGD,MAAM,WAAW,4BAA4B;IAE3C,UAAU,EAAE,MAAM,CAAC;IAEnB,WAAW,EAAE,OAAO,CAAC;CACtB;AAGD,MAAM,WAAW,6BAA6B;IAE5C,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;IAEzB,UAAU,EAAE,MAAM,CAAC;IAEnB,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB;AAGD,MAAM,WAAW,4BAA4B;IAE3C,SAAS,EAAE,UAAU,CAAC;IAEtB,WAAW,EAAE,OAAO,CAAC;CACtB;AAGD,MAAM,WAAW,oBAAoB;IAEnC,SAAS,EAAE,sBAAsB,CAAC;IAElC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAC3B;AAGD,MAAM,WAAW,mBAAmB;IAElC,MAAM,EAAE,MAAM,CAAC;IAEf,WAAW,EAAE,OAAO,CAAC;CACtB;AA4DD,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAUD,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,4BAA4B,CAAC,CAuDvC;AASD,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,4BAA4B,CAAC,CAmDvC;AASD,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CAiC9B"}
|
|
@@ -0,0 +1,179 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.isWebCryptoAvailable = isWebCryptoAvailable;
|
|
37
|
+
exports.webCryptoAesGcmEncrypt = webCryptoAesGcmEncrypt;
|
|
38
|
+
exports.webCryptoAesGcmDecrypt = webCryptoAesGcmDecrypt;
|
|
39
|
+
exports.webCryptoHash = webCryptoHash;
|
|
40
|
+
const aes_js_1 = require("@noble/ciphers/aes.js");
|
|
41
|
+
const utils_js_1 = require("@noble/ciphers/utils.js");
|
|
42
|
+
const sha2_js_1 = require("@noble/hashes/sha2.js");
|
|
43
|
+
const nodeCrypto = __importStar(require("node:crypto"));
|
|
44
|
+
function asBufferSource(view) {
|
|
45
|
+
return view;
|
|
46
|
+
}
|
|
47
|
+
const HEX_RE = /^[0-9a-fA-F]*$/;
|
|
48
|
+
const NONCE_LENGTH = 12;
|
|
49
|
+
const TAG_LENGTH = 16;
|
|
50
|
+
function toBytes(input, encoding = "utf8") {
|
|
51
|
+
if (input instanceof Uint8Array)
|
|
52
|
+
return input;
|
|
53
|
+
if (encoding === "hex") {
|
|
54
|
+
if (!HEX_RE.test(input)) {
|
|
55
|
+
throw new Error("Invalid hex string");
|
|
56
|
+
}
|
|
57
|
+
return Buffer.from(input, "hex");
|
|
58
|
+
}
|
|
59
|
+
return Buffer.from(input, "utf8");
|
|
60
|
+
}
|
|
61
|
+
function validateKey(key) {
|
|
62
|
+
if (key.length !== 16 && key.length !== 32) {
|
|
63
|
+
throw new Error(`Key must be 16 bytes (128 bits) or 32 bytes (256 bits), got ${key.length}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function getSubtle() {
|
|
67
|
+
try {
|
|
68
|
+
if (nodeCrypto.webcrypto &&
|
|
69
|
+
nodeCrypto.webcrypto.subtle &&
|
|
70
|
+
typeof nodeCrypto.webcrypto.subtle.encrypt === "function") {
|
|
71
|
+
return nodeCrypto.webcrypto.subtle;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
function isWebCryptoAvailable() {
|
|
79
|
+
return getSubtle() !== null;
|
|
80
|
+
}
|
|
81
|
+
async function webCryptoAesGcmEncrypt(options) {
|
|
82
|
+
const key = toBytes(options.key, "hex");
|
|
83
|
+
validateKey(key);
|
|
84
|
+
const plaintext = toBytes(options.plaintext, "utf8");
|
|
85
|
+
const nonce = (0, utils_js_1.randomBytes)(NONCE_LENGTH);
|
|
86
|
+
const subtle = getSubtle();
|
|
87
|
+
if (subtle) {
|
|
88
|
+
const cryptoKey = await subtle.importKey("raw", asBufferSource(key), { name: "AES-GCM" }, false, ["encrypt"]);
|
|
89
|
+
const algParams = {
|
|
90
|
+
name: "AES-GCM",
|
|
91
|
+
iv: asBufferSource(nonce),
|
|
92
|
+
tagLength: TAG_LENGTH * 8,
|
|
93
|
+
};
|
|
94
|
+
if (options.aad) {
|
|
95
|
+
algParams.additionalData = asBufferSource(options.aad);
|
|
96
|
+
}
|
|
97
|
+
const encrypted = await subtle.encrypt(algParams, cryptoKey, asBufferSource(plaintext));
|
|
98
|
+
const sealed = new Uint8Array(encrypted);
|
|
99
|
+
const combined = new Uint8Array(NONCE_LENGTH + sealed.length);
|
|
100
|
+
combined.set(nonce);
|
|
101
|
+
combined.set(sealed, NONCE_LENGTH);
|
|
102
|
+
return {
|
|
103
|
+
ciphertext: Buffer.from(combined).toString("base64"),
|
|
104
|
+
accelerated: true,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const cipher = (0, aes_js_1.gcm)(key, nonce, options.aad);
|
|
108
|
+
const sealed = cipher.encrypt(plaintext);
|
|
109
|
+
const combined = new Uint8Array(NONCE_LENGTH + sealed.length);
|
|
110
|
+
combined.set(nonce);
|
|
111
|
+
combined.set(sealed, NONCE_LENGTH);
|
|
112
|
+
return {
|
|
113
|
+
ciphertext: Buffer.from(combined).toString("base64"),
|
|
114
|
+
accelerated: false,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
async function webCryptoAesGcmDecrypt(options) {
|
|
118
|
+
const key = toBytes(options.key, "hex");
|
|
119
|
+
validateKey(key);
|
|
120
|
+
const combined = Buffer.from(options.ciphertext, "base64");
|
|
121
|
+
if (combined.length < NONCE_LENGTH + TAG_LENGTH) {
|
|
122
|
+
throw new Error("Ciphertext too short — missing nonce or auth tag");
|
|
123
|
+
}
|
|
124
|
+
const nonce = combined.subarray(0, NONCE_LENGTH);
|
|
125
|
+
const sealed = combined.subarray(NONCE_LENGTH);
|
|
126
|
+
const subtle = getSubtle();
|
|
127
|
+
if (subtle) {
|
|
128
|
+
const cryptoKey = await subtle.importKey("raw", asBufferSource(key), { name: "AES-GCM" }, false, ["decrypt"]);
|
|
129
|
+
const algParams = {
|
|
130
|
+
name: "AES-GCM",
|
|
131
|
+
iv: asBufferSource(nonce),
|
|
132
|
+
tagLength: TAG_LENGTH * 8,
|
|
133
|
+
};
|
|
134
|
+
if (options.aad) {
|
|
135
|
+
algParams.additionalData = asBufferSource(options.aad);
|
|
136
|
+
}
|
|
137
|
+
const decrypted = await subtle.decrypt(algParams, cryptoKey, asBufferSource(sealed));
|
|
138
|
+
return {
|
|
139
|
+
plaintext: new Uint8Array(decrypted),
|
|
140
|
+
accelerated: true,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const cipher = (0, aes_js_1.gcm)(key, nonce, options.aad);
|
|
144
|
+
const plaintext = cipher.decrypt(sealed);
|
|
145
|
+
return {
|
|
146
|
+
plaintext,
|
|
147
|
+
accelerated: false,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
async function webCryptoHash(options) {
|
|
151
|
+
const data = toBytes(options.data, "utf8");
|
|
152
|
+
const subtle = getSubtle();
|
|
153
|
+
if (subtle) {
|
|
154
|
+
const digest = await subtle.digest(options.algorithm, asBufferSource(data));
|
|
155
|
+
return {
|
|
156
|
+
digest: Buffer.from(digest).toString("hex"),
|
|
157
|
+
accelerated: true,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
let digest;
|
|
161
|
+
switch (options.algorithm) {
|
|
162
|
+
case "SHA-256":
|
|
163
|
+
digest = (0, sha2_js_1.sha256)(data);
|
|
164
|
+
break;
|
|
165
|
+
case "SHA-384":
|
|
166
|
+
digest = (0, sha2_js_1.sha384)(data);
|
|
167
|
+
break;
|
|
168
|
+
case "SHA-512":
|
|
169
|
+
digest = (0, sha2_js_1.sha512)(data);
|
|
170
|
+
break;
|
|
171
|
+
default:
|
|
172
|
+
throw new Error(`Unsupported hash algorithm: ${options.algorithm}`);
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
digest: Buffer.from(digest).toString("hex"),
|
|
176
|
+
accelerated: false,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=webcrypto-bridge.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface WebCryptoModernSupport {
|
|
2
|
+
chacha20poly1305: boolean;
|
|
3
|
+
sha3: boolean;
|
|
4
|
+
mlKem: boolean;
|
|
5
|
+
argon2: boolean;
|
|
6
|
+
kmac: boolean;
|
|
7
|
+
}
|
|
8
|
+
export type ModernSha3Algorithm = "SHA3-256" | "SHA3-512";
|
|
9
|
+
export interface ModernChaCha20EncryptOptions {
|
|
10
|
+
key: string | Uint8Array;
|
|
11
|
+
plaintext: string | Uint8Array;
|
|
12
|
+
aad?: Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
export interface ModernAeadResult {
|
|
15
|
+
ciphertext: string;
|
|
16
|
+
accelerated: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ModernChaCha20DecryptOptions {
|
|
19
|
+
key: string | Uint8Array;
|
|
20
|
+
ciphertext: string;
|
|
21
|
+
aad?: Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
export interface ModernChaCha20DecryptResult {
|
|
24
|
+
plaintext: Uint8Array;
|
|
25
|
+
accelerated: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface ModernSha3HashOptions {
|
|
28
|
+
algorithm: ModernSha3Algorithm;
|
|
29
|
+
data: string | Uint8Array;
|
|
30
|
+
}
|
|
31
|
+
export interface ModernSha3HashResult {
|
|
32
|
+
digest: string;
|
|
33
|
+
accelerated: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function detectModernWebCrypto(): WebCryptoModernSupport;
|
|
36
|
+
export declare function _resetModernWebCryptoDetection(): void;
|
|
37
|
+
export declare function modernChaCha20Encrypt(options: ModernChaCha20EncryptOptions): Promise<ModernAeadResult>;
|
|
38
|
+
export declare function modernChaCha20Decrypt(options: ModernChaCha20DecryptOptions): Promise<ModernChaCha20DecryptResult>;
|
|
39
|
+
export declare function modernSha3Hash(options: ModernSha3HashOptions): Promise<ModernSha3HashResult>;
|
|
40
|
+
//# sourceMappingURL=webcrypto-modern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webcrypto-modern.d.ts","sourceRoot":"","sources":["../../src/accel/webcrypto-modern.ts"],"names":[],"mappings":"AAkDA,MAAM,WAAW,sBAAsB;IAErC,gBAAgB,EAAE,OAAO,CAAC;IAE1B,IAAI,EAAE,OAAO,CAAC;IAEd,KAAK,EAAE,OAAO,CAAC;IAEf,MAAM,EAAE,OAAO,CAAC;IAEhB,IAAI,EAAE,OAAO,CAAC;CACf;AAGD,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,UAAU,CAAC;AAG1D,MAAM,WAAW,4BAA4B;IAE3C,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;IAEzB,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC;IAE/B,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB;AAGD,MAAM,WAAW,gBAAgB;IAE/B,UAAU,EAAE,MAAM,CAAC;IAEnB,WAAW,EAAE,OAAO,CAAC;CACtB;AAGD,MAAM,WAAW,4BAA4B;IAE3C,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;IAEzB,UAAU,EAAE,MAAM,CAAC;IAEnB,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB;AAGD,MAAM,WAAW,2BAA2B;IAE1C,SAAS,EAAE,UAAU,CAAC;IAEtB,WAAW,EAAE,OAAO,CAAC;CACtB;AAGD,MAAM,WAAW,qBAAqB;IAEpC,SAAS,EAAE,mBAAmB,CAAC;IAE/B,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAC3B;AAGD,MAAM,WAAW,oBAAoB;IAEnC,MAAM,EAAE,MAAM,CAAC;IAEf,WAAW,EAAE,OAAO,CAAC;CACtB;AA0ED,wBAAgB,qBAAqB,IAAI,sBAAsB,CAiC9D;AAUD,wBAAgB,8BAA8B,IAAI,IAAI,CAErD;AAmBD,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,gBAAgB,CAAC,CAyD3B;AAgBD,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,2BAA2B,CAAC,CAsDtC;AAmBD,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CA+B/B"}
|