Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
context("RSA_PKCS Sign/Verify", () => {
const SHA256_RSA_PKCS = graphene.MechanismEnum["SHA256_RSA_PKCS"];
before(() => {
// delete SHA256_RSA_PKCS
delete graphene.MechanismEnum["SHA256_RSA_PKCS"];
delete graphene.MechanismEnum[SHA256_RSA_PKCS];
})
after(() => {
// recover SHA256_RSA_PKCS
graphene.MechanismEnum["SHA256_RSA_PKCS"] = SHA256_RSA_PKCS;
graphene.MechanismEnum[SHA256_RSA_PKCS] = "SHA256_RSA_PKCS";
})
it("remove SHA256_RSA_PKCS mechanism", (done) => {
const algorithm = {
name: "RSASSA-PKCS1-v1_5",
after(() => {
// recover SHA256_RSA_PKCS
graphene.MechanismEnum["SHA256_RSA_PKCS"] = SHA256_RSA_PKCS;
graphene.MechanismEnum[SHA256_RSA_PKCS] = "SHA256_RSA_PKCS";
})
after(() => {
// recover SHA256_RSA_PKCS
graphene.MechanismEnum["SHA256_RSA_PKCS"] = SHA256_RSA_PKCS;
graphene.MechanismEnum[SHA256_RSA_PKCS] = "SHA256_RSA_PKCS";
})
switch (keyAlg.hash.name.toUpperCase()) {
case "SHA-1":
mech = "SHA1_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(graphene.MechanismEnum.SHA1, graphene.RsaMgf.MGF1_SHA1, saltLen);
break;
case "SHA-224":
mech = "SHA224_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(graphene.MechanismEnum.SHA224, graphene.RsaMgf.MGF1_SHA224, saltLen);
break;
case "SHA-256":
mech = "SHA256_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(graphene.MechanismEnum.SHA256, graphene.RsaMgf.MGF1_SHA256, saltLen);
break;
case "SHA-384":
mech = "SHA384_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(graphene.MechanismEnum.SHA384, graphene.RsaMgf.MGF1_SHA384, saltLen);
break;
case "SHA-512":
mech = "SHA512_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(graphene.MechanismEnum.SHA512, graphene.RsaMgf.MGF1_SHA512, saltLen);
break;
default:
throw new core.OperationError(`Cannot create PKCS11 mechanism from algorithm '${keyAlg.hash.name}'`);
}
return { name: mech, params: param };
}