@ac-kit/crypto-rsa 0.0.0-stage → 0.1.0

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 (76) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/LICENSE +28 -0
  3. package/README.md +113 -2
  4. package/dist/_bytes.d.ts +18 -0
  5. package/dist/_bytes.d.ts.map +1 -0
  6. package/dist/_bytes.js +42 -0
  7. package/dist/_bytes.js.map +1 -0
  8. package/dist/encoding/_der.d.ts +51 -0
  9. package/dist/encoding/_der.d.ts.map +1 -0
  10. package/dist/encoding/_der.js +173 -0
  11. package/dist/encoding/_der.js.map +1 -0
  12. package/dist/encoding/rsa-algorithm.d.ts +132 -0
  13. package/dist/encoding/rsa-algorithm.d.ts.map +1 -0
  14. package/dist/encoding/rsa-algorithm.js +475 -0
  15. package/dist/encoding/rsa-algorithm.js.map +1 -0
  16. package/dist/hash/rsa-hash.d.ts +68 -0
  17. package/dist/hash/rsa-hash.d.ts.map +1 -0
  18. package/dist/hash/rsa-hash.js +86 -0
  19. package/dist/hash/rsa-hash.js.map +1 -0
  20. package/dist/index.d.ts +9 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +9 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/key/_generate.d.ts +39 -0
  25. package/dist/key/_generate.d.ts.map +1 -0
  26. package/dist/key/_generate.js +124 -0
  27. package/dist/key/_generate.js.map +1 -0
  28. package/dist/key/_key-state.d.ts +53 -0
  29. package/dist/key/_key-state.d.ts.map +1 -0
  30. package/dist/key/_key-state.js +26 -0
  31. package/dist/key/_key-state.js.map +1 -0
  32. package/dist/key/_primality.d.ts +22 -0
  33. package/dist/key/_primality.d.ts.map +1 -0
  34. package/dist/key/_primality.js +156 -0
  35. package/dist/key/_primality.js.map +1 -0
  36. package/dist/key/_primitives.d.ts +27 -0
  37. package/dist/key/_primitives.d.ts.map +1 -0
  38. package/dist/key/_primitives.js +247 -0
  39. package/dist/key/_primitives.js.map +1 -0
  40. package/dist/key/_validate.d.ts +60 -0
  41. package/dist/key/_validate.d.ts.map +1 -0
  42. package/dist/key/_validate.js +328 -0
  43. package/dist/key/_validate.js.map +1 -0
  44. package/dist/key/rsa-private-key.d.ts +180 -0
  45. package/dist/key/rsa-private-key.d.ts.map +1 -0
  46. package/dist/key/rsa-private-key.js +479 -0
  47. package/dist/key/rsa-private-key.js.map +1 -0
  48. package/dist/key/rsa-public-key.d.ts +117 -0
  49. package/dist/key/rsa-public-key.d.ts.map +1 -0
  50. package/dist/key/rsa-public-key.js +196 -0
  51. package/dist/key/rsa-public-key.js.map +1 -0
  52. package/dist/rsa-error.d.ts +54 -0
  53. package/dist/rsa-error.d.ts.map +1 -0
  54. package/dist/rsa-error.js +14 -0
  55. package/dist/rsa-error.js.map +1 -0
  56. package/dist/scheme/_scheme-checks.d.ts +50 -0
  57. package/dist/scheme/_scheme-checks.d.ts.map +1 -0
  58. package/dist/scheme/_scheme-checks.js +162 -0
  59. package/dist/scheme/_scheme-checks.js.map +1 -0
  60. package/dist/scheme/_signature.d.ts +8 -0
  61. package/dist/scheme/_signature.d.ts.map +1 -0
  62. package/dist/scheme/_signature.js +13 -0
  63. package/dist/scheme/_signature.js.map +1 -0
  64. package/dist/scheme/rsaes-oaep.d.ts +75 -0
  65. package/dist/scheme/rsaes-oaep.d.ts.map +1 -0
  66. package/dist/scheme/rsaes-oaep.js +191 -0
  67. package/dist/scheme/rsaes-oaep.js.map +1 -0
  68. package/dist/scheme/rsassa-pkcs1-v1_5.d.ts +73 -0
  69. package/dist/scheme/rsassa-pkcs1-v1_5.d.ts.map +1 -0
  70. package/dist/scheme/rsassa-pkcs1-v1_5.js +133 -0
  71. package/dist/scheme/rsassa-pkcs1-v1_5.js.map +1 -0
  72. package/dist/scheme/rsassa-pss.d.ts +88 -0
  73. package/dist/scheme/rsassa-pss.d.ts.map +1 -0
  74. package/dist/scheme/rsassa-pss.js +175 -0
  75. package/dist/scheme/rsassa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vD,KAAK,IAAI,KAAK,GAAG,MAAM,EAAE,KAAK,GAAG,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC;QAC/C,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAE,GAAG,IAAI,CAAC,KAAK,GAAG,MAAM,CAAE,CAAC;IAClD,CAAC;AACF,CAAC"}
@@ -0,0 +1,9 @@
1
+ export { decodeRsaKeyAlgorithm, decodeRsaOaepAlgorithm, decodeRsaSignatureAlgorithm, encodeRsaKeyAlgorithm, encodeRsaOaepAlgorithm, encodeRsaSignatureAlgorithm, maskGenerationEqual, pssParametersEqual, type RsaKeyAlgorithm, type RsaOaepParameters, type RsaPssParameters, type RsaSignatureAlgorithm, } from "./encoding/rsa-algorithm.js";
2
+ export { defaultMaskGeneration, mgf1, RSA_HASHES, type RsaHash, type RsaHashInput, type RsaHashName, type RsaMaskGeneration, } from "./hash/rsa-hash.js";
3
+ export { type RsaAsyncKeyGenerationOptions, type RsaCrtComponents, type RsaKeyGenerationOptions, type RsaOtherPrimeComponents, RsaPrivateKey, type RsaPrivateKeyComponents, type RsaPrivateKeyImportOptions, type RsaPrivateKeyOptions, type RsaPrimesInput, } from "./key/rsa-private-key.js";
4
+ export { RSA_ENCRYPTION_ALGORITHM, RSA_MAXIMUM_MODULUS_BITS, RSA_MINIMUM_MODULUS_BITS, type RsaKeyOptions, RsaPublicKey, type RsaPublicKeyComponents, } from "./key/rsa-public-key.js";
5
+ export { RsaError, type RsaErrorReason } from "./rsa-error.js";
6
+ export { type RsaesOaepCallOptions, type RsaesOaepEncryptOptions, rsaesOaep, type RsaesOaepOptions, RsaesOaepScheme, } from "./scheme/rsaes-oaep.js";
7
+ export { rsassaPkcs1V15, RsassaPkcs1V15Scheme, } from "./scheme/rsassa-pkcs1-v1_5.js";
8
+ export { rsassaPss, type RsassaPssOptions, RsassaPssScheme, type RsassaPssSignOptions, } from "./scheme/rsassa-pss.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,GAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,qBAAqB,EACrB,IAAI,EACJ,UAAU,EACV,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,iBAAiB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,KAAK,4BAA4B,EACjC,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,aAAa,EACb,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,cAAc,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,aAAa,EAClB,YAAY,EACZ,KAAK,sBAAsB,GAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,SAAS,EACT,KAAK,gBAAgB,EACrB,eAAe,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,cAAc,EACd,oBAAoB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,SAAS,EACT,KAAK,gBAAgB,EACrB,eAAe,EACf,KAAK,oBAAoB,GACzB,MAAM,wBAAwB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { decodeRsaKeyAlgorithm, decodeRsaOaepAlgorithm, decodeRsaSignatureAlgorithm, encodeRsaKeyAlgorithm, encodeRsaOaepAlgorithm, encodeRsaSignatureAlgorithm, maskGenerationEqual, pssParametersEqual, } from "./encoding/rsa-algorithm.js";
2
+ export { defaultMaskGeneration, mgf1, RSA_HASHES, } from "./hash/rsa-hash.js";
3
+ export { RsaPrivateKey, } from "./key/rsa-private-key.js";
4
+ export { RSA_ENCRYPTION_ALGORITHM, RSA_MAXIMUM_MODULUS_BITS, RSA_MINIMUM_MODULUS_BITS, RsaPublicKey, } from "./key/rsa-public-key.js";
5
+ export { RsaError } from "./rsa-error.js";
6
+ export { rsaesOaep, RsaesOaepScheme, } from "./scheme/rsaes-oaep.js";
7
+ export { rsassaPkcs1V15, RsassaPkcs1V15Scheme, } from "./scheme/rsassa-pkcs1-v1_5.js";
8
+ export { rsassaPss, RsassaPssScheme, } from "./scheme/rsassa-pss.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,kBAAkB,GAKlB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,qBAAqB,EACrB,IAAI,EACJ,UAAU,GAKV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAKN,aAAa,GAKb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EAExB,YAAY,GAEZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAuB,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAGN,SAAS,EAET,eAAe,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,cAAc,EACd,oBAAoB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,SAAS,EAET,eAAe,GAEf,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The Miller–Rabin rounds of FIPS 186-5 Table B.1 for p and q, at the error
3
+ * probability that matches each modulus size's security strength (2⁻¹¹², 2⁻¹²⁸,
4
+ * 2⁻¹⁴⁴): 5 below 3072-bit moduli, 4 from there on.
5
+ */
6
+ export declare function millerRabinRoundsFor(modulusBits: number): number;
7
+ /**
8
+ * ⌈√2 · 2^(bits − 1)⌉ over ⌈bits / 8⌉ bytes: the smallest prime FIPS 186-5
9
+ * A.1.1 2(b) admits. Public; cached by size, never to be written.
10
+ */
11
+ export declare function primeLowerBound(bits: number): Uint8Array<ArrayBuffer>;
12
+ /** Why FIPS 186-5 A.1.3 discards a candidate, or `"accepted"`. */
13
+ export type CandidateVerdict = "accepted"
14
+ /** Step 4.4 or 5.4: below ⌈√2 · 2^(nlen/2 − 1)⌉. */
15
+ | "tooSmall"
16
+ /** Step 5.5: |p − q| ≤ 2^(nlen/2 − 100). */
17
+ | "tooClose"
18
+ /** Step 4.5 or 5.6: GCD(candidate − 1, e) ≠ 1. */
19
+ | "notCoprime"
20
+ /** Step 4.5.1 or 5.6.1: composite. */
21
+ | "composite";
22
+ /**
23
+ * Steps 4.3 to 4.5 (p) or 5.3 to 5.6 (q, with `other` = p) of FIPS 186-5 A.1.3
24
+ * for the random `bits`-bit string `candidate`, made odd here as step 4.3 says.
25
+ * On acceptance `inverse` holds e⁻¹ mod (candidate − 1), the CRT exponent.
26
+ * Constant time in an accepted candidate.
27
+ */
28
+ export declare function checkPrimeCandidate(candidate: Uint8Array, publicExponent: Uint8Array, bits: number, rounds: number, other: Uint8Array | undefined, inverse: Uint8Array): CandidateVerdict;
29
+ /**
30
+ * A prime of `bits` bits by FIPS 186-5 A.1.3 step 4 (p) or 5 (q, `other` = p),
31
+ * one candidate a step. Only candidates that reach the coprimality test count
32
+ * towards the bound i, as in the standard: a candidate refused at step 4.4, 5.4
33
+ * or 5.5 is redrawn at once.
34
+ *
35
+ * @throws {RsaError} `keyGenerationFailed` after 5·nlen (p) or 10·nlen (q)
36
+ * counted candidates (steps 4.7 and 5.8).
37
+ */
38
+ export declare function generatePrimeSteps(bits: number, publicExponent: Uint8Array, other: Uint8Array | undefined): Generator<undefined, Uint8Array<ArrayBuffer>, undefined>;
39
+ //# sourceMappingURL=_generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_generate.d.ts","sourceRoot":"","sources":["../../src/key/_generate.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEhE;AAID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CA8BrE;AAED,kEAAkE;AAClE,MAAM,MAAM,gBAAgB,GACzB,UAAU;AACZ,oDAAoD;GAClD,UAAU;AACZ,4CAA4C;GAC1C,UAAU;AACZ,kDAAkD;GAChD,YAAY;AACd,sCAAsC;GACpC,WAAW,CAAC;AAEf;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,UAAU,EACrB,cAAc,EAAE,UAAU,EAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,UAAU,GAAG,SAAS,EAC7B,OAAO,EAAE,UAAU,GACjB,gBAAgB,CAgClB;AAED;;;;;;;;GAQG;AACH,wBAAiB,kBAAkB,CAClC,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,UAAU,EAC1B,KAAK,EAAE,UAAU,GAAG,SAAS,GAC3B,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,CAyC1D"}
@@ -0,0 +1,124 @@
1
+ import { getRandomBytes } from "@ac-kit/crypto-random";
2
+ import { constantTimeUnsignedCompare, constantTimeUnsignedModInverse, constantTimeUnsignedSubtract, } from "@ac-kit/crypto-safe";
3
+ import { bytesOfUnsigned } from "../_bytes.js";
4
+ import { RsaError } from "../rsa-error.js";
5
+ import { passesMillerRabin, passesTrialDivision } from "./_primality.js";
6
+ /**
7
+ * The Miller–Rabin rounds of FIPS 186-5 Table B.1 for p and q, at the error
8
+ * probability that matches each modulus size's security strength (2⁻¹¹², 2⁻¹²⁸,
9
+ * 2⁻¹⁴⁴): 5 below 3072-bit moduli, 4 from there on.
10
+ */
11
+ export function millerRabinRoundsFor(modulusBits) {
12
+ return modulusBits < 3072 ? 5 : 4;
13
+ }
14
+ const LOWER_BOUNDS_ = new Map();
15
+ /**
16
+ * ⌈√2 · 2^(bits − 1)⌉ over ⌈bits / 8⌉ bytes: the smallest prime FIPS 186-5
17
+ * A.1.1 2(b) admits. Public; cached by size, never to be written.
18
+ */
19
+ export function primeLowerBound(bits) {
20
+ const cached = LOWER_BOUNDS_.get(bits);
21
+ if (cached !== undefined) {
22
+ return cached;
23
+ }
24
+ // √(2^(2·bits − 1)), rounded up.
25
+ const square = 1n << BigInt(2 * bits - 1);
26
+ let root = 1n << BigInt(bits);
27
+ for (;;) {
28
+ const next = (root + square / root) >> 1n;
29
+ if (next >= root) {
30
+ break;
31
+ }
32
+ root = next;
33
+ }
34
+ if (root * root < square) {
35
+ root++;
36
+ }
37
+ const bound = bytesOfUnsigned(root, Math.ceil(bits / 8));
38
+ LOWER_BOUNDS_.set(bits, bound);
39
+ return bound;
40
+ }
41
+ /**
42
+ * Steps 4.3 to 4.5 (p) or 5.3 to 5.6 (q, with `other` = p) of FIPS 186-5 A.1.3
43
+ * for the random `bits`-bit string `candidate`, made odd here as step 4.3 says.
44
+ * On acceptance `inverse` holds e⁻¹ mod (candidate − 1), the CRT exponent.
45
+ * Constant time in an accepted candidate.
46
+ */
47
+ export function checkPrimeCandidate(candidate, publicExponent, bits, rounds, other, inverse) {
48
+ const length = candidate.length;
49
+ candidate[length - 1] = candidate[length - 1] | 1;
50
+ if (constantTimeUnsignedCompare(candidate, primeLowerBound(bits)) < 0) {
51
+ return "tooSmall";
52
+ }
53
+ if (other !== undefined && !farEnough_(candidate, other, bits)) {
54
+ return "tooClose";
55
+ }
56
+ if (passesTrialDivision(candidate) === 0) {
57
+ return "composite";
58
+ }
59
+ const minusOne = candidate.slice();
60
+ try {
61
+ minusOne[length - 1] = minusOne[length - 1] & 0xfe;
62
+ if (constantTimeUnsignedModInverse(inverse, publicExponent, minusOne) === 0) {
63
+ return "notCoprime";
64
+ }
65
+ }
66
+ finally {
67
+ minusOne.fill(0);
68
+ }
69
+ return passesMillerRabin(candidate, rounds) === 1 ? "accepted" : "composite";
70
+ }
71
+ /**
72
+ * A prime of `bits` bits by FIPS 186-5 A.1.3 step 4 (p) or 5 (q, `other` = p),
73
+ * one candidate a step. Only candidates that reach the coprimality test count
74
+ * towards the bound i, as in the standard: a candidate refused at step 4.4, 5.4
75
+ * or 5.5 is redrawn at once.
76
+ *
77
+ * @throws {RsaError} `keyGenerationFailed` after 5·nlen (p) or 10·nlen (q)
78
+ * counted candidates (steps 4.7 and 5.8).
79
+ */
80
+ export function* generatePrimeSteps(bits, publicExponent, other) {
81
+ const length = Math.ceil(bits / 8);
82
+ const limit = (other === undefined ? 5 : 10) * 2 * bits;
83
+ const rounds = millerRabinRoundsFor(2 * bits);
84
+ const inverse = new Uint8Array(length);
85
+ try {
86
+ for (let counted = 0; counted < limit;) {
87
+ const candidate = getRandomBytes(length);
88
+ candidate[0] = candidate[0] & (0xff >>> (8 * length - bits));
89
+ const verdict = checkPrimeCandidate(candidate, publicExponent, bits, rounds, other, inverse);
90
+ if (verdict === "accepted") {
91
+ return candidate;
92
+ }
93
+ candidate.fill(0);
94
+ if (verdict === "notCoprime" || verdict === "composite") {
95
+ counted++;
96
+ }
97
+ yield;
98
+ }
99
+ }
100
+ finally {
101
+ inverse.fill(0);
102
+ }
103
+ throw new RsaError("keyGenerationFailed", "No RSA prime was found within the FIPS 186-5 iteration bound");
104
+ }
105
+ /** |a − b| > 2^(bits − 100), compared in constant time. */
106
+ function farEnough_(a, b, bits) {
107
+ const difference = new Uint8Array(a.length);
108
+ const reverse = new Uint8Array(a.length);
109
+ try {
110
+ const borrow = constantTimeUnsignedSubtract(difference, a, b);
111
+ constantTimeUnsignedSubtract(reverse, b, a);
112
+ // |a − b|: the forward difference, or the reverse one on a borrow.
113
+ for (let index = 0; index < a.length; index++) {
114
+ const forward = difference[index];
115
+ difference[index] = forward ^ (-borrow & (forward ^ reverse[index]));
116
+ }
117
+ return (constantTimeUnsignedCompare(difference, bytesOfUnsigned(1n << BigInt(bits - 100), a.length)) > 0);
118
+ }
119
+ finally {
120
+ difference.fill(0);
121
+ reverse.fill(0);
122
+ }
123
+ }
124
+ //# sourceMappingURL=_generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_generate.js","sourceRoot":"","sources":["../../src/key/_generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACN,2BAA2B,EAC3B,8BAA8B,EAC9B,4BAA4B,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAmB;IACvD,OAAO,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,aAAa,GAAG,IAAI,GAAG,EAAmC,CAAC;AAEjE;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC3C,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,MAAM,CAA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CAAC,MAAM,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAE,CAAC,CAAC,CAAC;QACvE,CAAC;QAED,OAAO,CACN,2BAA2B,CAC1B,UAAU,EACV,eAAe,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CACnD,GAAG,CAAC,CACL,CAAC;IACH,CAAC;YAAS,CAAC;QACV,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;AACF,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { type ConstantTimeModulus } from "@ac-kit/crypto-safe";
2
+ import type { RsaKeyAlgorithm } from "../encoding/rsa-algorithm.js";
3
+ import type { RsaPrivateKey } from "./rsa-private-key.js";
4
+ import type { RsaPublicKey } from "./rsa-public-key.js";
5
+ /** The fields of a public key, kept out of the instance. */
6
+ export type PublicKeyState = {
7
+ /** N, minimal big-endian: `k` bytes. */
8
+ readonly modulus: Uint8Array;
9
+ readonly modulusBitLength: number;
10
+ /** E, minimal big-endian. */
11
+ readonly publicExponent: Uint8Array;
12
+ /** Arithmetic modulo n. */
13
+ readonly ring: ConstantTimeModulus;
14
+ /** What the key may be used for, from its `AlgorithmIdentifier`. */
15
+ readonly algorithm: RsaKeyAlgorithm;
16
+ };
17
+ /** One prime of a private key in CRT form (RFC 8017 §3.2, second form). */
18
+ export type PrimeState = {
19
+ /** R_i, minimal big-endian. */
20
+ readonly prime: Uint8Array;
21
+ /** R_i − 1, as long as `prime`. */
22
+ readonly primeMinusOne: Uint8Array;
23
+ /** D_i = d mod (r_i − 1), as long as `prime`. */
24
+ readonly exponent: Uint8Array;
25
+ /**
26
+ * The CRT coefficient, as long as `prime`: q⁻¹ mod p for the first prime,
27
+ * empty for the second, t_i = (r_1 ⋯ r_(i−1))⁻¹ mod r_i for the others.
28
+ */
29
+ readonly coefficient: Uint8Array;
30
+ /** R_1 ⋯ r_(i−1) over `k` bytes for the third prime on, else empty. */
31
+ readonly productBefore: Uint8Array;
32
+ /** Arithmetic modulo r_i. */
33
+ readonly ring: ConstantTimeModulus;
34
+ };
35
+ /** The fields of a private key, kept out of the instance. */
36
+ export type PrivateKeyState = {
37
+ readonly publicKey: RsaPublicKey;
38
+ /** D over `k` bytes. */
39
+ readonly privateExponent: Uint8Array;
40
+ /** The primes, or `undefined` for a key of the first form, (n, d) only. */
41
+ readonly primes: readonly PrimeState[] | undefined;
42
+ /** E·d − 1, a multiple of λ(n), for blinding d in the first form; else empty. */
43
+ readonly multipleOfLambda: Uint8Array;
44
+ disposed: boolean;
45
+ };
46
+ export declare function setPublicState(key: RsaPublicKey, state: PublicKeyState): void;
47
+ export declare function setPrivateState(key: RsaPrivateKey, state: PrivateKeyState): void;
48
+ export declare function publicStateOf(key: RsaPublicKey): PublicKeyState;
49
+ /** The state of `key`, disposed or not. */
50
+ export declare function privateStateOf(key: RsaPrivateKey): PrivateKeyState;
51
+ /** @throws {RsaError} `disposed` once the key has been disposed. */
52
+ export declare function livePrivateStateOf(key: RsaPrivateKey): PrivateKeyState;
53
+ //# sourceMappingURL=_key-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_key-state.d.ts","sourceRoot":"","sources":["../../src/key/_key-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAiB,MAAM,qBAAqB,CAAC;AAE9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GAAG;IAC5B,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC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,GAAG,eAAe,CAElE;AAED,oEAAoE;AACpE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,eAAe,CAQtE"}
@@ -0,0 +1,26 @@
1
+ import { secretStateOf } from "@ac-kit/crypto-safe";
2
+ import { RsaError } from "../rsa-error.js";
3
+ const PUBLIC_KEYS_ = new WeakMap();
4
+ const PRIVATE_KEYS_ = new WeakMap();
5
+ export function setPublicState(key, state) {
6
+ PUBLIC_KEYS_.set(key, state);
7
+ }
8
+ export function setPrivateState(key, state) {
9
+ PRIVATE_KEYS_.set(key, state);
10
+ }
11
+ export function publicStateOf(key) {
12
+ return secretStateOf(PUBLIC_KEYS_, key, "This RSA public key");
13
+ }
14
+ /** The state of `key`, disposed or not. */
15
+ export function privateStateOf(key) {
16
+ return secretStateOf(PRIVATE_KEYS_, key, "This RSA private key");
17
+ }
18
+ /** @throws {RsaError} `disposed` once the key has been disposed. */
19
+ export function livePrivateStateOf(key) {
20
+ const state = privateStateOf(key);
21
+ if (state.disposed) {
22
+ throw new RsaError("disposed", "This RSA private key has been disposed");
23
+ }
24
+ return state;
25
+ }
26
+ //# sourceMappingURL=_key-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_key-state.js","sourceRoot":"","sources":["../../src/key/_key-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAG9E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAgD3C,MAAM,YAAY,GAAG,IAAI,OAAO,EAAgC,CAAC;AACjE,MAAM,aAAa,GAAG,IAAI,OAAO,EAAkC,CAAC;AAEpE,MAAM,UAAU,cAAc,CAAC,GAAiB,EAAE,KAAqB;IACtE,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,eAAe,CAC9B,GAAkB,EAClB,KAAsB;IAEtB,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAiB;IAC9C,OAAO,aAAa,CAAC,YAAY,EAAE,GAAG,EAAE,qBAAqB,CAAC,CAAC;AAChE,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,cAAc,CAAC,GAAkB;IAChD,OAAO,aAAa,CAAC,aAAa,EAAE,GAAG,EAAE,sBAAsB,CAAC,CAAC;AAClE,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,kBAAkB,CAAC,GAAkB;IACpD,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IAElC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,wCAAwC,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 1 when no odd prime below 2¹⁴ and below the odd `candidate` divides it, else
3
+ * 0: a small prime is not refused for dividing itself. Each residue is a Horner
4
+ * sum over the candidate's bytes reduced with a floating reciprocal and an
5
+ * arithmetic correction, so no division instruction sees the candidate. Stops
6
+ * at the first divisor found (that candidate is discarded) unless `exhaustive`,
7
+ * which runs every division whatever the candidate, for checks that must not
8
+ * reveal why a value was refused.
9
+ */
10
+ export declare function passesTrialDivision(candidate: Uint8Array, exhaustive?: boolean): number;
11
+ /**
12
+ * 1 when the odd `candidate` (w > 3) passes `rounds` Miller–Rabin rounds with
13
+ * bases drawn uniformly from [2, w − 2] (FIPS 186-5 B.3.1), else 0. Constant
14
+ * time in w: the decomposition w − 1 = 2^a·m is computed with a constant-time
15
+ * count and shift, z = b^m by the fixed-window exponentiation of
16
+ * `ConstantTimeModulus` over `w.length` bytes, and the chain of squarings masks
17
+ * its steps. `candidate` is minimal (its first byte non-zero); the caller
18
+ * ensures w is odd and above 3, for which a base exists. Stops at the first
19
+ * failing round unless `exhaustive`, which runs every round whatever w.
20
+ */
21
+ export declare function passesMillerRabin(candidate: Uint8Array, rounds: number, exhaustive?: boolean): number;
22
+ //# sourceMappingURL=_primality.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_primality.d.ts","sourceRoot":"","sources":["../../src/key/_primality.ts"],"names":[],"mappings":"AAoDA;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,UAAU,EACrB,UAAU,UAAQ,GAChB,MAAM,CA6BR;AAaD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,MAAM,EACd,UAAU,UAAQ,GAChB,MAAM,CAwDR"}
@@ -0,0 +1,156 @@
1
+ import { getRandomBytes } from "@ac-kit/crypto-random";
2
+ import { ConstantTimeModulus, constantTimeUnsignedCompare, constantTimeUnsignedShiftRight, constantTimeUnsignedTrailingZeros, } from "@ac-kit/crypto-safe";
3
+ /**
4
+ * Probable-prime testing for secret candidates (FIPS 186-5 Appendix B.3): trial
5
+ * division by the odd primes below 2¹⁴ (B.3's optional step, its limit between
6
+ * 10³ and 10⁵), then Miller–Rabin rounds with random bases (B.3.1), all
7
+ * constant time in the candidate. A candidate that is accepted always runs
8
+ * every step to its end with the same work, so its timing carries nothing but
9
+ * its length; one that is refused may stop at the first failing step, which
10
+ * reveals only that a discarded value was composite. Key import, which must not
11
+ * reveal why a key was refused, runs both tests exhaustively.
12
+ */
13
+ const TRIAL_DIVISION_LIMIT = 1 << 14;
14
+ /**
15
+ * The Miller–Rabin chain (B.3.1 step 4.5) runs a − 1 squarings, a being the
16
+ * 2-adic valuation of w − 1. It runs at least this many, masking the ones past
17
+ * a − 1, so that its length reveals a only for the 2⁻⁶⁴ of candidates whose a
18
+ * exceeds it.
19
+ */
20
+ const MINIMUM_CHAIN = 64;
21
+ const SMALL_PRIMES_ = sieveOddPrimes_(TRIAL_DIVISION_LIMIT);
22
+ function sieveOddPrimes_(limit) {
23
+ const composite = new Uint8Array(limit);
24
+ const primes = [];
25
+ for (let candidate = 3; candidate < limit; candidate += 2) {
26
+ if (composite[candidate] === 0) {
27
+ primes.push(candidate);
28
+ for (let multiple = candidate * candidate; multiple < limit; multiple += 2 * candidate) {
29
+ composite[multiple] = 1;
30
+ }
31
+ }
32
+ }
33
+ return Float64Array.from(primes);
34
+ }
35
+ /**
36
+ * 1 when no odd prime below 2¹⁴ and below the odd `candidate` divides it, else
37
+ * 0: a small prime is not refused for dividing itself. Each residue is a Horner
38
+ * sum over the candidate's bytes reduced with a floating reciprocal and an
39
+ * arithmetic correction, so no division instruction sees the candidate. Stops
40
+ * at the first divisor found (that candidate is discarded) unless `exhaustive`,
41
+ * which runs every division whatever the candidate, for checks that must not
42
+ * reveal why a value was refused.
43
+ */
44
+ export function passesTrialDivision(candidate, exhaustive = false) {
45
+ // Three bytes or more exceed every divisor; a shorter candidate is compared.
46
+ const small = candidate.length < 3 ? smallValueOf_(candidate) : TRIAL_DIVISION_LIMIT;
47
+ let passes = 1;
48
+ for (const prime of SMALL_PRIMES_) {
49
+ const reciprocal = 1 / prime;
50
+ let residue = 0;
51
+ for (const byte of candidate) {
52
+ // Below 2¹⁴ · 2⁸ + 2⁸: exact, and the quotient estimate is off by one at most.
53
+ const value = residue * 256 + byte;
54
+ let reduced = value - Math.floor(value * reciprocal) * prime;
55
+ reduced += prime & (reduced >> 31);
56
+ reduced -= prime & ~((reduced - prime) >> 31);
57
+ residue = reduced;
58
+ }
59
+ // A zero residue makes the candidate composite only above the divisor.
60
+ passes &= 1 - (((residue - 1) >>> 31) & ((prime - small) >>> 31));
61
+ if (!exhaustive && passes === 0) {
62
+ return 0;
63
+ }
64
+ }
65
+ return passes;
66
+ }
67
+ /** The value of a candidate of at most two bytes, with no branch on them. */
68
+ function smallValueOf_(candidate) {
69
+ let value = 0;
70
+ for (const byte of candidate) {
71
+ value = value * 256 + byte;
72
+ }
73
+ return value;
74
+ }
75
+ /**
76
+ * 1 when the odd `candidate` (w > 3) passes `rounds` Miller–Rabin rounds with
77
+ * bases drawn uniformly from [2, w − 2] (FIPS 186-5 B.3.1), else 0. Constant
78
+ * time in w: the decomposition w − 1 = 2^a·m is computed with a constant-time
79
+ * count and shift, z = b^m by the fixed-window exponentiation of
80
+ * `ConstantTimeModulus` over `w.length` bytes, and the chain of squarings masks
81
+ * its steps. `candidate` is minimal (its first byte non-zero); the caller
82
+ * ensures w is odd and above 3, for which a base exists. Stops at the first
83
+ * failing round unless `exhaustive`, which runs every round whatever w.
84
+ */
85
+ export function passesMillerRabin(candidate, rounds, exhaustive = false) {
86
+ const length = candidate.length;
87
+ const ring = new ConstantTimeModulus(candidate);
88
+ const minusOne = candidate.slice();
89
+ const exponent = new Uint8Array(length);
90
+ const base = new Uint8Array(length);
91
+ const z = ring.create();
92
+ const minusOneElement = ring.create();
93
+ const oneElement = ring.create();
94
+ const bitLength = 8 * length - Math.clz32(candidate[0]) + 24;
95
+ try {
96
+ minusOne[length - 1] = minusOne[length - 1] & 0xfe;
97
+ const twoAdicity = constantTimeUnsignedTrailingZeros(minusOne);
98
+ constantTimeUnsignedShiftRight(exponent, minusOne, twoAdicity);
99
+ ring.fromBytesBe(minusOneElement, minusOne);
100
+ ring.fromBytesBe(oneElement, Uint8Array.of(1));
101
+ const chain = Math.max(twoAdicity - 1, MINIMUM_CHAIN);
102
+ let passes = 1;
103
+ for (let round = 0; round < rounds; round++) {
104
+ drawBase_(base, candidate, minusOne, bitLength);
105
+ ring.fromBytesBe(z, base);
106
+ ring.power(z, z, exponent);
107
+ let probablyPrime = ring.isEqual(z, oneElement) | ring.isEqual(z, minusOneElement);
108
+ for (let step = 1; step <= chain; step++) {
109
+ // 1 while step < a and no earlier square hit w − 1.
110
+ const active = ((step - twoAdicity) >>> 31) & (1 - probablyPrime);
111
+ ring.multiply(z, z, z);
112
+ probablyPrime |= active & ring.isEqual(z, minusOneElement);
113
+ }
114
+ passes &= probablyPrime;
115
+ if (!exhaustive && passes === 0) {
116
+ return 0;
117
+ }
118
+ }
119
+ return passes;
120
+ }
121
+ finally {
122
+ minusOne.fill(0);
123
+ exponent.fill(0);
124
+ base.fill(0);
125
+ z.fill(0);
126
+ minusOneElement.fill(0);
127
+ oneElement.fill(0);
128
+ ring[Symbol.dispose]();
129
+ }
130
+ }
131
+ /**
132
+ * A base b with 1 < b < w − 1 from a string of len(w) random bits (B.3.1 steps
133
+ * 4.1 and 4.2). The top byte of `candidate` is secret, but its bit length is
134
+ * fixed by the caller (nlen/2), so masking with it reveals nothing new.
135
+ */
136
+ function drawBase_(out, candidate, minusOne, bitLength) {
137
+ const excess = 8 * candidate.length - bitLength;
138
+ const one = new Uint8Array(candidate.length);
139
+ one[candidate.length - 1] = 1;
140
+ for (;;) {
141
+ const random = getRandomBytes(candidate.length);
142
+ try {
143
+ random[0] = random[0] & (0xff >>> excess);
144
+ // Rejection reveals only that a discarded base was out of range.
145
+ if (constantTimeUnsignedCompare(random, one) > 0 &&
146
+ constantTimeUnsignedCompare(random, minusOne) < 0) {
147
+ out.set(random);
148
+ return;
149
+ }
150
+ }
151
+ finally {
152
+ random.fill(0);
153
+ }
154
+ }
155
+ }
156
+ //# sourceMappingURL=_primality.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_primality.js","sourceRoot":"","sources":["../../src/key/_primality.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACN,mBAAmB,EACnB,2BAA2B,EAC3B,8BAA8B,EAC9B,iCAAiC,GACjC,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;GASG;AAEH,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,CAAC;AAErC;;;;;GAKG;AACH,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,aAAa,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;AAE5D,SAAS,eAAe,CAAC,KAAa;IACrC,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAA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C,CAAE,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;YAE3C,iEAAiE;YACjE,IACC,2BAA2B,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC;gBAC5C,2BAA2B,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,EAChD,CAAC;gBACF,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAEhB,OAAO;YACR,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type PrivateKeyState, type PublicKeyState } from "./_key-state.js";
2
+ /**
3
+ * RSAEP / RSAVP1 (RFC 8017 §5.1.1, §5.2.2): `input^e mod n` over `k` bytes, or
4
+ * `undefined` when `input` is not below n. Constant time in `input`, which an
5
+ * encryption keeps secret; the range check is the only branch on it, and no
6
+ * encoding this package makes is out of range.
7
+ */
8
+ export declare function rsaPublicOperation(state: PublicKeyState, input: Uint8Array): Uint8Array<ArrayBuffer> | undefined;
9
+ /**
10
+ * RSADP / RSASP1 (RFC 8017 §5.1.2, §5.2.1): `input^d mod n` over `k` bytes, for
11
+ * an `input` below n (the caller checks). Constant time in the key, the input
12
+ * and the result, with the defences of the CFRG's RSA implementation guidance
13
+ * (draft-irtf-cfrg-rsa-guidance §6) on every call:
14
+ *
15
+ * - Base blinding: the input is multiplied by bb^e for a fresh random bb, and the
16
+ * result by bb⁻¹;
17
+ * - Exponent blinding: each exponent d_i becomes d_i + b_i·(r_i − 1) for a fresh
18
+ * 64-bit b_i (d + b·(e·d − 1) for a key without primes);
19
+ * - Modulus blinding: each prime's exponentiation runs modulo g_i·r_i for a fresh
20
+ * odd 64-bit g_i;
21
+ * - The result is checked by raising it to e, so that a fault in the CRT
22
+ * computation cannot release a value that factors n (Bellcore).
23
+ *
24
+ * @throws {RsaError} `privateKeyFault` when the check fails.
25
+ */
26
+ export declare function rsaPrivateOperation(state: PrivateKeyState, input: Uint8Array): Uint8Array<ArrayBuffer>;
27
+ //# sourceMappingURL=_primitives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_primitives.d.ts","sourceRoot":"","sources":["../../src/key/_primitives.ts"],"names":[],"mappings":"AAUA,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,cAAc,EAEnB,MAAM,iBAAiB,CAAC;AAKzB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,UAAU,GACf,UAAU,CAAC,WAAW,CAAC,GAAG,SAAS,CAiBrC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,UAAU,GACf,UAAU,CAAC,WAAW,CAAC,CAoDzB"}