Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
default:
}
} else {
throw new Error("Absent mandatory parameter \"crv\"");
}
["d"].forEach((name) => {
if (name in jwk) {
parsedKey.privateKey = new Asn1Js.OctetString({ valueHex: this.getCoordinate((jwk as any)[name], coordinateLength) });
} else {
throw new Error(`Absent mandatory parameter '${name}'`);
}
});
const pkcs8 = new pkijs.PrivateKeyInfo();
pkcs8.privateKeyAlgorithm = new pkijs.AlgorithmIdentifier({
algorithmId: "1.2.840.10045.2.1",
algorithmParams: new Asn1Js.ObjectIdentifier({ value: parsedKey.namedCurve }),
});
pkcs8.privateKey = new Asn1Js.OctetString({ valueHex: parsedKey.toSchema().toBER(false) });
return pkcs8.toSchema().toBER(false);
}
() => {
if(hashAlgorithm.toUpperCase() !== "SHA-256")
{
const oid = getOIDByAlgorithm({ name: hashAlgorithm });
if(oid === "")
return Promise.reject(`Incorrect hashing algorithm: ${hashAlgorithm}`);
_this.hashAlgorithm = new AlgorithmIdentifier({
algorithmId: oid,
algorithmParams: new asn1js.Null()
});
}
return Promise.resolve();
}
);
default:
}
} else {
throw new Error("Absent mandatory parameter \"crv\"");
}
["d"].forEach((name) => {
if (name in jwk) {
parsedKey.privateKey = new Asn1Js.OctetString({ valueHex: getCoordinate((jwk as any)[name], coordinateLength) });
} else {
throw new Error(`Absent mandatory parameter '${name}'`);
}
});
const pkcs8 = new PrivateKeyInfo();
pkcs8.privateKeyAlgorithm = new AlgorithmIdentifier({
algorithmId: "1.2.840.10045.2.1",
algorithmParams: new Asn1Js.ObjectIdentifier({ value: parsedKey.namedCurve }),
});
pkcs8.privateKey = new Asn1Js.OctetString({ valueHex: parsedKey.toSchema().toBER(false) });
return pkcs8.toSchema().toBER(false);
}
default:
}
} else {
throw new Error("Absent mandatory parameter \"crv\"");
}
["x", "y"].forEach((name) => {
if (name in jwk) {
parsedKey[name] = this.getCoordinate((jwk as any)[name], coordinateLength);
} else {
throw new Error(`Absent mandatory parameter '${name}'`);
}
});
const spki = new pkijs.PublicKeyInfo();
spki.algorithm = new pkijs.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);
}
default:
}
} 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);
}
issuerSerial: {
names: {
blockName: "issuerSerial"
}
}
}
})
);
if(asn1.verified === false)
throw new Error("Object's schema was not verified against input data for ESSCertIDv2");
//endregion
//region Get internal properties from parsed schema
if("hashAlgorithm" in asn1.result)
this.hashAlgorithm = new AlgorithmIdentifier({ schema: asn1.result.hashAlgorithm });
this.certHash = asn1.result.serialNumber;
this.issuerSerial = new IssuerSerial({ schema: asn1.result.issuerSerial });
//endregion
}
//**********************************************************************************
hashAlgorithm: {
names: {
blockName: "hashAlgorithm"
}
},
hashValue: "hashValue"
}
})
);
if(asn1.verified === false)
throw new Error("Object's schema was not verified against input data for OtherHashAlgAndValue");
//endregion
//region Get internal properties from parsed schema
this.hashAlgorithm = new AlgorithmIdentifier({ schema: asn1.result.hashAlgorithm });
this.hashValue = asn1.result.hashValue;
//endregion
}
//**********************************************************************************
() => {
if(hashAlgorithm.toUpperCase() !== "SHA-1")
{
const oid = getOIDByAlgorithm({ name: hashAlgorithm });
if(oid === "")
return Promise.reject(`Incorrect hashing algorithm: ${hashAlgorithm}`);
_this.otherCertHash = new OtherHashAlgAndValue({
hashAlgorithm: new AlgorithmIdentifier({
algorithmId: oid,
algorithmParams: new asn1js.Null()
})
});
}
else
_this.otherCertHash = new asn1js.OctetString();
return Promise.resolve();
}
);