Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* @property {string} [blockName]
* @property {Object} [directoryName]
* @property {Object} [builtInStandardAttributes]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Choice({
value: [
new asn1js.Constructed({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
name: (names.blockName || ""),
value: [
new asn1js.ObjectIdentifier(),
new asn1js.Constructed({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
},
value: [new asn1js.Any()]
})
]
}),
new asn1js.Primitive({
name: (names.blockName || ""),
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 1 // [1]
}
}),
* @property {string} [type]
* @property {string} [setName]
* @property {string} [values]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || "TimeStampReq"),
value: [
new asn1js.Integer({ name: (names.version || "TimeStampReq.version") }),
MessageImprint.schema(names.messageImprint || {
names: {
blockName: "TimeStampReq.messageImprint"
}
}),
new asn1js.ObjectIdentifier({
name: (names.reqPolicy || "TimeStampReq.reqPolicy"),
optional: true
}),
new asn1js.Integer({
name: (names.nonce || "TimeStampReq.nonce"),
optional: true
}),
new asn1js.Boolean({
name: (names.certReq || "TimeStampReq.certReq"),
optional: true
}),
new asn1js.Constructed({
optional: true,
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 0 // [0]
static schema(parameters = {})
{
/**
* @type {Object}
* @property {string} [blockName]
* @property {string} [responseType]
* @property {string} [response]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.ObjectIdentifier({ name: (names.responseType || "") }),
new asn1js.OctetString({ name: (names.response || "") })
]
}));
}
//**********************************************************************************
/**
* @type {Object}
* @property {string} [blockName]
* @property {string} [contentDescription]
* @property {string} [contentType]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.Utf8String({
name: (names.contentDescription || ""),
optinal: true
}),
new asn1js.ObjectIdentifier({ name: (names.contentType || "") })
]
}));
}
//**********************************************************************************
fromJSON(json)
{
if("kty" in json)
{
switch(json.kty.toUpperCase())
{
case "EC":
this.parsedKey = new ECPublicKey({ json });
this.algorithm = new AlgorithmIdentifier({
algorithmId: "1.2.840.10045.2.1",
algorithmParams: new asn1js.ObjectIdentifier({ value: this.parsedKey.namedCurve })
});
break;
case "RSA":
this.parsedKey = new RSAPublicKey({ json });
this.algorithm = 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.subjectPublicKey = new asn1js.BitString({ valueHex: this.parsedKey.toSchema().toBER(false) });
}
static schema(parameters = {})
{
/**
* @type {Object}
* @property {string} [blockName]
* @property {string} [otherRevInfoFormat]
* @property {string} [otherRevInfo]
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
value: [
new asn1js.ObjectIdentifier({ name: (names.otherRevInfoFormat || "otherRevInfoFormat") }),
new asn1js.Any({ name: (names.otherRevInfo || "otherRevInfo") })
]
}));
}
//**********************************************************************************
static schema(parameters = {})
{
/**
* @type {Object}
* @property {string} algorithmIdentifier ObjectIdentifier for the algorithm
* @property {string} algorithmParams Any algorithm parameters
*/
const names = getParametersValue(parameters, "names", {});
return (new asn1js.Sequence({
name: (names.blockName || ""),
optional: (names.optional || false),
value: [
new asn1js.ObjectIdentifier({ name: (names.algorithmIdentifier || "") }),
new asn1js.Any({ name: (names.algorithmParams || ""), optional: true })
]
}));
}
//**********************************************************************************
} else {
throw new Error("Absent mandatory parameter \"crv\"");
}
["x", "y"].forEach((name) => {
if (name in jwk) {
parsedKey[name] = getCoordinate((jwk as any)[name], coordinateLength);
} else {
throw new Error(`Absent mandatory parameter '${name}'`);
}
});
const spki = new PublicKeyInfo();
spki.algorithm = new AlgorithmIdentifier({
algorithmId: "1.2.840.10045.2.1",
algorithmParams: new Asn1Js.ObjectIdentifier({ value: parsedKey.namedCurve }),
});
spki.subjectPublicKey = new Asn1Js.BitString({ valueHex: parsedKey.toSchema().toBER(false) });
return spki.toSchema().toBER(false);
}
toSchema()
{
//region Construct and return new ASN.1 schema for this object
return (new asn1js.Sequence({
value: [
new asn1js.ObjectIdentifier({ value: this.oriType }),
this.oriValue
]
}));
//endregion
}
//**********************************************************************************
toSchema()
{
//region Construct and return new ASN.1 schema for this object
return (new asn1js.Sequence({
value: [
new asn1js.ObjectIdentifier({ value: this.accessMethod }),
this.accessLocation.toSchema()
]
}));
//endregion
}
//**********************************************************************************