@blamejs/pki 0.8.31 → 0.8.48
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 +393 -0
- package/README.md +66 -15
- package/bin/pki.js +716 -30
- package/examples/issue-a-certificate.js +90 -0
- package/examples/post-quantum.js +66 -0
- package/examples/read-a-certificate.js +56 -0
- package/examples/revoke-and-check.js +86 -0
- package/examples/sign-and-verify-cms.js +63 -0
- package/index.js +18 -5
- package/lib/acme.js +223 -74
- package/lib/alt-sig.js +441 -0
- package/lib/asn1-der.js +48 -25
- package/lib/attrcert-sign.js +27 -19
- package/lib/cbor-det.js +24 -14
- package/lib/cmc-build.js +9 -2
- package/lib/cmc-verify.js +14 -3
- package/lib/cmp-build.js +17 -5
- package/lib/cmp-session.js +24 -11
- package/lib/cmp-verify.js +28 -19
- package/lib/cms-compress.js +3 -1
- package/lib/cms-decrypt.js +102 -7
- package/lib/cms-encrypt.js +59 -7
- package/lib/cms-sign.js +31 -9
- package/lib/cms-verify.js +22 -18
- package/lib/composite-kem.js +30 -18
- package/lib/composite-sig.js +29 -14
- package/lib/constants.js +26 -0
- package/lib/crl-sign.js +111 -19
- package/lib/crmf-sign.js +167 -15
- package/lib/csr-sign.js +117 -6
- package/lib/ct.js +939 -48
- package/lib/est.js +29 -16
- package/lib/framework-error.js +12 -0
- package/lib/guard-async.js +1 -1
- package/lib/guard-bytes.js +103 -20
- package/lib/guard-crypto.js +205 -3
- package/lib/guard-encoding.js +6 -1
- package/lib/guard-identifier.js +55 -8
- package/lib/guard-intrinsic.js +43 -0
- package/lib/guard-json.js +122 -9
- package/lib/guard-limits.js +12 -1
- package/lib/guard-list.js +63 -8
- package/lib/guard-name.js +167 -20
- package/lib/guard-range.js +43 -5
- package/lib/guard-text.js +41 -0
- package/lib/guard-verdict.js +39 -8
- package/lib/hpke.js +688 -42
- package/lib/http-transport.js +156 -4
- package/lib/identity-match.js +4 -4
- package/lib/inspect.js +33 -6
- package/lib/jose.js +93 -25
- package/lib/key.js +18 -13
- package/lib/lint.js +165 -1
- package/lib/merkle.js +233 -27
- package/lib/ocsp.js +27 -14
- package/lib/oid.js +14 -4
- package/lib/path-validate.js +143 -61
- package/lib/pkcs12-build.js +7 -2
- package/lib/pki-build.js +31 -7
- package/lib/possession.js +575 -0
- package/lib/related-cert.js +708 -0
- package/lib/revocation-fetch.js +6 -6
- package/lib/scep.js +15 -5
- package/lib/schema-c509.js +5 -2
- package/lib/schema-cmc.js +1 -1
- package/lib/schema-cmp.js +8 -8
- package/lib/schema-cms.js +2 -15
- package/lib/schema-csr.js +69 -0
- package/lib/schema-engine.js +10 -3
- package/lib/schema-pkix.js +228 -2
- package/lib/schema-tsp.js +7 -6
- package/lib/sign-scheme.js +22 -9
- package/lib/sigstore.js +684 -168
- package/lib/sleep.js +8 -1
- package/lib/smime.js +22 -1
- package/lib/tlog.js +1235 -0
- package/lib/tls-cert-compress.js +25 -8
- package/lib/tsp-sign.js +120 -35
- package/lib/tuf.js +1395 -0
- package/lib/validator-tpm.js +4 -1
- package/lib/verify-seam.js +7 -1
- package/lib/webauthn-mds.js +41 -4
- package/lib/webauthn.js +43 -25
- package/lib/webcrypto.js +48 -46
- package/lib/x509-sign.js +225 -19
- package/package.json +2 -1
- package/sbom.cdx.json +6 -6
package/lib/pkcs12-build.js
CHANGED
|
@@ -89,9 +89,14 @@ var _ENCRYPT_KEYS = intrinsic.assign(intrinsic.create(null), { password: 1, ciph
|
|
|
89
89
|
var _MAC_KEYS = intrinsic.assign(intrinsic.create(null), { algorithm: 1, hash: 1, salt: 1, iterations: 1, keyLength: 1, password: 1 });
|
|
90
90
|
var _MAC_KEYS_HMAC = intrinsic.assign(intrinsic.create(null), { algorithm: 1, hash: 1, salt: 1, iterations: 1, password: 1 });
|
|
91
91
|
var _MAC_KEYS_PBMAC1 = intrinsic.assign(intrinsic.create(null), { algorithm: 1, hash: 1, salt: 1, iterations: 1, keyLength: 1, password: 1 });
|
|
92
|
+
/** @internal `allowUnauthenticatedRsa15` reaches `pki.cms.decrypt` through the options this verb already
|
|
93
|
+
* forwards. A public-key-privacy safe IS a CMS EnvelopedData, and the one `openssl pkcs12` or
|
|
94
|
+
* `openssl cms -encrypt` produces uses RSAES-PKCS1-v1_5 key transport over an AES-CBC content, which that
|
|
95
|
+
* verb refuses by default. An operator opening such a file needs the option, and naming it here is what
|
|
96
|
+
* lets them pass it rather than meeting an unknown-option refusal first. */
|
|
92
97
|
var _OPEN_OPTS = intrinsic.assign(intrinsic.create(null), {
|
|
93
|
-
allowUnauthenticated: 1,
|
|
94
|
-
recipientKey: 1, recipientCert: 1, recipientIndex: 1,
|
|
98
|
+
allowUnauthenticated: 1, allowUnauthenticatedRsa15: 1, importAlgorithm: 1, keys: 1, maxIterations: 1,
|
|
99
|
+
signerCerts: 1, recipientKey: 1, recipientCert: 1, recipientIndex: 1,
|
|
95
100
|
});
|
|
96
101
|
var _VERIFY_MAC_OPTS = intrinsic.assign(intrinsic.create(null), { maxIterations: 1 });
|
|
97
102
|
|
package/lib/pki-build.js
CHANGED
|
@@ -29,6 +29,7 @@ var _stringify = intrinsic.stringify;
|
|
|
29
29
|
var _mapIntrinsic = intrinsic.map;
|
|
30
30
|
var _bufferConcatIntrinsic = intrinsic.bufferConcat;
|
|
31
31
|
var OID_SKI = oid.byName("subjectKeyIdentifier");
|
|
32
|
+
var OID_SAPKI = oid.byName("subjectAltPublicKeyInfo");
|
|
32
33
|
|
|
33
34
|
function _isAlphaCode(c) { return (c >= 65 && c <= 90) || (c >= 97 && c <= 122); }
|
|
34
35
|
function _isDigitCode(c) { return c >= 48 && c <= 57; }
|
|
@@ -1375,15 +1376,15 @@ function makeBuilder(ctx) {
|
|
|
1375
1376
|
});
|
|
1376
1377
|
}
|
|
1377
1378
|
var pub;
|
|
1378
|
-
try { pub =
|
|
1379
|
+
try { pub = guard.crypto.publicKey({ key: spki, format: "der", type: "spki" }); }
|
|
1379
1380
|
catch (e) { throw E("bad-input", "the public key could not be imported for the signature self-check", e); }
|
|
1380
1381
|
var s = scheme.sign, ok;
|
|
1381
1382
|
try {
|
|
1382
|
-
if (s.name === "ECDSA") ok =
|
|
1383
|
-
else if (s.name === "RSA-PSS") ok =
|
|
1384
|
-
else if (s.name === "RSASSA-PKCS1-v1_5") ok =
|
|
1383
|
+
if (s.name === "ECDSA") ok = guard.crypto.verify(scheme.digest, preimage, { key: pub, dsaEncoding: "der" }, sig);
|
|
1384
|
+
else if (s.name === "RSA-PSS") ok = guard.crypto.verify(scheme.digest, preimage, { key: pub, padding: guard.crypto.padding.RSA_PKCS1_PSS, saltLength: s.saltLength }, sig);
|
|
1385
|
+
else if (s.name === "RSASSA-PKCS1-v1_5") ok = guard.crypto.verify(scheme.digest, preimage, pub, sig);
|
|
1385
1386
|
// allow:eddsa-verify-without-loworder-gate -- a self-check that OUR just-produced signature verifies
|
|
1386
|
-
else ok =
|
|
1387
|
+
else ok = guard.crypto.verify(null, preimage, pub, sig);
|
|
1387
1388
|
} catch (e) { throw E("bad-input", "the signature self-check could not run against the public key", e); }
|
|
1388
1389
|
if (!ok) throw E("bad-input", "the signing key does not correspond to the public key -- the signature would not verify");
|
|
1389
1390
|
}
|
|
@@ -1404,6 +1405,7 @@ function makeBuilder(ctx) {
|
|
|
1404
1405
|
extMsCertificateTemplate: extMsCertificateTemplate, extMsCaVersion: extMsCaVersion,
|
|
1405
1406
|
extMsPreviousCertHash: extMsPreviousCertHash, extMsEnrollCertType: extMsEnrollCertType,
|
|
1406
1407
|
spkiKeyId: spkiKeyId, skiKeyId: skiKeyId, skiValueOf: skiValueOf,
|
|
1408
|
+
altPublicKeyValueOf: altPublicKeyValueOf,
|
|
1407
1409
|
reqDer: reqDer, reqDenseArray: reqDenseArray, reqDerSequence: reqDerSequence, assertValidSpki: assertValidSpki, assertValidExtension: assertValidExtension,
|
|
1408
1410
|
assertExtnValueIsDer: assertExtnValueIsDer,
|
|
1409
1411
|
assertCertCriticality: assertCertCriticality,
|
|
@@ -1435,6 +1437,28 @@ function skiValueOf(parsedCert) {
|
|
|
1435
1437
|
catch (_e) { return null; } // allow:swallow-unverified -- a malformed SKI is read as absent; a signer then derives the authorityKeyIdentifier keyIdentifier from the public key, and a verifier matches on nothing
|
|
1436
1438
|
}
|
|
1437
1439
|
|
|
1440
|
+
/** @internal The alternative public key a parsed certificate PUBLISHES, from its
|
|
1441
|
+
* subjectAltPublicKeyInfo extension (ITU-T X.509 (2019) clause 9.8.2), or null when it carries none.
|
|
1442
|
+
*
|
|
1443
|
+
* A signer needs this to bind an alternative signature to the issuer the same way the native signature
|
|
1444
|
+
* is already bound: the native key is read out of the issuer certificate, while the alternative key is
|
|
1445
|
+
* handed in beside it, so without this the two can be different keys. Clause 9.8.4 has a relying party
|
|
1446
|
+
* check an alternative signature with the issuer's alternative public key, which is the one in the
|
|
1447
|
+
* issuer's own certificate, so a signature made with any other key verifies for nobody. */
|
|
1448
|
+
function altPublicKeyValueOf(parsedCert) {
|
|
1449
|
+
var exts = intrinsic.filter(parsedCert.extensions, function (e) { return e.oid === OID_SAPKI; });
|
|
1450
|
+
if (!exts.length) return null;
|
|
1451
|
+
/** @internal The extension's value IS a SubjectPublicKeyInfo, so unlike subjectKeyIdentifier there is
|
|
1452
|
+
* no inner OCTET STRING to read through: the bytes are the SPKI. They are decoded only to confirm the
|
|
1453
|
+
* shape, and the original bytes returned rather than a re-encoding, so the comparison a signer makes is
|
|
1454
|
+
* against what the certificate actually carries. */
|
|
1455
|
+
try {
|
|
1456
|
+
var node = asn1.decode(exts[0].value);
|
|
1457
|
+
if (!node.constructed || node.tagNumber !== asn1.TAGS.SEQUENCE) return null;
|
|
1458
|
+
return _bufferFrom(exts[0].value);
|
|
1459
|
+
} catch (_e) { return null; } // allow:swallow-unverified -- an unreadable extension publishes no key, and a signer then refuses rather than binding to bytes it could not decode
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1438
1462
|
/** @internal Whether two SubjectPublicKeyInfo encodings carry the same public key: byte-equal, or
|
|
1439
1463
|
* equal under the runtime's key comparison once both import. */
|
|
1440
1464
|
function samePublicKey(spkiA, spkiB) {
|
|
@@ -1443,8 +1467,8 @@ function samePublicKey(spkiA, spkiB) {
|
|
|
1443
1467
|
var ka, kb;
|
|
1444
1468
|
// allow:swallow-unverified an SPKI the key layer cannot import matches nothing, which is the
|
|
1445
1469
|
try {
|
|
1446
|
-
ka =
|
|
1447
|
-
kb =
|
|
1470
|
+
ka = guard.crypto.publicKey({ key: a, format: "der", type: "spki" });
|
|
1471
|
+
kb = guard.crypto.publicKey({ key: bb, format: "der", type: "spki" });
|
|
1448
1472
|
} catch (_e) { return false; }
|
|
1449
1473
|
/** @internal Two keys of different types are never the same key, and comparing them through
|
|
1450
1474
|
* the runtime's equality leaves a fault queued in the crypto library that surfaces on the
|