Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
makeAttribute(parameters = {})
{
//region Create and return attribute
return new Attribute({
type: "1.2.840.113549.1.9.16.2.22",
values: [
this.toSchema()
]
});
//endregion
}
//**********************************************************************************
result => {
//region Create signed attribute with "message digest" value
const attribute = new Attribute({
type: "1.2.840.113549.1.9.4",
values: [
new asn1js.OctetString({ valueHex: result })
]
});
//endregion
resultAttributes.push(attribute);
},
error => Promise.reject(error)
//endregion
//region Change type of "tspResponse"
const asn1 = asn1js.fromBER(tspResponse);
tspResponse = new TimeStampResp({ schema: asn1.result });
//endregion
//region Initialize internal variables from "tspResponse"
if("timeStampToken" in tspResponse)
this.fromSchema(tspResponse.timeStampToken.toSchema());
else
throw new Error("No neccessary \"timeStampToken\" inside \"tspResponse\"");
//endregion
//region Create and return attribute
return new Attribute({
type: "1.2.840.113549.1.9.16.2.14",
values: [
this.toSchema()
]
});
//endregion
}
//**********************************************************************************
makeAttribute(parameters = {})
{
//region Create and return attribute
return new Attribute({
type: "1.2.840.113549.1.9.16.2.21",
values: [
this.toSchema()
]
});
//endregion
}
//**********************************************************************************
throw new Error("Incorrect object schema for archive-time-stamp-v3 attribute: incorrect content type");
this.tspResponse = new TimeStampResp({ timeStampToken: schema });
const cmsSignedData = new SignedData({ schema: this.content });
if(cmsSignedData.signerInfos.length !== 1)
throw new Error("Incorrect object schema for archive-time-stamp-v3 attribute: incorrect signerInfos length");
if(("unsignedAttrs" in cmsSignedData.signerInfos[0]) === false)
throw new Error("Incorrect object schema for archive-time-stamp-v3 attribute: missing unsignedAttrs");
if(cmsSignedData.signerInfos[0].unsignedAttrs.attributes.length !== 1)
throw new Error("Incorrect object schema for archive-time-stamp-v3 attribute: incorrect unsignedAttrs length");
const attribute = new Attribute(cmsSignedData.signerInfos[0].unsignedAttrs.attributes[0]);
if(attribute.type !== "0.4.0.1733.2.5")
throw new Error("Incorrect object schema for archive-time-stamp-v3 attribute: incorrect type for aTSHashIndex value");
let parsedValue;
try
{
parsedValue = new ATSHashIndex({ schema: attribute.values[0] });
}
catch(e)
{
throw new Error("Incorrect object schema for archive-time-stamp-v3 attribute: incorrect aTSHashIndex value");
}
this.aTSHashIndex = parsedValue;
makeAttribute()
{
return new Attribute({
type: "1.2.840.113549.1.9.16.2.23",
values: [
this.toSchema()
]
});
}
//**********************************************************************************
makeAttribute(parameters = {})
{
//region Create and return attribute
return new Attribute({
type: "0.4.0.1733.2.5",
values: [
this.toSchema()
]
});
//endregion
}
//**********************************************************************************
() => {
//region Create "Content type" attribute
const contentTypeAttribute = new Attribute({
type: "1.2.840.113549.1.9.3",
values: [
new asn1js.ObjectIdentifier({ value: contentOID })
]
});
resultAttributes.push(contentTypeAttribute);
//endregion
//region Create "Signing Time" attribute
const signingTimeAttribute = new Attribute({
type: "1.2.840.113549.1.9.5",
values: [
new asn1js.UTCTime({ valueDate: getUTCDate(new Date()) })
]
});
resultAttributes.push(signingTimeAttribute);
//endregion
},
error => Promise.reject(error)
//endregion
//region Change type of "tspResponse"
const asn1 = asn1js.fromBER(tspResponse);
tspResponse = new TimeStampResp({ schema: asn1.result });
//endregion
//region Initialize internal variables from "tspResponse"
if("timeStampToken" in tspResponse)
this.fromSchema(tspResponse.timeStampToken.toSchema());
else
throw new Error("No neccessary \"timeStampToken\" inside \"tspResponse\"");
//endregion
//region Create and return attribute
return new Attribute({
type: "1.2.840.113549.1.9.16.2.25",
values: [
this.toSchema()
]
});
//endregion
}
//**********************************************************************************