@peculiar/certificates-viewer 4.7.0 → 4.7.1-alpha.1
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/components/attribute-certificate-viewer.js +4 -2
- package/components/attribute-certificate-viewer.js.map +1 -1
- package/components/attribute.js +1 -1
- package/components/certificate-chain-viewer.js +1 -1
- package/components/certificate-viewer.js +3 -2
- package/components/certificate-viewer.js.map +1 -1
- package/components/crl-viewer.js +4 -2
- package/components/crl-viewer.js.map +1 -1
- package/components/csr-viewer.js +2 -2
- package/components/download.js +2 -12680
- package/components/download.js.map +1 -1
- package/components/index.js +2 -1
- package/components/index.js.map +1 -1
- package/components/index2.js +3 -2
- package/components/index2.js.map +1 -1
- package/components/issuer_name.js +2 -2
- package/components/link.js +14335 -0
- package/components/link.js.map +1 -0
- package/components/miscellaneous.js +5 -79
- package/components/miscellaneous.js.map +1 -1
- package/components/peculiar-certificate-decoder.js +32 -16
- package/components/peculiar-certificate-decoder.js.map +1 -1
- package/components/peculiar-certificates-viewer.js +2 -1
- package/components/peculiar-certificates-viewer.js.map +1 -1
- package/components/peculiar-ssh-certificate-viewer.d.ts +11 -0
- package/components/peculiar-ssh-certificate-viewer.js +12 -0
- package/components/peculiar-ssh-certificate-viewer.js.map +1 -0
- package/components/peculiar-text-hider.js +1 -32
- package/components/peculiar-text-hider.js.map +1 -1
- package/components/pkcs10_certificate_request.js +2 -1
- package/components/pkcs10_certificate_request.js.map +1 -1
- package/components/row.js +87 -0
- package/components/row.js.map +1 -0
- package/components/ssh-certificate-viewer.js +193 -0
- package/components/ssh-certificate-viewer.js.map +1 -0
- package/components/subject_name.js +2 -2
- package/components/text-hider.js +40 -0
- package/components/text-hider.js.map +1 -0
- package/dist/cjs/extension-D8YKlAu4.js +110 -0
- package/dist/cjs/{extension-CGZpfI3W.js.map → extension-D8YKlAu4.js.map} +1 -1
- package/dist/cjs/index.cjs.js +4 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{miscellaneous-D_RAtkZz.js → miscellaneous-DvVSM5KJ.js} +147 -147
- package/dist/cjs/{miscellaneous-D_RAtkZz.js.map → miscellaneous-DvVSM5KJ.js.map} +1 -1
- package/dist/cjs/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.peculiar-ssh-certificate-viewer.entry.cjs.js.map +1 -0
- package/dist/cjs/{peculiar-attribute-certificate-viewer_4.cjs.entry.js → peculiar-attribute-certificate-viewer_5.cjs.entry.js} +197 -44
- package/dist/{peculiar/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.entry.esm.js.map → cjs/peculiar-attribute-certificate-viewer_5.cjs.entry.js.map} +1 -1
- package/dist/cjs/peculiar-certificate-decoder.cjs.entry.js +25 -21
- package/dist/cjs/peculiar-certificate-decoder.cjs.entry.js.map +1 -1
- package/dist/cjs/peculiar-certificate-decoder.entry.cjs.js.map +1 -1
- package/dist/cjs/peculiar-certificate-viewer.cjs.entry.js +4 -4
- package/dist/cjs/peculiar-certificates-viewer.cjs.entry.js +23 -23
- package/dist/cjs/peculiar-certificates-viewer.cjs.entry.js.map +1 -1
- package/dist/cjs/peculiar-certificates-viewer.entry.cjs.js.map +1 -1
- package/dist/cjs/peculiar.cjs.js +1 -1
- package/dist/cjs/pkcs10_certificate_request-BoHhadiA.js +146 -0
- package/dist/cjs/{pkcs10_certificate_request-BQkkkT42.js.map → pkcs10_certificate_request-BoHhadiA.js.map} +1 -1
- package/dist/cjs/{certification_request-DISQwgjn.js → ssh_certificate-s3-rwdMT.js} +1664 -16
- package/dist/cjs/ssh_certificate-s3-rwdMT.js.map +1 -0
- package/dist/cjs/{x509_certificate-DGRpZGA2.js → x509_certificate-DfXuxxZp.js} +29 -29
- package/dist/cjs/{x509_certificate-DGRpZGA2.js.map → x509_certificate-DfXuxxZp.js.map} +1 -1
- package/dist/cjs/{x509_crl-DMvJk_81.js → x509_crl-CxJ2lyGX.js} +32 -32
- package/dist/cjs/{x509_crl-DMvJk_81.js.map → x509_crl-CxJ2lyGX.js.map} +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/certificate-decoder/certificate-decoder.js +10 -6
- package/dist/collection/components/certificate-decoder/certificate-decoder.js.map +1 -1
- package/dist/collection/components/ssh-certificate-viewer/-components/basic_information.js +29 -0
- package/dist/collection/components/ssh-certificate-viewer/-components/basic_information.js.map +1 -0
- package/dist/collection/components/ssh-certificate-viewer/-components/public_key.js +26 -0
- package/dist/collection/components/ssh-certificate-viewer/-components/public_key.js.map +1 -0
- package/dist/collection/components/ssh-certificate-viewer/-components/signature_key.js +26 -0
- package/dist/collection/components/ssh-certificate-viewer/-components/signature_key.js.map +1 -0
- package/dist/collection/components/ssh-certificate-viewer/ssh-certificate-viewer.js +193 -0
- package/dist/collection/components/ssh-certificate-viewer/ssh-certificate-viewer.js.map +1 -0
- package/dist/collection/crypto/index.js +1 -0
- package/dist/collection/crypto/index.js.map +1 -1
- package/dist/collection/crypto/ssh_certificate.js +68 -0
- package/dist/collection/crypto/ssh_certificate.js.map +1 -0
- package/dist/collection/locales/en.json +5 -1
- package/dist/esm/{extension-CUOKUt7o.js → extension-oK2qpCU6.js} +3 -3
- package/dist/{esm-es5/extension-CUOKUt7o.js.map → esm/extension-oK2qpCU6.js.map} +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{miscellaneous-DVlekgVM.js → miscellaneous-DrmTXljc.js} +4 -4
- package/dist/esm/{miscellaneous-DVlekgVM.js.map → miscellaneous-DrmTXljc.js.map} +1 -1
- package/dist/esm/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.peculiar-ssh-certificate-viewer.entry.js.map +1 -0
- package/dist/esm/{peculiar-attribute-certificate-viewer_4.entry.js → peculiar-attribute-certificate-viewer_5.entry.js} +166 -14
- package/dist/esm/peculiar-attribute-certificate-viewer_5.entry.js.map +1 -0
- package/dist/esm/peculiar-certificate-decoder.entry.js +14 -10
- package/dist/esm/peculiar-certificate-decoder.entry.js.map +1 -1
- package/dist/esm/peculiar-certificate-viewer.entry.js +4 -4
- package/dist/esm/peculiar-certificates-viewer.entry.js +3 -3
- package/dist/esm/peculiar.js +1 -1
- package/dist/esm/{pkcs10_certificate_request-B9Q42jiE.js → pkcs10_certificate_request-Bdt_qA_g.js} +3 -3
- package/dist/esm/{pkcs10_certificate_request-B9Q42jiE.js.map → pkcs10_certificate_request-Bdt_qA_g.js.map} +1 -1
- package/dist/esm/{certification_request-CSS3OhZq.js → ssh_certificate-Ct-r021h.js} +1664 -17
- package/dist/esm/ssh_certificate-Ct-r021h.js.map +1 -0
- package/dist/esm/{x509_certificate-fWXLCtc8.js → x509_certificate-5DEbrOA7.js} +4 -4
- package/dist/esm/{x509_certificate-fWXLCtc8.js.map → x509_certificate-5DEbrOA7.js.map} +1 -1
- package/dist/esm/{x509_crl-Dq33Vv-q.js → x509_crl-CPgNUkh7.js} +5 -5
- package/dist/esm/{x509_crl-Dq33Vv-q.js.map → x509_crl-CPgNUkh7.js.map} +1 -1
- package/dist/esm-es5/{extension-CUOKUt7o.js → extension-oK2qpCU6.js} +2 -2
- package/dist/{esm/extension-CUOKUt7o.js.map → esm-es5/extension-oK2qpCU6.js.map} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/loader.js +2 -2
- package/dist/esm-es5/{miscellaneous-DVlekgVM.js → miscellaneous-DrmTXljc.js} +2 -2
- package/dist/esm-es5/{miscellaneous-DVlekgVM.js.map → miscellaneous-DrmTXljc.js.map} +1 -1
- package/dist/esm-es5/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.peculiar-ssh-certificate-viewer.entry.js.map +1 -0
- package/dist/esm-es5/{peculiar-attribute-certificate-viewer_4.entry.js → peculiar-attribute-certificate-viewer_5.entry.js} +24 -3
- package/dist/esm-es5/peculiar-attribute-certificate-viewer_5.entry.js.map +1 -0
- package/dist/esm-es5/peculiar-certificate-decoder.entry.js +1 -1
- package/dist/esm-es5/peculiar-certificate-decoder.entry.js.map +1 -1
- package/dist/esm-es5/peculiar-certificate-viewer.entry.js +1 -1
- package/dist/esm-es5/peculiar-certificates-viewer.entry.js +1 -1
- package/dist/esm-es5/peculiar.js +1 -1
- package/dist/esm-es5/{pkcs10_certificate_request-B9Q42jiE.js → pkcs10_certificate_request-Bdt_qA_g.js} +2 -2
- package/dist/esm-es5/{pkcs10_certificate_request-B9Q42jiE.js.map → pkcs10_certificate_request-Bdt_qA_g.js.map} +1 -1
- package/dist/esm-es5/{certification_request-CSS3OhZq.js → ssh_certificate-Ct-r021h.js} +7 -7
- package/dist/{peculiar/p-D_WeukQa.system.js.map → esm-es5/ssh_certificate-Ct-r021h.js.map} +1 -1
- package/dist/esm-es5/{x509_certificate-fWXLCtc8.js → x509_certificate-5DEbrOA7.js} +2 -2
- package/dist/esm-es5/{x509_certificate-fWXLCtc8.js.map → x509_certificate-5DEbrOA7.js.map} +1 -1
- package/dist/esm-es5/{x509_crl-Dq33Vv-q.js → x509_crl-CPgNUkh7.js} +2 -2
- package/dist/esm-es5/{x509_crl-Dq33Vv-q.js.map → x509_crl-CPgNUkh7.js.map} +1 -1
- package/dist/peculiar/index.esm.js +1 -1
- package/dist/peculiar/locales/en.json +5 -1
- package/dist/peculiar/{p-4cc72a56.entry.js → p-0b895a8e.entry.js} +2 -2
- package/dist/peculiar/{p-a193f8fd.system.entry.js → p-11434880.system.entry.js} +2 -2
- package/dist/peculiar/{p-DTz3NA_M.system.js → p-2GQYAR0v.system.js} +2 -2
- package/dist/peculiar/{p-DTz3NA_M.system.js.map → p-2GQYAR0v.system.js.map} +1 -1
- package/dist/peculiar/{p-17ebc78c.system.entry.js → p-364fd32b.system.entry.js} +2 -2
- package/dist/peculiar/{p-e7c60082.system.entry.js → p-5df0f22b.system.entry.js} +40 -19
- package/dist/{esm-es5/peculiar-attribute-certificate-viewer_4.entry.js.map → peculiar/p-5df0f22b.system.entry.js.map} +1 -1
- package/dist/peculiar/{p-a4e74904.entry.js → p-62b723f6.entry.js} +40 -19
- package/dist/peculiar/p-62b723f6.entry.js.map +1 -0
- package/dist/peculiar/{p-e3967e76.entry.js → p-83a53b4f.entry.js} +2 -2
- package/dist/peculiar/{p-DKooqn40.js → p-B2G7qjfV.js} +10 -10
- package/dist/peculiar/{p-DKooqn40.js.map → p-B2G7qjfV.js.map} +1 -1
- package/dist/peculiar/{p-D8TC0Na9.system.js.map → p-BCsPspKr.system.js.map} +1 -1
- package/dist/peculiar/p-BGASC3UX.system.js +1 -1
- package/dist/peculiar/p-BGIWeG8l.js +12 -0
- package/dist/peculiar/{p-CZuaTO2G.js.map → p-BGIWeG8l.js.map} +1 -1
- package/dist/peculiar/{p-CEzxVCEh.system.js → p-BQiABBi1.system.js} +4 -4
- package/dist/peculiar/{p-CEzxVCEh.system.js.map → p-BQiABBi1.system.js.map} +1 -1
- package/dist/peculiar/{p-DcTXA-2R.system.js → p-BeVuAzsd.system.js} +39 -39
- package/dist/peculiar/{p-DcTXA-2R.system.js.map → p-BeVuAzsd.system.js.map} +1 -1
- package/dist/peculiar/{p-BTn-wukS.system.js → p-C31rbtuG.system.js} +2 -2
- package/dist/peculiar/p-C31rbtuG.system.js.map +1 -0
- package/dist/peculiar/p-Ce-IF7_R.system.js.map +1 -0
- package/dist/peculiar/p-ClkgAXnd.system.js +135 -0
- package/dist/peculiar/{p-CSS3OhZq.js.map → p-ClkgAXnd.system.js.map} +1 -1
- package/dist/peculiar/{p-CSS3OhZq.js → p-Ct-r021h.js} +12 -12
- package/dist/peculiar/p-Ct-r021h.js.map +1 -0
- package/dist/peculiar/{p-Bsy7Sqzl.system.js.map → p-CxtUQdcj.system.js.map} +1 -1
- package/dist/peculiar/{p-tl0v45Y7.js → p-D9qq15zG.js} +2 -2
- package/dist/peculiar/{p-tl0v45Y7.js.map → p-D9qq15zG.js.map} +1 -1
- package/dist/peculiar/{p-BG_D4qzJ.js → p-DOpiv0-8.js} +3 -3
- package/dist/peculiar/{p-BG_D4qzJ.js.map → p-DOpiv0-8.js.map} +1 -1
- package/dist/peculiar/p-IOtHTzYC.system.js +12 -0
- package/dist/peculiar/{p-CgCUixvk.system.js.map → p-IOtHTzYC.system.js.map} +1 -1
- package/dist/peculiar/p-LmKU8Smy.system.js.map +1 -0
- package/dist/peculiar/{p-CoPYW15U.js → p-RWPI76Dh.js} +4 -4
- package/dist/peculiar/{p-CoPYW15U.js.map → p-RWPI76Dh.js.map} +1 -1
- package/dist/peculiar/p-da9eb1e7.entry.js +5 -0
- package/dist/peculiar/p-da9eb1e7.entry.js.map +1 -0
- package/dist/peculiar/p-fd98bb82.system.entry.js +5 -0
- package/dist/peculiar/p-fd98bb82.system.entry.js.map +1 -0
- package/dist/peculiar/p-zQwWLfga.system.js +19 -0
- package/dist/peculiar/{p-7fTYvx_V.system.js.map → p-zQwWLfga.system.js.map} +1 -1
- package/dist/peculiar/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.peculiar-ssh-certificate-viewer.entry.esm.js.map +1 -0
- package/dist/peculiar/peculiar-certificate-decoder.entry.esm.js.map +1 -1
- package/dist/peculiar/peculiar.esm.js +1 -1
- package/dist/types/components/certificate-decoder/certificate-decoder.d.ts +4 -4
- package/dist/types/components/ssh-certificate-viewer/-components/basic_information.d.ts +21 -0
- package/dist/types/components/ssh-certificate-viewer/-components/public_key.d.ts +14 -0
- package/dist/types/components/ssh-certificate-viewer/-components/signature_key.d.ts +14 -0
- package/dist/types/components/ssh-certificate-viewer/ssh-certificate-viewer.d.ts +43 -0
- package/dist/types/components.d.ts +43 -0
- package/dist/types/crypto/index.d.ts +1 -0
- package/dist/types/crypto/ssh_certificate.d.ts +28 -0
- package/dist/types/utils/l10n.d.ts +4 -0
- package/hydrate/index.js +1840 -27
- package/hydrate/index.mjs +1840 -27
- package/package.json +3 -2
- package/dist/cjs/certification_request-DISQwgjn.js.map +0 -1
- package/dist/cjs/extension-CGZpfI3W.js +0 -110
- package/dist/cjs/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.entry.cjs.js.map +0 -1
- package/dist/cjs/peculiar-attribute-certificate-viewer_4.cjs.entry.js.map +0 -1
- package/dist/cjs/pkcs10_certificate_request-BQkkkT42.js +0 -146
- package/dist/esm/certification_request-CSS3OhZq.js.map +0 -1
- package/dist/esm/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.entry.js.map +0 -1
- package/dist/esm/peculiar-attribute-certificate-viewer_4.entry.js.map +0 -1
- package/dist/esm-es5/certification_request-CSS3OhZq.js.map +0 -1
- package/dist/esm-es5/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.entry.js.map +0 -1
- package/dist/peculiar/p-7fTYvx_V.system.js +0 -19
- package/dist/peculiar/p-BTn-wukS.system.js.map +0 -1
- package/dist/peculiar/p-CZuaTO2G.js +0 -12
- package/dist/peculiar/p-CgCUixvk.system.js +0 -12
- package/dist/peculiar/p-DLsQGkmT.system.js.map +0 -1
- package/dist/peculiar/p-D_WeukQa.system.js +0 -135
- package/dist/peculiar/p-a4e74904.entry.js.map +0 -1
- package/dist/peculiar/p-ce006f1c.system.entry.js +0 -5
- package/dist/peculiar/p-ce006f1c.system.entry.js.map +0 -1
- package/dist/peculiar/p-e7c60082.system.entry.js.map +0 -1
- package/dist/peculiar/p-f465afe6.entry.js +0 -5
- package/dist/peculiar/p-f465afe6.entry.js.map +0 -1
- package/dist/peculiar/p-tBL0ekYY.system.js.map +0 -1
- /package/dist/peculiar/{p-4cc72a56.entry.js.map → p-0b895a8e.entry.js.map} +0 -0
- /package/dist/peculiar/{p-a193f8fd.system.entry.js.map → p-11434880.system.entry.js.map} +0 -0
- /package/dist/peculiar/{p-17ebc78c.system.entry.js.map → p-364fd32b.system.entry.js.map} +0 -0
- /package/dist/peculiar/{p-e3967e76.entry.js.map → p-83a53b4f.entry.js.map} +0 -0
|
@@ -6767,6 +6767,10 @@ const crlEntryExtensions = "CRL Entry Extensions";
|
|
|
6767
6767
|
const previewCertificate = "Preview certificate";
|
|
6768
6768
|
const viewDetails = "View details";
|
|
6769
6769
|
const downloadOptions = "Download options";
|
|
6770
|
+
const keyId = "Key ID";
|
|
6771
|
+
const principals = "Principals";
|
|
6772
|
+
const criticalOptions = "Critical Options";
|
|
6773
|
+
const signingCA = "Signing CA";
|
|
6770
6774
|
var en = {
|
|
6771
6775
|
basicInformation: basicInformation,
|
|
6772
6776
|
subjectName: subjectName,
|
|
@@ -6814,7 +6818,11 @@ var en = {
|
|
|
6814
6818
|
crlEntryExtensions: crlEntryExtensions,
|
|
6815
6819
|
previewCertificate: previewCertificate,
|
|
6816
6820
|
viewDetails: viewDetails,
|
|
6817
|
-
downloadOptions: downloadOptions
|
|
6821
|
+
downloadOptions: downloadOptions,
|
|
6822
|
+
keyId: keyId,
|
|
6823
|
+
principals: principals,
|
|
6824
|
+
criticalOptions: criticalOptions,
|
|
6825
|
+
signingCA: signingCA
|
|
6818
6826
|
};
|
|
6819
6827
|
|
|
6820
6828
|
/**
|
|
@@ -9234,13 +9242,13 @@ const OIDs = {
|
|
|
9234
9242
|
* This source code is licensed under the MIT license found in the
|
|
9235
9243
|
* LICENSE file in the root directory of this source tree.
|
|
9236
9244
|
*/
|
|
9237
|
-
var __classPrivateFieldSet$
|
|
9245
|
+
var __classPrivateFieldSet$2 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
9238
9246
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9239
9247
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9240
9248
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
9241
9249
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
9242
9250
|
};
|
|
9243
|
-
var __classPrivateFieldGet$
|
|
9251
|
+
var __classPrivateFieldGet$2 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9244
9252
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9245
9253
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
9246
9254
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -9250,15 +9258,15 @@ class Name {
|
|
|
9250
9258
|
constructor(data) {
|
|
9251
9259
|
_Name_asn.set(this, new exports.Name$1());
|
|
9252
9260
|
if (buildExports.BufferSourceConverter.isBufferSource(data)) {
|
|
9253
|
-
__classPrivateFieldSet$
|
|
9261
|
+
__classPrivateFieldSet$2(this, _Name_asn, AsnParser.parse(data, exports.Name$1), "f");
|
|
9254
9262
|
}
|
|
9255
9263
|
else {
|
|
9256
|
-
__classPrivateFieldSet$
|
|
9264
|
+
__classPrivateFieldSet$2(this, _Name_asn, data, "f");
|
|
9257
9265
|
}
|
|
9258
9266
|
}
|
|
9259
9267
|
toJSON() {
|
|
9260
9268
|
const res = [];
|
|
9261
|
-
__classPrivateFieldGet$
|
|
9269
|
+
__classPrivateFieldGet$2(this, _Name_asn, "f").forEach((o) => (o.forEach((a) => {
|
|
9262
9270
|
res.push({
|
|
9263
9271
|
type: a.type,
|
|
9264
9272
|
name: OIDs[a.type],
|
|
@@ -10799,13 +10807,13 @@ __decorate([
|
|
|
10799
10807
|
* This source code is licensed under the MIT license found in the
|
|
10800
10808
|
* LICENSE file in the root directory of this source tree.
|
|
10801
10809
|
*/
|
|
10802
|
-
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
10810
|
+
var __classPrivateFieldSet$1 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
10803
10811
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
10804
10812
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10805
10813
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10806
10814
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
10807
10815
|
};
|
|
10808
|
-
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
10816
|
+
var __classPrivateFieldGet$1 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
10809
10817
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10810
10818
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10811
10819
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -10818,20 +10826,20 @@ class AsnData {
|
|
|
10818
10826
|
_AsnData_raw.set(this, void 0);
|
|
10819
10827
|
if (args.length === 1) {
|
|
10820
10828
|
// asn
|
|
10821
|
-
__classPrivateFieldSet(this, _AsnData_asn, args[0], "f");
|
|
10822
|
-
__classPrivateFieldSet(this, _AsnData_raw, AsnConvert.serialize(__classPrivateFieldGet(this, _AsnData_asn, "f")), "f");
|
|
10829
|
+
__classPrivateFieldSet$1(this, _AsnData_asn, args[0], "f");
|
|
10830
|
+
__classPrivateFieldSet$1(this, _AsnData_raw, AsnConvert.serialize(__classPrivateFieldGet$1(this, _AsnData_asn, "f")), "f");
|
|
10823
10831
|
}
|
|
10824
10832
|
else {
|
|
10825
10833
|
// raw, type
|
|
10826
|
-
__classPrivateFieldSet(this, _AsnData_asn, AsnConvert.parse(args[0], args[1]), "f");
|
|
10827
|
-
__classPrivateFieldSet(this, _AsnData_raw, buildExports.BufferSourceConverter.toArrayBuffer(args[0]), "f");
|
|
10834
|
+
__classPrivateFieldSet$1(this, _AsnData_asn, AsnConvert.parse(args[0], args[1]), "f");
|
|
10835
|
+
__classPrivateFieldSet$1(this, _AsnData_raw, buildExports.BufferSourceConverter.toArrayBuffer(args[0]), "f");
|
|
10828
10836
|
}
|
|
10829
10837
|
}
|
|
10830
10838
|
get asn() {
|
|
10831
|
-
return __classPrivateFieldGet(this, _AsnData_asn, "f");
|
|
10839
|
+
return __classPrivateFieldGet$1(this, _AsnData_asn, "f");
|
|
10832
10840
|
}
|
|
10833
10841
|
get raw() {
|
|
10834
|
-
return __classPrivateFieldGet(this, _AsnData_raw, "f");
|
|
10842
|
+
return __classPrivateFieldGet$1(this, _AsnData_raw, "f");
|
|
10835
10843
|
}
|
|
10836
10844
|
}
|
|
10837
10845
|
_AsnData_asn = new WeakMap(), _AsnData_raw = new WeakMap();
|
|
@@ -12697,6 +12705,1645 @@ __decorate$1([
|
|
|
12697
12705
|
AsnProp({ type: exports.AsnPropTypes.BitString })
|
|
12698
12706
|
], CertificationRequest.prototype, "signature", void 0);
|
|
12699
12707
|
|
|
12708
|
+
let globalCrypto = globalThis.crypto;
|
|
12709
|
+
function getCrypto() {
|
|
12710
|
+
return globalCrypto;
|
|
12711
|
+
}
|
|
12712
|
+
|
|
12713
|
+
class SshError extends Error {
|
|
12714
|
+
code;
|
|
12715
|
+
constructor(message, code) {
|
|
12716
|
+
super(message);
|
|
12717
|
+
this.code = code;
|
|
12718
|
+
this.name = this.constructor.name;
|
|
12719
|
+
if (Error.captureStackTrace) {
|
|
12720
|
+
Error.captureStackTrace(this, this.constructor);
|
|
12721
|
+
}
|
|
12722
|
+
}
|
|
12723
|
+
}
|
|
12724
|
+
class UnsupportedAlgorithmError extends SshError {
|
|
12725
|
+
constructor(algorithm, supportedAlgorithms) {
|
|
12726
|
+
const supported = supportedAlgorithms ? ` Supported: ${supportedAlgorithms.join(', ')}` : '';
|
|
12727
|
+
super(`Unsupported algorithm: ${algorithm}.${supported}`, 'UNSUPPORTED_ALGORITHM');
|
|
12728
|
+
}
|
|
12729
|
+
}
|
|
12730
|
+
class InvalidFormatError extends SshError {
|
|
12731
|
+
constructor(format, expectedFormat) {
|
|
12732
|
+
const expected = expectedFormat ? ` Expected: ${expectedFormat}` : '';
|
|
12733
|
+
super(`Invalid format: ${format}.${expected}`, 'INVALID_FORMAT');
|
|
12734
|
+
}
|
|
12735
|
+
}
|
|
12736
|
+
class UnsupportedKeyTypeError extends SshError {
|
|
12737
|
+
constructor(keyType, supportedTypes) {
|
|
12738
|
+
const supported = supportedTypes ? ` Supported: ${supportedTypes.join(', ')}` : '';
|
|
12739
|
+
super(`Unsupported key type: ${keyType}.${supported}`, 'UNSUPPORTED_KEY_TYPE');
|
|
12740
|
+
}
|
|
12741
|
+
}
|
|
12742
|
+
class InvalidPrivateKeyFormatError extends SshError {
|
|
12743
|
+
constructor(details) {
|
|
12744
|
+
const message = details
|
|
12745
|
+
? `Invalid SSH private key format: ${details}`
|
|
12746
|
+
: 'Invalid SSH private key format';
|
|
12747
|
+
super(message, 'INVALID_PRIVATE_KEY_FORMAT');
|
|
12748
|
+
}
|
|
12749
|
+
}
|
|
12750
|
+
class EncryptedKeyNotSupportedError extends SshError {
|
|
12751
|
+
constructor(cipher) {
|
|
12752
|
+
const message = cipher
|
|
12753
|
+
? `Encrypted SSH private keys are not supported (cipher: ${cipher})`
|
|
12754
|
+
: 'Encrypted SSH private keys are not supported';
|
|
12755
|
+
super(message, 'ENCRYPTED_KEY_NOT_SUPPORTED');
|
|
12756
|
+
}
|
|
12757
|
+
}
|
|
12758
|
+
class InvalidKeyDataError extends SshError {
|
|
12759
|
+
constructor(details) {
|
|
12760
|
+
const message = details ? `Invalid key data: ${details}` : 'Invalid key data';
|
|
12761
|
+
super(message, 'INVALID_KEY_DATA');
|
|
12762
|
+
}
|
|
12763
|
+
}
|
|
12764
|
+
class UnexpectedEOFError extends SshError {
|
|
12765
|
+
constructor(expected, actual) {
|
|
12766
|
+
const details = expected !== undefined && actual !== undefined
|
|
12767
|
+
? ` Expected ${expected} bytes, got ${actual}`
|
|
12768
|
+
: '';
|
|
12769
|
+
super(`Unexpected end of data${details}`, 'UNEXPECTED_EOF');
|
|
12770
|
+
}
|
|
12771
|
+
}
|
|
12772
|
+
|
|
12773
|
+
const encoder = new TextEncoder();
|
|
12774
|
+
const decoder = new TextDecoder();
|
|
12775
|
+
|
|
12776
|
+
class SshReader {
|
|
12777
|
+
buffer;
|
|
12778
|
+
offset;
|
|
12779
|
+
constructor(data) {
|
|
12780
|
+
this.buffer = data;
|
|
12781
|
+
this.offset = 0;
|
|
12782
|
+
}
|
|
12783
|
+
readUint8() {
|
|
12784
|
+
if (this.offset >= this.buffer.length) {
|
|
12785
|
+
throw new UnexpectedEOFError(1, 0);
|
|
12786
|
+
}
|
|
12787
|
+
return this.buffer[this.offset++];
|
|
12788
|
+
}
|
|
12789
|
+
readUint32() {
|
|
12790
|
+
const value = (this.readUint8() << 24) |
|
|
12791
|
+
(this.readUint8() << 16) |
|
|
12792
|
+
(this.readUint8() << 8) |
|
|
12793
|
+
this.readUint8();
|
|
12794
|
+
return value >>> 0;
|
|
12795
|
+
}
|
|
12796
|
+
readUint64() {
|
|
12797
|
+
const high = this.readUint32();
|
|
12798
|
+
const low = this.readUint32();
|
|
12799
|
+
return (BigInt(high) << 32n) | BigInt(low);
|
|
12800
|
+
}
|
|
12801
|
+
readBytes(length) {
|
|
12802
|
+
if (length < 0) {
|
|
12803
|
+
throw new InvalidFormatError(`Invalid length: ${length}`);
|
|
12804
|
+
}
|
|
12805
|
+
if (this.offset + length > this.buffer.length) {
|
|
12806
|
+
throw new UnexpectedEOFError(length, this.buffer.length - this.offset);
|
|
12807
|
+
}
|
|
12808
|
+
const result = this.buffer.subarray(this.offset, this.offset + length);
|
|
12809
|
+
this.offset += length;
|
|
12810
|
+
return result;
|
|
12811
|
+
}
|
|
12812
|
+
readString() {
|
|
12813
|
+
const length = this.readUint32();
|
|
12814
|
+
const bytes = this.readBytes(length);
|
|
12815
|
+
return decoder.decode(bytes);
|
|
12816
|
+
}
|
|
12817
|
+
peekString(length) {
|
|
12818
|
+
if (this.offset + length > this.buffer.length) {
|
|
12819
|
+
throw new UnexpectedEOFError(length, this.buffer.length - this.offset);
|
|
12820
|
+
}
|
|
12821
|
+
const bytes = this.buffer.subarray(this.offset, this.offset + length);
|
|
12822
|
+
return decoder.decode(bytes);
|
|
12823
|
+
}
|
|
12824
|
+
readMpInt(sshEncoding = false) {
|
|
12825
|
+
const length = this.readUint32();
|
|
12826
|
+
const bytes = this.readBytes(length);
|
|
12827
|
+
if (sshEncoding && bytes.length > 1 && bytes[0] === 0x00) {
|
|
12828
|
+
return bytes.subarray(1);
|
|
12829
|
+
}
|
|
12830
|
+
return bytes;
|
|
12831
|
+
}
|
|
12832
|
+
readMpIntSsh() {
|
|
12833
|
+
return this.readMpInt(true);
|
|
12834
|
+
}
|
|
12835
|
+
remaining() {
|
|
12836
|
+
return this.buffer.length - this.offset;
|
|
12837
|
+
}
|
|
12838
|
+
getOffset() {
|
|
12839
|
+
return this.offset;
|
|
12840
|
+
}
|
|
12841
|
+
seek(offset) {
|
|
12842
|
+
if (offset < 0 || offset > this.buffer.length) {
|
|
12843
|
+
throw new InvalidFormatError(`Invalid offset: ${offset}. Buffer length: ${this.buffer.length}`);
|
|
12844
|
+
}
|
|
12845
|
+
this.offset = offset;
|
|
12846
|
+
}
|
|
12847
|
+
}
|
|
12848
|
+
|
|
12849
|
+
class SshWriter {
|
|
12850
|
+
buffer;
|
|
12851
|
+
offset;
|
|
12852
|
+
constructor(initialSize = 1024) {
|
|
12853
|
+
this.buffer = new Uint8Array(initialSize);
|
|
12854
|
+
this.offset = 0;
|
|
12855
|
+
}
|
|
12856
|
+
ensureCapacity(additional) {
|
|
12857
|
+
const required = this.offset + additional;
|
|
12858
|
+
if (required > this.buffer.length) {
|
|
12859
|
+
const newSize = Math.max(required, this.buffer.length * 2);
|
|
12860
|
+
const newBuffer = new Uint8Array(newSize);
|
|
12861
|
+
newBuffer.set(this.buffer.subarray(0, this.offset));
|
|
12862
|
+
this.buffer = newBuffer;
|
|
12863
|
+
}
|
|
12864
|
+
}
|
|
12865
|
+
reserve(minCapacity) {
|
|
12866
|
+
if (minCapacity > this.buffer.length) {
|
|
12867
|
+
const newBuffer = new Uint8Array(minCapacity);
|
|
12868
|
+
newBuffer.set(this.buffer.subarray(0, this.offset));
|
|
12869
|
+
this.buffer = newBuffer;
|
|
12870
|
+
}
|
|
12871
|
+
}
|
|
12872
|
+
writeUint8(value) {
|
|
12873
|
+
this.ensureCapacity(1);
|
|
12874
|
+
this.buffer[this.offset++] = value & 0xff;
|
|
12875
|
+
}
|
|
12876
|
+
writeUint32(value) {
|
|
12877
|
+
this.ensureCapacity(4);
|
|
12878
|
+
this.buffer[this.offset++] = (value >>> 24) & 0xff;
|
|
12879
|
+
this.buffer[this.offset++] = (value >>> 16) & 0xff;
|
|
12880
|
+
this.buffer[this.offset++] = (value >>> 8) & 0xff;
|
|
12881
|
+
this.buffer[this.offset++] = value & 0xff;
|
|
12882
|
+
}
|
|
12883
|
+
writeUint64(value) {
|
|
12884
|
+
this.ensureCapacity(8);
|
|
12885
|
+
const high = Number(value >> 32n);
|
|
12886
|
+
const low = Number(value & 0xffffffffn);
|
|
12887
|
+
this.writeUint32(high);
|
|
12888
|
+
this.writeUint32(low);
|
|
12889
|
+
}
|
|
12890
|
+
writeBytes(data) {
|
|
12891
|
+
this.ensureCapacity(data.length);
|
|
12892
|
+
this.buffer.set(data, this.offset);
|
|
12893
|
+
this.offset += data.length;
|
|
12894
|
+
}
|
|
12895
|
+
writeString(value) {
|
|
12896
|
+
const bytes = encoder.encode(value);
|
|
12897
|
+
this.writeUint32(bytes.length);
|
|
12898
|
+
this.writeBytes(bytes);
|
|
12899
|
+
}
|
|
12900
|
+
writeMpInt(value, sshEncoding = false) {
|
|
12901
|
+
if (sshEncoding && value.length > 0 && (value[0] & 0x80) !== 0) {
|
|
12902
|
+
const paddedBytes = new Uint8Array(value.length + 1);
|
|
12903
|
+
paddedBytes[0] = 0x00;
|
|
12904
|
+
paddedBytes.set(value, 1);
|
|
12905
|
+
this.writeUint32(paddedBytes.length);
|
|
12906
|
+
this.writeBytes(paddedBytes);
|
|
12907
|
+
}
|
|
12908
|
+
else {
|
|
12909
|
+
this.writeUint32(value.length);
|
|
12910
|
+
this.writeBytes(value);
|
|
12911
|
+
}
|
|
12912
|
+
}
|
|
12913
|
+
writeMpIntSsh(value) {
|
|
12914
|
+
this.writeMpInt(value, true);
|
|
12915
|
+
}
|
|
12916
|
+
toUint8Array() {
|
|
12917
|
+
return this.buffer.subarray(0, this.offset);
|
|
12918
|
+
}
|
|
12919
|
+
getOffset() {
|
|
12920
|
+
return this.offset;
|
|
12921
|
+
}
|
|
12922
|
+
seek(offset) {
|
|
12923
|
+
if (offset < 0 || offset > this.buffer.length) {
|
|
12924
|
+
throw new InvalidFormatError('Invalid offset');
|
|
12925
|
+
}
|
|
12926
|
+
this.offset = offset;
|
|
12927
|
+
}
|
|
12928
|
+
}
|
|
12929
|
+
|
|
12930
|
+
class RsaBinding {
|
|
12931
|
+
hash = 'SHA-256';
|
|
12932
|
+
constructor(hash = 'SHA-256') {
|
|
12933
|
+
this.hash = hash;
|
|
12934
|
+
}
|
|
12935
|
+
async importPublicSsh(params) {
|
|
12936
|
+
const { blob, crypto } = params;
|
|
12937
|
+
const reader = new SshReader(blob);
|
|
12938
|
+
reader.readString();
|
|
12939
|
+
const e = reader.readMpInt(true);
|
|
12940
|
+
const n = reader.readMpInt(true);
|
|
12941
|
+
const jwk = {
|
|
12942
|
+
kty: 'RSA',
|
|
12943
|
+
n: buildExports.Convert.ToBase64Url(n),
|
|
12944
|
+
e: buildExports.Convert.ToBase64Url(e),
|
|
12945
|
+
};
|
|
12946
|
+
return crypto.subtle.importKey('jwk', jwk, {
|
|
12947
|
+
name: 'RSASSA-PKCS1-v1_5',
|
|
12948
|
+
hash: this.hash,
|
|
12949
|
+
}, true, ['verify']);
|
|
12950
|
+
}
|
|
12951
|
+
async exportPublicSsh(params) {
|
|
12952
|
+
const { publicKey, crypto } = params;
|
|
12953
|
+
const jwk = await crypto.subtle.exportKey('jwk', publicKey);
|
|
12954
|
+
if (!jwk.n || !jwk.e) {
|
|
12955
|
+
throw new InvalidKeyDataError('RSA JWK missing required parameters (n, e)');
|
|
12956
|
+
}
|
|
12957
|
+
const n = buildExports.BufferSourceConverter.toUint8Array(buildExports.Convert.FromBase64Url(jwk.n));
|
|
12958
|
+
const e = buildExports.BufferSourceConverter.toUint8Array(buildExports.Convert.FromBase64Url(jwk.e));
|
|
12959
|
+
const writer = new SshWriter();
|
|
12960
|
+
writer.writeString('ssh-rsa');
|
|
12961
|
+
writer.writeMpInt(e, true);
|
|
12962
|
+
writer.writeMpInt(n, true);
|
|
12963
|
+
return writer.toUint8Array();
|
|
12964
|
+
}
|
|
12965
|
+
async importPublicSpki(params) {
|
|
12966
|
+
const { spki, crypto } = params;
|
|
12967
|
+
return crypto.subtle.importKey('spki', spki, {
|
|
12968
|
+
name: 'RSASSA-PKCS1-v1_5',
|
|
12969
|
+
hash: this.hash,
|
|
12970
|
+
}, true, ['verify']);
|
|
12971
|
+
}
|
|
12972
|
+
async exportPublicSpki(params) {
|
|
12973
|
+
const { publicKey, crypto } = params;
|
|
12974
|
+
const spki = await crypto.subtle.exportKey('spki', publicKey);
|
|
12975
|
+
return buildExports.BufferSourceConverter.toUint8Array(spki);
|
|
12976
|
+
}
|
|
12977
|
+
async importPrivatePkcs8(params) {
|
|
12978
|
+
const { pkcs8, crypto } = params;
|
|
12979
|
+
return crypto.subtle.importKey('pkcs8', pkcs8, {
|
|
12980
|
+
name: 'RSASSA-PKCS1-v1_5',
|
|
12981
|
+
hash: this.hash,
|
|
12982
|
+
}, true, ['sign']);
|
|
12983
|
+
}
|
|
12984
|
+
async exportPrivatePkcs8(params) {
|
|
12985
|
+
const { privateKey, crypto } = params;
|
|
12986
|
+
const pkcs8 = await crypto.subtle.exportKey('pkcs8', privateKey);
|
|
12987
|
+
return buildExports.BufferSourceConverter.toUint8Array(pkcs8);
|
|
12988
|
+
}
|
|
12989
|
+
async importPrivateSsh(params) {
|
|
12990
|
+
const { sshKey, crypto } = params;
|
|
12991
|
+
const base64Data = sshKey
|
|
12992
|
+
.replace(/-----BEGIN OPENSSH PRIVATE KEY-----/, '')
|
|
12993
|
+
.replace(/-----END OPENSSH PRIVATE KEY-----/, '')
|
|
12994
|
+
.replace(/\s/g, '');
|
|
12995
|
+
const binaryData = buildExports.Convert.FromBase64(base64Data);
|
|
12996
|
+
const reader = new SshReader(buildExports.BufferSourceConverter.toUint8Array(binaryData));
|
|
12997
|
+
const magic = reader.readBytes(15);
|
|
12998
|
+
if (buildExports.Convert.ToHex(magic) !== '6f70656e7373682d6b65792d763100') {
|
|
12999
|
+
throw new InvalidPrivateKeyFormatError('invalid magic string');
|
|
13000
|
+
}
|
|
13001
|
+
const _cipherName = reader.readString();
|
|
13002
|
+
reader.readString();
|
|
13003
|
+
reader.readString();
|
|
13004
|
+
if (_cipherName !== 'none') {
|
|
13005
|
+
throw new EncryptedKeyNotSupportedError(_cipherName);
|
|
13006
|
+
}
|
|
13007
|
+
const numKeys = reader.readUint32();
|
|
13008
|
+
if (numKeys !== 1) {
|
|
13009
|
+
throw new InvalidPrivateKeyFormatError('multiple keys not supported');
|
|
13010
|
+
}
|
|
13011
|
+
const publicKeyLength = reader.readUint32();
|
|
13012
|
+
reader.readBytes(publicKeyLength);
|
|
13013
|
+
const privateKeyLength = reader.readUint32();
|
|
13014
|
+
const privateKeyData = reader.readBytes(privateKeyLength);
|
|
13015
|
+
const privateReader = new SshReader(privateKeyData);
|
|
13016
|
+
const checkint1 = privateReader.readUint32();
|
|
13017
|
+
const checkint2 = privateReader.readUint32();
|
|
13018
|
+
if (checkint1 !== checkint2) {
|
|
13019
|
+
throw new InvalidPrivateKeyFormatError('invalid checkints');
|
|
13020
|
+
}
|
|
13021
|
+
privateReader.readString();
|
|
13022
|
+
const n = privateReader.readMpInt(true);
|
|
13023
|
+
const e = privateReader.readMpInt(true);
|
|
13024
|
+
const d = privateReader.readMpInt(true);
|
|
13025
|
+
const iqmp = privateReader.readMpInt(true);
|
|
13026
|
+
const p = privateReader.readMpInt(true);
|
|
13027
|
+
const q = privateReader.readMpInt(true);
|
|
13028
|
+
privateReader.readString();
|
|
13029
|
+
const dBig = BigInt('0x' + buildExports.Convert.ToHex(d));
|
|
13030
|
+
const pBig = BigInt('0x' + buildExports.Convert.ToHex(p));
|
|
13031
|
+
const qBig = BigInt('0x' + buildExports.Convert.ToHex(q));
|
|
13032
|
+
const dpBig = dBig % (pBig - 1n);
|
|
13033
|
+
const dqBig = dBig % (qBig - 1n);
|
|
13034
|
+
const dpBytes = buildExports.Convert.FromHex(dpBig.toString(16).padStart(p.length * 2, '0'));
|
|
13035
|
+
const dqBytes = buildExports.Convert.FromHex(dqBig.toString(16).padStart(q.length * 2, '0'));
|
|
13036
|
+
const jwk = {
|
|
13037
|
+
kty: 'RSA',
|
|
13038
|
+
n: buildExports.Convert.ToBase64Url(n),
|
|
13039
|
+
e: buildExports.Convert.ToBase64Url(e),
|
|
13040
|
+
d: buildExports.Convert.ToBase64Url(d),
|
|
13041
|
+
p: buildExports.Convert.ToBase64Url(p),
|
|
13042
|
+
q: buildExports.Convert.ToBase64Url(q),
|
|
13043
|
+
dp: buildExports.Convert.ToBase64Url(dpBytes),
|
|
13044
|
+
dq: buildExports.Convert.ToBase64Url(dqBytes),
|
|
13045
|
+
qi: buildExports.Convert.ToBase64Url(iqmp),
|
|
13046
|
+
};
|
|
13047
|
+
return crypto.subtle.importKey('jwk', jwk, {
|
|
13048
|
+
name: 'RSASSA-PKCS1-v1_5',
|
|
13049
|
+
hash: this.hash,
|
|
13050
|
+
}, true, ['sign']);
|
|
13051
|
+
}
|
|
13052
|
+
async exportPrivateSsh(params) {
|
|
13053
|
+
const { privateKey, crypto, jwk: providedJwk } = params;
|
|
13054
|
+
const jwk = providedJwk || (await crypto.subtle.exportKey('jwk', privateKey));
|
|
13055
|
+
if (!jwk.n || !jwk.e || !jwk.d || !jwk.p || !jwk.q) {
|
|
13056
|
+
throw new InvalidKeyDataError('RSA JWK missing required parameters');
|
|
13057
|
+
}
|
|
13058
|
+
const n = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.n));
|
|
13059
|
+
const e = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.e));
|
|
13060
|
+
const d = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.d));
|
|
13061
|
+
const p = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.p));
|
|
13062
|
+
const q = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.q));
|
|
13063
|
+
const qi = jwk.qi ? new Uint8Array(buildExports.Convert.FromBase64Url(jwk.qi)) : new Uint8Array();
|
|
13064
|
+
const writer = new SshWriter();
|
|
13065
|
+
writer.writeString('ssh-rsa');
|
|
13066
|
+
writer.writeMpInt(n, true);
|
|
13067
|
+
writer.writeMpInt(e, true);
|
|
13068
|
+
writer.writeMpInt(d, true);
|
|
13069
|
+
writer.writeMpInt(qi, true);
|
|
13070
|
+
writer.writeMpInt(p, true);
|
|
13071
|
+
writer.writeMpInt(q, true);
|
|
13072
|
+
return writer.toUint8Array();
|
|
13073
|
+
}
|
|
13074
|
+
async sign(params) {
|
|
13075
|
+
const { privateKey, data, crypto, hash } = params;
|
|
13076
|
+
if (hash && hash !== this.hash) {
|
|
13077
|
+
throw new InvalidKeyDataError(`Hash ${hash} not supported for this RSA algorithm`);
|
|
13078
|
+
}
|
|
13079
|
+
if (!privateKey.extractable) {
|
|
13080
|
+
throw new InvalidKeyDataError('Private key is not extractable');
|
|
13081
|
+
}
|
|
13082
|
+
const pkcs8 = await this.exportPrivatePkcs8({ privateKey, crypto });
|
|
13083
|
+
const keyToUse = await this.importPrivatePkcs8({ pkcs8: new Uint8Array(pkcs8), crypto });
|
|
13084
|
+
const signature = await crypto.subtle.sign('RSASSA-PKCS1-v1_5', keyToUse, data);
|
|
13085
|
+
return buildExports.BufferSourceConverter.toUint8Array(signature);
|
|
13086
|
+
}
|
|
13087
|
+
async verify(params) {
|
|
13088
|
+
const { publicKey, signature, data, crypto, hash } = params;
|
|
13089
|
+
if (hash && hash !== this.hash) {
|
|
13090
|
+
return false;
|
|
13091
|
+
}
|
|
13092
|
+
if (!publicKey.extractable) {
|
|
13093
|
+
throw new InvalidKeyDataError('Public key is not extractable');
|
|
13094
|
+
}
|
|
13095
|
+
const spki = await this.exportPublicSpki({ publicKey, crypto });
|
|
13096
|
+
const keyToUse = await this.importPublicSpki({ spki: new Uint8Array(spki), crypto });
|
|
13097
|
+
return crypto.subtle.verify('RSASSA-PKCS1-v1_5', keyToUse, signature, data);
|
|
13098
|
+
}
|
|
13099
|
+
encodeSignature(params) {
|
|
13100
|
+
const { signature, algo } = params;
|
|
13101
|
+
const writer = new SshWriter();
|
|
13102
|
+
writer.writeString(algo);
|
|
13103
|
+
writer.writeUint32(signature.byteLength);
|
|
13104
|
+
writer.writeBytes(signature);
|
|
13105
|
+
return writer.toUint8Array();
|
|
13106
|
+
}
|
|
13107
|
+
decodeSignature(params) {
|
|
13108
|
+
const { signature } = params;
|
|
13109
|
+
const reader = new SshReader(signature);
|
|
13110
|
+
const algo = reader.readString();
|
|
13111
|
+
const sigLength = reader.readUint32();
|
|
13112
|
+
const sig = reader.readBytes(sigLength);
|
|
13113
|
+
return { signature: sig, algo };
|
|
13114
|
+
}
|
|
13115
|
+
supportsCryptoKey(cryptoKey) {
|
|
13116
|
+
return cryptoKey.algorithm.name === 'RSASSA-PKCS1-v1_5';
|
|
13117
|
+
}
|
|
13118
|
+
parsePublicKey(reader) {
|
|
13119
|
+
const publicKeyExponent = reader.readBytes(reader.readUint32());
|
|
13120
|
+
const publicKeyModulus = reader.readBytes(reader.readUint32());
|
|
13121
|
+
const writer = new SshWriter();
|
|
13122
|
+
writer.writeString('ssh-rsa');
|
|
13123
|
+
writer.writeMpInt(publicKeyExponent);
|
|
13124
|
+
writer.writeMpInt(publicKeyModulus);
|
|
13125
|
+
return {
|
|
13126
|
+
type: 'ssh-rsa',
|
|
13127
|
+
keyData: writer.toUint8Array(),
|
|
13128
|
+
};
|
|
13129
|
+
}
|
|
13130
|
+
writePublicKey(writer, publicKey) {
|
|
13131
|
+
const publicKeyReader = new SshReader(publicKey.keyData);
|
|
13132
|
+
publicKeyReader.readString();
|
|
13133
|
+
const e = publicKeyReader.readMpInt();
|
|
13134
|
+
const n = publicKeyReader.readMpInt();
|
|
13135
|
+
writer.writeUint32(e.length);
|
|
13136
|
+
writer.writeBytes(e);
|
|
13137
|
+
writer.writeUint32(n.length);
|
|
13138
|
+
writer.writeBytes(n);
|
|
13139
|
+
}
|
|
13140
|
+
getCertificateType() {
|
|
13141
|
+
return 'ssh-rsa-cert-v01@openssh.com';
|
|
13142
|
+
}
|
|
13143
|
+
getSignatureAlgo() {
|
|
13144
|
+
return this.hash === 'SHA-256' ? 'rsa-sha2-256' : 'rsa-sha2-512';
|
|
13145
|
+
}
|
|
13146
|
+
}
|
|
13147
|
+
|
|
13148
|
+
class EcdsaBinding {
|
|
13149
|
+
curveName;
|
|
13150
|
+
sshType;
|
|
13151
|
+
namedCurve;
|
|
13152
|
+
constructor(curveName, sshType, namedCurve) {
|
|
13153
|
+
this.curveName = curveName;
|
|
13154
|
+
this.sshType = sshType;
|
|
13155
|
+
this.namedCurve = namedCurve;
|
|
13156
|
+
}
|
|
13157
|
+
getHashAlgorithm() {
|
|
13158
|
+
switch (this.namedCurve) {
|
|
13159
|
+
case 'P-256':
|
|
13160
|
+
return 'SHA-256';
|
|
13161
|
+
case 'P-384':
|
|
13162
|
+
return 'SHA-384';
|
|
13163
|
+
case 'P-521':
|
|
13164
|
+
return 'SHA-512';
|
|
13165
|
+
default:
|
|
13166
|
+
return 'SHA-256';
|
|
13167
|
+
}
|
|
13168
|
+
}
|
|
13169
|
+
getExpectedLength() {
|
|
13170
|
+
switch (this.namedCurve) {
|
|
13171
|
+
case 'P-256':
|
|
13172
|
+
return 32;
|
|
13173
|
+
case 'P-384':
|
|
13174
|
+
return 48;
|
|
13175
|
+
case 'P-521':
|
|
13176
|
+
return 66;
|
|
13177
|
+
default:
|
|
13178
|
+
return 32;
|
|
13179
|
+
}
|
|
13180
|
+
}
|
|
13181
|
+
getSignatureCoordLength() {
|
|
13182
|
+
return this.getExpectedLength();
|
|
13183
|
+
}
|
|
13184
|
+
async importPublicSsh(params) {
|
|
13185
|
+
const { blob, crypto } = params;
|
|
13186
|
+
const reader = new SshReader(blob);
|
|
13187
|
+
reader.readString();
|
|
13188
|
+
const curve = reader.readString();
|
|
13189
|
+
if (curve !== this.curveName) {
|
|
13190
|
+
throw new InvalidKeyDataError(`ECDSA curve name ${curve}, expected ${this.curveName}`);
|
|
13191
|
+
}
|
|
13192
|
+
const q = reader.readMpInt();
|
|
13193
|
+
const coordLength = Math.floor((q.length - 1) / 2);
|
|
13194
|
+
const jwk = {
|
|
13195
|
+
kty: 'EC',
|
|
13196
|
+
crv: this.namedCurve,
|
|
13197
|
+
x: buildExports.Convert.ToBase64Url(q.slice(1, 1 + coordLength)),
|
|
13198
|
+
y: buildExports.Convert.ToBase64Url(q.slice(1 + coordLength)),
|
|
13199
|
+
};
|
|
13200
|
+
return crypto.subtle.importKey('jwk', jwk, {
|
|
13201
|
+
name: 'ECDSA',
|
|
13202
|
+
namedCurve: this.namedCurve,
|
|
13203
|
+
}, true, ['verify']);
|
|
13204
|
+
}
|
|
13205
|
+
async exportPublicSsh(params) {
|
|
13206
|
+
const { publicKey, crypto } = params;
|
|
13207
|
+
const jwk = await crypto.subtle.exportKey('jwk', publicKey);
|
|
13208
|
+
if (!jwk.x || !jwk.y) {
|
|
13209
|
+
throw new InvalidKeyDataError('ECDSA JWK missing x or y parameters');
|
|
13210
|
+
}
|
|
13211
|
+
const x = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.x));
|
|
13212
|
+
const y = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.y));
|
|
13213
|
+
const q = new Uint8Array(1 + x.length + y.length);
|
|
13214
|
+
q[0] = 0x04;
|
|
13215
|
+
q.set(x, 1);
|
|
13216
|
+
q.set(y, 1 + x.length);
|
|
13217
|
+
const writer = new SshWriter();
|
|
13218
|
+
writer.writeString(this.sshType);
|
|
13219
|
+
writer.writeString(this.curveName);
|
|
13220
|
+
writer.writeMpInt(q);
|
|
13221
|
+
return writer.toUint8Array();
|
|
13222
|
+
}
|
|
13223
|
+
async importPublicSpki(params) {
|
|
13224
|
+
const { spki, crypto } = params;
|
|
13225
|
+
return crypto.subtle.importKey('spki', spki, {
|
|
13226
|
+
name: 'ECDSA',
|
|
13227
|
+
namedCurve: this.namedCurve,
|
|
13228
|
+
}, true, ['verify']);
|
|
13229
|
+
}
|
|
13230
|
+
async exportPublicSpki(params) {
|
|
13231
|
+
const { publicKey, crypto } = params;
|
|
13232
|
+
const spki = await crypto.subtle.exportKey('spki', publicKey);
|
|
13233
|
+
return buildExports.BufferSourceConverter.toUint8Array(spki);
|
|
13234
|
+
}
|
|
13235
|
+
async importPrivatePkcs8(params) {
|
|
13236
|
+
const { pkcs8, crypto } = params;
|
|
13237
|
+
return crypto.subtle.importKey('pkcs8', pkcs8, {
|
|
13238
|
+
name: 'ECDSA',
|
|
13239
|
+
namedCurve: this.namedCurve,
|
|
13240
|
+
}, true, ['sign']);
|
|
13241
|
+
}
|
|
13242
|
+
async exportPrivatePkcs8(params) {
|
|
13243
|
+
const { privateKey, crypto } = params;
|
|
13244
|
+
const pkcs8 = await crypto.subtle.exportKey('pkcs8', privateKey);
|
|
13245
|
+
return buildExports.BufferSourceConverter.toUint8Array(pkcs8);
|
|
13246
|
+
}
|
|
13247
|
+
async exportPrivateSsh(params) {
|
|
13248
|
+
const { privateKey, crypto, jwk: providedJwk } = params;
|
|
13249
|
+
const jwk = providedJwk || (await crypto.subtle.exportKey('jwk', privateKey));
|
|
13250
|
+
if (!jwk.d || !jwk.x || !jwk.y) {
|
|
13251
|
+
throw new InvalidKeyDataError('ECDSA private key JWK missing required parameters');
|
|
13252
|
+
}
|
|
13253
|
+
const x = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.x));
|
|
13254
|
+
const y = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.y));
|
|
13255
|
+
const d = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.d));
|
|
13256
|
+
const publicPoint = new Uint8Array(1 + x.length + y.length);
|
|
13257
|
+
publicPoint[0] = 0x04;
|
|
13258
|
+
publicPoint.set(x, 1);
|
|
13259
|
+
publicPoint.set(y, 1 + x.length);
|
|
13260
|
+
const writer = new SshWriter();
|
|
13261
|
+
writer.writeString(this.sshType);
|
|
13262
|
+
writer.writeString(this.curveName);
|
|
13263
|
+
writer.writeMpInt(publicPoint);
|
|
13264
|
+
writer.writeMpInt(d);
|
|
13265
|
+
return writer.toUint8Array();
|
|
13266
|
+
}
|
|
13267
|
+
async importPrivateSsh(params) {
|
|
13268
|
+
const { sshKey, crypto } = params;
|
|
13269
|
+
const base64Data = sshKey
|
|
13270
|
+
.replace(/-----BEGIN OPENSSH PRIVATE KEY-----/, '')
|
|
13271
|
+
.replace(/-----END OPENSSH PRIVATE KEY-----/, '')
|
|
13272
|
+
.replace(/\s/g, '');
|
|
13273
|
+
const binaryData = buildExports.Convert.FromBase64(base64Data);
|
|
13274
|
+
const reader = new SshReader(buildExports.BufferSourceConverter.toUint8Array(binaryData));
|
|
13275
|
+
const magic = reader.readBytes(15);
|
|
13276
|
+
if (buildExports.Convert.ToHex(magic) !== '6f70656e7373682d6b65792d763100') {
|
|
13277
|
+
throw new InvalidPrivateKeyFormatError('invalid magic string');
|
|
13278
|
+
}
|
|
13279
|
+
const _cipherName = reader.readString();
|
|
13280
|
+
reader.readString();
|
|
13281
|
+
reader.readString();
|
|
13282
|
+
if (_cipherName !== 'none') {
|
|
13283
|
+
throw new EncryptedKeyNotSupportedError(_cipherName);
|
|
13284
|
+
}
|
|
13285
|
+
const numKeys = reader.readUint32();
|
|
13286
|
+
if (numKeys !== 1) {
|
|
13287
|
+
throw new InvalidPrivateKeyFormatError('multiple keys not supported');
|
|
13288
|
+
}
|
|
13289
|
+
const publicKeyLength = reader.readUint32();
|
|
13290
|
+
reader.readBytes(publicKeyLength);
|
|
13291
|
+
const privateKeyLength = reader.readUint32();
|
|
13292
|
+
const privateKeyData = reader.readBytes(privateKeyLength);
|
|
13293
|
+
const privateReader = new SshReader(privateKeyData);
|
|
13294
|
+
const checkint1 = privateReader.readUint32();
|
|
13295
|
+
const checkint2 = privateReader.readUint32();
|
|
13296
|
+
if (checkint1 !== checkint2) {
|
|
13297
|
+
throw new InvalidPrivateKeyFormatError('invalid checkints');
|
|
13298
|
+
}
|
|
13299
|
+
privateReader.readString();
|
|
13300
|
+
privateReader.readString();
|
|
13301
|
+
const publicKeyPoint = privateReader.readMpInt();
|
|
13302
|
+
const privateKeyValue = privateReader.readMpInt();
|
|
13303
|
+
privateReader.readString();
|
|
13304
|
+
if (publicKeyPoint[0] !== 0x04) {
|
|
13305
|
+
throw new InvalidKeyDataError('invalid ECDSA public key point format');
|
|
13306
|
+
}
|
|
13307
|
+
const coordLength = Math.floor((publicKeyPoint.length - 1) / 2);
|
|
13308
|
+
const x = publicKeyPoint.slice(1, 1 + coordLength);
|
|
13309
|
+
const y = publicKeyPoint.slice(1 + coordLength);
|
|
13310
|
+
const jwk = {
|
|
13311
|
+
kty: 'EC',
|
|
13312
|
+
crv: this.namedCurve,
|
|
13313
|
+
x: buildExports.Convert.ToBase64Url(x),
|
|
13314
|
+
y: buildExports.Convert.ToBase64Url(y),
|
|
13315
|
+
d: buildExports.Convert.ToBase64Url(privateKeyValue),
|
|
13316
|
+
};
|
|
13317
|
+
return crypto.subtle.importKey('jwk', jwk, {
|
|
13318
|
+
name: 'ECDSA',
|
|
13319
|
+
namedCurve: this.namedCurve,
|
|
13320
|
+
}, true, ['sign']);
|
|
13321
|
+
}
|
|
13322
|
+
async sign(params) {
|
|
13323
|
+
const { privateKey, data, crypto, hash } = params;
|
|
13324
|
+
const expectedHash = this.getHashAlgorithm();
|
|
13325
|
+
if (hash && hash !== expectedHash) {
|
|
13326
|
+
throw new InvalidKeyDataError(`ECDSA ${this.namedCurve} requires ${expectedHash}, got ${hash}`);
|
|
13327
|
+
}
|
|
13328
|
+
const signature = await crypto.subtle.sign({
|
|
13329
|
+
name: 'ECDSA',
|
|
13330
|
+
hash: expectedHash,
|
|
13331
|
+
}, privateKey, data);
|
|
13332
|
+
return buildExports.BufferSourceConverter.toUint8Array(signature);
|
|
13333
|
+
}
|
|
13334
|
+
async verify(params) {
|
|
13335
|
+
const { publicKey, signature, data, crypto, hash } = params;
|
|
13336
|
+
const expectedHash = this.getHashAlgorithm();
|
|
13337
|
+
if (hash && hash !== expectedHash) {
|
|
13338
|
+
throw new InvalidKeyDataError(`ECDSA ${this.namedCurve} requires ${expectedHash}, got ${hash}`);
|
|
13339
|
+
}
|
|
13340
|
+
return crypto.subtle.verify({
|
|
13341
|
+
name: 'ECDSA',
|
|
13342
|
+
hash: expectedHash,
|
|
13343
|
+
}, publicKey, signature, data);
|
|
13344
|
+
}
|
|
13345
|
+
encodeSignature(params) {
|
|
13346
|
+
const { signature, algo } = params;
|
|
13347
|
+
if (algo.startsWith('ecdsa-sha2-')) {
|
|
13348
|
+
const coordLength = this.getSignatureCoordLength();
|
|
13349
|
+
const r = signature.subarray(0, coordLength);
|
|
13350
|
+
const s = signature.subarray(coordLength);
|
|
13351
|
+
const writer = new SshWriter();
|
|
13352
|
+
writer.writeString(algo);
|
|
13353
|
+
const sigWriter = new SshWriter();
|
|
13354
|
+
sigWriter.writeMpInt(r, true);
|
|
13355
|
+
sigWriter.writeMpInt(s, true);
|
|
13356
|
+
const sigData = sigWriter.toUint8Array();
|
|
13357
|
+
writer.writeUint32(sigData.length);
|
|
13358
|
+
writer.writeBytes(sigData);
|
|
13359
|
+
return writer.toUint8Array();
|
|
13360
|
+
}
|
|
13361
|
+
const writer = new SshWriter();
|
|
13362
|
+
writer.writeString(algo);
|
|
13363
|
+
writer.writeUint32(signature.byteLength);
|
|
13364
|
+
writer.writeBytes(signature);
|
|
13365
|
+
return writer.toUint8Array();
|
|
13366
|
+
}
|
|
13367
|
+
decodeSignature(params) {
|
|
13368
|
+
const { signature } = params;
|
|
13369
|
+
const reader = new SshReader(signature);
|
|
13370
|
+
const algo = reader.readString();
|
|
13371
|
+
const sigLength = reader.readUint32();
|
|
13372
|
+
const sig = reader.readBytes(sigLength);
|
|
13373
|
+
if (algo.startsWith('ecdsa-sha2-')) {
|
|
13374
|
+
const sigReader = new SshReader(sig);
|
|
13375
|
+
let r = sigReader.readMpInt();
|
|
13376
|
+
let s = sigReader.readMpInt();
|
|
13377
|
+
if (r[0] === 0x00 && r.length > 1 && (r[1] & 0x80) === 0) {
|
|
13378
|
+
r = r.slice(1);
|
|
13379
|
+
}
|
|
13380
|
+
if (s[0] === 0x00 && s.length > 1 && (s[1] & 0x80) === 0) {
|
|
13381
|
+
s = s.slice(1);
|
|
13382
|
+
}
|
|
13383
|
+
const expectedLength = this.getExpectedLength();
|
|
13384
|
+
const rPadded = new Uint8Array(expectedLength);
|
|
13385
|
+
const sPadded = new Uint8Array(expectedLength);
|
|
13386
|
+
if (r.length <= expectedLength) {
|
|
13387
|
+
rPadded.set(r, expectedLength - r.length);
|
|
13388
|
+
}
|
|
13389
|
+
else {
|
|
13390
|
+
rPadded.set(r.slice(r.length - expectedLength), 0);
|
|
13391
|
+
}
|
|
13392
|
+
if (s.length <= expectedLength) {
|
|
13393
|
+
sPadded.set(s, expectedLength - s.length);
|
|
13394
|
+
}
|
|
13395
|
+
else {
|
|
13396
|
+
sPadded.set(s.slice(s.length - expectedLength), 0);
|
|
13397
|
+
}
|
|
13398
|
+
const rawSignature = new Uint8Array([...rPadded, ...sPadded]);
|
|
13399
|
+
return { signature: rawSignature, algo };
|
|
13400
|
+
}
|
|
13401
|
+
return { signature: sig, algo };
|
|
13402
|
+
}
|
|
13403
|
+
supportsCryptoKey(cryptoKey) {
|
|
13404
|
+
return (cryptoKey.algorithm.name === 'ECDSA' &&
|
|
13405
|
+
cryptoKey.algorithm.namedCurve === this.namedCurve);
|
|
13406
|
+
}
|
|
13407
|
+
parsePublicKey(reader) {
|
|
13408
|
+
const curveName = reader.readString();
|
|
13409
|
+
if (curveName !== this.curveName) {
|
|
13410
|
+
throw new InvalidKeyDataError(`ECDSA certificate curve name ${curveName}, expected ${this.curveName}`);
|
|
13411
|
+
}
|
|
13412
|
+
const publicKeyPoint = reader.readBytes(reader.readUint32());
|
|
13413
|
+
const writer = new SshWriter();
|
|
13414
|
+
writer.writeString(this.sshType);
|
|
13415
|
+
writer.writeString(curveName);
|
|
13416
|
+
writer.writeMpInt(publicKeyPoint);
|
|
13417
|
+
return {
|
|
13418
|
+
type: this.sshType,
|
|
13419
|
+
keyData: writer.toUint8Array(),
|
|
13420
|
+
};
|
|
13421
|
+
}
|
|
13422
|
+
writePublicKey(writer, publicKey) {
|
|
13423
|
+
const publicKeyReader = new SshReader(publicKey.keyData);
|
|
13424
|
+
publicKeyReader.readString();
|
|
13425
|
+
const curveName = publicKeyReader.readString();
|
|
13426
|
+
const publicPoint = publicKeyReader.readMpInt();
|
|
13427
|
+
writer.writeString(curveName);
|
|
13428
|
+
writer.writeUint32(publicPoint.length);
|
|
13429
|
+
writer.writeBytes(publicPoint);
|
|
13430
|
+
}
|
|
13431
|
+
getCertificateType() {
|
|
13432
|
+
return `${this.sshType}-cert-v01@openssh.com`;
|
|
13433
|
+
}
|
|
13434
|
+
getSignatureAlgo() {
|
|
13435
|
+
return this.sshType;
|
|
13436
|
+
}
|
|
13437
|
+
}
|
|
13438
|
+
const EcdsaP256Binding = new EcdsaBinding('nistp256', 'ecdsa-sha2-nistp256', 'P-256');
|
|
13439
|
+
const EcdsaP384Binding = new EcdsaBinding('nistp384', 'ecdsa-sha2-nistp384', 'P-384');
|
|
13440
|
+
const EcdsaP521Binding = new EcdsaBinding('nistp521', 'ecdsa-sha2-nistp521', 'P-521');
|
|
13441
|
+
|
|
13442
|
+
class Ed25519Binding {
|
|
13443
|
+
async importPublicSsh(params) {
|
|
13444
|
+
const { blob, crypto } = params;
|
|
13445
|
+
const reader = new SshReader(blob);
|
|
13446
|
+
reader.readString();
|
|
13447
|
+
const keyLength = reader.readUint32();
|
|
13448
|
+
if (keyLength !== 32) {
|
|
13449
|
+
throw new InvalidKeyDataError(`Ed25519 key length ${keyLength}, expected 32`);
|
|
13450
|
+
}
|
|
13451
|
+
const publicKeyBytes = reader.readBytes(keyLength);
|
|
13452
|
+
return crypto.subtle.importKey('raw', publicKeyBytes, 'Ed25519', true, [
|
|
13453
|
+
'verify',
|
|
13454
|
+
]);
|
|
13455
|
+
}
|
|
13456
|
+
async exportPublicSsh(params) {
|
|
13457
|
+
const { publicKey, crypto } = params;
|
|
13458
|
+
const jwk = await crypto.subtle.exportKey('jwk', publicKey);
|
|
13459
|
+
if (!jwk.x) {
|
|
13460
|
+
throw new InvalidKeyDataError('Ed25519 JWK missing x parameter');
|
|
13461
|
+
}
|
|
13462
|
+
const keyBytes = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.x));
|
|
13463
|
+
const writer = new SshWriter();
|
|
13464
|
+
writer.writeString('ssh-ed25519');
|
|
13465
|
+
writer.writeUint32(keyBytes.length);
|
|
13466
|
+
writer.writeBytes(keyBytes);
|
|
13467
|
+
return writer.toUint8Array();
|
|
13468
|
+
}
|
|
13469
|
+
async importPublicSpki(params) {
|
|
13470
|
+
const { spki, crypto } = params;
|
|
13471
|
+
return crypto.subtle.importKey('spki', spki, 'Ed25519', true, ['verify']);
|
|
13472
|
+
}
|
|
13473
|
+
async exportPublicSpki(params) {
|
|
13474
|
+
const { publicKey, crypto } = params;
|
|
13475
|
+
const spki = await crypto.subtle.exportKey('spki', publicKey);
|
|
13476
|
+
return buildExports.BufferSourceConverter.toUint8Array(spki);
|
|
13477
|
+
}
|
|
13478
|
+
async importPrivatePkcs8(params) {
|
|
13479
|
+
const { pkcs8, crypto } = params;
|
|
13480
|
+
return crypto.subtle.importKey('pkcs8', pkcs8, 'Ed25519', true, ['sign']);
|
|
13481
|
+
}
|
|
13482
|
+
async exportPrivatePkcs8(params) {
|
|
13483
|
+
const { privateKey, crypto } = params;
|
|
13484
|
+
const pkcs8 = await crypto.subtle.exportKey('pkcs8', privateKey);
|
|
13485
|
+
return buildExports.BufferSourceConverter.toUint8Array(pkcs8);
|
|
13486
|
+
}
|
|
13487
|
+
async exportPrivateSsh(params) {
|
|
13488
|
+
const { privateKey, crypto, jwk: providedJwk } = params;
|
|
13489
|
+
const jwk = providedJwk || (await crypto.subtle.exportKey('jwk', privateKey));
|
|
13490
|
+
if (!jwk.d || !jwk.x) {
|
|
13491
|
+
throw new InvalidKeyDataError('Ed25519 private key JWK missing required parameters');
|
|
13492
|
+
}
|
|
13493
|
+
const privateBytes = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.d));
|
|
13494
|
+
const publicBytes = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.x));
|
|
13495
|
+
const writer = new SshWriter();
|
|
13496
|
+
writer.writeString('ssh-ed25519');
|
|
13497
|
+
writer.writeUint32(publicBytes.length);
|
|
13498
|
+
writer.writeBytes(publicBytes);
|
|
13499
|
+
const privKeyPart = new Uint8Array(64);
|
|
13500
|
+
privKeyPart.set(privateBytes, 0);
|
|
13501
|
+
privKeyPart.set(publicBytes, 32);
|
|
13502
|
+
writer.writeUint32(privKeyPart.length);
|
|
13503
|
+
writer.writeBytes(privKeyPart);
|
|
13504
|
+
return writer.toUint8Array();
|
|
13505
|
+
}
|
|
13506
|
+
async importPrivateSsh(params) {
|
|
13507
|
+
const { sshKey, crypto } = params;
|
|
13508
|
+
const base64Data = sshKey
|
|
13509
|
+
.replace(/-----BEGIN OPENSSH PRIVATE KEY-----/, '')
|
|
13510
|
+
.replace(/-----END OPENSSH PRIVATE KEY-----/, '')
|
|
13511
|
+
.replace(/\s/g, '');
|
|
13512
|
+
const binaryData = buildExports.Convert.FromBase64(base64Data);
|
|
13513
|
+
const reader = new SshReader(buildExports.BufferSourceConverter.toUint8Array(binaryData));
|
|
13514
|
+
const magic = reader.readBytes(15);
|
|
13515
|
+
if (buildExports.Convert.ToHex(magic) !== '6f70656e7373682d6b65792d763100') {
|
|
13516
|
+
throw new InvalidPrivateKeyFormatError('invalid magic string');
|
|
13517
|
+
}
|
|
13518
|
+
const _cipherName = reader.readString();
|
|
13519
|
+
reader.readString();
|
|
13520
|
+
reader.readString();
|
|
13521
|
+
if (_cipherName !== 'none') {
|
|
13522
|
+
throw new EncryptedKeyNotSupportedError(_cipherName);
|
|
13523
|
+
}
|
|
13524
|
+
const numKeys = reader.readUint32();
|
|
13525
|
+
if (numKeys !== 1) {
|
|
13526
|
+
throw new InvalidPrivateKeyFormatError('multiple keys not supported');
|
|
13527
|
+
}
|
|
13528
|
+
const publicKeyLength = reader.readUint32();
|
|
13529
|
+
reader.readBytes(publicKeyLength);
|
|
13530
|
+
const privateKeyLength = reader.readUint32();
|
|
13531
|
+
const privateKeyData = reader.readBytes(privateKeyLength);
|
|
13532
|
+
const privateReader = new SshReader(privateKeyData);
|
|
13533
|
+
const checkint1 = privateReader.readUint32();
|
|
13534
|
+
const checkint2 = privateReader.readUint32();
|
|
13535
|
+
if (checkint1 !== checkint2) {
|
|
13536
|
+
throw new InvalidPrivateKeyFormatError('invalid checkints');
|
|
13537
|
+
}
|
|
13538
|
+
privateReader.readString();
|
|
13539
|
+
const pubKeyLength = privateReader.readUint32();
|
|
13540
|
+
const _publicKeyBytes = privateReader.readBytes(pubKeyLength);
|
|
13541
|
+
const privKeyLength = privateReader.readUint32();
|
|
13542
|
+
const privateKeyBytes = privateReader.readBytes(privKeyLength);
|
|
13543
|
+
privateReader.readString();
|
|
13544
|
+
const privateKey = privateKeyBytes.slice(0, 32);
|
|
13545
|
+
const jwk = {
|
|
13546
|
+
kty: 'OKP',
|
|
13547
|
+
crv: 'Ed25519',
|
|
13548
|
+
d: buildExports.Convert.ToBase64Url(privateKey),
|
|
13549
|
+
x: buildExports.Convert.ToBase64Url(_publicKeyBytes),
|
|
13550
|
+
};
|
|
13551
|
+
return crypto.subtle.importKey('jwk', jwk, 'Ed25519', true, ['sign']);
|
|
13552
|
+
}
|
|
13553
|
+
async sign(params) {
|
|
13554
|
+
const { privateKey, data, crypto } = params;
|
|
13555
|
+
const signature = await crypto.subtle.sign('Ed25519', privateKey, data);
|
|
13556
|
+
return buildExports.BufferSourceConverter.toUint8Array(signature);
|
|
13557
|
+
}
|
|
13558
|
+
async verify(params) {
|
|
13559
|
+
const { publicKey, signature, data, crypto } = params;
|
|
13560
|
+
return crypto.subtle.verify('Ed25519', publicKey, signature, data);
|
|
13561
|
+
}
|
|
13562
|
+
encodeSignature(params) {
|
|
13563
|
+
const { signature, algo } = params;
|
|
13564
|
+
const sigBytes = new Uint8Array(signature);
|
|
13565
|
+
const writer = new SshWriter();
|
|
13566
|
+
writer.writeString(algo);
|
|
13567
|
+
writer.writeUint32(sigBytes.length);
|
|
13568
|
+
writer.writeBytes(sigBytes);
|
|
13569
|
+
return writer.toUint8Array();
|
|
13570
|
+
}
|
|
13571
|
+
decodeSignature(params) {
|
|
13572
|
+
const { signature } = params;
|
|
13573
|
+
const reader = new SshReader(signature);
|
|
13574
|
+
const algo = reader.readString();
|
|
13575
|
+
const sigLength = reader.readUint32();
|
|
13576
|
+
const sigBytes = reader.readBytes(sigLength);
|
|
13577
|
+
return {
|
|
13578
|
+
signature: sigBytes,
|
|
13579
|
+
algo,
|
|
13580
|
+
};
|
|
13581
|
+
}
|
|
13582
|
+
supportsCryptoKey(cryptoKey) {
|
|
13583
|
+
return cryptoKey.algorithm.name === 'Ed25519';
|
|
13584
|
+
}
|
|
13585
|
+
parsePublicKey(reader) {
|
|
13586
|
+
const publicKeyData = reader.readBytes(reader.readUint32());
|
|
13587
|
+
const writer = new SshWriter();
|
|
13588
|
+
writer.writeString('ssh-ed25519');
|
|
13589
|
+
writer.writeUint32(publicKeyData.length);
|
|
13590
|
+
writer.writeBytes(publicKeyData);
|
|
13591
|
+
return {
|
|
13592
|
+
type: 'ssh-ed25519',
|
|
13593
|
+
keyData: writer.toUint8Array(),
|
|
13594
|
+
};
|
|
13595
|
+
}
|
|
13596
|
+
writePublicKey(writer, publicKey) {
|
|
13597
|
+
const publicKeyReader = new SshReader(publicKey.keyData);
|
|
13598
|
+
publicKeyReader.readString();
|
|
13599
|
+
const keyLength = publicKeyReader.readUint32();
|
|
13600
|
+
const rawKeyData = publicKeyReader.readBytes(keyLength);
|
|
13601
|
+
writer.writeUint32(rawKeyData.length);
|
|
13602
|
+
writer.writeBytes(rawKeyData);
|
|
13603
|
+
}
|
|
13604
|
+
getCertificateType() {
|
|
13605
|
+
return 'ssh-ed25519-cert-v01@openssh.com';
|
|
13606
|
+
}
|
|
13607
|
+
getSignatureAlgo() {
|
|
13608
|
+
return 'ssh-ed25519';
|
|
13609
|
+
}
|
|
13610
|
+
}
|
|
13611
|
+
|
|
13612
|
+
const registry = new Map();
|
|
13613
|
+
class AlgorithmRegistry {
|
|
13614
|
+
static get(name) {
|
|
13615
|
+
const binding = registry.get(name);
|
|
13616
|
+
if (!binding) {
|
|
13617
|
+
throw new UnsupportedKeyTypeError(name, Array.from(registry.keys()));
|
|
13618
|
+
}
|
|
13619
|
+
return binding;
|
|
13620
|
+
}
|
|
13621
|
+
static register(name, binding) {
|
|
13622
|
+
registry.set(name, binding);
|
|
13623
|
+
}
|
|
13624
|
+
static getSshTypeFromCryptoKey(cryptoKey) {
|
|
13625
|
+
for (const [sshType, binding] of registry.entries()) {
|
|
13626
|
+
if (binding.supportsCryptoKey(cryptoKey)) {
|
|
13627
|
+
return sshType;
|
|
13628
|
+
}
|
|
13629
|
+
}
|
|
13630
|
+
throw new UnsupportedKeyTypeError(cryptoKey.algorithm.name, Array.from(registry.keys()));
|
|
13631
|
+
}
|
|
13632
|
+
static certTypeToKeyType(certType) {
|
|
13633
|
+
const mapping = {
|
|
13634
|
+
'ssh-rsa-cert-v01@openssh.com': 'ssh-rsa',
|
|
13635
|
+
'ssh-ed25519-cert-v01@openssh.com': 'ssh-ed25519',
|
|
13636
|
+
'ecdsa-sha2-nistp256-cert-v01@openssh.com': 'ecdsa-sha2-nistp256',
|
|
13637
|
+
'ecdsa-sha2-nistp384-cert-v01@openssh.com': 'ecdsa-sha2-nistp384',
|
|
13638
|
+
'ecdsa-sha2-nistp521-cert-v01@openssh.com': 'ecdsa-sha2-nistp521',
|
|
13639
|
+
};
|
|
13640
|
+
return mapping[certType];
|
|
13641
|
+
}
|
|
13642
|
+
static getSupportedCertTypes() {
|
|
13643
|
+
return Object.keys({
|
|
13644
|
+
'ssh-rsa-cert-v01@openssh.com': 'ssh-rsa',
|
|
13645
|
+
'ssh-ed25519-cert-v01@openssh.com': 'ssh-ed25519',
|
|
13646
|
+
'ecdsa-sha2-nistp256-cert-v01@openssh.com': 'ecdsa-sha2-nistp256',
|
|
13647
|
+
'ecdsa-sha2-nistp384-cert-v01@openssh.com': 'ecdsa-sha2-nistp384',
|
|
13648
|
+
'ecdsa-sha2-nistp521-cert-v01@openssh.com': 'ecdsa-sha2-nistp521',
|
|
13649
|
+
});
|
|
13650
|
+
}
|
|
13651
|
+
}
|
|
13652
|
+
AlgorithmRegistry.register('ssh-ed25519', new Ed25519Binding());
|
|
13653
|
+
AlgorithmRegistry.register('ssh-rsa', new RsaBinding('SHA-256'));
|
|
13654
|
+
AlgorithmRegistry.register('rsa-sha2-256', new RsaBinding('SHA-256'));
|
|
13655
|
+
AlgorithmRegistry.register('rsa-sha2-512', new RsaBinding('SHA-512'));
|
|
13656
|
+
AlgorithmRegistry.register('ecdsa-sha2-nistp256', EcdsaP256Binding);
|
|
13657
|
+
AlgorithmRegistry.register('ecdsa-sha2-nistp384', EcdsaP384Binding);
|
|
13658
|
+
AlgorithmRegistry.register('ecdsa-sha2-nistp521', EcdsaP521Binding);
|
|
13659
|
+
|
|
13660
|
+
function parsePublicKey(input) {
|
|
13661
|
+
const parts = typeof input === 'string' ? input.trim().split(/\s+/) : null;
|
|
13662
|
+
if (!parts || parts.length < 2) {
|
|
13663
|
+
throw new InvalidFormatError('Invalid SSH public key format');
|
|
13664
|
+
}
|
|
13665
|
+
const type = parts[0];
|
|
13666
|
+
const blob = new Uint8Array(buildExports.Convert.FromBase64(parts[1]));
|
|
13667
|
+
const comment = parts.length > 2 ? parts.slice(2).join(' ') : undefined;
|
|
13668
|
+
const reader = new SshReader(blob);
|
|
13669
|
+
const blobType = reader.readString();
|
|
13670
|
+
if (blobType !== type) {
|
|
13671
|
+
throw new InvalidFormatError('Key type mismatch');
|
|
13672
|
+
}
|
|
13673
|
+
return {
|
|
13674
|
+
type,
|
|
13675
|
+
keyData: blob,
|
|
13676
|
+
comment,
|
|
13677
|
+
};
|
|
13678
|
+
}
|
|
13679
|
+
function serializePublicKey(blob) {
|
|
13680
|
+
const base64 = buildExports.Convert.ToBase64(blob.keyData);
|
|
13681
|
+
const parts = [blob.type, base64];
|
|
13682
|
+
if (blob.comment) {
|
|
13683
|
+
parts.push(blob.comment);
|
|
13684
|
+
}
|
|
13685
|
+
return parts.join(' ');
|
|
13686
|
+
}
|
|
13687
|
+
|
|
13688
|
+
function parse(input) {
|
|
13689
|
+
if (typeof input === 'string') {
|
|
13690
|
+
const parts = input.trim().split(/\s+/);
|
|
13691
|
+
if (parts.length < 2) {
|
|
13692
|
+
throw new InvalidFormatError('SSH certificate string', 'type base64 [comment]');
|
|
13693
|
+
}
|
|
13694
|
+
const type = parts[0];
|
|
13695
|
+
const blob = new Uint8Array(buildExports.Convert.FromBase64(parts[1]));
|
|
13696
|
+
const comment = parts.length > 2 ? parts.slice(2).join(' ') : undefined;
|
|
13697
|
+
const reader = new SshReader(blob);
|
|
13698
|
+
const blobType = reader.readString();
|
|
13699
|
+
if (blobType !== type) {
|
|
13700
|
+
throw new InvalidFormatError(`certificate blob type ${blobType}`, `expected ${type}`);
|
|
13701
|
+
}
|
|
13702
|
+
return {
|
|
13703
|
+
type,
|
|
13704
|
+
keyData: blob,
|
|
13705
|
+
comment,
|
|
13706
|
+
};
|
|
13707
|
+
}
|
|
13708
|
+
else {
|
|
13709
|
+
const reader = new SshReader(input);
|
|
13710
|
+
const type = reader.readString();
|
|
13711
|
+
const keyData = input.slice(reader.getOffset());
|
|
13712
|
+
return {
|
|
13713
|
+
type,
|
|
13714
|
+
keyData,
|
|
13715
|
+
};
|
|
13716
|
+
}
|
|
13717
|
+
}
|
|
13718
|
+
function parseCertificateData(keyData) {
|
|
13719
|
+
const reader = new SshReader(keyData);
|
|
13720
|
+
const certType = reader.readString();
|
|
13721
|
+
const nonce = reader.readBytes(reader.readUint32());
|
|
13722
|
+
const mappedKeyType = AlgorithmRegistry.certTypeToKeyType(certType);
|
|
13723
|
+
if (!mappedKeyType) {
|
|
13724
|
+
throw new UnsupportedAlgorithmError(certType, AlgorithmRegistry.getSupportedCertTypes());
|
|
13725
|
+
}
|
|
13726
|
+
const binding = AlgorithmRegistry.get(mappedKeyType);
|
|
13727
|
+
const publicKey = binding.parsePublicKey(reader);
|
|
13728
|
+
const keyType = mappedKeyType;
|
|
13729
|
+
const serial = reader.readUint64();
|
|
13730
|
+
const typeValue = reader.readUint32();
|
|
13731
|
+
const type = typeValue === 1 ? 'user' : 'host';
|
|
13732
|
+
const keyId = reader.readString();
|
|
13733
|
+
const principalsLength = reader.readUint32();
|
|
13734
|
+
const principalsData = reader.readBytes(principalsLength);
|
|
13735
|
+
const validPrincipals = [];
|
|
13736
|
+
if (principalsData.length > 0) {
|
|
13737
|
+
const principalsReader = new SshReader(principalsData);
|
|
13738
|
+
while (principalsReader.getOffset() < principalsData.length) {
|
|
13739
|
+
try {
|
|
13740
|
+
const principal = principalsReader.readString();
|
|
13741
|
+
validPrincipals.push(principal);
|
|
13742
|
+
}
|
|
13743
|
+
catch {
|
|
13744
|
+
break;
|
|
13745
|
+
}
|
|
13746
|
+
}
|
|
13747
|
+
}
|
|
13748
|
+
const validAfter = reader.readUint64();
|
|
13749
|
+
const validBefore = reader.readUint64();
|
|
13750
|
+
const criticalOptions = {};
|
|
13751
|
+
const criticalLength = reader.readUint32();
|
|
13752
|
+
const criticalData = reader.readBytes(criticalLength);
|
|
13753
|
+
if (criticalData.length > 0) {
|
|
13754
|
+
const optionsReader = new SshReader(criticalData);
|
|
13755
|
+
while (optionsReader.getOffset() < criticalData.length) {
|
|
13756
|
+
try {
|
|
13757
|
+
const name = optionsReader.readString();
|
|
13758
|
+
const valueData = optionsReader.readBytes(optionsReader.readUint32());
|
|
13759
|
+
const value = valueData.length === 0 ? '' : decoder.decode(valueData);
|
|
13760
|
+
criticalOptions[name] = value;
|
|
13761
|
+
}
|
|
13762
|
+
catch {
|
|
13763
|
+
break;
|
|
13764
|
+
}
|
|
13765
|
+
}
|
|
13766
|
+
}
|
|
13767
|
+
const extensions = {};
|
|
13768
|
+
const extensionsLength = reader.readUint32();
|
|
13769
|
+
const extensionsData = reader.readBytes(extensionsLength);
|
|
13770
|
+
if (extensionsData.length > 0) {
|
|
13771
|
+
const extReader = new SshReader(extensionsData);
|
|
13772
|
+
while (extReader.getOffset() < extensionsData.length) {
|
|
13773
|
+
try {
|
|
13774
|
+
const name = extReader.readString();
|
|
13775
|
+
const valueData = extReader.readBytes(extReader.readUint32());
|
|
13776
|
+
const value = valueData.length === 0 ? '' : decoder.decode(valueData);
|
|
13777
|
+
extensions[name] = value;
|
|
13778
|
+
}
|
|
13779
|
+
catch {
|
|
13780
|
+
break;
|
|
13781
|
+
}
|
|
13782
|
+
}
|
|
13783
|
+
}
|
|
13784
|
+
const reservedLength = reader.readUint32();
|
|
13785
|
+
const reserved = reader.readBytes(reservedLength);
|
|
13786
|
+
const signatureKeyLength = reader.readUint32();
|
|
13787
|
+
const signatureKeyData = reader.readBytes(signatureKeyLength);
|
|
13788
|
+
const signatureKeyReader = new SshReader(signatureKeyData);
|
|
13789
|
+
const signatureKeyType = signatureKeyReader.readString();
|
|
13790
|
+
const signatureKey = {
|
|
13791
|
+
type: signatureKeyType,
|
|
13792
|
+
keyData: signatureKeyData,
|
|
13793
|
+
};
|
|
13794
|
+
const signatureLength = reader.readUint32();
|
|
13795
|
+
const signature = reader.readBytes(signatureLength);
|
|
13796
|
+
return {
|
|
13797
|
+
nonce,
|
|
13798
|
+
keyType,
|
|
13799
|
+
publicKey,
|
|
13800
|
+
serial,
|
|
13801
|
+
type,
|
|
13802
|
+
keyId,
|
|
13803
|
+
validPrincipals,
|
|
13804
|
+
validAfter,
|
|
13805
|
+
validBefore,
|
|
13806
|
+
criticalOptions,
|
|
13807
|
+
extensions,
|
|
13808
|
+
reserved,
|
|
13809
|
+
signatureKey,
|
|
13810
|
+
signature,
|
|
13811
|
+
};
|
|
13812
|
+
}
|
|
13813
|
+
function serialize(cert) {
|
|
13814
|
+
const base64 = buildExports.Convert.ToBase64(cert.keyData);
|
|
13815
|
+
const parts = [cert.type, base64];
|
|
13816
|
+
if (cert.comment) {
|
|
13817
|
+
parts.push(cert.comment);
|
|
13818
|
+
}
|
|
13819
|
+
return parts.join(' ');
|
|
13820
|
+
}
|
|
13821
|
+
|
|
13822
|
+
function parseSignature(data) {
|
|
13823
|
+
const reader = new SshReader(data);
|
|
13824
|
+
if (data.length >= 6 && new TextDecoder().decode(data.subarray(0, 6)) === 'SSHSIG') {
|
|
13825
|
+
return parseSshSignatureFormat(reader);
|
|
13826
|
+
}
|
|
13827
|
+
else {
|
|
13828
|
+
return parseLegacyFormat(reader);
|
|
13829
|
+
}
|
|
13830
|
+
}
|
|
13831
|
+
function parseSshSignatureFormat(reader) {
|
|
13832
|
+
const magicBytes = reader.readBytes(6);
|
|
13833
|
+
const magic = new TextDecoder().decode(magicBytes);
|
|
13834
|
+
if (magic !== 'SSHSIG') {
|
|
13835
|
+
throw new InvalidFormatError(magic, 'SSHSIG');
|
|
13836
|
+
}
|
|
13837
|
+
const version = reader.readUint32();
|
|
13838
|
+
const publicKeyLength = reader.readUint32();
|
|
13839
|
+
const publicKey = reader.readBytes(publicKeyLength);
|
|
13840
|
+
const namespace = reader.readString();
|
|
13841
|
+
const reserved = reader.readString();
|
|
13842
|
+
const hashAlgorithm = reader.readString();
|
|
13843
|
+
const signatureLength = reader.readUint32();
|
|
13844
|
+
const signatureData = reader.readBytes(signatureLength);
|
|
13845
|
+
const sigReader = new SshReader(signatureData);
|
|
13846
|
+
const algorithm = sigReader.readString();
|
|
13847
|
+
const signatureLength2 = sigReader.readUint32();
|
|
13848
|
+
const signature = sigReader.readBytes(signatureLength2);
|
|
13849
|
+
return {
|
|
13850
|
+
format: 'ssh-signature',
|
|
13851
|
+
algorithm,
|
|
13852
|
+
signature,
|
|
13853
|
+
version,
|
|
13854
|
+
publicKey,
|
|
13855
|
+
namespace,
|
|
13856
|
+
reserved,
|
|
13857
|
+
hashAlgorithm,
|
|
13858
|
+
};
|
|
13859
|
+
}
|
|
13860
|
+
function parseLegacyFormat(reader) {
|
|
13861
|
+
const algorithm = reader.readString();
|
|
13862
|
+
const signatureLength = reader.readUint32();
|
|
13863
|
+
const signature = reader.readBytes(signatureLength);
|
|
13864
|
+
return {
|
|
13865
|
+
format: 'legacy',
|
|
13866
|
+
algorithm,
|
|
13867
|
+
signature,
|
|
13868
|
+
};
|
|
13869
|
+
}
|
|
13870
|
+
function serializeSignature(blob) {
|
|
13871
|
+
if (blob.format === 'ssh-signature') {
|
|
13872
|
+
return serializeSshSignatureFormat(blob);
|
|
13873
|
+
}
|
|
13874
|
+
else {
|
|
13875
|
+
return serializeLegacyFormat(blob);
|
|
13876
|
+
}
|
|
13877
|
+
}
|
|
13878
|
+
function serializeSshSignatureFormat(blob) {
|
|
13879
|
+
const writer = new SshWriter();
|
|
13880
|
+
writer.writeBytes(new TextEncoder().encode('SSHSIG'));
|
|
13881
|
+
writer.writeUint32(blob.version || 1);
|
|
13882
|
+
if (blob.publicKey) {
|
|
13883
|
+
writer.writeUint32(blob.publicKey.length);
|
|
13884
|
+
writer.writeBytes(blob.publicKey);
|
|
13885
|
+
}
|
|
13886
|
+
else {
|
|
13887
|
+
writer.writeUint32(0);
|
|
13888
|
+
}
|
|
13889
|
+
writer.writeString(blob.namespace || 'file');
|
|
13890
|
+
writer.writeString(blob.reserved || '');
|
|
13891
|
+
writer.writeString(blob.hashAlgorithm || 'sha512');
|
|
13892
|
+
const sigWriter = new SshWriter();
|
|
13893
|
+
sigWriter.writeString(blob.algorithm);
|
|
13894
|
+
sigWriter.writeUint32(blob.signature.length);
|
|
13895
|
+
sigWriter.writeBytes(blob.signature);
|
|
13896
|
+
const sigData = sigWriter.toUint8Array();
|
|
13897
|
+
writer.writeUint32(sigData.length);
|
|
13898
|
+
writer.writeBytes(sigData);
|
|
13899
|
+
return writer.toUint8Array();
|
|
13900
|
+
}
|
|
13901
|
+
function serializeLegacyFormat(blob) {
|
|
13902
|
+
const writer = new SshWriter();
|
|
13903
|
+
writer.writeString(blob.algorithm);
|
|
13904
|
+
writer.writeUint32(blob.signature.length);
|
|
13905
|
+
writer.writeBytes(blob.signature);
|
|
13906
|
+
return writer.toUint8Array();
|
|
13907
|
+
}
|
|
13908
|
+
|
|
13909
|
+
class SshObject {
|
|
13910
|
+
}
|
|
13911
|
+
|
|
13912
|
+
class SshPublicKey extends SshObject {
|
|
13913
|
+
static TYPE = 'public-key';
|
|
13914
|
+
type = SshPublicKey.TYPE;
|
|
13915
|
+
blob;
|
|
13916
|
+
cachedCryptoKey;
|
|
13917
|
+
constructor(blob) {
|
|
13918
|
+
super();
|
|
13919
|
+
this.blob = blob;
|
|
13920
|
+
}
|
|
13921
|
+
async getCryptoKey(crypto = getCrypto()) {
|
|
13922
|
+
if (!this.cachedCryptoKey) {
|
|
13923
|
+
const binding = AlgorithmRegistry.get(this.blob.type);
|
|
13924
|
+
this.cachedCryptoKey = await binding.importPublicSsh({ blob: this.blob.keyData, crypto });
|
|
13925
|
+
}
|
|
13926
|
+
return this.cachedCryptoKey;
|
|
13927
|
+
}
|
|
13928
|
+
static async fromSSH(sshKey, crypto = getCrypto()) {
|
|
13929
|
+
const blob = parsePublicKey(sshKey);
|
|
13930
|
+
const binding = AlgorithmRegistry.get(blob.type);
|
|
13931
|
+
await binding.importPublicSsh({ blob: blob.keyData, crypto });
|
|
13932
|
+
return new SshPublicKey(blob);
|
|
13933
|
+
}
|
|
13934
|
+
static async fromSPKI(spki, type, crypto = getCrypto()) {
|
|
13935
|
+
const binding = AlgorithmRegistry.get(type);
|
|
13936
|
+
const cryptoKey = await binding.importPublicSpki({ spki, crypto });
|
|
13937
|
+
const exported = await binding.exportPublicSsh({ publicKey: cryptoKey, crypto });
|
|
13938
|
+
const blob = {
|
|
13939
|
+
type,
|
|
13940
|
+
keyData: exported,
|
|
13941
|
+
};
|
|
13942
|
+
return new SshPublicKey(blob);
|
|
13943
|
+
}
|
|
13944
|
+
static async fromWebCrypto(cryptoKey, type, crypto = getCrypto()) {
|
|
13945
|
+
const sshType = type || AlgorithmRegistry.getSshTypeFromCryptoKey(cryptoKey);
|
|
13946
|
+
const binding = AlgorithmRegistry.get(sshType);
|
|
13947
|
+
const exported = await binding.exportPublicSsh({ publicKey: cryptoKey, crypto });
|
|
13948
|
+
const blob = {
|
|
13949
|
+
type: sshType,
|
|
13950
|
+
keyData: exported,
|
|
13951
|
+
};
|
|
13952
|
+
return new SshPublicKey(blob);
|
|
13953
|
+
}
|
|
13954
|
+
async export(format = 'ssh', crypto = getCrypto()) {
|
|
13955
|
+
if (format === 'ssh') {
|
|
13956
|
+
return serializePublicKey(this.blob);
|
|
13957
|
+
}
|
|
13958
|
+
else if (format === 'spki') {
|
|
13959
|
+
const cryptoKey = await this.getCryptoKey(crypto);
|
|
13960
|
+
const binding = AlgorithmRegistry.get(this.blob.type);
|
|
13961
|
+
const spki = await binding.exportPublicSpki({ publicKey: cryptoKey, crypto });
|
|
13962
|
+
return new Uint8Array(spki);
|
|
13963
|
+
}
|
|
13964
|
+
throw new UnsupportedKeyTypeError(`Unsupported export format: ${format}`);
|
|
13965
|
+
}
|
|
13966
|
+
async toSSH() {
|
|
13967
|
+
const result = await this.export('ssh');
|
|
13968
|
+
return result;
|
|
13969
|
+
}
|
|
13970
|
+
async toSPKI() {
|
|
13971
|
+
const result = await this.export('spki');
|
|
13972
|
+
return result;
|
|
13973
|
+
}
|
|
13974
|
+
async toWebCrypto(crypto = getCrypto()) {
|
|
13975
|
+
return this.getCryptoKey(crypto);
|
|
13976
|
+
}
|
|
13977
|
+
async verify(algorithm, signature, data, crypto = getCrypto()) {
|
|
13978
|
+
const binding = AlgorithmRegistry.get(algorithm);
|
|
13979
|
+
const cryptoKey = await this.toWebCrypto(crypto);
|
|
13980
|
+
return binding.verify({
|
|
13981
|
+
publicKey: cryptoKey,
|
|
13982
|
+
signature,
|
|
13983
|
+
data,
|
|
13984
|
+
crypto,
|
|
13985
|
+
});
|
|
13986
|
+
}
|
|
13987
|
+
get keyType() {
|
|
13988
|
+
return this.blob.type;
|
|
13989
|
+
}
|
|
13990
|
+
get comment() {
|
|
13991
|
+
return this.blob.comment;
|
|
13992
|
+
}
|
|
13993
|
+
getBlob() {
|
|
13994
|
+
return { ...this.blob };
|
|
13995
|
+
}
|
|
13996
|
+
async thumbprint(algorithm = 'sha256', crypto = getCrypto()) {
|
|
13997
|
+
const hashAlgorithm = algorithm === 'sha256' ? 'SHA-256' : 'SHA-512';
|
|
13998
|
+
const data = this.blob.keyData;
|
|
13999
|
+
const hash = await crypto.subtle.digest(hashAlgorithm, data);
|
|
14000
|
+
return new Uint8Array(hash);
|
|
14001
|
+
}
|
|
14002
|
+
}
|
|
14003
|
+
|
|
14004
|
+
class SshSignature extends SshObject {
|
|
14005
|
+
static TYPE = 'signature';
|
|
14006
|
+
type = SshSignature.TYPE;
|
|
14007
|
+
blob;
|
|
14008
|
+
format;
|
|
14009
|
+
algorithm;
|
|
14010
|
+
signature;
|
|
14011
|
+
version;
|
|
14012
|
+
publicKey;
|
|
14013
|
+
namespace;
|
|
14014
|
+
reserved;
|
|
14015
|
+
hashAlgorithm;
|
|
14016
|
+
constructor(blob) {
|
|
14017
|
+
super();
|
|
14018
|
+
this.blob = blob;
|
|
14019
|
+
this.format = blob.format;
|
|
14020
|
+
this.algorithm = blob.algorithm;
|
|
14021
|
+
this.signature = blob.signature;
|
|
14022
|
+
this.version = blob.version;
|
|
14023
|
+
this.namespace = blob.namespace;
|
|
14024
|
+
this.reserved = blob.reserved;
|
|
14025
|
+
this.hashAlgorithm = blob.hashAlgorithm;
|
|
14026
|
+
if (blob.publicKey) {
|
|
14027
|
+
const reader = new SshReader(blob.publicKey);
|
|
14028
|
+
const type = reader.readString();
|
|
14029
|
+
this.publicKey = new SshPublicKey({ type, keyData: blob.publicKey });
|
|
14030
|
+
}
|
|
14031
|
+
}
|
|
14032
|
+
static parse(data) {
|
|
14033
|
+
const blob = parseSignature(data);
|
|
14034
|
+
return new SshSignature(blob);
|
|
14035
|
+
}
|
|
14036
|
+
static fromBlob(blob) {
|
|
14037
|
+
return new SshSignature(blob);
|
|
14038
|
+
}
|
|
14039
|
+
static fromBase64(base64) {
|
|
14040
|
+
const data = new Uint8Array(buildExports.Convert.FromBase64(base64));
|
|
14041
|
+
return SshSignature.parse(data);
|
|
14042
|
+
}
|
|
14043
|
+
static fromText(text) {
|
|
14044
|
+
const base64 = text
|
|
14045
|
+
.replace(/-----BEGIN SSH SIGNATURE-----/, '')
|
|
14046
|
+
.replace(/-----END SSH SIGNATURE-----/, '')
|
|
14047
|
+
.replace(/[\r\n\s]/g, '');
|
|
14048
|
+
return SshSignature.fromBase64(base64);
|
|
14049
|
+
}
|
|
14050
|
+
serialize() {
|
|
14051
|
+
return serializeSignature(this.blob);
|
|
14052
|
+
}
|
|
14053
|
+
toBase64() {
|
|
14054
|
+
return buildExports.Convert.ToBase64(this.serialize());
|
|
14055
|
+
}
|
|
14056
|
+
toText() {
|
|
14057
|
+
const base64 = this.toBase64();
|
|
14058
|
+
const lines = [];
|
|
14059
|
+
for (let i = 0; i < base64.length; i += 70) {
|
|
14060
|
+
lines.push(base64.substring(i, i + 70));
|
|
14061
|
+
}
|
|
14062
|
+
return ['-----BEGIN SSH SIGNATURE-----', ...lines, '-----END SSH SIGNATURE-----'].join('\n');
|
|
14063
|
+
}
|
|
14064
|
+
async toSSH() {
|
|
14065
|
+
return this.toText();
|
|
14066
|
+
}
|
|
14067
|
+
async verify(data, publicKey) {
|
|
14068
|
+
const binding = AlgorithmRegistry.get(this.algorithm);
|
|
14069
|
+
const cryptoKey = await publicKey['getCryptoKey']();
|
|
14070
|
+
const crypto = getCrypto();
|
|
14071
|
+
let dataToVerify = data;
|
|
14072
|
+
if (this.format === 'ssh-signature') {
|
|
14073
|
+
const hashAlg = this.hashAlgorithm || 'sha512';
|
|
14074
|
+
const namespace = this.namespace || 'file';
|
|
14075
|
+
const reserved = this.reserved || '';
|
|
14076
|
+
const hashAlgorithm = hashAlg === 'sha256' ? 'SHA-256' : 'SHA-512';
|
|
14077
|
+
const messageHash = await crypto.subtle.digest(hashAlgorithm, data);
|
|
14078
|
+
const messageHashBytes = new Uint8Array(messageHash);
|
|
14079
|
+
const writer = new SshWriter();
|
|
14080
|
+
writer.writeBytes(new TextEncoder().encode('SSHSIG'));
|
|
14081
|
+
writer.writeString(namespace);
|
|
14082
|
+
writer.writeString(reserved);
|
|
14083
|
+
writer.writeString(hashAlg);
|
|
14084
|
+
writer.writeUint32(messageHashBytes.length);
|
|
14085
|
+
writer.writeBytes(messageHashBytes);
|
|
14086
|
+
dataToVerify = writer.toUint8Array();
|
|
14087
|
+
}
|
|
14088
|
+
let hashAlgorithm;
|
|
14089
|
+
if (this.algorithm === 'rsa-sha2-256') {
|
|
14090
|
+
hashAlgorithm = 'SHA-256';
|
|
14091
|
+
}
|
|
14092
|
+
else if (this.algorithm === 'rsa-sha2-512') {
|
|
14093
|
+
hashAlgorithm = 'SHA-512';
|
|
14094
|
+
}
|
|
14095
|
+
let signatureToVerify;
|
|
14096
|
+
if (this.format === 'legacy' || this.format === 'ssh-signature') {
|
|
14097
|
+
const sigWriter = new SshWriter();
|
|
14098
|
+
sigWriter.writeString(this.algorithm);
|
|
14099
|
+
sigWriter.writeUint32(this.signature.length);
|
|
14100
|
+
sigWriter.writeBytes(this.signature);
|
|
14101
|
+
const wireFormatSignature = sigWriter.toUint8Array();
|
|
14102
|
+
const decodedSig = binding.decodeSignature({
|
|
14103
|
+
signature: wireFormatSignature,
|
|
14104
|
+
});
|
|
14105
|
+
signatureToVerify = decodedSig.signature;
|
|
14106
|
+
}
|
|
14107
|
+
else {
|
|
14108
|
+
signatureToVerify = this.signature;
|
|
14109
|
+
}
|
|
14110
|
+
return binding.verify({
|
|
14111
|
+
publicKey: cryptoKey,
|
|
14112
|
+
signature: signatureToVerify,
|
|
14113
|
+
data: dataToVerify,
|
|
14114
|
+
crypto,
|
|
14115
|
+
hash: hashAlgorithm,
|
|
14116
|
+
});
|
|
14117
|
+
}
|
|
14118
|
+
static fromLegacy(algorithm, signature) {
|
|
14119
|
+
const binding = AlgorithmRegistry.get(algorithm);
|
|
14120
|
+
const encodedSignature = binding.encodeSignature({
|
|
14121
|
+
signature,
|
|
14122
|
+
algo: algorithm,
|
|
14123
|
+
});
|
|
14124
|
+
const sigReader = new SshReader(encodedSignature);
|
|
14125
|
+
sigReader.readString();
|
|
14126
|
+
const sigLength = sigReader.readUint32();
|
|
14127
|
+
const signatureData = sigReader.readBytes(sigLength);
|
|
14128
|
+
return new SshSignature({
|
|
14129
|
+
format: 'legacy',
|
|
14130
|
+
algorithm,
|
|
14131
|
+
signature: signatureData,
|
|
14132
|
+
});
|
|
14133
|
+
}
|
|
14134
|
+
static fromSshSignature(algorithm, signature, options = {}) {
|
|
14135
|
+
const blob = {
|
|
14136
|
+
format: 'ssh-signature',
|
|
14137
|
+
algorithm,
|
|
14138
|
+
signature,
|
|
14139
|
+
version: options.version || 1,
|
|
14140
|
+
publicKey: options.publicKey ? options.publicKey.getBlob().keyData : undefined,
|
|
14141
|
+
namespace: options.namespace || 'file',
|
|
14142
|
+
reserved: options.reserved || '',
|
|
14143
|
+
hashAlgorithm: options.hashAlgorithm || 'sha512',
|
|
14144
|
+
};
|
|
14145
|
+
return new SshSignature(blob);
|
|
14146
|
+
}
|
|
14147
|
+
static async sign(algorithm, privateKey, data, options = {}) {
|
|
14148
|
+
const { format = 'legacy', namespace = 'file' } = options;
|
|
14149
|
+
if (format === 'legacy') {
|
|
14150
|
+
const rawSignature = await privateKey.sign(algorithm, data);
|
|
14151
|
+
const algorithmUsed = algorithm || privateKey.keyType;
|
|
14152
|
+
return SshSignature.fromLegacy(algorithmUsed, rawSignature);
|
|
14153
|
+
}
|
|
14154
|
+
else {
|
|
14155
|
+
const signatureAlgorithm = algorithm;
|
|
14156
|
+
const binding = AlgorithmRegistry.get(signatureAlgorithm);
|
|
14157
|
+
const hashAlgorithm = algorithm === 'rsa-sha2-256' ? 'sha256' : 'sha512';
|
|
14158
|
+
const publicKey = await privateKey.getPublicKey();
|
|
14159
|
+
const crypto = getCrypto();
|
|
14160
|
+
const webCryptoHashAlg = hashAlgorithm === 'sha256' ? 'SHA-256' : 'SHA-512';
|
|
14161
|
+
const messageHash = await crypto.subtle.digest(webCryptoHashAlg, data);
|
|
14162
|
+
const messageHashBytes = new Uint8Array(messageHash);
|
|
14163
|
+
const writer = new SshWriter();
|
|
14164
|
+
writer.writeBytes(new TextEncoder().encode('SSHSIG'));
|
|
14165
|
+
writer.writeString(namespace);
|
|
14166
|
+
writer.writeString('');
|
|
14167
|
+
writer.writeString(hashAlgorithm);
|
|
14168
|
+
writer.writeUint32(messageHashBytes.length);
|
|
14169
|
+
writer.writeBytes(messageHashBytes);
|
|
14170
|
+
const dataToSign = writer.toUint8Array();
|
|
14171
|
+
const rawSignature = await privateKey.sign(signatureAlgorithm, dataToSign);
|
|
14172
|
+
const encodedSignature = binding.encodeSignature({
|
|
14173
|
+
signature: rawSignature,
|
|
14174
|
+
algo: signatureAlgorithm,
|
|
14175
|
+
});
|
|
14176
|
+
const sigReader = new SshReader(encodedSignature);
|
|
14177
|
+
sigReader.readString();
|
|
14178
|
+
const sigLength = sigReader.readUint32();
|
|
14179
|
+
const signatureData = sigReader.readBytes(sigLength);
|
|
14180
|
+
return SshSignature.fromSshSignature(signatureAlgorithm, signatureData, {
|
|
14181
|
+
namespace,
|
|
14182
|
+
hashAlgorithm,
|
|
14183
|
+
publicKey,
|
|
14184
|
+
});
|
|
14185
|
+
}
|
|
14186
|
+
}
|
|
14187
|
+
}
|
|
14188
|
+
|
|
14189
|
+
let SshCertificate$1 = class SshCertificate extends SshObject {
|
|
14190
|
+
static TYPE = 'certificate';
|
|
14191
|
+
type = SshCertificate.TYPE;
|
|
14192
|
+
_blob;
|
|
14193
|
+
data;
|
|
14194
|
+
_validAfter;
|
|
14195
|
+
_validBefore;
|
|
14196
|
+
keyId;
|
|
14197
|
+
principals;
|
|
14198
|
+
certType;
|
|
14199
|
+
serial;
|
|
14200
|
+
validAfter;
|
|
14201
|
+
validBefore;
|
|
14202
|
+
publicKey;
|
|
14203
|
+
signatureKey;
|
|
14204
|
+
criticalOptions;
|
|
14205
|
+
extensions;
|
|
14206
|
+
constructor(blob) {
|
|
14207
|
+
super();
|
|
14208
|
+
this._blob = blob;
|
|
14209
|
+
this.data = parseCertificateData(blob.keyData);
|
|
14210
|
+
this._validAfter = this.data.validAfter;
|
|
14211
|
+
this._validBefore = this.data.validBefore;
|
|
14212
|
+
this.keyId = this.data.keyId;
|
|
14213
|
+
this.principals = this.data.validPrincipals;
|
|
14214
|
+
this.certType = this.data.type;
|
|
14215
|
+
this.serial = this.data.serial;
|
|
14216
|
+
this.validAfter = new Date(Number(this.data.validAfter) * 1000);
|
|
14217
|
+
this.validBefore = new Date(Number(this.data.validBefore) * 1000);
|
|
14218
|
+
this.publicKey = new SshPublicKey(this.data.publicKey);
|
|
14219
|
+
this.signatureKey = new SshPublicKey(this.data.signatureKey);
|
|
14220
|
+
this.criticalOptions = { ...this.data.criticalOptions };
|
|
14221
|
+
this.extensions = { ...this.data.extensions };
|
|
14222
|
+
}
|
|
14223
|
+
static async fromSSH(text) {
|
|
14224
|
+
const blob = parse(text);
|
|
14225
|
+
return new SshCertificate(blob);
|
|
14226
|
+
}
|
|
14227
|
+
static async fromBlob(blob) {
|
|
14228
|
+
return new SshCertificate(blob);
|
|
14229
|
+
}
|
|
14230
|
+
async toSSH() {
|
|
14231
|
+
return serialize(this._blob);
|
|
14232
|
+
}
|
|
14233
|
+
toBlob() {
|
|
14234
|
+
return { ...this._blob };
|
|
14235
|
+
}
|
|
14236
|
+
get blob() {
|
|
14237
|
+
return this.toBlob();
|
|
14238
|
+
}
|
|
14239
|
+
validate(date = new Date()) {
|
|
14240
|
+
const ts = BigInt(Math.floor(date.getTime() / 1000));
|
|
14241
|
+
const after = this._validAfter;
|
|
14242
|
+
const before = this._validBefore;
|
|
14243
|
+
const INFINITY = 0xffffffffffffffffn;
|
|
14244
|
+
const upper = before === INFINITY ? ts : before;
|
|
14245
|
+
return ts >= after && ts <= upper;
|
|
14246
|
+
}
|
|
14247
|
+
async verify(caPublicKey, crypto = getCrypto()) {
|
|
14248
|
+
const verifyKey = caPublicKey || this.signatureKey;
|
|
14249
|
+
const signedData = this.getSignedData();
|
|
14250
|
+
const sshSignature = SshSignature.parse(this.data.signature);
|
|
14251
|
+
const binding = AlgorithmRegistry.get(sshSignature.algorithm);
|
|
14252
|
+
const cryptoKey = await verifyKey.toWebCrypto(crypto);
|
|
14253
|
+
return binding.verify({
|
|
14254
|
+
publicKey: cryptoKey,
|
|
14255
|
+
signature: sshSignature.signature,
|
|
14256
|
+
data: signedData,
|
|
14257
|
+
crypto,
|
|
14258
|
+
});
|
|
14259
|
+
}
|
|
14260
|
+
getSignedData() {
|
|
14261
|
+
const reader = new SshReader(this._blob.keyData);
|
|
14262
|
+
reader.readString();
|
|
14263
|
+
reader.readBytes(reader.readUint32());
|
|
14264
|
+
if (this.data.keyType === 'ssh-ed25519') {
|
|
14265
|
+
reader.readBytes(reader.readUint32());
|
|
14266
|
+
}
|
|
14267
|
+
else if (this.data.keyType === 'ssh-rsa') {
|
|
14268
|
+
reader.readBytes(reader.readUint32());
|
|
14269
|
+
reader.readBytes(reader.readUint32());
|
|
14270
|
+
}
|
|
14271
|
+
else if (this.data.keyType.startsWith('ecdsa-sha2-')) {
|
|
14272
|
+
reader.readString();
|
|
14273
|
+
reader.readBytes(reader.readUint32());
|
|
14274
|
+
}
|
|
14275
|
+
reader.readUint64();
|
|
14276
|
+
reader.readUint32();
|
|
14277
|
+
reader.readBytes(reader.readUint32());
|
|
14278
|
+
reader.readBytes(reader.readUint32());
|
|
14279
|
+
reader.readUint64();
|
|
14280
|
+
reader.readUint64();
|
|
14281
|
+
reader.readBytes(reader.readUint32());
|
|
14282
|
+
reader.readBytes(reader.readUint32());
|
|
14283
|
+
reader.readBytes(reader.readUint32());
|
|
14284
|
+
reader.readBytes(reader.readUint32());
|
|
14285
|
+
const signedDataEnd = reader.getOffset();
|
|
14286
|
+
return this._blob.keyData.slice(0, signedDataEnd);
|
|
14287
|
+
}
|
|
14288
|
+
};
|
|
14289
|
+
|
|
14290
|
+
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
14291
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14292
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14293
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
14294
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
14295
|
+
};
|
|
14296
|
+
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
14297
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
14298
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
14299
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
14300
|
+
};
|
|
14301
|
+
var _SshCertificate_cert;
|
|
14302
|
+
class SshCertificate {
|
|
14303
|
+
constructor(raw) {
|
|
14304
|
+
_SshCertificate_cert.set(this, void 0);
|
|
14305
|
+
const blob = parse(raw.trim());
|
|
14306
|
+
// @ts-expect-error - SshCertificateType is not a constructor
|
|
14307
|
+
__classPrivateFieldSet(this, _SshCertificate_cert, new SshCertificate$1(blob), "f");
|
|
14308
|
+
this.notBefore = __classPrivateFieldGet(this, _SshCertificate_cert, "f").validAfter;
|
|
14309
|
+
this.notAfter = __classPrivateFieldGet(this, _SshCertificate_cert, "f").validBefore;
|
|
14310
|
+
this.validity = dateDiff(this.notBefore, this.notAfter);
|
|
14311
|
+
this.type = [__classPrivateFieldGet(this, _SshCertificate_cert, "f").blob.type, __classPrivateFieldGet(this, _SshCertificate_cert, "f").certType, __classPrivateFieldGet(this, _SshCertificate_cert, "f").type].join(' ');
|
|
14312
|
+
this.serialNumber = __classPrivateFieldGet(this, _SshCertificate_cert, "f").serial.toString();
|
|
14313
|
+
this.keyId = __classPrivateFieldGet(this, _SshCertificate_cert, "f").keyId;
|
|
14314
|
+
this.principals = __classPrivateFieldGet(this, _SshCertificate_cert, "f").principals;
|
|
14315
|
+
this.extensions = __classPrivateFieldGet(this, _SshCertificate_cert, "f").extensions;
|
|
14316
|
+
this.criticalOptions = __classPrivateFieldGet(this, _SshCertificate_cert, "f").criticalOptions;
|
|
14317
|
+
}
|
|
14318
|
+
async parseSignatureKey() {
|
|
14319
|
+
const key = await __classPrivateFieldGet(this, _SshCertificate_cert, "f").signatureKey.toWebCrypto();
|
|
14320
|
+
const blob = __classPrivateFieldGet(this, _SshCertificate_cert, "f").signatureKey.getBlob();
|
|
14321
|
+
const thumbprint = await __classPrivateFieldGet(this, _SshCertificate_cert, "f").signatureKey.thumbprint('sha256');
|
|
14322
|
+
this.signatureKey = {
|
|
14323
|
+
algorithm: key.algorithm.name,
|
|
14324
|
+
type: blob.type,
|
|
14325
|
+
value: await __classPrivateFieldGet(this, _SshCertificate_cert, "f").signatureKey.toSSH(),
|
|
14326
|
+
thumbprint: buildExports.Convert.ToBase64(thumbprint),
|
|
14327
|
+
};
|
|
14328
|
+
}
|
|
14329
|
+
async parsePublicKey() {
|
|
14330
|
+
const key = await __classPrivateFieldGet(this, _SshCertificate_cert, "f").publicKey.toWebCrypto();
|
|
14331
|
+
const blob = __classPrivateFieldGet(this, _SshCertificate_cert, "f").publicKey.getBlob();
|
|
14332
|
+
const thumbprint = await __classPrivateFieldGet(this, _SshCertificate_cert, "f").publicKey.thumbprint('sha256');
|
|
14333
|
+
this.publicKey = {
|
|
14334
|
+
algorithm: key.algorithm.name,
|
|
14335
|
+
type: blob.type,
|
|
14336
|
+
value: await __classPrivateFieldGet(this, _SshCertificate_cert, "f").publicKey.toSSH(),
|
|
14337
|
+
thumbprint: buildExports.Convert.ToBase64(thumbprint),
|
|
14338
|
+
};
|
|
14339
|
+
}
|
|
14340
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14341
|
+
async toString(_format = 'pem') {
|
|
14342
|
+
return __classPrivateFieldGet(this, _SshCertificate_cert, "f").toSSH();
|
|
14343
|
+
}
|
|
14344
|
+
}
|
|
14345
|
+
_SshCertificate_cert = new WeakMap();
|
|
14346
|
+
|
|
12700
14347
|
exports.ArchiveRevInfo = ArchiveRevInfo;
|
|
12701
14348
|
exports.AsnArray = AsnArray;
|
|
12702
14349
|
exports.AsnConvert = AsnConvert;
|
|
@@ -12739,6 +14386,7 @@ exports.RootOfTrust = RootOfTrust;
|
|
|
12739
14386
|
exports.SemanticsInformation = SemanticsInformation;
|
|
12740
14387
|
exports.SignedCertificateTimestamp = SignedCertificateTimestamp;
|
|
12741
14388
|
exports.SignedData = SignedData;
|
|
14389
|
+
exports.SshCertificate = SshCertificate;
|
|
12742
14390
|
exports.SubjectKeyIdentifier = SubjectKeyIdentifier;
|
|
12743
14391
|
exports.Timestamp = Timestamp;
|
|
12744
14392
|
exports.UserNotice = UserNotice;
|
|
@@ -12806,6 +14454,6 @@ exports.id_qcs_pkixQCSyntax_v2 = id_qcs_pkixQCSyntax_v2;
|
|
|
12806
14454
|
exports.id_role = id_role;
|
|
12807
14455
|
exports.id_rsaEncryption = id_rsaEncryption;
|
|
12808
14456
|
exports.l10n = l10n;
|
|
12809
|
-
//# sourceMappingURL=
|
|
14457
|
+
//# sourceMappingURL=ssh_certificate-s3-rwdMT.js.map
|
|
12810
14458
|
|
|
12811
|
-
//# sourceMappingURL=
|
|
14459
|
+
//# sourceMappingURL=ssh_certificate-s3-rwdMT.js.map
|