Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected wc2pk11(alg: RsaPssParams, keyAlg: RsaHashedKeyAlgorithm): IAlgorithm {
let mech: string;
let param: graphene.RsaPssParams;
const saltLen = alg.saltLength;
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}'`);
}
protected wc2pk11(alg: RsaPssParams, keyAlg: RsaHashedKeyAlgorithm): IAlgorithm {
let mech: string;
let param: graphene.RsaPssParams;
const saltLen = alg.saltLength;
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);
switch ((keyAlg as any).hash.name.toUpperCase()) {
case "SHA-1":
mech = "SHA1_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA1, RsaMgf.MGF1_SHA1, saltLen);
break;
case "SHA-224":
mech = "SHA224_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA224, RsaMgf.MGF1_SHA224, saltLen);
break;
case "SHA-256":
mech = "SHA256_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA256, RsaMgf.MGF1_SHA256, saltLen);
break;
case "SHA-384":
mech = "SHA384_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA384, RsaMgf.MGF1_SHA384, saltLen);
break;
case "SHA-512":
mech = "SHA512_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA512, RsaMgf.MGF1_SHA512, saltLen);
break;
default:
throw new AlgorithmError(AlgorithmError.UNSUPPORTED_ALGORITHM, (keyAlg as any).hash.name);
}
return { name: mech, params: param };
}
}
protected static wc2pk11(alg: Algorithm, keyAlg: Algorithm): IAlgorithm {
let mech: string;
let param: graphene.RsaPssParams;
const saltLen = (alg as any).saltLength;
switch ((keyAlg as any).hash.name.toUpperCase()) {
case "SHA-1":
mech = "SHA1_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA1, RsaMgf.MGF1_SHA1, saltLen);
break;
case "SHA-224":
mech = "SHA224_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA224, RsaMgf.MGF1_SHA224, saltLen);
break;
case "SHA-256":
mech = "SHA256_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA256, RsaMgf.MGF1_SHA256, saltLen);
break;
case "SHA-384":
mech = "SHA384_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA384, RsaMgf.MGF1_SHA384, saltLen);
break;
case "SHA-512":
mech = "SHA512_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA512, RsaMgf.MGF1_SHA512, saltLen);
protected static wc2pk11(alg: Algorithm, keyAlg: Algorithm): IAlgorithm {
let mech: string;
let param: graphene.RsaPssParams;
const saltLen = (alg as any).saltLength;
switch ((keyAlg as any).hash.name.toUpperCase()) {
case "SHA-1":
mech = "SHA1_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA1, RsaMgf.MGF1_SHA1, saltLen);
break;
case "SHA-224":
mech = "SHA224_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA224, RsaMgf.MGF1_SHA224, saltLen);
break;
case "SHA-256":
mech = "SHA256_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA256, RsaMgf.MGF1_SHA256, saltLen);
break;
case "SHA-384":
mech = "SHA384_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA384, RsaMgf.MGF1_SHA384, saltLen);
break;
case "SHA-512":
mech = "SHA512_RSA_PKCS_PSS";
param = new graphene.RsaPssParams(MechanismEnum.SHA512, RsaMgf.MGF1_SHA512, saltLen);
break;
default:
throw new AlgorithmError(AlgorithmError.UNSUPPORTED_ALGORITHM, (keyAlg as any).hash.name);
}
protected wc2pk11(alg: RsaPssParams, keyAlg: RsaHashedKeyAlgorithm): IAlgorithm {
let mech: string;
let param: graphene.RsaPssParams;
const saltLen = alg.saltLength;
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 };
}