@blamejs/pki 0.6.14 → 0.6.16

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 (112) hide show
  1. package/CHANGELOG.md +27 -1
  2. package/lib/acme.js +59 -815
  3. package/lib/asn1-der.js +7 -245
  4. package/lib/attrcert-sign.js +12 -260
  5. package/lib/attrcert-verify.js +1 -7
  6. package/lib/byte-reader.js +0 -8
  7. package/lib/byte-writer.js +0 -11
  8. package/lib/cbor-det.js +0 -54
  9. package/lib/cmc-build.js +15 -357
  10. package/lib/cmc-verify.js +6 -239
  11. package/lib/cmp-build.js +41 -317
  12. package/lib/cmp-session.js +73 -760
  13. package/lib/cmp-verify.js +32 -488
  14. package/lib/cms-compress.js +3 -32
  15. package/lib/cms-decrypt.js +29 -294
  16. package/lib/cms-encrypt.js +14 -234
  17. package/lib/cms-sign.js +29 -324
  18. package/lib/cms-verify.js +9 -500
  19. package/lib/composite-kem.js +2 -102
  20. package/lib/composite-sig.js +1 -77
  21. package/lib/constants.js +0 -249
  22. package/lib/crl-sign.js +9 -237
  23. package/lib/crl-verify.js +1 -10
  24. package/lib/crmf-sign.js +19 -198
  25. package/lib/crmf-verify.js +1 -12
  26. package/lib/csr-sign.js +3 -34
  27. package/lib/csr-verify.js +1 -12
  28. package/lib/ct.js +28 -253
  29. package/lib/edwards-point.js +10 -44
  30. package/lib/est.js +28 -764
  31. package/lib/framework-error.js +4 -182
  32. package/lib/guard-all.js +1 -58
  33. package/lib/guard-async.js +1 -36
  34. package/lib/guard-bytes.js +6 -650
  35. package/lib/guard-compress.js +5 -102
  36. package/lib/guard-crypto.js +1 -40
  37. package/lib/guard-der.js +2 -93
  38. package/lib/guard-encoding.js +2 -60
  39. package/lib/guard-header.js +1 -36
  40. package/lib/guard-identifier.js +7 -531
  41. package/lib/guard-intrinsic.js +1 -150
  42. package/lib/guard-json.js +10 -73
  43. package/lib/guard-limits.js +1 -77
  44. package/lib/guard-list.js +1 -49
  45. package/lib/guard-name.js +3 -209
  46. package/lib/guard-parsed.js +7 -335
  47. package/lib/guard-range.js +1 -71
  48. package/lib/guard-secret.js +1 -102
  49. package/lib/guard-text.js +1 -64
  50. package/lib/guard-time.js +1 -97
  51. package/lib/hpke.js +3 -105
  52. package/lib/http-digest.js +14 -142
  53. package/lib/http-retry-after.js +1 -47
  54. package/lib/http-transport.js +21 -131
  55. package/lib/inspect.js +30 -284
  56. package/lib/ip-utils.js +6 -47
  57. package/lib/jose.js +7 -142
  58. package/lib/key.js +2 -67
  59. package/lib/lint.js +9 -194
  60. package/lib/merkle.js +1 -27
  61. package/lib/mime.js +9 -82
  62. package/lib/ocsp-request-verify.js +1 -14
  63. package/lib/ocsp-verify.js +1 -82
  64. package/lib/ocsp.js +11 -169
  65. package/lib/oid.js +5 -337
  66. package/lib/path-validate.js +103 -1492
  67. package/lib/pbes2.js +2 -89
  68. package/lib/pkcs12-build.js +31 -379
  69. package/lib/pki-build.js +64 -290
  70. package/lib/rc2.js +2 -18
  71. package/lib/rfc3339.js +4 -27
  72. package/lib/scep.js +140 -286
  73. package/lib/schema-all.js +0 -122
  74. package/lib/schema-attrcert.js +4 -146
  75. package/lib/schema-c509.js +153 -802
  76. package/lib/schema-cmc.js +5 -220
  77. package/lib/schema-cmp.js +2 -223
  78. package/lib/schema-cms.js +13 -427
  79. package/lib/schema-crl.js +5 -68
  80. package/lib/schema-crmf.js +6 -167
  81. package/lib/schema-csr.js +1 -54
  82. package/lib/schema-csrattrs.js +2 -87
  83. package/lib/schema-engine.js +0 -152
  84. package/lib/schema-ocsp.js +0 -117
  85. package/lib/schema-pkcs12.js +2 -93
  86. package/lib/schema-pkcs8.js +3 -35
  87. package/lib/schema-pkix.js +24 -655
  88. package/lib/schema-smime.js +0 -54
  89. package/lib/schema-tsp.js +3 -99
  90. package/lib/schema-x509.js +4 -63
  91. package/lib/shbs.js +11 -95
  92. package/lib/sign-scheme.js +2 -97
  93. package/lib/sigstore.js +9 -169
  94. package/lib/sleep.js +2 -8
  95. package/lib/smime.js +15 -408
  96. package/lib/tls-cert-compress.js +0 -62
  97. package/lib/trust.js +19 -185
  98. package/lib/tsp-sign.js +16 -270
  99. package/lib/validator-all.js +1 -30
  100. package/lib/validator-attcert.js +2 -46
  101. package/lib/validator-cose.js +2 -153
  102. package/lib/validator-keydesc.js +1 -37
  103. package/lib/validator-sig.js +1 -46
  104. package/lib/validator-tls.js +1 -88
  105. package/lib/validator-tpm.js +19 -122
  106. package/lib/verify-seam.js +1 -24
  107. package/lib/webauthn-mds.js +3 -400
  108. package/lib/webauthn.js +12 -833
  109. package/lib/webcrypto.js +5 -485
  110. package/lib/x509-sign.js +4 -108
  111. package/package.json +1 -1
  112. package/sbom.cdx.json +6 -6
@@ -41,22 +41,13 @@ var frameworkError = require("./framework-error");
41
41
  var Pkcs8Error = frameworkError.Pkcs8Error;
42
42
  var PemError = frameworkError.PemError;
43
43
 
44
- // The pkcs8 error namespace the schema engine walks under.
45
44
  var NS = pkix.makeNS("pkcs8", Pkcs8Error, oid);
46
45
 
47
46
  var ALGORITHM_IDENTIFIER = pkix.algorithmIdentifier(NS);
48
47
  var ATTRIBUTE = pkix.attribute(NS);
49
48
 
50
- // version ::= INTEGER { v1(0), v2(1) }, where 0 and 1 are both legal (the divergence
51
- // from every other reader; cert/CRL reject 0, CSR accepts only 0). Surface as the
52
- // RFC's vN number.
53
49
  var PKCS8_VERSION = pkix.versionReader(NS, { "0": 1, "1": 2 });
54
50
 
55
- // PrivateKeyInfo ::= SEQUENCE { version, privateKeyAlgorithm AlgorithmIdentifier,
56
- // privateKey OCTET STRING, attributes [0] IMPLICIT SET OF Attribute OPTIONAL,
57
- // publicKey [1] IMPLICIT BIT STRING OPTIONAL (v2 only) }. The two trailing
58
- // context fields are modeled with `trailing` so they must appear in ascending tag
59
- // order and an unknown trailing context tag is rejected (not bled into a field).
60
51
  var PRIVATE_KEY_INFO = schema.seq([
61
52
  schema.field("version", PKCS8_VERSION),
62
53
  schema.field("privateKeyAlgorithm", ALGORITHM_IDENTIFIER),
@@ -68,24 +59,20 @@ var PRIVATE_KEY_INFO = schema.seq([
68
59
  ], {
69
60
  assert: "sequence", arity: { min: 3 }, code: "pkcs8/not-a-private-key-info", what: "PrivateKeyInfo",
70
61
  build: function (m) {
71
- var version = m.fields.version.value; // 1 (v1) | 2 (v2)
62
+ var version = m.fields.version.value;
72
63
  var hasPublicKey = m.fields.publicKey.present;
73
- // RFC 5958 sec. 2 -- publicKey present <=> version is v2. Enforce both directions.
74
64
  if (hasPublicKey && version !== 2) throw NS.E("pkcs8/bad-version", "a [1] publicKey is permitted only in a v2 OneAsymmetricKey");
75
65
  if (!hasPublicKey && version === 2) throw NS.E("pkcs8/bad-version", "a v2 OneAsymmetricKey must carry a [1] publicKey");
76
66
  return {
77
67
  version: version,
78
68
  privateKeyAlgorithm: m.fields.privateKeyAlgorithm.value.result,
79
- privateKey: m.fields.privateKey.value, // raw OCTET STRING content (the inner key DER)
69
+ privateKey: m.fields.privateKey.value,
80
70
  attributes: m.fields.attributes.present ? m.fields.attributes.value.items.map(function (it) { return it.value.result; }) : [],
81
71
  publicKey: hasPublicKey ? m.fields.publicKey.value : null,
82
72
  };
83
73
  },
84
74
  });
85
75
 
86
- // EncryptedPrivateKeyInfo ::= SEQUENCE { encryptionAlgorithm AlgorithmIdentifier,
87
- // encryptedData OCTET STRING } (RFC 5958 sec. 3). Recognized and surfaced; the raw
88
- // ciphertext is kept for a later decryption layer (PBES2/PBKDF2 + a passphrase).
89
76
  var ENCRYPTED_PRIVATE_KEY_INFO = schema.seq([
90
77
  schema.field("encryptionAlgorithm", ALGORITHM_IDENTIFIER),
91
78
  schema.field("encryptedData", schema.octetString()),
@@ -94,7 +81,7 @@ var ENCRYPTED_PRIVATE_KEY_INFO = schema.seq([
94
81
  build: function (m) {
95
82
  return {
96
83
  encryptionAlgorithm: m.fields.encryptionAlgorithm.value.result,
97
- encryptedData: m.fields.encryptedData.value, // raw ciphertext
84
+ encryptedData: m.fields.encryptedData.value,
98
85
  };
99
86
  },
100
87
  });
@@ -180,12 +167,6 @@ function pemDecode(text, label) { return pkix.pemDecode(text, label || "PRIVATE
180
167
  */
181
168
  function pemEncode(der, label) { return pkix.pemEncode(der, label || "PRIVATE KEY", PemError); }
182
169
 
183
- // A PKCS#8 PrivateKeyInfo root is a SEQUENCE whose first child is a universal
184
- // INTEGER (version) and third child a universal OCTET STRING (privateKey) -- a
185
- // shape the signed-envelope trio (whose children[0] is a SEQUENCE and children[2]
186
- // a BIT STRING) can never present, so the detectors are mutually exclusive
187
- // regardless of registry order. Trailing context fields are [0]/[1] in ascending
188
- // order.
189
170
  function matches(root) {
190
171
  var TAGS = asn1.TAGS;
191
172
  var k = pkix.rootSequenceChildren(root, 3, 5);
@@ -201,20 +182,7 @@ function matches(root) {
201
182
  return true;
202
183
  }
203
184
 
204
- // NOTE: there is intentionally no `matchesEncrypted` detector. An
205
- // EncryptedPrivateKeyInfo is a SEQUENCE { SEQUENCE, OCTET STRING } -- a shape it
206
- // shares with a PKCS#1 DigestInfo and other AlgorithmIdentifier-plus-octets
207
- // structures -- so it cannot be classified from structure alone. The orchestrator
208
- // does not auto-route it; an operator who knows a key is encrypted (e.g. from an
209
- // 'ENCRYPTED PRIVATE KEY' PEM label) calls parseEncrypted directly. A structural
210
- // auto-route can return once a validated encryption-algorithm discriminator (the
211
- // PBES layer) exists.
212
185
 
213
- // Validate a bare, already-decoded PrivateKeyInfo / EncryptedPrivateKeyInfo
214
- // node -- for a composer that holds a decoded node and must not re-parse its
215
- // bytes (an RFC 7292 PFX key bag, whose wire encoding may be BER that the
216
- // strict `parse` entry would refuse). Same contract as the CMS walkers: the
217
- // node is the bare structure, typed pkcs8/* on rejection.
218
186
  function walkPrivateKeyInfo(node) { return schema.walk(PRIVATE_KEY_INFO, node, NS).result; }
219
187
  function walkEncryptedPrivateKeyInfo(node) { return schema.walk(ENCRYPTED_PRIVATE_KEY_INFO, node, NS).result; }
220
188