@reallyme/crypto 0.2.0 → 0.3.1

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 (46) hide show
  1. package/README.md +107 -17
  2. package/dist/aead.js +15 -8
  3. package/dist/aesKw.d.ts +7 -4
  4. package/dist/aesKw.js +69 -22
  5. package/dist/algorithms.d.ts +12 -4
  6. package/dist/algorithms.js +8 -2
  7. package/dist/argon2id.d.ts +1 -0
  8. package/dist/argon2id.js +13 -4
  9. package/dist/cryptoFacade.d.ts +33 -8
  10. package/dist/cryptoFacade.js +42 -29
  11. package/dist/hkdf.d.ts +1 -0
  12. package/dist/hkdf.js +5 -1
  13. package/dist/hmac.d.ts +3 -0
  14. package/dist/hmac.js +24 -3
  15. package/dist/hpke.d.ts +1 -2
  16. package/dist/hpke.js +33 -22
  17. package/dist/index.d.ts +9 -7
  18. package/dist/index.js +8 -6
  19. package/dist/jwk.d.ts +2 -1
  20. package/dist/jwk.js +104 -63
  21. package/dist/kmac.d.ts +11 -0
  22. package/dist/kmac.js +49 -0
  23. package/dist/mlDsa.js +22 -11
  24. package/dist/mlKem.d.ts +0 -3
  25. package/dist/mlKem.js +19 -37
  26. package/dist/operationResponse.d.ts +16 -0
  27. package/dist/operationResponse.js +46 -0
  28. package/dist/pbkdf2.d.ts +6 -8
  29. package/dist/pbkdf2.js +12 -12
  30. package/dist/proto/generated/reallyme/crypto/v1/crypto_pb.d.ts +1741 -328
  31. package/dist/proto/generated/reallyme/crypto/v1/crypto_pb.js +731 -344
  32. package/dist/proto.d.ts +6 -22
  33. package/dist/proto.js +124 -102
  34. package/dist/rsa.d.ts +2 -1
  35. package/dist/rsa.js +5 -1
  36. package/dist/slhDsa.js +21 -11
  37. package/dist/validateBytes.d.ts +6 -1
  38. package/dist/validateBytes.js +57 -3
  39. package/dist/wasm/reallyme_crypto_wasm.js +91 -134
  40. package/dist/wasm/reallyme_crypto_wasm_bg.wasm +0 -0
  41. package/dist/wasmModuleTypes.d.ts +7 -10
  42. package/dist/wasmProvider.d.ts +11 -13
  43. package/dist/wasmProvider.js +16 -19
  44. package/dist/xWing.d.ts +0 -5
  45. package/dist/xWing.js +20 -52
  46. package/package.json +15 -2
package/dist/pbkdf2.js CHANGED
@@ -6,27 +6,27 @@ import { sha256, sha512 } from "@noble/hashes/sha2.js";
6
6
  import { ReallyMeCryptoError } from "./errors.js";
7
7
  export const PBKDF2_MIN_INPUT_LENGTH = 1;
8
8
  export const PBKDF2_MAX_INPUT_LENGTH = 4096;
9
- // The primitive accepts any count >= 1 so it can verify PBKDF2 hashes created
10
- // elsewhere at their stored iteration count (a required interop use), matching
11
- // the Rust lane. It is NOT a security floor; see the recommended minimums
12
- // below for deriving *new* password keys.
13
- export const PBKDF2_MIN_ITERATIONS = 1;
9
+ // Public derivation routes enforce a modern baseline. Historical hashes with a
10
+ // lower work factor require an explicit migration tool, not a silent downgrade
11
+ // in the v0.3 API.
12
+ export const PBKDF2_MIN_ITERATIONS = 100_000;
13
+ // Bound hostile work-factor inputs before the provider begins CPU-expensive
14
+ // derivation. This matches the Rust, Swift, and Kotlin public lanes.
15
+ export const PBKDF2_MAX_ITERATIONS = 10_000_000;
14
16
  export const PBKDF2_MIN_OUTPUT_LENGTH = 1;
15
17
  export const PBKDF2_MAX_OUTPUT_LENGTH = 4096;
16
18
  /**
17
19
  * OWASP Password Storage Cheat Sheet minimum iteration counts for deriving a
18
20
  * *new* password key.
19
- * The primitive does not enforce these (it must remain able to verify
20
- * externally created hashes), so callers creating new key material SHOULD
21
- * pass at least the value for their PRF.
21
+ * These stronger profile recommendations remain above the enforced public
22
+ * baseline and should be selected when protocol latency budgets permit.
22
23
  */
23
24
  export const PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA256 = 600_000;
24
25
  export const PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA512 = 220_000;
25
26
  export const ReallyMePbkdf2 = {
26
27
  /**
27
28
  * PBKDF2-HMAC-SHA-256. For a new password key pass at least
28
- * {@link PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA256} iterations; lower counts
29
- * are accepted only to verify hashes created elsewhere.
29
+ * {@link PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA256} iterations.
30
30
  */
31
31
  deriveHmacSha256(password, salt, iterations, outputLength) {
32
32
  validate(password, salt, iterations, outputLength);
@@ -34,8 +34,7 @@ export const ReallyMePbkdf2 = {
34
34
  },
35
35
  /**
36
36
  * PBKDF2-HMAC-SHA-512. For a new password key pass at least
37
- * {@link PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA512} iterations; lower counts
38
- * are accepted only to verify hashes created elsewhere.
37
+ * {@link PBKDF2_RECOMMENDED_MIN_ITERATIONS_SHA512} iterations.
39
38
  */
40
39
  deriveHmacSha512(password, salt, iterations, outputLength) {
41
40
  validate(password, salt, iterations, outputLength);
@@ -49,6 +48,7 @@ function validate(password, salt, iterations, outputLength) {
49
48
  salt.length > PBKDF2_MAX_INPUT_LENGTH ||
50
49
  !Number.isInteger(iterations) ||
51
50
  iterations < PBKDF2_MIN_ITERATIONS ||
51
+ iterations > PBKDF2_MAX_ITERATIONS ||
52
52
  !Number.isInteger(outputLength) ||
53
53
  outputLength < PBKDF2_MIN_OUTPUT_LENGTH ||
54
54
  outputLength > PBKDF2_MAX_OUTPUT_LENGTH) {