Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sequence = sequence.then(() =>
{
const tspResponse = new TimeStampResp({
status: new PKIStatusInfo({
status: 0 // granted
}),
timeStampToken: new ContentInfo({
contentType: "1.2.840.113549.1.7.2",
content: cmsSignedSimpl.toSchema(false)
})
});
return tspResponse.toSchema().toBER(false);
});
document.getElementById("cms-certs").style.display = "none";
document.getElementById("cms-crls").style.display = "none";
const certificatesTable = document.getElementById("cms-certificates");
while(certificatesTable.rows.length > 1)
certificatesTable.deleteRow(certificatesTable.rows.length - 1);
const crlsTable = document.getElementById("cms-rev-lists");
while(crlsTable.rows.length > 1)
crlsTable.deleteRow(crlsTable.rows.length - 1);
//endregion
//region Decode existing CMS Signed Data
const asn1 = asn1js.fromBER(cmsSignedBuffer);
const cmsContentSimpl = new ContentInfo({ schema: asn1.result });
const cmsSignedSimpl = new SignedData({ schema: cmsContentSimpl.content });
for(const signerInfo of cmsSignedSimpl.signerInfos)
{
if("signedAttrs" in signerInfo)
signerInfo.signedAttrs.attributes = Array.from(signerInfo.signedAttrs.attributes, element => new AttributeCAdES(element));
if("unsignedAttrs" in signerInfo)
signerInfo.unsignedAttrs.attributes = Array.from(signerInfo.unsignedAttrs.attributes, element => new AttributeCAdES(element));
}
//endregion
//region Put information about digest algorithms in the CMS Signed Data
const dgstmap = {
"1.3.14.3.2.26": "SHA-1",
"2.16.840.1.101.3.4.2.1": "SHA-256",
sequence = sequence.then(() =>
{
const cmsContent = new ContentInfo({
contentType: "1.2.840.113549.1.7.2",
content: cmsSignedSimpl.toSchema(true)
});
cmsSignedBuffer = cmsContent.toSchema().toBER(false);
});
//endregion
if(!data) {
let res = request('GET', this.fetchurl, { 'timeout': 10000, 'retry': true, 'headers': { 'user-agent': 'nodejs' } });
databuf = res.body.buffer;
} else {
databuf = Pvutils.stringToArrayBuffer(data);
}
let asn1obj = Asn1js.fromBER(databuf);
let contentInfo = new Pkijs.ContentInfo({schema: asn1obj.result});
if(contentInfo.contentType !== "1.2.840.113549.1.7.2")
throw new Error(`Unknown content type '${contentInfo.contentType}' for contentInfo`);
this.signedData = new Pkijs.SignedData({schema: contentInfo.content});
let asn1obj2 = Asn1js.fromBER(this.signedData.encapContentInfo.eContent.valueBlock.valueHex);
let contentInfo2 = new Pkijs.ContentInfo({schema: asn1obj2.result});
if(contentInfo.contentType !== "1.2.840.113549.1.7.2")
throw new Error(`Unknown content type '${contentInfo.contentType}' for contentInfo`);
let signedData2 = new Pkijs.SignedData({schema: contentInfo2.content});
for(let cert of signedData2.certificates) {
let operator = "Unknown";
for(let rdn of cert.subject.typesAndValues) {
if(rdn.type === "2.5.4.10") {
operator = rdn.value.valueBlock.value;
break;
}
}
tl.AddCertificate({
raw: Pvutils.toBase64(Pvutils.arrayBufferToString(cert.toSchema(true).toBER())),
getTrusted(data?: string): TrustedList {
let tl = new TrustedList();
let databuf: Buffer;
if(!data) {
let res = request('GET', this.fetchurl, { 'timeout': 10000, 'retry': true, 'headers': { 'user-agent': 'nodejs' } });
databuf = res.body.buffer;
} else {
databuf = Pvutils.stringToArrayBuffer(data);
}
let asn1obj = Asn1js.fromBER(databuf);
let contentInfo = new Pkijs.ContentInfo({schema: asn1obj.result});
if(contentInfo.contentType !== "1.2.840.113549.1.7.2")
throw new Error(`Unknown content type '${contentInfo.contentType}' for contentInfo`);
this.signedData = new Pkijs.SignedData({schema: contentInfo.content});
let asn1obj2 = Asn1js.fromBER(this.signedData.encapContentInfo.eContent.valueBlock.valueHex);
let contentInfo2 = new Pkijs.ContentInfo({schema: asn1obj2.result});
if(contentInfo.contentType !== "1.2.840.113549.1.7.2")
throw new Error(`Unknown content type '${contentInfo.contentType}' for contentInfo`);
let signedData2 = new Pkijs.SignedData({schema: contentInfo2.content});
for(let cert of signedData2.certificates) {
let operator = "Unknown";
for(let rdn of cert.subject.typesAndValues) {
Cisco.prototype.getTrusted = function (data) {
var tl = new tl_create.TrustedList();
var databuf;
if (!data) {
var res = request('GET', this.fetchurl, { 'timeout': 10000, 'retry': true, 'headers': { 'user-agent': 'nodejs' } });
databuf = res.body.buffer;
}
else {
databuf = Pvutils.stringToArrayBuffer(data);
}
var asn1obj = Asn1js.fromBER(databuf);
var contentInfo = new Pkijs.ContentInfo({ schema: asn1obj.result });
if (contentInfo.contentType !== "1.2.840.113549.1.7.2")
throw new Error("Unknown content type '" + contentInfo.contentType + "' for contentInfo");
this.signedData = new Pkijs.SignedData({ schema: contentInfo.content });
var asn1obj2 = Asn1js.fromBER(this.signedData.encapContentInfo.eContent.valueBlock.valueHex);
var contentInfo2 = new Pkijs.ContentInfo({ schema: asn1obj2.result });
if (contentInfo.contentType !== "1.2.840.113549.1.7.2")
throw new Error("Unknown content type '" + contentInfo.contentType + "' for contentInfo");
var signedData2 = new Pkijs.SignedData({ schema: contentInfo2.content });
for (var _i = 0, _a = signedData2.certificates; _i < _a.length; _i++) {
var cert = _a[_i];
var operator = "Unknown";
for (var _b = 0, _c = cert.subject.typesAndValues; _b < _c.length; _b++) {
var rdn = _c[_b];
if (rdn.type === "2.5.4.10") {
operator = rdn.value.valueBlock.value;
break;
var tl = new tl_create.TrustedList();
var databuf;
if (!data) {
var res = request('GET', this.fetchurl, { 'timeout': 10000, 'retry': true, 'headers': { 'user-agent': 'nodejs' } });
databuf = res.body.buffer;
}
else {
databuf = Pvutils.stringToArrayBuffer(data);
}
var asn1obj = Asn1js.fromBER(databuf);
var contentInfo = new Pkijs.ContentInfo({ schema: asn1obj.result });
if (contentInfo.contentType !== "1.2.840.113549.1.7.2")
throw new Error("Unknown content type '" + contentInfo.contentType + "' for contentInfo");
this.signedData = new Pkijs.SignedData({ schema: contentInfo.content });
var asn1obj2 = Asn1js.fromBER(this.signedData.encapContentInfo.eContent.valueBlock.valueHex);
var contentInfo2 = new Pkijs.ContentInfo({ schema: asn1obj2.result });
if (contentInfo.contentType !== "1.2.840.113549.1.7.2")
throw new Error("Unknown content type '" + contentInfo.contentType + "' for contentInfo");
var signedData2 = new Pkijs.SignedData({ schema: contentInfo2.content });
for (var _i = 0, _a = signedData2.certificates; _i < _a.length; _i++) {
var cert = _a[_i];
var operator = "Unknown";
for (var _b = 0, _c = cert.subject.typesAndValues; _b < _c.length; _b++) {
var rdn = _c[_b];
if (rdn.type === "2.5.4.10") {
operator = rdn.value.valueBlock.value;
break;
}
}
tl.AddCertificate({
raw: Pvutils.toBase64(Pvutils.arrayBufferToString(cert.toSchema(true).toBER())),
trust: ["ANY"],