@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.
- package/CHANGELOG.md +27 -1
- package/lib/acme.js +59 -815
- package/lib/asn1-der.js +7 -245
- package/lib/attrcert-sign.js +12 -260
- package/lib/attrcert-verify.js +1 -7
- package/lib/byte-reader.js +0 -8
- package/lib/byte-writer.js +0 -11
- package/lib/cbor-det.js +0 -54
- package/lib/cmc-build.js +15 -357
- package/lib/cmc-verify.js +6 -239
- package/lib/cmp-build.js +41 -317
- package/lib/cmp-session.js +73 -760
- package/lib/cmp-verify.js +32 -488
- package/lib/cms-compress.js +3 -32
- package/lib/cms-decrypt.js +29 -294
- package/lib/cms-encrypt.js +14 -234
- package/lib/cms-sign.js +29 -324
- package/lib/cms-verify.js +9 -500
- package/lib/composite-kem.js +2 -102
- package/lib/composite-sig.js +1 -77
- package/lib/constants.js +0 -249
- package/lib/crl-sign.js +9 -237
- package/lib/crl-verify.js +1 -10
- package/lib/crmf-sign.js +19 -198
- package/lib/crmf-verify.js +1 -12
- package/lib/csr-sign.js +3 -34
- package/lib/csr-verify.js +1 -12
- package/lib/ct.js +28 -253
- package/lib/edwards-point.js +10 -44
- package/lib/est.js +28 -764
- package/lib/framework-error.js +4 -182
- package/lib/guard-all.js +1 -58
- package/lib/guard-async.js +1 -36
- package/lib/guard-bytes.js +6 -650
- package/lib/guard-compress.js +5 -102
- package/lib/guard-crypto.js +1 -40
- package/lib/guard-der.js +2 -93
- package/lib/guard-encoding.js +2 -60
- package/lib/guard-header.js +1 -36
- package/lib/guard-identifier.js +7 -531
- package/lib/guard-intrinsic.js +1 -150
- package/lib/guard-json.js +10 -73
- package/lib/guard-limits.js +1 -77
- package/lib/guard-list.js +1 -49
- package/lib/guard-name.js +3 -209
- package/lib/guard-parsed.js +7 -335
- package/lib/guard-range.js +1 -71
- package/lib/guard-secret.js +1 -102
- package/lib/guard-text.js +1 -64
- package/lib/guard-time.js +1 -97
- package/lib/hpke.js +3 -105
- package/lib/http-digest.js +14 -142
- package/lib/http-retry-after.js +1 -47
- package/lib/http-transport.js +21 -131
- package/lib/inspect.js +30 -284
- package/lib/ip-utils.js +6 -47
- package/lib/jose.js +7 -142
- package/lib/key.js +2 -67
- package/lib/lint.js +9 -194
- package/lib/merkle.js +1 -27
- package/lib/mime.js +9 -82
- package/lib/ocsp-request-verify.js +1 -14
- package/lib/ocsp-verify.js +1 -82
- package/lib/ocsp.js +11 -169
- package/lib/oid.js +5 -337
- package/lib/path-validate.js +103 -1492
- package/lib/pbes2.js +2 -89
- package/lib/pkcs12-build.js +31 -379
- package/lib/pki-build.js +64 -290
- package/lib/rc2.js +2 -18
- package/lib/rfc3339.js +4 -27
- package/lib/scep.js +140 -286
- package/lib/schema-all.js +0 -122
- package/lib/schema-attrcert.js +4 -146
- package/lib/schema-c509.js +153 -802
- package/lib/schema-cmc.js +5 -220
- package/lib/schema-cmp.js +2 -223
- package/lib/schema-cms.js +13 -427
- package/lib/schema-crl.js +5 -68
- package/lib/schema-crmf.js +6 -167
- package/lib/schema-csr.js +1 -54
- package/lib/schema-csrattrs.js +2 -87
- package/lib/schema-engine.js +0 -152
- package/lib/schema-ocsp.js +0 -117
- package/lib/schema-pkcs12.js +2 -93
- package/lib/schema-pkcs8.js +3 -35
- package/lib/schema-pkix.js +24 -655
- package/lib/schema-smime.js +0 -54
- package/lib/schema-tsp.js +3 -99
- package/lib/schema-x509.js +4 -63
- package/lib/shbs.js +11 -95
- package/lib/sign-scheme.js +2 -97
- package/lib/sigstore.js +9 -169
- package/lib/sleep.js +2 -8
- package/lib/smime.js +15 -408
- package/lib/tls-cert-compress.js +0 -62
- package/lib/trust.js +19 -185
- package/lib/tsp-sign.js +16 -270
- package/lib/validator-all.js +1 -30
- package/lib/validator-attcert.js +2 -46
- package/lib/validator-cose.js +2 -153
- package/lib/validator-keydesc.js +1 -37
- package/lib/validator-sig.js +1 -46
- package/lib/validator-tls.js +1 -88
- package/lib/validator-tpm.js +19 -122
- package/lib/verify-seam.js +1 -24
- package/lib/webauthn-mds.js +3 -400
- package/lib/webauthn.js +12 -833
- package/lib/webcrypto.js +5 -485
- package/lib/x509-sign.js +4 -108
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/lib/schema-pkcs8.js
CHANGED
|
@@ -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;
|
|
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,
|
|
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,
|
|
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
|
|