@sebastienrousseau/crypto-lib 0.0.9 → 0.0.25
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/dist/accel/wasm-bridge.d.ts.map +1 -1
- package/dist/accel/wasm-bridge.js +46 -46
- package/dist/high-level/index.d.ts +1 -1
- package/dist/high-level/index.d.ts.map +1 -1
- package/dist/high-level/index.js +3 -1
- package/dist/high-level/multi-recipient.d.ts +6 -0
- package/dist/high-level/multi-recipient.d.ts.map +1 -1
- package/dist/high-level/multi-recipient.js +34 -23
- package/dist/modern/hash.d.ts.map +1 -1
- package/dist/modern/hash.js +26 -14
- package/dist/modern/hpke.d.ts +1 -1
- package/dist/modern/hpke.d.ts.map +1 -1
- package/dist/modern/hpke.js +74 -11
- package/dist/modern/index.d.ts +1 -1
- package/dist/modern/index.d.ts.map +1 -1
- package/dist/modern/index.js +2 -0
- package/dist/modern/kdf.d.ts.map +1 -1
- package/dist/modern/kdf.js +25 -19
- package/dist/streaming/index.d.ts +6 -2
- package/dist/streaming/index.d.ts.map +1 -1
- package/dist/streaming/index.js +18 -1
- package/dist/streaming/stream-multi-pq-aead.d.ts +35 -0
- package/dist/streaming/stream-multi-pq-aead.d.ts.map +1 -0
- package/dist/streaming/stream-multi-pq-aead.js +315 -0
- package/dist/streaming/stream-pq-aead.d.ts +29 -0
- package/dist/streaming/stream-pq-aead.d.ts.map +1 -0
- package/dist/streaming/stream-pq-aead.js +175 -0
- package/dist/streaming/web-streams.d.ts +25 -0
- package/dist/streaming/web-streams.d.ts.map +1 -1
- package/dist/streaming/web-streams.js +106 -0
- package/package.json +2 -2
|
@@ -1 +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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;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;AAmED,wBAAgB,iBAAiB,IAAI,WAAW,CA4B/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"}
|
|
@@ -11,6 +11,51 @@ const blake3_js_1 = require("@noble/hashes/blake3.js");
|
|
|
11
11
|
const chacha_js_1 = require("@noble/ciphers/chacha.js");
|
|
12
12
|
const utils_js_1 = require("@noble/ciphers/utils.js");
|
|
13
13
|
let cachedBackend;
|
|
14
|
+
const SIMD_TEST_BYTES = new Uint8Array([
|
|
15
|
+
0x00,
|
|
16
|
+
0x61,
|
|
17
|
+
0x73,
|
|
18
|
+
0x6d,
|
|
19
|
+
0x01,
|
|
20
|
+
0x00,
|
|
21
|
+
0x00,
|
|
22
|
+
0x00,
|
|
23
|
+
0x01,
|
|
24
|
+
0x05,
|
|
25
|
+
0x01,
|
|
26
|
+
0x60,
|
|
27
|
+
0x00,
|
|
28
|
+
0x01,
|
|
29
|
+
0x7b,
|
|
30
|
+
0x03,
|
|
31
|
+
0x02,
|
|
32
|
+
0x01,
|
|
33
|
+
0x00,
|
|
34
|
+
0x0a,
|
|
35
|
+
0x0a,
|
|
36
|
+
0x01,
|
|
37
|
+
0x08,
|
|
38
|
+
0x00,
|
|
39
|
+
0xfd,
|
|
40
|
+
0x0c,
|
|
41
|
+
0x00,
|
|
42
|
+
0x00,
|
|
43
|
+
0x00,
|
|
44
|
+
0x00,
|
|
45
|
+
0x00,
|
|
46
|
+
0x00,
|
|
47
|
+
0x00,
|
|
48
|
+
0x00,
|
|
49
|
+
0x00,
|
|
50
|
+
0x00,
|
|
51
|
+
0x00,
|
|
52
|
+
0x00,
|
|
53
|
+
0x00,
|
|
54
|
+
0x00,
|
|
55
|
+
0x00,
|
|
56
|
+
0x00,
|
|
57
|
+
0x0b,
|
|
58
|
+
]);
|
|
14
59
|
function detectWasmBackend() {
|
|
15
60
|
if (cachedBackend !== undefined)
|
|
16
61
|
return cachedBackend;
|
|
@@ -21,52 +66,7 @@ function detectWasmBackend() {
|
|
|
21
66
|
return cachedBackend;
|
|
22
67
|
}
|
|
23
68
|
try {
|
|
24
|
-
const
|
|
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);
|
|
69
|
+
const mod = new WA.Module(SIMD_TEST_BYTES);
|
|
70
70
|
if (mod) {
|
|
71
71
|
cachedBackend = "wasm-simd";
|
|
72
72
|
return cachedBackend;
|
|
@@ -6,6 +6,6 @@ export { passwordEncrypt, passwordDecrypt } from "./password-encrypt";
|
|
|
6
6
|
export type { PasswordEncryptOptions, PasswordEncryptResult, } from "./password-encrypt";
|
|
7
7
|
export { aesKwWrap, aesKwUnwrap, aesKwpWrap, aesKwpUnwrap, x25519AesKwWrap, x25519AesKwUnwrap, } from "./key-wrap";
|
|
8
8
|
export type { AesKwWrapResult, X25519AesKwWrapResult } from "./key-wrap";
|
|
9
|
-
export { multiEncrypt, multiDecryptClassical, multiDecryptPQ, } from "./multi-recipient";
|
|
9
|
+
export { multiEncrypt, multiDecryptClassical, multiDecryptPQ, wrapDekHybrid, unwrapDekHybrid, } from "./multi-recipient";
|
|
10
10
|
export type { ClassicalRecipient, PqRecipient, Recipient, WrappedKey, MultiRecipientEncryptResult, } from "./multi-recipient";
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/high-level/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEtE,YAAY,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,eAAe,EACf,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEzE,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/high-level/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEtE,YAAY,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,eAAe,EACf,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEzE,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,UAAU,EACV,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC"}
|
package/dist/high-level/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.multiDecryptPQ = exports.multiDecryptClassical = exports.multiEncrypt = exports.x25519AesKwUnwrap = exports.x25519AesKwWrap = exports.aesKwpUnwrap = exports.aesKwpWrap = exports.aesKwUnwrap = exports.aesKwWrap = exports.passwordDecrypt = exports.passwordEncrypt = exports.sealedbox = exports.secretbox = void 0;
|
|
36
|
+
exports.unwrapDekHybrid = exports.wrapDekHybrid = exports.multiDecryptPQ = exports.multiDecryptClassical = exports.multiEncrypt = exports.x25519AesKwUnwrap = exports.x25519AesKwWrap = exports.aesKwpUnwrap = exports.aesKwpWrap = exports.aesKwUnwrap = exports.aesKwWrap = exports.passwordDecrypt = exports.passwordEncrypt = exports.sealedbox = exports.secretbox = void 0;
|
|
37
37
|
exports.secretbox = __importStar(require("./secretbox"));
|
|
38
38
|
exports.sealedbox = __importStar(require("./sealedbox"));
|
|
39
39
|
var password_encrypt_1 = require("./password-encrypt");
|
|
@@ -50,4 +50,6 @@ var multi_recipient_1 = require("./multi-recipient");
|
|
|
50
50
|
Object.defineProperty(exports, "multiEncrypt", { enumerable: true, get: function () { return multi_recipient_1.multiEncrypt; } });
|
|
51
51
|
Object.defineProperty(exports, "multiDecryptClassical", { enumerable: true, get: function () { return multi_recipient_1.multiDecryptClassical; } });
|
|
52
52
|
Object.defineProperty(exports, "multiDecryptPQ", { enumerable: true, get: function () { return multi_recipient_1.multiDecryptPQ; } });
|
|
53
|
+
Object.defineProperty(exports, "wrapDekHybrid", { enumerable: true, get: function () { return multi_recipient_1.wrapDekHybrid; } });
|
|
54
|
+
Object.defineProperty(exports, "unwrapDekHybrid", { enumerable: true, get: function () { return multi_recipient_1.unwrapDekHybrid; } });
|
|
53
55
|
//# sourceMappingURL=index.js.map
|
|
@@ -21,5 +21,11 @@ export interface MultiRecipientEncryptResult {
|
|
|
21
21
|
}
|
|
22
22
|
export declare function multiEncrypt(recipients: Recipient[], plaintext: string | Uint8Array): MultiRecipientEncryptResult;
|
|
23
23
|
export declare function multiDecryptClassical(secretKey: string | Uint8Array, wrappedKey: WrappedKey, ciphertext: string): Uint8Array;
|
|
24
|
+
export declare function wrapDekHybrid(dek: Uint8Array, x25519PublicKey: string, mlKemPublicKey: string): {
|
|
25
|
+
wrappedKey: string;
|
|
26
|
+
ephemeralPublicKey: string;
|
|
27
|
+
mlKemCiphertext: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function unwrapDekHybrid(x25519SecretKey: string | Uint8Array, mlKemSecretKey: string | Uint8Array, ephemeralPublicKey: string, mlKemCiphertext: string, wrappedKey: string): Uint8Array;
|
|
24
30
|
export declare function multiDecryptPQ(x25519SecretKey: string | Uint8Array, mlKemSecretKey: string | Uint8Array, wrappedKey: WrappedKey, ciphertext: string): Uint8Array;
|
|
25
31
|
//# sourceMappingURL=multi-recipient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-recipient.d.ts","sourceRoot":"","sources":["../../src/high-level/multi-recipient.ts"],"names":[],"mappings":"AAwCA,MAAM,WAAW,kBAAkB;IAEjC,IAAI,EAAE,QAAQ,CAAC;IAEf,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,WAAW;IAE1B,IAAI,EAAE,mBAAmB,CAAC;IAE1B,eAAe,EAAE,MAAM,CAAC;IAExB,cAAc,EAAE,MAAM,CAAC;CACxB;AAGD,MAAM,MAAM,SAAS,GAAG,kBAAkB,GAAG,WAAW,CAAC;AAGzD,MAAM,WAAW,UAAU;IAEzB,IAAI,EAAE,QAAQ,GAAG,mBAAmB,CAAC;IAErC,UAAU,EAAE,MAAM,CAAC;IAEnB,kBAAkB,EAAE,MAAM,CAAC;IAE3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAGD,MAAM,WAAW,2BAA2B;IAE1C,UAAU,EAAE,MAAM,CAAC;IAE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kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB,CAkCA;AAWD,wBAAgB,eAAe,CAC7B,eAAe,EAAE,MAAM,GAAG,UAAU,EACpC,cAAc,EAAE,MAAM,GAAG,UAAU,EACnC,kBAAkB,EAAE,MAAM,EAC1B,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,GACjB,UAAU,CAiCZ;AAUD,wBAAgB,cAAc,CAC5B,eAAe,EAAE,MAAM,GAAG,UAAU,EACpC,cAAc,EAAE,MAAM,GAAG,UAAU,EACnC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,MAAM,GACjB,UAAU,CAcZ"}
|
|
@@ -35,6 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.multiEncrypt = multiEncrypt;
|
|
37
37
|
exports.multiDecryptClassical = multiDecryptClassical;
|
|
38
|
+
exports.wrapDekHybrid = wrapDekHybrid;
|
|
39
|
+
exports.unwrapDekHybrid = unwrapDekHybrid;
|
|
38
40
|
exports.multiDecryptPQ = multiDecryptPQ;
|
|
39
41
|
const utils_js_1 = require("@noble/ciphers/utils.js");
|
|
40
42
|
const secretbox = __importStar(require("./secretbox"));
|
|
@@ -66,23 +68,10 @@ function multiEncrypt(recipients, plaintext) {
|
|
|
66
68
|
};
|
|
67
69
|
}
|
|
68
70
|
else {
|
|
69
|
-
const
|
|
70
|
-
const mlKemPub = hexToBytes(r.mlKemPublicKey);
|
|
71
|
-
const ephPriv = (0, utils_js_1.randomBytes)(32);
|
|
72
|
-
const ephPub = ed25519_js_1.x25519.getPublicKey(ephPriv);
|
|
73
|
-
const x25519Shared = ed25519_js_1.x25519.getSharedSecret(ephPriv, x25519Pub);
|
|
74
|
-
const { cipherText: mlKemCt, sharedSecret: mlKemShared } = ml_kem_js_1.ml_kem768.encapsulate(mlKemPub);
|
|
75
|
-
const combined = new Uint8Array(x25519Shared.length + mlKemShared.length);
|
|
76
|
-
combined.set(x25519Shared);
|
|
77
|
-
combined.set(mlKemShared, x25519Shared.length);
|
|
78
|
-
const kek = (0, hkdf_js_1.hkdf)(sha2_js_1.sha256, combined, ephPub, new TextEncoder().encode("multi-recipient-pq-v1"), 32);
|
|
79
|
-
const cipher = (0, aes_js_1.aeskw)(kek);
|
|
80
|
-
const wrapped = cipher.encrypt(dek);
|
|
71
|
+
const wrapped = wrapDekHybrid(dek, r.x25519PublicKey, r.mlKemPublicKey);
|
|
81
72
|
return {
|
|
82
73
|
type: "x25519-ml-kem-768",
|
|
83
|
-
|
|
84
|
-
ephemeralPublicKey: Buffer.from(ephPub).toString("hex"),
|
|
85
|
-
mlKemCiphertext: Buffer.from(mlKemCt).toString("hex"),
|
|
74
|
+
...wrapped,
|
|
86
75
|
};
|
|
87
76
|
}
|
|
88
77
|
});
|
|
@@ -96,27 +85,49 @@ function multiDecryptClassical(secretKey, wrappedKey, ciphertext) {
|
|
|
96
85
|
const dek = (0, key_wrap_1.x25519AesKwUnwrap)(secretKey, wrappedKey.ephemeralPublicKey, wrappedKey.wrappedKey);
|
|
97
86
|
return secretbox.open(dek, ciphertext);
|
|
98
87
|
}
|
|
99
|
-
function
|
|
88
|
+
function wrapDekHybrid(dek, x25519PublicKey, mlKemPublicKey) {
|
|
89
|
+
const x25519Pub = hexToBytes(x25519PublicKey);
|
|
90
|
+
const mlKemPub = hexToBytes(mlKemPublicKey);
|
|
91
|
+
const ephPriv = (0, utils_js_1.randomBytes)(32);
|
|
92
|
+
const ephPub = ed25519_js_1.x25519.getPublicKey(ephPriv);
|
|
93
|
+
const x25519Shared = ed25519_js_1.x25519.getSharedSecret(ephPriv, x25519Pub);
|
|
94
|
+
const { cipherText: mlKemCt, sharedSecret: mlKemShared } = ml_kem_js_1.ml_kem768.encapsulate(mlKemPub);
|
|
95
|
+
const combined = new Uint8Array(x25519Shared.length + mlKemShared.length);
|
|
96
|
+
combined.set(x25519Shared);
|
|
97
|
+
combined.set(mlKemShared, x25519Shared.length);
|
|
98
|
+
const kek = (0, hkdf_js_1.hkdf)(sha2_js_1.sha256, combined, ephPub, new TextEncoder().encode("multi-recipient-pq-v1"), 32);
|
|
99
|
+
const cipher = (0, aes_js_1.aeskw)(kek);
|
|
100
|
+
const wrapped = cipher.encrypt(dek);
|
|
101
|
+
return {
|
|
102
|
+
wrappedKey: Buffer.from(wrapped).toString("base64"),
|
|
103
|
+
ephemeralPublicKey: Buffer.from(ephPub).toString("hex"),
|
|
104
|
+
mlKemCiphertext: Buffer.from(mlKemCt).toString("hex"),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function unwrapDekHybrid(x25519SecretKey, mlKemSecretKey, ephemeralPublicKey, mlKemCiphertext, wrappedKey) {
|
|
100
108
|
const x25519Sec = typeof x25519SecretKey === "string"
|
|
101
109
|
? hexToBytes(x25519SecretKey)
|
|
102
110
|
: x25519SecretKey;
|
|
103
111
|
const mlKemSec = typeof mlKemSecretKey === "string"
|
|
104
112
|
? hexToBytes(mlKemSecretKey)
|
|
105
113
|
: mlKemSecretKey;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
const ephPub = hexToBytes(wrappedKey.ephemeralPublicKey);
|
|
110
|
-
const mlKemCt = hexToBytes(wrappedKey.mlKemCiphertext);
|
|
114
|
+
const ephPub = hexToBytes(ephemeralPublicKey);
|
|
115
|
+
const mlKemCt = hexToBytes(mlKemCiphertext);
|
|
111
116
|
const x25519Shared = ed25519_js_1.x25519.getSharedSecret(x25519Sec, ephPub);
|
|
112
117
|
const mlKemShared = ml_kem_js_1.ml_kem768.decapsulate(mlKemCt, mlKemSec);
|
|
113
118
|
const combined = new Uint8Array(x25519Shared.length + mlKemShared.length);
|
|
114
119
|
combined.set(x25519Shared);
|
|
115
120
|
combined.set(mlKemShared, x25519Shared.length);
|
|
116
121
|
const kek = (0, hkdf_js_1.hkdf)(sha2_js_1.sha256, combined, ephPub, new TextEncoder().encode("multi-recipient-pq-v1"), 32);
|
|
117
|
-
const wrapped = Buffer.from(wrappedKey
|
|
122
|
+
const wrapped = Buffer.from(wrappedKey, "base64");
|
|
118
123
|
const cipher = (0, aes_js_1.aeskw)(kek);
|
|
119
|
-
|
|
124
|
+
return cipher.decrypt(wrapped);
|
|
125
|
+
}
|
|
126
|
+
function multiDecryptPQ(x25519SecretKey, mlKemSecretKey, wrappedKey, ciphertext) {
|
|
127
|
+
if (!wrappedKey.mlKemCiphertext) {
|
|
128
|
+
throw new Error("Missing ML-KEM ciphertext in wrapped key");
|
|
129
|
+
}
|
|
130
|
+
const dek = unwrapDekHybrid(x25519SecretKey, mlKemSecretKey, wrappedKey.ephemeralPublicKey, wrappedKey.mlKemCiphertext, wrappedKey.wrappedKey);
|
|
120
131
|
return secretbox.open(dek, ciphertext);
|
|
121
132
|
}
|
|
122
133
|
//# sourceMappingURL=multi-recipient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/modern/hash.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,eAAe,sFAQlB,CAAC;AAGX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAG7D,MAAM,WAAW,WAAW;IAE1B,SAAS,EAAE,aAAa,CAAC;IAEzB,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAC3B;AAGD,MAAM,WAAW,UAAU;IAEzB,MAAM,EAAE,MAAM,CAAC;IAEf,SAAS,EAAE,aAAa,CAAC;IAEzB,MAAM,EAAE,MAAM,CAAC;CAChB;
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/modern/hash.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,eAAe,sFAQlB,CAAC;AAGX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAG7D,MAAM,WAAW,WAAW;IAE1B,SAAS,EAAE,aAAa,CAAC;IAEzB,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAC3B;AAGD,MAAM,WAAW,UAAU;IAEzB,MAAM,EAAE,MAAM,CAAC;IAEf,SAAS,EAAE,aAAa,CAAC;IAEzB,MAAM,EAAE,MAAM,CAAC;CAChB;AAWD,wBAAgB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAqCrD"}
|
package/dist/modern/hash.js
CHANGED
|
@@ -20,22 +20,34 @@ function toBytes(input) {
|
|
|
20
20
|
return input;
|
|
21
21
|
return Buffer.from(input, "utf8");
|
|
22
22
|
}
|
|
23
|
-
const hashFunctions = {
|
|
24
|
-
sha256: (d) => (0, sha2_js_1.sha256)(d),
|
|
25
|
-
sha384: (d) => (0, sha2_js_1.sha384)(d),
|
|
26
|
-
sha512: (d) => (0, sha2_js_1.sha512)(d),
|
|
27
|
-
"sha3-256": (d) => (0, sha3_js_1.sha3_256)(d),
|
|
28
|
-
"sha3-512": (d) => (0, sha3_js_1.sha3_512)(d),
|
|
29
|
-
blake2b: (d) => (0, blake2_js_1.blake2b)(d),
|
|
30
|
-
blake3: (d) => (0, blake3_js_1.blake3)(d),
|
|
31
|
-
};
|
|
32
23
|
function hash(options) {
|
|
33
|
-
const fn = hashFunctions[options.algorithm];
|
|
34
|
-
if (!fn) {
|
|
35
|
-
throw new Error(`Unsupported algorithm: ${options.algorithm}. Supported: ${exports.HASH_ALGORITHMS.join(", ")}`);
|
|
36
|
-
}
|
|
37
24
|
const data = toBytes(options.data);
|
|
38
|
-
|
|
25
|
+
let digest;
|
|
26
|
+
switch (options.algorithm) {
|
|
27
|
+
case "sha256":
|
|
28
|
+
digest = (0, sha2_js_1.sha256)(data);
|
|
29
|
+
break;
|
|
30
|
+
case "sha384":
|
|
31
|
+
digest = (0, sha2_js_1.sha384)(data);
|
|
32
|
+
break;
|
|
33
|
+
case "sha512":
|
|
34
|
+
digest = (0, sha2_js_1.sha512)(data);
|
|
35
|
+
break;
|
|
36
|
+
case "sha3-256":
|
|
37
|
+
digest = (0, sha3_js_1.sha3_256)(data);
|
|
38
|
+
break;
|
|
39
|
+
case "sha3-512":
|
|
40
|
+
digest = (0, sha3_js_1.sha3_512)(data);
|
|
41
|
+
break;
|
|
42
|
+
case "blake2b":
|
|
43
|
+
digest = (0, blake2_js_1.blake2b)(data);
|
|
44
|
+
break;
|
|
45
|
+
case "blake3":
|
|
46
|
+
digest = (0, blake3_js_1.blake3)(data);
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
throw new Error(`Unsupported algorithm: ${options.algorithm}. Supported: ${exports.HASH_ALGORITHMS.join(", ")}`);
|
|
50
|
+
}
|
|
39
51
|
return {
|
|
40
52
|
digest: Buffer.from(digest).toString("hex"),
|
|
41
53
|
algorithm: options.algorithm,
|
package/dist/modern/hpke.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hpke.d.ts","sourceRoot":"","sources":["../../src/modern/hpke.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hpke.d.ts","sourceRoot":"","sources":["../../src/modern/hpke.ts"],"names":[],"mappings":"AA+DA,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,mBAAmB,CAAC;AAU9D,MAAM,MAAM,QAAQ,GAAG,mBAAmB,GAAG,aAAa,CAAC;AAU3D,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAUtC,MAAM,WAAW,WAAW;IAE1B,SAAS,EAAE,MAAM,CAAC;IAElB,UAAU,EAAE,MAAM,CAAC;CACpB;AAUD,MAAM,WAAW,cAAc;IAE7B,UAAU,EAAE,MAAM,CAAC;IAEnB,eAAe,EAAE,MAAM,CAAC;CACzB;AAUD,MAAM,WAAW,cAAc;IAE7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAUD,MAAM,WAAW,gBAAgB;IAE/B,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAUD,MAAM,WAAW,cAAc;IAE7B,GAAG,EAAE,MAAM,CAAC;IAEZ,KAAK,EAAE,MAAM,CAAC;CACf;AAoaD,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,OAAkB,GAAG,WAAW,CAexE;AAuBD,wBAAgB,QAAQ,CAAC,OAAO,EAAE;IAEhC,kBAAkB,EAAE,MAAM,CAAC;IAE3B,SAAS,EAAE,MAAM,CAAC;IAElB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAEzB,GAAG,CAAC,EAAE,cAAc,CAAC;CACtB,GAAG,cAAc,CAWjB;AAUD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EACvC,mBAAmB,EAAE,UAAU,GAC9B,cAAc,GAAG;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB,CAyBA;AA0BD,wBAAgB,QAAQ,CAAC,OAAO,EAAE;IAEhC,mBAAmB,EAAE,MAAM,CAAC;IAE5B,eAAe,EAAE,MAAM,CAAC;IAExB,UAAU,EAAE,MAAM,CAAC;IAEnB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAEzB,GAAG,CAAC,EAAE,cAAc,CAAC;CACtB,GAAG,cAAc,CAmBjB"}
|
package/dist/modern/hpke.js
CHANGED
|
@@ -10,8 +10,10 @@ const hkdf_js_1 = require("@noble/hashes/hkdf.js");
|
|
|
10
10
|
const sha2_js_1 = require("@noble/hashes/sha2.js");
|
|
11
11
|
const chacha_js_1 = require("@noble/ciphers/chacha.js");
|
|
12
12
|
const aes_js_1 = require("@noble/ciphers/aes.js");
|
|
13
|
+
const ml_kem_js_1 = require("@noble/post-quantum/ml-kem.js");
|
|
13
14
|
const KEM_X25519 = 0x0020;
|
|
14
15
|
const KEM_P256 = 0x0010;
|
|
16
|
+
const KEM_X25519_MLKEM768 = 0x0030;
|
|
15
17
|
const KDF_HKDF_SHA256 = 0x0001;
|
|
16
18
|
const AEAD_AES_128_GCM = 0x0001;
|
|
17
19
|
const AEAD_CHACHA20_POLY1305 = 0x0003;
|
|
@@ -31,31 +33,42 @@ function i2osp2(n) {
|
|
|
31
33
|
return new Uint8Array([(n >> 8) & 0xff, n & 0xff]);
|
|
32
34
|
}
|
|
33
35
|
function concat(...arrays) {
|
|
34
|
-
|
|
36
|
+
let len = 0;
|
|
37
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
38
|
+
len += arrays[i].length;
|
|
39
|
+
}
|
|
35
40
|
const result = new Uint8Array(len);
|
|
36
41
|
let offset = 0;
|
|
37
|
-
for (
|
|
42
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
43
|
+
const a = arrays[i];
|
|
38
44
|
result.set(a, offset);
|
|
39
45
|
offset += a.length;
|
|
40
46
|
}
|
|
41
47
|
return result;
|
|
42
48
|
}
|
|
43
49
|
function suiteParams(kem, aead) {
|
|
44
|
-
|
|
45
|
-
const aeadId = aead === "chacha20-poly1305" ? AEAD_CHACHA20_POLY1305 : AEAD_AES_128_GCM;
|
|
46
|
-
const nk = aead === "chacha20-poly1305" ? 32 : 16;
|
|
47
|
-
const nn = 12;
|
|
48
|
-
const nSecret = 32;
|
|
50
|
+
let kemId;
|
|
49
51
|
let nEnc;
|
|
50
52
|
let nSk;
|
|
51
53
|
if (kem === "x25519") {
|
|
54
|
+
kemId = KEM_X25519;
|
|
52
55
|
nEnc = 32;
|
|
53
56
|
nSk = 32;
|
|
54
57
|
}
|
|
55
|
-
else {
|
|
58
|
+
else if (kem === "p256") {
|
|
59
|
+
kemId = KEM_P256;
|
|
56
60
|
nEnc = 65;
|
|
57
61
|
nSk = 32;
|
|
58
62
|
}
|
|
63
|
+
else {
|
|
64
|
+
kemId = KEM_X25519_MLKEM768;
|
|
65
|
+
nEnc = 1120;
|
|
66
|
+
nSk = 2432;
|
|
67
|
+
}
|
|
68
|
+
const aeadId = aead === "chacha20-poly1305" ? AEAD_CHACHA20_POLY1305 : AEAD_AES_128_GCM;
|
|
69
|
+
const nk = aead === "chacha20-poly1305" ? 32 : 16;
|
|
70
|
+
const nn = 12;
|
|
71
|
+
const nSecret = 32;
|
|
59
72
|
return {
|
|
60
73
|
kemId,
|
|
61
74
|
kdfId: KDF_HKDF_SHA256,
|
|
@@ -113,6 +126,40 @@ function dhkemDecap(kem, enc, recipientPriv, params) {
|
|
|
113
126
|
const recipientPub = kemPublicKey(kem, recipientPriv);
|
|
114
127
|
return extractAndExpand(params, dh, concat(enc, recipientPub));
|
|
115
128
|
}
|
|
129
|
+
function hybridEncap(recipientPub, ephemeralPrivateKey, params) {
|
|
130
|
+
if (recipientPub.length !== 1216) {
|
|
131
|
+
throw new Error("Invalid recipient public key length for x25519-ml-kem-768");
|
|
132
|
+
}
|
|
133
|
+
const pkX = recipientPub.subarray(0, 32);
|
|
134
|
+
const pkMlKem = recipientPub.subarray(32);
|
|
135
|
+
const ephPrivX = ephemeralPrivateKey.subarray(0, 32);
|
|
136
|
+
const encX = ed25519_js_1.x25519.getPublicKey(ephPrivX);
|
|
137
|
+
const ssClassical = ed25519_js_1.x25519.getSharedSecret(ephPrivX, pkX);
|
|
138
|
+
const { cipherText: ctMlKem, sharedSecret: ssMlKem } = ml_kem_js_1.ml_kem768.encapsulate(pkMlKem);
|
|
139
|
+
const enc = concat(encX, ctMlKem);
|
|
140
|
+
const ikm = concat(ssClassical, ssMlKem);
|
|
141
|
+
const sharedSecret = extractAndExpand(params, ikm, concat(enc, recipientPub));
|
|
142
|
+
return { sharedSecret, enc };
|
|
143
|
+
}
|
|
144
|
+
function hybridDecap(enc, recipientPriv, params) {
|
|
145
|
+
if (recipientPriv.length !== 2432) {
|
|
146
|
+
throw new Error("Invalid recipient private key length for x25519-ml-kem-768");
|
|
147
|
+
}
|
|
148
|
+
if (enc.length !== 1120) {
|
|
149
|
+
throw new Error("Invalid encapsulated key length for x25519-ml-kem-768");
|
|
150
|
+
}
|
|
151
|
+
const skX = recipientPriv.subarray(0, 32);
|
|
152
|
+
const skMlKem = recipientPriv.subarray(32);
|
|
153
|
+
const encX = enc.subarray(0, 32);
|
|
154
|
+
const ctMlKem = enc.subarray(32);
|
|
155
|
+
const ssClassical = ed25519_js_1.x25519.getSharedSecret(skX, encX);
|
|
156
|
+
const ssMlKem = ml_kem_js_1.ml_kem768.decapsulate(ctMlKem, skMlKem);
|
|
157
|
+
const pkX = ed25519_js_1.x25519.getPublicKey(skX);
|
|
158
|
+
const pkMlKem = ml_kem_js_1.ml_kem768.getPublicKey(skMlKem);
|
|
159
|
+
const recipientPub = concat(pkX, pkMlKem);
|
|
160
|
+
const ikm = concat(ssClassical, ssMlKem);
|
|
161
|
+
return extractAndExpand(params, ikm, concat(enc, recipientPub));
|
|
162
|
+
}
|
|
116
163
|
function keySchedule(params, sharedSecret, inputs) {
|
|
117
164
|
const suiteId = hpkeSuiteId(params);
|
|
118
165
|
const empty = new Uint8Array(0);
|
|
@@ -156,6 +203,15 @@ function aeadOpen(aead, key, nonce, aad, ciphertext) {
|
|
|
156
203
|
return (0, aes_js_1.gcm)(key, nonce, aad).decrypt(ciphertext);
|
|
157
204
|
}
|
|
158
205
|
function hpkeGenerateKeyPair(kem = "x25519") {
|
|
206
|
+
if (kem === "x25519-ml-kem-768") {
|
|
207
|
+
const skX = ed25519_js_1.x25519.utils.randomSecretKey();
|
|
208
|
+
const pkX = ed25519_js_1.x25519.getPublicKey(skX);
|
|
209
|
+
const { publicKey: pkMlKem, secretKey: skMlKem } = ml_kem_js_1.ml_kem768.keygen();
|
|
210
|
+
return {
|
|
211
|
+
publicKey: bytesToHex(concat(pkX, pkMlKem)),
|
|
212
|
+
privateKey: bytesToHex(concat(skX, skMlKem)),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
159
215
|
const privateKey = kemRandomPrivateKey(kem);
|
|
160
216
|
return {
|
|
161
217
|
publicKey: bytesToHex(kemPublicKey(kem, privateKey)),
|
|
@@ -164,7 +220,10 @@ function hpkeGenerateKeyPair(kem = "x25519") {
|
|
|
164
220
|
}
|
|
165
221
|
function hpkeSeal(options) {
|
|
166
222
|
const kem = options.suite?.kem ?? "x25519";
|
|
167
|
-
const
|
|
223
|
+
const ephemeralPrivateKey = kem === "x25519-ml-kem-768"
|
|
224
|
+
? ed25519_js_1.x25519.utils.randomSecretKey()
|
|
225
|
+
: kemRandomPrivateKey(kem);
|
|
226
|
+
const sealed = hpkeSealWithEphemeral(options, ephemeralPrivateKey);
|
|
168
227
|
return {
|
|
169
228
|
ciphertext: sealed.ciphertext,
|
|
170
229
|
encapsulatedKey: sealed.encapsulatedKey,
|
|
@@ -178,7 +237,9 @@ function hpkeSealWithEphemeral(options, ephemeralPrivateKey) {
|
|
|
178
237
|
const plaintext = hexToBytes(options.plaintext);
|
|
179
238
|
const aad = options.aad ? hexToBytes(options.aad) : new Uint8Array(0);
|
|
180
239
|
const inputs = scheduleInputs(options);
|
|
181
|
-
const { sharedSecret, enc } =
|
|
240
|
+
const { sharedSecret, enc } = kem === "x25519-ml-kem-768"
|
|
241
|
+
? hybridEncap(recipientPub, ephemeralPrivateKey, params)
|
|
242
|
+
: dhkemEncap(kem, recipientPub, ephemeralPrivateKey, params);
|
|
182
243
|
const ks = keySchedule(params, sharedSecret, inputs);
|
|
183
244
|
const ct = aeadSeal(aead, ks.key, ks.baseNonce, aad, plaintext);
|
|
184
245
|
return {
|
|
@@ -199,7 +260,9 @@ function hpkeOpen(options) {
|
|
|
199
260
|
const ciphertext = hexToBytes(options.ciphertext);
|
|
200
261
|
const aad = options.aad ? hexToBytes(options.aad) : new Uint8Array(0);
|
|
201
262
|
const inputs = scheduleInputs(options);
|
|
202
|
-
const sharedSecret =
|
|
263
|
+
const sharedSecret = kem === "x25519-ml-kem-768"
|
|
264
|
+
? hybridDecap(enc, recipientPriv, params)
|
|
265
|
+
: dhkemDecap(kem, enc, recipientPriv, params);
|
|
203
266
|
const { key, baseNonce } = keySchedule(params, sharedSecret, inputs);
|
|
204
267
|
const pt = aeadOpen(aead, key, baseNonce, aad, ciphertext);
|
|
205
268
|
return { plaintext: bytesToHex(pt) };
|
package/dist/modern/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare const SUPPORTED_ALGORITHMS: {
|
|
|
34
34
|
readonly kdf: readonly ["scrypt", "hkdf-sha256", "pbkdf2-sha256", "argon2id", "argon2i", "argon2d"];
|
|
35
35
|
readonly mac: readonly ["hmac-sha256", "hmac-sha384", "hmac-sha512", "hmac-sha3-256", "hmac-sha3-512", "kmac-128", "kmac-256"];
|
|
36
36
|
readonly signing: readonly ["ed25519", "ed448", "ecdsa-p256", "ecdsa-p384", "schnorr", "ml-dsa-44", "ml-dsa-65", "ml-dsa-87", "slh-dsa-sha2-128f", "slh-dsa-sha2-128s", "slh-dsa-sha2-192f", "slh-dsa-sha2-192s", "slh-dsa-sha2-256f", "slh-dsa-sha2-256s", "slh-dsa-shake-128f", "slh-dsa-shake-128s", "slh-dsa-shake-192f", "slh-dsa-shake-192s", "slh-dsa-shake-256f", "slh-dsa-shake-256s", "ed25519-ml-dsa-44", "ed25519-ml-dsa-65", "ed25519-ml-dsa-87", "fn-dsa-512", "fn-dsa-1024"];
|
|
37
|
-
readonly keyExchange: readonly ["x25519", "x448", "ecdh-p256", "ecdh-p384", "x25519-ml-kem-512", "x25519-ml-kem-768", "x25519-ml-kem-1024", "p256-ml-kem-768", "x448-ml-kem-1024", "hpke-x25519-chacha20", "hpke-x25519-aes128gcm", "hpke-p256-aes128gcm"];
|
|
37
|
+
readonly keyExchange: readonly ["x25519", "x448", "ecdh-p256", "ecdh-p384", "x25519-ml-kem-512", "x25519-ml-kem-768", "x25519-ml-kem-1024", "p256-ml-kem-768", "x448-ml-kem-1024", "hpke-x25519-chacha20", "hpke-x25519-aes128gcm", "hpke-p256-aes128gcm", "hpke-x25519-ml-kem-768-chacha20", "hpke-x25519-ml-kem-768-aes128gcm"];
|
|
38
38
|
readonly postQuantum: readonly ["ml-kem-512", "ml-kem-768", "ml-kem-1024", "ml-dsa-44", "ml-dsa-65", "ml-dsa-87", "slh-dsa-sha2-128f", "slh-dsa-sha2-128s", "slh-dsa-sha2-192f", "slh-dsa-sha2-192s", "slh-dsa-sha2-256f", "slh-dsa-sha2-256s", "slh-dsa-shake-128f", "slh-dsa-shake-128s", "slh-dsa-shake-192f", "slh-dsa-shake-192s", "slh-dsa-shake-256f", "slh-dsa-shake-256s", "fn-dsa-512", "fn-dsa-1024"];
|
|
39
39
|
};
|
|
40
40
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modern/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAElD,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,OAAO,CAAC;AAEf,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE/C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAElD,YAAY,E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AAmB,GACpB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEjE,YAAY,EACV,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,QAAQ,CAAC;AAKhB,eAAO,MAAM,oBAAoB;;;;;;;;CA0GvB,CAAC"}
|
package/dist/modern/index.js
CHANGED
package/dist/modern/kdf.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kdf.d.ts","sourceRoot":"","sources":["../../src/modern/kdf.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,cAAc,qDAIjB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAG3D,MAAM,WAAW,gBAAgB;IAE/B,SAAS,EAAE,YAAY,CAAC;IAExB,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC;IAE9B,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE3B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,MAAM,CAAC,EAAE;QAEP,CAAC,CAAC,EAAE,MAAM,CAAC;QAEX,CAAC,CAAC,EAAE,MAAM,CAAC;QAEX,CAAC,CAAC,EAAE,MAAM,CAAC;QAEX,UAAU,CAAC,EAAE,MAAM,CAAC;QAEpB,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;KAC5B,CAAC;CACH;AAGD,MAAM,WAAW,SAAS;IAExB,UAAU,EAAE,MAAM,CAAC;IAEnB,IAAI,EAAE,MAAM,CAAC;IAEb,SAAS,EAAE,YAAY,CAAC;IAExB,SAAS,EAAE,MAAM,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"kdf.d.ts","sourceRoot":"","sources":["../../src/modern/kdf.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,cAAc,qDAIjB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAG3D,MAAM,WAAW,gBAAgB;IAE/B,SAAS,EAAE,YAAY,CAAC;IAExB,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC;IAE9B,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE3B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,MAAM,CAAC,EAAE;QAEP,CAAC,CAAC,EAAE,MAAM,CAAC;QAEX,CAAC,CAAC,EAAE,MAAM,CAAC;QAEX,CAAC,CAAC,EAAE,MAAM,CAAC;QAEX,UAAU,CAAC,EAAE,MAAM,CAAC;QAEpB,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;KAC5B,CAAC;CACH;AAGD,MAAM,WAAW,SAAS;IAExB,UAAU,EAAE,MAAM,CAAC;IAEnB,IAAI,EAAE,MAAM,CAAC;IAEb,SAAS,EAAE,YAAY,CAAC;IAExB,SAAS,EAAE,MAAM,CAAC;CACnB;AA4DD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CA4B9D"}
|
package/dist/modern/kdf.js
CHANGED
|
@@ -25,6 +25,25 @@ function toBytes(input, encoding = "utf8") {
|
|
|
25
25
|
}
|
|
26
26
|
return Buffer.from(input, "utf8");
|
|
27
27
|
}
|
|
28
|
+
function deriveScrypt(password, salt, keyLength, params) {
|
|
29
|
+
const N = params.N ?? 131072;
|
|
30
|
+
const r = params.r ?? 8;
|
|
31
|
+
const p = params.p ?? 1;
|
|
32
|
+
(0, cost_limits_1.checkScryptCosts)(N, r, p);
|
|
33
|
+
return (0, scrypt_js_1.scrypt)(password, salt, { N, r, p, dkLen: keyLength });
|
|
34
|
+
}
|
|
35
|
+
function deriveHkdf(password, salt, keyLength, params) {
|
|
36
|
+
const info = params.info ? toBytes(params.info, "utf8") : undefined;
|
|
37
|
+
return (0, hkdf_js_1.hkdf)(sha2_js_1.sha256, password, salt, info, keyLength);
|
|
38
|
+
}
|
|
39
|
+
function derivePbkdf2(password, salt, keyLength, params) {
|
|
40
|
+
const iterations = params.iterations ?? 600000;
|
|
41
|
+
(0, cost_limits_1.checkPbkdf2Iterations)(iterations);
|
|
42
|
+
return (0, pbkdf2_js_1.pbkdf2)(sha2_js_1.sha256, password, salt, {
|
|
43
|
+
c: iterations,
|
|
44
|
+
dkLen: keyLength,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
28
47
|
function kdfDerive(options) {
|
|
29
48
|
const password = toBytes(options.password, "utf8");
|
|
30
49
|
const salt = options.salt ? toBytes(options.salt, "hex") : (0, utils_js_1.randomBytes)(16);
|
|
@@ -32,28 +51,15 @@ function kdfDerive(options) {
|
|
|
32
51
|
const params = options.params ?? {};
|
|
33
52
|
let derived;
|
|
34
53
|
switch (options.algorithm) {
|
|
35
|
-
case "scrypt":
|
|
36
|
-
|
|
37
|
-
const r = params.r ?? 8;
|
|
38
|
-
const p = params.p ?? 1;
|
|
39
|
-
(0, cost_limits_1.checkScryptCosts)(N, r, p);
|
|
40
|
-
derived = (0, scrypt_js_1.scrypt)(password, salt, { N, r, p, dkLen: keyLength });
|
|
54
|
+
case "scrypt":
|
|
55
|
+
derived = deriveScrypt(password, salt, keyLength, params);
|
|
41
56
|
break;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const info = params.info ? toBytes(params.info, "utf8") : undefined;
|
|
45
|
-
derived = (0, hkdf_js_1.hkdf)(sha2_js_1.sha256, password, salt, info, keyLength);
|
|
57
|
+
case "hkdf-sha256":
|
|
58
|
+
derived = deriveHkdf(password, salt, keyLength, params);
|
|
46
59
|
break;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const iterations = params.iterations ?? 600000;
|
|
50
|
-
(0, cost_limits_1.checkPbkdf2Iterations)(iterations);
|
|
51
|
-
derived = (0, pbkdf2_js_1.pbkdf2)(sha2_js_1.sha256, password, salt, {
|
|
52
|
-
c: iterations,
|
|
53
|
-
dkLen: keyLength,
|
|
54
|
-
});
|
|
60
|
+
case "pbkdf2-sha256":
|
|
61
|
+
derived = derivePbkdf2(password, salt, keyLength, params);
|
|
55
62
|
break;
|
|
56
|
-
}
|
|
57
63
|
default:
|
|
58
64
|
throw new Error(`Unsupported KDF algorithm: ${options.algorithm}`);
|
|
59
65
|
}
|
|
@@ -2,6 +2,10 @@ export { createHasher, STREAM_HASH_ALGORITHMS } from "./stream-hash";
|
|
|
2
2
|
export type { StreamingHasher, StreamHashAlgorithm } from "./stream-hash";
|
|
3
3
|
export { streamEncrypt, streamDecrypt } from "./stream-aead";
|
|
4
4
|
export type { StreamEncryptOptions, StreamEncryptResult, StreamDecryptOptions, } from "./stream-aead";
|
|
5
|
-
export { createEncryptStream, createDecryptStream, createHashStream, WEB_STREAM_HASH_ALGORITHMS, } from "./web-streams";
|
|
6
|
-
export type { WebStreamHashAlgorithm, HashStreamResult, EncryptStreamOptions, DecryptStreamOptions, CryptoTransformStream, } from "./web-streams";
|
|
5
|
+
export { createEncryptStream, createDecryptStream, createHashStream, createPqEncryptStream, createPqDecryptStream, createMultiPqEncryptStream, createMultiPqDecryptStream, WEB_STREAM_HASH_ALGORITHMS, } from "./web-streams";
|
|
6
|
+
export type { WebStreamHashAlgorithm, HashStreamResult, EncryptStreamOptions, DecryptStreamOptions, PqEncryptStreamOptions, PqDecryptStreamOptions, MultiPqEncryptStreamOptions, MultiPqDecryptStreamOptions, CryptoTransformStream, } from "./web-streams";
|
|
7
|
+
export { streamPqEncrypt, streamPqDecrypt, PQ_STREAM_HEADER_LEN, } from "./stream-pq-aead";
|
|
8
|
+
export type { StreamPqEncryptOptions, StreamPqEncryptResult, StreamPqDecryptOptions, } from "./stream-pq-aead";
|
|
9
|
+
export { streamMultiPqEncrypt, streamMultiPqDecrypt, MULTI_PQ_STREAM_MAGIC, MULTI_PQ_STREAM_VERSION, MULTI_PQ_PREFIX_LEN, CEK_LEN, WRAPPED_CEK_LEN, SLOT_FIXED_OVERHEAD, } from "./stream-multi-pq-aead";
|
|
10
|
+
export type { MultiPqRecipient, StreamMultiPqEncryptOptions, StreamMultiPqEncryptResult, StreamMultiPqDecryptOptions, StreamMultiPqDecryptResult, } from "./stream-multi-pq-aead";
|
|
7
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/streaming/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAErE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE7D,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/streaming/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAErE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE7D,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EACf,eAAe,EACf,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,OAAO,EACP,eAAe,EACf,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,gBAAgB,EAChB,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC"}
|