@sebastienrousseau/crypto-lib 0.0.35 → 0.0.37

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.
Files changed (174) hide show
  1. package/README.md +17 -2
  2. package/dist/accel/index.d.ts +5 -4
  3. package/dist/accel/index.d.ts.map +1 -1
  4. package/dist/accel/index.js +5 -5
  5. package/dist/accel/kdf-backend.d.ts +13 -0
  6. package/dist/accel/kdf-backend.d.ts.map +1 -0
  7. package/dist/accel/kdf-backend.js +81 -0
  8. package/dist/accel/native-pqc-bridge.d.ts.map +1 -1
  9. package/dist/accel/native-pqc-bridge.js +12 -52
  10. package/dist/accel/pq-backend.d.ts +3652 -0
  11. package/dist/accel/pq-backend.d.ts.map +1 -0
  12. package/dist/accel/pq-backend.js +215 -0
  13. package/dist/accel/runtime.d.ts +3 -0
  14. package/dist/accel/runtime.d.ts.map +1 -0
  15. package/dist/accel/runtime.js +9 -0
  16. package/dist/accel/wasm-bridge.d.ts.map +1 -1
  17. package/dist/accel/wasm-bridge.js +14 -13
  18. package/dist/accel/webcrypto-bridge.d.ts.map +1 -1
  19. package/dist/accel/webcrypto-bridge.js +14 -13
  20. package/dist/accel/webcrypto-modern.d.ts.map +1 -1
  21. package/dist/accel/webcrypto-modern.js +15 -14
  22. package/dist/accel/worker-pool.d.ts +18 -0
  23. package/dist/accel/worker-pool.d.ts.map +1 -1
  24. package/dist/accel/worker-pool.js +113 -37
  25. package/dist/bin/cryptolib.d.ts +7 -4
  26. package/dist/bin/cryptolib.d.ts.map +1 -1
  27. package/dist/bin/cryptolib.js +6 -6
  28. package/dist/crypto.d.ts.map +1 -1
  29. package/dist/crypto.js +2 -1
  30. package/dist/encoding.d.ts +10 -0
  31. package/dist/encoding.d.ts.map +1 -0
  32. package/dist/encoding.js +84 -0
  33. package/dist/errors.d.ts +11 -0
  34. package/dist/errors.d.ts.map +1 -1
  35. package/dist/errors.js +20 -1
  36. package/dist/high-level/key-wrap.d.ts.map +1 -1
  37. package/dist/high-level/key-wrap.js +12 -17
  38. package/dist/high-level/multi-recipient.d.ts.map +1 -1
  39. package/dist/high-level/multi-recipient.js +15 -28
  40. package/dist/high-level/password-encrypt.d.ts.map +1 -1
  41. package/dist/high-level/password-encrypt.js +11 -11
  42. package/dist/high-level/sealedbox.d.ts.map +1 -1
  43. package/dist/high-level/sealedbox.js +16 -28
  44. package/dist/high-level/secretbox.d.ts.map +1 -1
  45. package/dist/high-level/secretbox.js +11 -10
  46. package/dist/index.d.ts +1 -1
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +3 -1
  49. package/dist/key/keystore.d.ts.map +1 -1
  50. package/dist/key/keystore.js +2 -1
  51. package/dist/keys/keygen.d.ts.map +1 -1
  52. package/dist/keys/keygen.js +13 -14
  53. package/dist/keys/keyring.d.ts.map +1 -1
  54. package/dist/keys/keyring.js +4 -2
  55. package/dist/keys/serialize.d.ts.map +1 -1
  56. package/dist/keys/serialize.js +18 -16
  57. package/dist/lib/decrypt.d.ts.map +1 -1
  58. package/dist/lib/decrypt.js +2 -1
  59. package/dist/lib/generate.d.ts +2 -1
  60. package/dist/lib/generate.d.ts.map +1 -1
  61. package/dist/lib/generate.js +7 -6
  62. package/dist/lib/key-output.d.ts +4 -1
  63. package/dist/lib/key-output.d.ts.map +1 -1
  64. package/dist/lib/key-output.js +2 -2
  65. package/dist/lib/reformat.d.ts +2 -1
  66. package/dist/lib/reformat.d.ts.map +1 -1
  67. package/dist/lib/reformat.js +2 -2
  68. package/dist/lib/revoke.d.ts +2 -1
  69. package/dist/lib/revoke.d.ts.map +1 -1
  70. package/dist/lib/revoke.js +2 -2
  71. package/dist/lib/verify.d.ts +6 -2
  72. package/dist/lib/verify.d.ts.map +1 -1
  73. package/dist/lib/verify.js +28 -9
  74. package/dist/modern/aead.d.ts.map +1 -1
  75. package/dist/modern/aead.js +11 -10
  76. package/dist/modern/aes.d.ts.map +1 -1
  77. package/dist/modern/aes.js +10 -9
  78. package/dist/modern/cost-limits.d.ts.map +1 -1
  79. package/dist/modern/cost-limits.js +3 -2
  80. package/dist/modern/curves.d.ts +10 -5
  81. package/dist/modern/curves.d.ts.map +1 -1
  82. package/dist/modern/curves.js +43 -36
  83. package/dist/modern/ecdh.d.ts +2 -1
  84. package/dist/modern/ecdh.d.ts.map +1 -1
  85. package/dist/modern/ecdh.js +10 -9
  86. package/dist/modern/fn-dsa.d.ts.map +1 -1
  87. package/dist/modern/fn-dsa.js +9 -8
  88. package/dist/modern/hash.d.ts.map +1 -1
  89. package/dist/modern/hash.js +5 -3
  90. package/dist/modern/hpke-xwing.d.ts +10 -0
  91. package/dist/modern/hpke-xwing.d.ts.map +1 -0
  92. package/dist/modern/hpke-xwing.js +26 -0
  93. package/dist/modern/hpke.d.ts +1 -1
  94. package/dist/modern/hpke.d.ts.map +1 -1
  95. package/dist/modern/hpke.js +60 -28
  96. package/dist/modern/hybrid-combiner.d.ts +20 -0
  97. package/dist/modern/hybrid-combiner.d.ts.map +1 -0
  98. package/dist/modern/hybrid-combiner.js +79 -0
  99. package/dist/modern/index.d.ts +10 -10
  100. package/dist/modern/index.d.ts.map +1 -1
  101. package/dist/modern/index.js +17 -7
  102. package/dist/modern/kdf.d.ts.map +1 -1
  103. package/dist/modern/kdf.js +12 -12
  104. package/dist/modern/mac.d.ts +1 -0
  105. package/dist/modern/mac.d.ts.map +1 -1
  106. package/dist/modern/mac.js +24 -15
  107. package/dist/modern/password.d.ts.map +1 -1
  108. package/dist/modern/password.js +19 -18
  109. package/dist/modern/pq-hash-sign.d.ts.map +1 -1
  110. package/dist/modern/pq-hash-sign.js +23 -22
  111. package/dist/modern/pq-kem.d.ts +8 -0
  112. package/dist/modern/pq-kem.d.ts.map +1 -1
  113. package/dist/modern/pq-kem.js +71 -79
  114. package/dist/modern/pq-sign.d.ts +9 -2
  115. package/dist/modern/pq-sign.d.ts.map +1 -1
  116. package/dist/modern/pq-sign.js +60 -23
  117. package/dist/modern/pq.d.ts +0 -17
  118. package/dist/modern/pq.d.ts.map +1 -1
  119. package/dist/modern/pq.js +15 -43
  120. package/dist/modern/signing.d.ts +2 -1
  121. package/dist/modern/signing.d.ts.map +1 -1
  122. package/dist/modern/signing.js +14 -13
  123. package/dist/protocols/iso20022.d.ts.map +1 -1
  124. package/dist/protocols/iso20022.js +12 -6
  125. package/dist/protocols/opaque/ksf.js +2 -2
  126. package/dist/protocols/opaque/suite.d.ts +1 -8
  127. package/dist/protocols/opaque/suite.d.ts.map +1 -1
  128. package/dist/protocols/opaque/suite.js +5 -10
  129. package/dist/protocols/pqxdh.d.ts +9 -2
  130. package/dist/protocols/pqxdh.d.ts.map +1 -1
  131. package/dist/protocols/pqxdh.js +99 -94
  132. package/dist/protocols/ratchet.d.ts.map +1 -1
  133. package/dist/protocols/ratchet.js +14 -15
  134. package/dist/protocols/threshold.d.ts.map +1 -1
  135. package/dist/protocols/threshold.js +16 -15
  136. package/dist/registry.d.ts.map +1 -1
  137. package/dist/registry.js +26 -0
  138. package/dist/streaming/chunks.d.ts +31 -0
  139. package/dist/streaming/chunks.d.ts.map +1 -1
  140. package/dist/streaming/chunks.js +149 -13
  141. package/dist/streaming/stream-aead.d.ts +9 -0
  142. package/dist/streaming/stream-aead.d.ts.map +1 -1
  143. package/dist/streaming/stream-aead.js +27 -53
  144. package/dist/streaming/stream-hash.d.ts.map +1 -1
  145. package/dist/streaming/stream-hash.js +6 -4
  146. package/dist/streaming/stream-multi-pq-aead.d.ts +12 -0
  147. package/dist/streaming/stream-multi-pq-aead.d.ts.map +1 -1
  148. package/dist/streaming/stream-multi-pq-aead.js +82 -106
  149. package/dist/streaming/stream-pq-aead.d.ts +7 -2
  150. package/dist/streaming/stream-pq-aead.d.ts.map +1 -1
  151. package/dist/streaming/stream-pq-aead.js +29 -79
  152. package/dist/streaming/web-streams.d.ts +5 -2
  153. package/dist/streaming/web-streams.d.ts.map +1 -1
  154. package/dist/streaming/web-streams.js +90 -151
  155. package/dist/testing/index.d.ts +5 -0
  156. package/dist/testing/index.d.ts.map +1 -0
  157. package/dist/testing/index.js +13 -0
  158. package/dist/tokens/index.d.ts.map +1 -1
  159. package/dist/tokens/key-rotation.d.ts.map +1 -1
  160. package/dist/tokens/key-rotation.js +4 -2
  161. package/dist/tokens/paseto.d.ts +2 -0
  162. package/dist/tokens/paseto.d.ts.map +1 -1
  163. package/dist/tokens/paseto.js +56 -29
  164. package/dist/types/types.d.ts +1 -0
  165. package/dist/types/types.d.ts.map +1 -1
  166. package/dist/utils.d.ts.map +1 -1
  167. package/dist/utils.js +3 -2
  168. package/package.json +12 -2
  169. package/dist/config/config.d.ts +0 -8
  170. package/dist/config/config.d.ts.map +0 -1
  171. package/dist/config/config.js +0 -13
  172. package/dist/key/key.d.ts +0 -10
  173. package/dist/key/key.d.ts.map +0 -1
  174. package/dist/key/key.js +0 -25
@@ -2,35 +2,35 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KDF_ALGORITHMS = void 0;
4
4
  exports.kdfDerive = kdfDerive;
5
- const scrypt_js_1 = require("@noble/hashes/scrypt.js");
5
+ const kdf_backend_1 = require("../accel/kdf-backend");
6
6
  const hkdf_js_1 = require("@noble/hashes/hkdf.js");
7
- const pbkdf2_js_1 = require("@noble/hashes/pbkdf2.js");
8
7
  const sha2_js_1 = require("@noble/hashes/sha2.js");
9
8
  const utils_js_1 = require("@noble/ciphers/utils.js");
10
9
  const cost_limits_1 = require("./cost-limits");
10
+ const errors_1 = require("../errors");
11
+ const encoding_1 = require("../encoding");
11
12
  exports.KDF_ALGORITHMS = [
12
13
  "scrypt",
13
14
  "hkdf-sha256",
14
15
  "pbkdf2-sha256",
15
16
  ];
16
- const HEX_RE = /^[0-9a-fA-F]*$/;
17
17
  function toBytes(input, encoding = "utf8") {
18
18
  if (input instanceof Uint8Array)
19
19
  return input;
20
20
  if (encoding === "hex") {
21
- if (!HEX_RE.test(input)) {
22
- throw new Error("Invalid hex string");
21
+ if (!(0, encoding_1.isHex)(input)) {
22
+ throw new errors_1.CryptoError("Invalid hex string", errors_1.CryptoErrorCode.INVALID_HEX);
23
23
  }
24
- return Buffer.from(input, "hex");
24
+ return (0, encoding_1.decodeHex)(input);
25
25
  }
26
- return Buffer.from(input, "utf8");
26
+ return (0, encoding_1.utf8)(input);
27
27
  }
28
28
  function deriveScrypt(password, salt, keyLength, params) {
29
29
  const N = params.N ?? 131072;
30
30
  const r = params.r ?? 8;
31
31
  const p = params.p ?? 1;
32
32
  (0, cost_limits_1.checkScryptCosts)(N, r, p);
33
- return (0, scrypt_js_1.scrypt)(password, salt, { N, r, p, dkLen: keyLength });
33
+ return (0, kdf_backend_1.scrypt)(password, salt, { N, r, p, dkLen: keyLength });
34
34
  }
35
35
  function deriveHkdf(password, salt, keyLength, params) {
36
36
  const info = params.info ? toBytes(params.info, "utf8") : undefined;
@@ -39,7 +39,7 @@ function deriveHkdf(password, salt, keyLength, params) {
39
39
  function derivePbkdf2(password, salt, keyLength, params) {
40
40
  const iterations = params.iterations ?? 600000;
41
41
  (0, cost_limits_1.checkPbkdf2Iterations)(iterations);
42
- return (0, pbkdf2_js_1.pbkdf2)(sha2_js_1.sha256, password, salt, {
42
+ return (0, kdf_backend_1.pbkdf2)(sha2_js_1.sha256, password, salt, {
43
43
  c: iterations,
44
44
  dkLen: keyLength,
45
45
  });
@@ -61,11 +61,11 @@ function kdfDerive(options) {
61
61
  derived = derivePbkdf2(password, salt, keyLength, params);
62
62
  break;
63
63
  default:
64
- throw new Error(`Unsupported KDF algorithm: ${options.algorithm}`);
64
+ throw new errors_1.CryptoError(`Unsupported KDF algorithm: ${options.algorithm}`, errors_1.CryptoErrorCode.UNSUPPORTED_ALGORITHM);
65
65
  }
66
66
  return {
67
- derivedKey: Buffer.from(derived).toString("hex"),
68
- salt: Buffer.from(salt).toString("hex"),
67
+ derivedKey: (0, encoding_1.toHex)(derived),
68
+ salt: (0, encoding_1.toHex)(salt),
69
69
  algorithm: options.algorithm,
70
70
  keyLength,
71
71
  };
@@ -19,6 +19,7 @@ export interface HmacVerifyResult {
19
19
  valid: boolean;
20
20
  algorithm: HmacAlgorithm;
21
21
  }
22
+ export declare const MIN_MAC_KEY_BYTES = 16;
22
23
  export declare function computeHmac(options: HmacComputeOptions): HmacComputeResult;
23
24
  export declare function verifyHmac(options: HmacVerifyOptions): HmacVerifyResult;
24
25
  export declare const KMAC_ALGORITHMS: readonly ["kmac-128", "kmac-256"];
@@ -1 +1 @@
1
- {"version":3,"file":"mac.d.ts","sourceRoot":"","sources":["../../src/modern/mac.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,eAAe,iEAMlB,CAAC;AAGX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAG7D,MAAM,WAAW,kBAAkB;IAEjC,SAAS,EAAE,aAAa,CAAC;IAEzB,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;IAEzB,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAC3B;AAGD,MAAM,WAAW,iBAAiB;IAEhC,GAAG,EAAE,MAAM,CAAC;IAEZ,SAAS,EAAE,aAAa,CAAC;CAC1B;AAGD,MAAM,WAAW,iBAAiB;IAEhC,SAAS,EAAE,aAAa,CAAC;IAEzB,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;IAEzB,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAE1B,GAAG,EAAE,MAAM,CAAC;CACb;AAGD,MAAM,WAAW,gBAAgB;IAE/B,KAAK,EAAE,OAAO,CAAC;IAEf,SAAS,EAAE,aAAa,CAAC;CAC1B;AAmDD,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,iBAAiB,CAW1E;AAKD,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAavE;AAKD,eAAO,MAAM,eAAe,mCAAoC,CAAC;AAGjE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,C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,MAAM,WAAW,gBAAgB;IAE/B,KAAK,EAAE,OAAO,CAAC;IAEf,SAAS,EAAE,aAAa,CAAC;CAC1B;AAoBD,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,iBAAiB,CA2B1E;AAKD,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CA6BvE"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KMAC_ALGORITHMS = exports.HMAC_ALGORITHMS = void 0;
3
+ exports.KMAC_ALGORITHMS = exports.MIN_MAC_KEY_BYTES = exports.HMAC_ALGORITHMS = void 0;
4
4
  exports.computeHmac = computeHmac;
5
5
  exports.verifyHmac = verifyHmac;
6
6
  exports.computeKmac = computeKmac;
@@ -10,6 +10,8 @@ const sha2_js_1 = require("@noble/hashes/sha2.js");
10
10
  const sha3_js_1 = require("@noble/hashes/sha3.js");
11
11
  const sha3_addons_js_1 = require("@noble/hashes/sha3-addons.js");
12
12
  const utils_1 = require("../utils");
13
+ const errors_1 = require("../errors");
14
+ const encoding_1 = require("../encoding");
13
15
  exports.HMAC_ALGORITHMS = [
14
16
  "sha256",
15
17
  "sha384",
@@ -17,17 +19,16 @@ exports.HMAC_ALGORITHMS = [
17
19
  "sha3-256",
18
20
  "sha3-512",
19
21
  ];
20
- const HEX_RE = /^[0-9a-fA-F]*$/;
21
22
  function toBytes(input, encoding = "utf8") {
22
23
  if (input instanceof Uint8Array)
23
24
  return input;
24
25
  if (encoding === "hex") {
25
- if (!HEX_RE.test(input)) {
26
- throw new Error("Invalid hex string");
26
+ if (!(0, encoding_1.isHex)(input)) {
27
+ throw new errors_1.CryptoError("Invalid hex string", errors_1.CryptoErrorCode.INVALID_HEX);
27
28
  }
28
- return Buffer.from(input, "hex");
29
+ return (0, encoding_1.decodeHex)(input);
29
30
  }
30
- return Buffer.from(input, "utf8");
31
+ return (0, encoding_1.utf8)(input);
31
32
  }
32
33
  const hashFunctions = {
33
34
  sha256: sha2_js_1.sha256,
@@ -39,23 +40,31 @@ const hashFunctions = {
39
40
  function getHashFn(algorithm) {
40
41
  const fn = hashFunctions[algorithm];
41
42
  if (!fn) {
42
- throw new Error(`Unsupported HMAC algorithm: ${algorithm}. Supported: ${exports.HMAC_ALGORITHMS.join(", ")}`);
43
+ throw new errors_1.CryptoError(`Unsupported HMAC algorithm: ${algorithm}. Supported: ${exports.HMAC_ALGORITHMS.join(", ")}`, errors_1.CryptoErrorCode.UNSUPPORTED_ALGORITHM);
43
44
  }
44
45
  return fn;
45
46
  }
47
+ exports.MIN_MAC_KEY_BYTES = 16;
48
+ function macKey(hex) {
49
+ const key = toBytes(hex, "hex");
50
+ if (key.length < exports.MIN_MAC_KEY_BYTES) {
51
+ throw new errors_1.CryptoError(`MAC key must be at least ${exports.MIN_MAC_KEY_BYTES} bytes, got ${key.length}`, "INVALID_KEY");
52
+ }
53
+ return key;
54
+ }
46
55
  function computeHmac(options) {
47
56
  const hashFn = getHashFn(options.algorithm);
48
- const key = toBytes(options.key, "hex");
57
+ const key = macKey(options.key);
49
58
  const data = toBytes(options.data, "utf8");
50
59
  const mac = (0, hmac_js_1.hmac)(hashFn, key, data);
51
60
  return {
52
- mac: Buffer.from(mac).toString("hex"),
61
+ mac: (0, encoding_1.toHex)(mac),
53
62
  algorithm: options.algorithm,
54
63
  };
55
64
  }
56
65
  function verifyHmac(options) {
57
66
  const hashFn = getHashFn(options.algorithm);
58
- const key = toBytes(options.key, "hex");
67
+ const key = macKey(options.key);
59
68
  const data = toBytes(options.data, "utf8");
60
69
  const expectedMac = toBytes(options.mac, "hex");
61
70
  const computedMac = (0, hmac_js_1.hmac)(hashFn, key, data);
@@ -77,9 +86,9 @@ const kmacDefaultLength = {
77
86
  function computeKmac(options) {
78
87
  const fn = kmacFunctions[options.algorithm];
79
88
  if (!fn) {
80
- throw new Error(`Unsupported KMAC algorithm: ${options.algorithm}. Supported: ${exports.KMAC_ALGORITHMS.join(", ")}`);
89
+ throw new errors_1.CryptoError(`Unsupported KMAC algorithm: ${options.algorithm}. Supported: ${exports.KMAC_ALGORITHMS.join(", ")}`, errors_1.CryptoErrorCode.UNSUPPORTED_ALGORITHM);
81
90
  }
82
- const key = toBytes(options.key, "hex");
91
+ const key = macKey(options.key);
83
92
  const data = toBytes(options.data, "utf8");
84
93
  const outputLength = options.outputLength ?? kmacDefaultLength[options.algorithm];
85
94
  const opts = {
@@ -90,16 +99,16 @@ function computeKmac(options) {
90
99
  }
91
100
  const mac = fn(key, data, opts);
92
101
  return {
93
- mac: Buffer.from(mac).toString("hex"),
102
+ mac: (0, encoding_1.toHex)(mac),
94
103
  algorithm: options.algorithm,
95
104
  };
96
105
  }
97
106
  function verifyKmac(options) {
98
107
  const fn = kmacFunctions[options.algorithm];
99
108
  if (!fn) {
100
- throw new Error(`Unsupported KMAC algorithm: ${options.algorithm}. Supported: ${exports.KMAC_ALGORITHMS.join(", ")}`);
109
+ throw new errors_1.CryptoError(`Unsupported KMAC algorithm: ${options.algorithm}. Supported: ${exports.KMAC_ALGORITHMS.join(", ")}`, errors_1.CryptoErrorCode.UNSUPPORTED_ALGORITHM);
101
110
  }
102
- const key = toBytes(options.key, "hex");
111
+ const key = macKey(options.key);
103
112
  const data = toBytes(options.data, "utf8");
104
113
  const expectedMac = toBytes(options.mac, "hex");
105
114
  const outputLength = options.outputLength ?? kmacDefaultLength[options.algorithm];
@@ -1 +1 @@
1
- {"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../src/modern/password.ts"],"names":[],"mappings":"AA2BA,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAG/D,MAAM,WAAW,YAAY;IAE3B,CAAC,EAAE,MAAM,CAAC;IAEV,CAAC,EAAE,MAAM,CAAC;IAEV,CAAC,EAAE,MAAM,CAAC;CACX;AAGD,MAAM,WAAW,mBAAmB;IAElC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC;IAE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ports.verifyPasswordPhc = verifyPasswordPhc;
6
- const argon2_js_1 = require("@noble/hashes/argon2.js");
6
+ const kdf_backend_1 = require("../accel/kdf-backend");
7
7
  const utils_js_1 = require("@noble/ciphers/utils.js");
8
8
  const utils_1 = require("../utils");
9
9
  const cost_limits_1 = require("./cost-limits");
10
- const HEX_RE = /^[0-9a-fA-F]*$/;
10
+ const errors_1 = require("../errors");
11
+ const encoding_1 = require("../encoding");
11
12
  function toBytes(input, encoding = "utf8") {
12
13
  if (input instanceof Uint8Array)
13
14
  return input;
14
15
  if (encoding === "hex") {
15
- if (!HEX_RE.test(input)) {
16
- throw new Error("Invalid hex string");
16
+ if (!(0, encoding_1.isHex)(input)) {
17
+ throw new errors_1.CryptoError("Invalid hex string", errors_1.CryptoErrorCode.INVALID_HEX);
17
18
  }
18
- return Buffer.from(input, "hex");
19
+ return (0, encoding_1.decodeHex)(input);
19
20
  }
20
- return Buffer.from(input, "utf8");
21
+ return (0, encoding_1.utf8)(input);
21
22
  }
22
23
  function getArgon2Fn(variant) {
23
24
  switch (variant) {
24
25
  case "argon2id":
25
- return argon2_js_1.argon2id;
26
+ return kdf_backend_1.argon2id;
26
27
  case "argon2i":
27
- return argon2_js_1.argon2i;
28
+ return kdf_backend_1.argon2i;
28
29
  case "argon2d":
29
- return argon2_js_1.argon2d;
30
+ return kdf_backend_1.argon2d;
30
31
  default:
31
- throw new Error(`Unsupported Argon2 variant: ${variant}. Supported: argon2id, argon2i, argon2d`);
32
+ throw new errors_1.CryptoError(`Unsupported Argon2 variant: ${variant}. Supported: argon2id, argon2i, argon2d`, errors_1.CryptoErrorCode.UNSUPPORTED_ALGORITHM);
32
33
  }
33
34
  }
34
35
  function toPhcString(variant, params, salt, hash) {
35
- let saltB64 = Buffer.from(salt).toString("base64");
36
+ let saltB64 = (0, encoding_1.toBase64)(salt);
36
37
  while (saltB64.endsWith("="))
37
38
  saltB64 = saltB64.slice(0, -1);
38
- let hashB64 = Buffer.from(hash).toString("base64");
39
+ let hashB64 = (0, encoding_1.toBase64)(hash);
39
40
  while (hashB64.endsWith("="))
40
41
  hashB64 = hashB64.slice(0, -1);
41
42
  return `$${variant}$v=19$m=${params.m},t=${params.t},p=${params.p}$${saltB64}$${hashB64}`;
@@ -43,11 +44,11 @@ function toPhcString(variant, params, salt, hash) {
43
44
  function parsePhcString(phc) {
44
45
  const parts = phc.split("$").filter(Boolean);
45
46
  if (parts.length < 5) {
46
- throw new Error("Invalid PHC string format");
47
+ throw new errors_1.CryptoError("Invalid PHC string format", errors_1.CryptoErrorCode.INVALID_INPUT);
47
48
  }
48
49
  const variant = parts[0];
49
50
  if (!["argon2id", "argon2i", "argon2d"].includes(variant)) {
50
- throw new Error(`Unsupported variant in PHC string: ${variant}`);
51
+ throw new errors_1.CryptoError(`Unsupported variant in PHC string: ${variant}`, errors_1.CryptoErrorCode.INVALID_INPUT);
51
52
  }
52
53
  const paramStr = parts[2];
53
54
  const paramParts = paramStr.split(",");
@@ -61,8 +62,8 @@ function parsePhcString(phc) {
61
62
  t: paramMap["t"],
62
63
  p: paramMap["p"],
63
64
  };
64
- const salt = Buffer.from(parts[3], "base64");
65
- const hash = Buffer.from(parts[4], "base64");
65
+ const salt = (0, encoding_1.fromBase64)(parts[3]);
66
+ const hash = (0, encoding_1.fromBase64)(parts[4]);
66
67
  return { variant, params, salt, hash };
67
68
  }
68
69
  const DEFAULT_TIME_COST = 3;
@@ -85,8 +86,8 @@ function hashPassword(options) {
85
86
  const hash = argon2Fn(password, salt, { t, m, p, dkLen });
86
87
  const params = { t, m, p };
87
88
  return {
88
- hash: Buffer.from(hash).toString("hex"),
89
- salt: Buffer.from(salt).toString("hex"),
89
+ hash: (0, encoding_1.toHex)(hash),
90
+ salt: (0, encoding_1.toHex)(salt),
90
91
  params,
91
92
  algorithm: variant,
92
93
  phc: toPhcString(variant, params, salt, hash),
@@ -1 +1 @@
1
- {"version":3,"file":"pq-hash-sign.d.ts","sourceRoot":"","sources":["../../src/modern/pq-hash-sign.ts"],"names":[],"mappings":"AAqCA,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,CAAC;AAGjB,MAAM,WAAW,mBAAmB;IAElC,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,gBAAgB;IAE/B,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,kBAAkB;IAEjC,KAAK,EAAE,OAAO,CAAC;IAEf,SAAS,EAAE,MAAM,CAAC;CACnB;AA0DD,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,mBAAmB,CAQxE;AAKD,wBAAgB,UAAU,CACxB,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GAAG,UAAU,GAC3B,gBAAgB,CASlB;AAKD,wBAAgB,YAAY,CAC1B,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,YAAY,EAAE,MAAM,GACnB,kBAAkB,CAUpB"}
1
+ {"version":3,"file":"pq-hash-sign.d.ts","sourceRoot":"","sources":["../../src/modern/pq-hash-sign.ts"],"names":[],"mappings":"AAuCA,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,CAAC;AAGjB,MAAM,WAAW,mBAAmB;IAElC,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,gBAAgB;IAE/B,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,kBAAkB;IAEjC,KAAK,EAAE,OAAO,CAAC;IAEf,SAAS,EAAE,MAAM,CAAC;CACnB;AA2DD,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,mBAAmB,CAQxE;AAKD,wBAAgB,UAAU,CACxB,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GAAG,UAAU,GAC3B,gBAAgB,CASlB;AAKD,wBAAgB,YAAY,CAC1B,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,YAAY,EAAE,MAAM,GACnB,kBAAkB,CAUpB"}
@@ -3,37 +3,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.slhDsaKeygen = slhDsaKeygen;
4
4
  exports.slhDsaSign = slhDsaSign;
5
5
  exports.slhDsaVerify = slhDsaVerify;
6
- const slh_dsa_js_1 = require("@noble/post-quantum/slh-dsa.js");
7
- const HEX_RE = /^[0-9a-fA-F]*$/;
6
+ const pq_backend_1 = require("../accel/pq-backend");
7
+ const errors_1 = require("../errors");
8
+ const encoding_1 = require("../encoding");
8
9
  function assertHex(input, label) {
9
- if (!HEX_RE.test(input)) {
10
- throw new Error(`Invalid hex string for ${label}`);
10
+ if (!(0, encoding_1.isHex)(input)) {
11
+ throw new errors_1.CryptoError(`Invalid hex string for ${label}`, errors_1.CryptoErrorCode.INVALID_HEX);
11
12
  }
12
- return Buffer.from(input, "hex");
13
+ return (0, encoding_1.decodeHex)(input);
13
14
  }
14
15
  function toBytes(input) {
15
16
  if (input instanceof Uint8Array)
16
17
  return input;
17
- return Buffer.from(input, "utf8");
18
+ return (0, encoding_1.utf8)(input);
18
19
  }
19
20
  const SLH_DSA_VARIANTS = {
20
- "sha2-128f": slh_dsa_js_1.slh_dsa_sha2_128f,
21
- "sha2-128s": slh_dsa_js_1.slh_dsa_sha2_128s,
22
- "sha2-192f": slh_dsa_js_1.slh_dsa_sha2_192f,
23
- "sha2-192s": slh_dsa_js_1.slh_dsa_sha2_192s,
24
- "sha2-256f": slh_dsa_js_1.slh_dsa_sha2_256f,
25
- "sha2-256s": slh_dsa_js_1.slh_dsa_sha2_256s,
26
- "shake-128f": slh_dsa_js_1.slh_dsa_shake_128f,
27
- "shake-128s": slh_dsa_js_1.slh_dsa_shake_128s,
28
- "shake-192f": slh_dsa_js_1.slh_dsa_shake_192f,
29
- "shake-192s": slh_dsa_js_1.slh_dsa_shake_192s,
30
- "shake-256f": slh_dsa_js_1.slh_dsa_shake_256f,
31
- "shake-256s": slh_dsa_js_1.slh_dsa_shake_256s,
21
+ "sha2-128f": pq_backend_1.slh_dsa_sha2_128f,
22
+ "sha2-128s": pq_backend_1.slh_dsa_sha2_128s,
23
+ "sha2-192f": pq_backend_1.slh_dsa_sha2_192f,
24
+ "sha2-192s": pq_backend_1.slh_dsa_sha2_192s,
25
+ "sha2-256f": pq_backend_1.slh_dsa_sha2_256f,
26
+ "sha2-256s": pq_backend_1.slh_dsa_sha2_256s,
27
+ "shake-128f": pq_backend_1.slh_dsa_shake_128f,
28
+ "shake-128s": pq_backend_1.slh_dsa_shake_128s,
29
+ "shake-192f": pq_backend_1.slh_dsa_shake_192f,
30
+ "shake-192s": pq_backend_1.slh_dsa_shake_192s,
31
+ "shake-256f": pq_backend_1.slh_dsa_shake_256f,
32
+ "shake-256s": pq_backend_1.slh_dsa_shake_256s,
32
33
  };
33
34
  function getVariant(variant) {
34
35
  const impl = SLH_DSA_VARIANTS[variant];
35
36
  if (!impl) {
36
- throw new Error(`Unsupported SLH-DSA variant: ${variant}. Supported: ${Object.keys(SLH_DSA_VARIANTS).join(", ")}`);
37
+ throw new errors_1.CryptoError(`Unsupported SLH-DSA variant: ${variant}. Supported: ${Object.keys(SLH_DSA_VARIANTS).join(", ")}`, errors_1.CryptoErrorCode.UNSUPPORTED_ALGORITHM);
37
38
  }
38
39
  return impl;
39
40
  }
@@ -44,8 +45,8 @@ function slhDsaKeygen(variant) {
44
45
  const dsa = getVariant(variant);
45
46
  const { publicKey, secretKey } = dsa.keygen();
46
47
  return {
47
- publicKey: Buffer.from(publicKey).toString("hex"),
48
- secretKey: Buffer.from(secretKey).toString("hex"),
48
+ publicKey: (0, encoding_1.toHex)(publicKey),
49
+ secretKey: (0, encoding_1.toHex)(secretKey),
49
50
  algorithm: algorithmName(variant),
50
51
  };
51
52
  }
@@ -55,7 +56,7 @@ function slhDsaSign(variant, secretKeyHex, message) {
55
56
  const msg = toBytes(message);
56
57
  const signature = dsa.sign(msg, secretKey);
57
58
  return {
58
- signature: Buffer.from(signature).toString("hex"),
59
+ signature: (0, encoding_1.toHex)(signature),
59
60
  algorithm: algorithmName(variant),
60
61
  };
61
62
  }
@@ -41,7 +41,15 @@ export interface HybridKemDecapsulateResult {
41
41
  }
42
42
  export declare function mlKemKeygen(level: MlKemLevel): MlKemKeyPairResult;
43
43
  export declare function mlKemEncapsulate(level: MlKemLevel, publicKeyHex: string): MlKemEncapsulateResult;
44
+ export declare function mlKemEncapsulate(publicKeyHex: string): MlKemEncapsulateResult;
44
45
  export declare function mlKemDecapsulate(level: MlKemLevel, secretKeyHex: string, ciphertextHex: string): MlKemDecapsulateResult;
46
+ export declare function mlKemDecapsulate(secretKeyHex: string, ciphertextHex: string): MlKemDecapsulateResult;
47
+ export declare const mlKemGenerateKeyPair: () => MlKemKeyPairResult;
48
+ export declare const mlKemEncap: (level: MlKemLevel, publicKeyHex: string) => MlKemEncapsulateResult;
49
+ export declare const mlKemDecap: (level: MlKemLevel, secretKeyHex: string, ciphertextHex: string) => MlKemDecapsulateResult;
50
+ export type MlKemKeyPair = MlKemKeyPairResult;
51
+ export type MlKemEncapResult = MlKemEncapsulateResult;
52
+ export type MlKemDecapResult = MlKemDecapsulateResult;
45
53
  export declare function hybridKemKeygen(kemLevel?: MlKemLevel): HybridKemKeyPair;
46
54
  export declare function hybridKemEncapsulate(kemLevel: MlKemLevel, theirX25519Public: string, theirMlKemPublic: string): HybridKemEncapsulateResult;
47
55
  export declare function hybridKemDecapsulate(kemLevel: MlKemLevel, ourX25519Private: string, ourMlKemSecret: string, theirX25519Ephemeral: string, mlKemCiphertext: string): HybridKemDecapsulateResult;
@@ -1 +1 @@
1
- {"version":3,"file":"pq-kem.d.ts","sourceRoot":"","sources":["../../src/modern/pq-kem.ts"],"names":[],"mappings":"AAmDA,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;AAG1C,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,YAAY,GAAG,aAAa,CAAC;AAMzE,eAAO,MAAM,wBAAwB,EAAG,gBAAyB,CAAC;AAMlE,eAAO,MAAM,2BAA2B,EAAG,mBAA4B,CAAC;AAGxE,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAGX,MAAM,MAAM,kBAAkB,GAC1B,mBAAmB,GACnB,mBAAmB,GACnB,oBAAoB,GACpB,iBAAiB,GACjB,kBAAkB,CAAC;AASvB,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,kBAAkB,GAAG,MAAM,GAChC,MAAM,CAWR;AAGD,MAAM,WAAW,kBAAkB;IAEjC,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,cAAc,CAAC;CAC3B;AAGD,MAAM,WAAW,sBAAsB;IAErC,UAAU,EAAE,MAAM,CAAC;IAEnB,YAAY,EAAE,MAAM,CAAC;IAErB,SAAS,EAAE,cAAc,CAAC;CAC3B;AAGD,MAAM,WAAW,sBAAsB;IAErC,YAAY,EAAE,MAAM,CAAC;IAErB,SAAS,EAAE,cAAc,CAAC;CAC3B;AAGD,MAAM,WAAW,gBAAgB;IAE/B,gBAAgB,EAAE,MAAM,CAAC;IAEzB,eAAe,EAAE,MAAM,CAAC;IAExB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