Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected static getNamedCurve(name: string): INamedCurve {
let namedCurve: string;
switch (name) {
case "P-192":
namedCurve = "secp192r1";
break;
case "K-256":
const p256 = NamedCurve.getByName("secp256r1");
return {
name: "secp256k1",
oid: "1.3.132.0.10",
value: Buffer.from("06052b8104000A", "hex"),
size: p256.size,
};
case "P-256":
namedCurve = "secp256r1";
break;
case "P-384":
namedCurve = "secp384r1";
break;
case "P-521":
namedCurve = "secp521r1";
break;
case "X25519":
case "P-256":
namedCurve = "secp256r1";
break;
case "P-384":
namedCurve = "secp384r1";
break;
case "P-521":
namedCurve = "secp521r1";
break;
case "X25519":
namedCurve = "curve25519";
break;
default:
throw new Error(`Unsupported namedCurve in use ${name}`);
}
return NamedCurve.getByName(namedCurve);
}