Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
toSchema()
{
//region Create array for output sequence
const outputArray = [];
if("notBefore" in this)
{
outputArray.push(new asn1js.Primitive({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
valueHex: (new asn1js.GeneralizedTime({ valueDate: this.notBefore })).valueBlock.valueHex
}));
}
if("notAfter" in this)
{
outputArray.push(new asn1js.Primitive({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 1 // [1]
},
valueHex: (new asn1js.GeneralizedTime({ valueDate: this.notAfter })).valueBlock.valueHex
* @property {string} [notAfter]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.Primitive({
name: (names.notBefore || ""),
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
}
}),
new asn1js.Primitive({
name: (names.notAfter || ""),
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 1 // [1]
}
})
]
}));
}
//**********************************************************************************
* @property {string} [blockName]
* @property {string} [seconds]
* @property {string} [millis]
* @property {string} [micros]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
optional: true,
value: [
new asn1js.Integer({
optional: true,
name: (names.seconds || "")
}),
new asn1js.Primitive({
name: (names.millis || ""),
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
}
}),
new asn1js.Primitive({
name: (names.micros || ""),
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 1 // [1]
}
})
]
static schema(parameters = {})
{
/**
* @type {Object}
* @property {string} [blockName]
* @property {string} [keyIdentifier]
* @property {string} [authorityCertIssuer]
* @property {string} [authorityCertSerialNumber]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.Primitive({
name: (names.keyIdentifier || ""),
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
}
}),
new asn1js.Constructed({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 1 // [1]
},
value: [
new asn1js.Repeated({
name: (names.authorityCertIssuer || ""),
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 2 // [2]
},
name: (names.private_domain_name || ""),
value: [
new asn1js.Choice({
value: [
new asn1js.NumericString(),
new asn1js.PrintableString()
]
})
]
}),
new asn1js.Primitive({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 3 // [3]
},
name: (names.organization_name || ""),
isHexOnly: true
}),
new asn1js.Primitive({
optional: true,
name: (names.numeric_user_identifier || ""),
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 4 // [4]
},
isHexOnly: true
outputArray.push(this.signature.toSchema());
outputArray.push(this.issuer.toSchema());
outputArray.push(new asn1js.Sequence({
value: [
this.notBefore.toSchema(),
this.notAfter.toSchema()
]
}));
outputArray.push(this.subject.toSchema());
outputArray.push(this.subjectPublicKeyInfo.toSchema());
if("issuerUniqueID" in this)
{
outputArray.push(new asn1js.Primitive({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 1 // [1]
},
valueHex: this.issuerUniqueID
}));
}
if("subjectUniqueID" in this)
{
outputArray.push(new asn1js.Primitive({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 2 // [2]
},
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 1 // [1]
},
value: [
new asn1js.GeneralizedTime(),
new asn1js.Constructed({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
value: [new asn1js.Enumerated()]
})
]
}),
new asn1js.Primitive({
name: (names.certStatus || ""),
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 2 // [2]
},
lenBlock: { length: 1 }
}) // IMPLICIT NULL (no "valueBlock")
]
}),
new asn1js.GeneralizedTime({ name: (names.thisUpdate || "") }),
new asn1js.Constructed({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
static schema(parameters = {})
{
/**
* @type {Object}
* @property {string} [blockName]
* @property {string} [requireExplicitPolicy]
* @property {string} [inhibitPolicyMapping]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.Primitive({
name: (names.requireExplicitPolicy || ""),
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
}
}), // IMPLICIT integer value
new asn1js.Primitive({
name: (names.inhibitPolicyMapping || ""),
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 1 // [1]
}
}) // IMPLICIT integer value
]
ocspRespSimpl.responseBytes = new ResponseBytes();
ocspRespSimpl.responseBytes.responseType = "1.3.6.1.5.5.7.48.1.1";
const responderIDBuffer = new ArrayBuffer(1);
const responderIDView = new Uint8Array(responderIDBuffer);
responderIDView[0] = 0x01;
ocspBasicResp.tbsResponseData.responderID = certSimpl.issuer;
ocspBasicResp.tbsResponseData.producedAt = new Date();
const response = new SingleResponse();
response.certID.hashAlgorithm.algorithmId = "1.3.14.3.2.26"; // SHA-1
response.certID.issuerNameHash.valueBlock.valueHex = responderIDBuffer; // Fiction hash
response.certID.issuerKeyHash.valueBlock.valueHex = responderIDBuffer; // Fiction hash
response.certID.serialNumber.valueBlock.valueDec = 1; // Fiction serial number
response.certStatus = new asn1js.Primitive({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
lenBlockLength: 1 // The length contains one byte 0x00
}); // status - success
response.thisUpdate = new Date();
ocspBasicResp.tbsResponseData.responses.push(response);
ocspBasicResp.certs = [certSimpl];
return ocspBasicResp.sign(privateKey, hashAlg);
}
);