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(() =>
{
cmsSignedSimpl = new SignedData({
version: 3,
encapContentInfo: new EncapsulatedContentInfo({
eContentType: "1.2.840.113549.1.9.16.1.4" // "tSTInfo" content type
//eContentType: "1.2.840.113549.1.7.1" // "data" content type
}),
signerInfos: [signerInfo],
certificates: [certSimpl]
});
cmsSignedSimpl.encapContentInfo.eContent = new asn1js.OctetString({ valueHex: tstInfo.toSchema().toBER(false) });
const parameters = getAlgorithmParameters(tspPublicKey.algorithm.name, "sign");
return cmsSignedSimpl.sign(tspKey, 0, parameters.algorithm.hash.name || {});
});
* @property {string} [blockName]
* @property {string} [extnID]
* @property {string} [critical]
* @property {string} [extnValue]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.ObjectIdentifier({ name: (names.extnID || "") }),
new asn1js.Boolean({
name: (names.critical || ""),
optional: true
}),
new asn1js.OctetString({ name: (names.extnValue || "") })
]
}));
}
//**********************************************************************************
result => {
if(this.ocspRepHash instanceof OtherHashAlgAndValue)
this.ocspRepHash.hashValue = new asn1js.OctetString({ valueHex: result });
else
this.ocspRepHash = new asn1js.OctetString({ valueHex: result });
this.ocspIdentifier = new OcspIdentifier();
this.ocspIdentifier.fillValues({
ocspResponse
});
},
error => Promise.reject(error)
result => {
for(let i = 0; i < result.length; i++)
_this.certificatesHashIndex.push(new asn1js.OctetString({ valueHex: result[i] }));
},
error => Promise.reject(error)
result => {
if(_this._crlHashType === 0)
_this.crlHash = new asn1js.OctetString({ valueHex: result });
else
_this.crlHash.hashValue = new asn1js.OctetString({ valueHex: result });
_this.crlIdentifier = new CrlIdentifier();
_this.crlIdentifier.fillValues({
crl
});
},
error => Promise.reject(error)
static defaultValues(memberName)
{
switch(memberName)
{
case "subjectKeyIdentifier":
return new asn1js.OctetString();
case "date":
return new asn1js.GeneralizedTime();
case "other":
return new OtherKeyAttribute();
default:
throw new Error(`Invalid member name for RecipientKeyIdentifier class: ${memberName}`);
}
}
//**********************************************************************************
result =>
{
const hashedBuffer = new ArrayBuffer(4);
const hashedView = new Uint8Array(hashedBuffer);
hashedView[0] = 0x7F;
hashedView[1] = 0x02;
hashedView[2] = 0x03;
hashedView[3] = 0x04;
const tstInfoSimpl = new TSTInfo({
version: 1,
policy: "1.1.1",
messageImprint: new MessageImprint({
hashAlgorithm: new AlgorithmIdentifier({ algorithmId: getOIDByAlgorithm({ name: hashAlg }) }),
hashedMessage: new asn1js.OctetString({ valueHex: result })
}),
serialNumber: new asn1js.Integer({ valueHex: hashedBuffer }),
genTime: new Date(),
ordering: true,
accuracy: new Accuracy({
seconds: 1,
millis: 1,
micros: 10
}),
nonce: new asn1js.Integer({ valueHex: hashedBuffer })
});
return tstInfoSimpl.toSchema().toBER(false);
}
);
algorithmParams: new asn1js.ObjectIdentifier({ value: this.parsedKey.namedCurve })
});
break;
case "RSA":
this.parsedKey = new RSAPrivateKey({ json });
this.privateKeyAlgorithm = new AlgorithmIdentifier({
algorithmId: "1.2.840.113549.1.1.1",
algorithmParams: new asn1js.Null()
});
break;
default:
throw new Error(`Invalid value for "kty" parameter: ${json.kty}`);
}
this.privateKey = new asn1js.OctetString({ valueHex: this.parsedKey.toSchema().toBER(false) });
}
}
//**********************************************************************************
result => {
if(_this.otherCertHash instanceof asn1js.OctetString)
_this.otherCertHash.valueBlock.valueHex = result;
else
_this.otherCertHash.hashValue = new asn1js.OctetString({ valueHex: result });
_this.issuerSerial = new IssuerSerial({
issuer: new GeneralNames({
names: [
new GeneralName({
type: 4,
value: certificate.issuer
})
]
}),
serialNumber: certificate.serialNumber
});
},
error => Promise.reject(error)
static schema(parameters = {})
{
/**
* @type {Object}
* @property {string} [blockName]
* @property {string} [hashAlgorithm]
* @property {string} [hashedMessage]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
AlgorithmIdentifier.schema(names.hashAlgorithm || {}),
new asn1js.OctetString({ name: (names.hashedMessage || "") })
]
}));
}
//**********************************************************************************