@blamejs/pki 0.6.13 → 0.6.15

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 (114) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/README.md +1 -1
  3. package/index.js +1 -1
  4. package/lib/acme.js +59 -815
  5. package/lib/asn1-der.js +7 -245
  6. package/lib/attrcert-sign.js +12 -260
  7. package/lib/attrcert-verify.js +1 -7
  8. package/lib/byte-reader.js +0 -8
  9. package/lib/byte-writer.js +0 -11
  10. package/lib/cbor-det.js +0 -54
  11. package/lib/cmc-build.js +15 -357
  12. package/lib/cmc-verify.js +6 -239
  13. package/lib/cmp-build.js +41 -317
  14. package/lib/cmp-session.js +73 -760
  15. package/lib/cmp-verify.js +32 -488
  16. package/lib/cms-compress.js +3 -32
  17. package/lib/cms-decrypt.js +29 -294
  18. package/lib/cms-encrypt.js +14 -234
  19. package/lib/cms-sign.js +29 -324
  20. package/lib/cms-verify.js +9 -500
  21. package/lib/composite-kem.js +2 -102
  22. package/lib/composite-sig.js +1 -77
  23. package/lib/constants.js +0 -249
  24. package/lib/crl-sign.js +9 -237
  25. package/lib/crl-verify.js +1 -10
  26. package/lib/crmf-sign.js +19 -198
  27. package/lib/crmf-verify.js +1 -12
  28. package/lib/csr-sign.js +3 -34
  29. package/lib/csr-verify.js +1 -12
  30. package/lib/ct.js +28 -253
  31. package/lib/edwards-point.js +10 -44
  32. package/lib/est.js +28 -764
  33. package/lib/framework-error.js +4 -182
  34. package/lib/guard-all.js +1 -58
  35. package/lib/guard-async.js +1 -36
  36. package/lib/guard-bytes.js +6 -650
  37. package/lib/guard-compress.js +5 -102
  38. package/lib/guard-crypto.js +1 -40
  39. package/lib/guard-der.js +2 -93
  40. package/lib/guard-encoding.js +2 -60
  41. package/lib/guard-header.js +1 -36
  42. package/lib/guard-identifier.js +7 -531
  43. package/lib/guard-intrinsic.js +1 -150
  44. package/lib/guard-json.js +10 -73
  45. package/lib/guard-limits.js +1 -77
  46. package/lib/guard-list.js +1 -49
  47. package/lib/guard-name.js +3 -209
  48. package/lib/guard-parsed.js +7 -335
  49. package/lib/guard-range.js +1 -71
  50. package/lib/guard-secret.js +1 -102
  51. package/lib/guard-text.js +1 -64
  52. package/lib/guard-time.js +1 -97
  53. package/lib/hpke.js +3 -105
  54. package/lib/http-digest.js +14 -142
  55. package/lib/http-retry-after.js +1 -47
  56. package/lib/http-transport.js +21 -131
  57. package/lib/inspect.js +30 -284
  58. package/lib/ip-utils.js +6 -47
  59. package/lib/jose.js +7 -142
  60. package/lib/key.js +2 -67
  61. package/lib/lint.js +9 -194
  62. package/lib/merkle.js +1 -27
  63. package/lib/mime.js +9 -82
  64. package/lib/ocsp-request-verify.js +1 -14
  65. package/lib/ocsp-verify.js +1 -82
  66. package/lib/ocsp.js +11 -169
  67. package/lib/oid.js +5 -337
  68. package/lib/path-validate.js +103 -1492
  69. package/lib/pbes2.js +2 -89
  70. package/lib/pkcs12-build.js +31 -379
  71. package/lib/pki-build.js +64 -290
  72. package/lib/rc2.js +2 -18
  73. package/lib/rfc3339.js +4 -27
  74. package/lib/scep.js +59 -233
  75. package/lib/schema-all.js +0 -122
  76. package/lib/schema-attrcert.js +4 -146
  77. package/lib/schema-c509.js +153 -802
  78. package/lib/schema-cmc.js +5 -220
  79. package/lib/schema-cmp.js +2 -223
  80. package/lib/schema-cms.js +13 -427
  81. package/lib/schema-crl.js +5 -68
  82. package/lib/schema-crmf.js +6 -167
  83. package/lib/schema-csr.js +1 -54
  84. package/lib/schema-csrattrs.js +2 -87
  85. package/lib/schema-engine.js +0 -152
  86. package/lib/schema-ocsp.js +0 -117
  87. package/lib/schema-pkcs12.js +2 -93
  88. package/lib/schema-pkcs8.js +3 -35
  89. package/lib/schema-pkix.js +24 -655
  90. package/lib/schema-smime.js +0 -54
  91. package/lib/schema-tsp.js +3 -99
  92. package/lib/schema-x509.js +4 -63
  93. package/lib/shbs.js +11 -95
  94. package/lib/sign-scheme.js +2 -97
  95. package/lib/sigstore.js +9 -169
  96. package/lib/sleep.js +2 -8
  97. package/lib/smime.js +15 -408
  98. package/lib/tls-cert-compress.js +0 -62
  99. package/lib/trust.js +19 -185
  100. package/lib/tsp-sign.js +16 -270
  101. package/lib/validator-all.js +1 -30
  102. package/lib/validator-attcert.js +2 -46
  103. package/lib/validator-cose.js +2 -153
  104. package/lib/validator-keydesc.js +1 -37
  105. package/lib/validator-sig.js +1 -46
  106. package/lib/validator-tls.js +1 -88
  107. package/lib/validator-tpm.js +19 -122
  108. package/lib/verify-seam.js +1 -24
  109. package/lib/webauthn-mds.js +3 -400
  110. package/lib/webauthn.js +12 -833
  111. package/lib/webcrypto.js +5 -485
  112. package/lib/x509-sign.js +4 -108
  113. package/package.json +1 -1
  114. 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