Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before(() => {
const privateTemplate = [
{ type: pkcs11.CKA_ID, value: new Buffer("1234567890") },
{ type: pkcs11.CKA_SIGN, value: true },
];
const publicTemplate = [
{ type: pkcs11.CKA_ID, value: new Buffer("1234567890") },
{ type: pkcs11.CKA_PUBLIC_EXPONENT, value: new Buffer([1, 0, 1]) },
{ type: pkcs11.CKA_MODULUS_BITS, value: 1024 },
{ type: pkcs11.CKA_VERIFY, value: true },
];
const keys = mod.C_GenerateKeyPair(session, { mechanism: pkcs11.CKM_RSA_PKCS_KEY_PAIR_GEN, parameter: null }, publicTemplate, privateTemplate);
privateKey = keys.privateKey;
publicKey = keys.publicKey;
});
const privateTemplate = [
{ type: pkcs11.CKA_ID, value: new Buffer("1234567890") },
{ type: pkcs11.CKA_SIGN, value: true },
{ type: pkcs11.CKA_DECRYPT, value: true },
{ type: pkcs11.CKA_UNWRAP, value: true },
];
const publicTemplate = [
{ type: pkcs11.CKA_ID, value: new Buffer("1234567890") },
{ type: pkcs11.CKA_PUBLIC_EXPONENT, value: new Buffer([1, 0, 1]) },
{ type: pkcs11.CKA_MODULUS_BITS, value: 1024 },
{ type: pkcs11.CKA_VERIFY, value: true },
{ type: pkcs11.CKA_ENCRYPT, value: true },
{ type: pkcs11.CKA_WRAP, value: true },
];
const keys = mod.C_GenerateKeyPair(session, { mechanism: pkcs11.CKM_RSA_PKCS_KEY_PAIR_GEN, parameter: null }, publicTemplate, privateTemplate);
let attrs = mod.C_GetAttributeValue(session, keys.privateKey, [
{ type: pkcs11.CKA_TOKEN }
]);
});
});
AES = pkcs11.CKK_AES,
GOSTR3410 = pkcs11.CKK_GOSTR3410,
GOSTR3411 = pkcs11.CKK_GOSTR3411,
GOST28147 = pkcs11.CKK_GOST28147,
BLOWFISH = pkcs11.CKK_BLOWFISH,
TWOFISH = pkcs11.CKK_TWOFISH,
SECURID = pkcs11.CKK_SECURID,
HOTP = pkcs11.CKK_HOTP,
ACTI = pkcs11.CKK_ACTI,
CAMELLIA = pkcs11.CKK_CAMELLIA,
ARIA = pkcs11.CKK_ARIA,
}
export enum KeyGenMechanism {
AES = pkcs11.CKM_AES_KEY_GEN,
RSA = pkcs11.CKM_RSA_PKCS_KEY_PAIR_GEN,
RSA_X9_31 = pkcs11.CKM_RSA_X9_31_KEY_PAIR_GEN,
DSA = pkcs11.CKM_DSA_KEY_PAIR_GEN,
DH_PKCS = pkcs11.CKM_DH_PKCS_KEY_PAIR_GEN,
DH_X9_42 = pkcs11.CKM_X9_42_DH_KEY_PAIR_GEN,
GOSTR3410 = pkcs11.CKM_GOSTR3410_KEY_PAIR_GEN,
GOST28147 = pkcs11.CKM_GOST28147_KEY_GEN,
RC2 = pkcs11.CKM_RC2_KEY_GEN,
RC4 = pkcs11.CKM_RC4_KEY_GEN,
DES = pkcs11.CKM_DES_KEY_GEN,
DES2 = pkcs11.CKM_DES2_KEY_GEN,
SECURID = pkcs11.CKM_SECURID_KEY_GEN,
ACTI = pkcs11.CKM_ACTI_KEY_GEN,
CAST = pkcs11.CKM_CAST_KEY_GEN,
CAST3 = pkcs11.CKM_CAST3_KEY_GEN,
CAST5 = pkcs11.CKM_CAST5_KEY_GEN,
CAST128 = pkcs11.CKM_CAST128_KEY_GEN,
(function (KeyGenMechanism) {
KeyGenMechanism[KeyGenMechanism["AES"] = pkcs11.CKM_AES_KEY_GEN] = "AES";
KeyGenMechanism[KeyGenMechanism["RSA"] = pkcs11.CKM_RSA_PKCS_KEY_PAIR_GEN] = "RSA";
KeyGenMechanism[KeyGenMechanism["RSA_X9_31"] = pkcs11.CKM_RSA_X9_31_KEY_PAIR_GEN] = "RSA_X9_31";
KeyGenMechanism[KeyGenMechanism["DSA"] = pkcs11.CKM_DSA_KEY_PAIR_GEN] = "DSA";
KeyGenMechanism[KeyGenMechanism["DH_PKCS"] = pkcs11.CKM_DH_PKCS_KEY_PAIR_GEN] = "DH_PKCS";
KeyGenMechanism[KeyGenMechanism["DH_X9_42"] = pkcs11.CKM_X9_42_DH_KEY_PAIR_GEN] = "DH_X9_42";
KeyGenMechanism[KeyGenMechanism["GOSTR3410"] = pkcs11.CKM_GOSTR3410_KEY_PAIR_GEN] = "GOSTR3410";
KeyGenMechanism[KeyGenMechanism["GOST28147"] = pkcs11.CKM_GOST28147_KEY_GEN] = "GOST28147";
KeyGenMechanism[KeyGenMechanism["RC2"] = pkcs11.CKM_RC2_KEY_GEN] = "RC2";
KeyGenMechanism[KeyGenMechanism["RC4"] = pkcs11.CKM_RC4_KEY_GEN] = "RC4";
KeyGenMechanism[KeyGenMechanism["DES"] = pkcs11.CKM_DES_KEY_GEN] = "DES";
KeyGenMechanism[KeyGenMechanism["DES2"] = pkcs11.CKM_DES2_KEY_GEN] = "DES2";
KeyGenMechanism[KeyGenMechanism["SECURID"] = pkcs11.CKM_SECURID_KEY_GEN] = "SECURID";
KeyGenMechanism[KeyGenMechanism["ACTI"] = pkcs11.CKM_ACTI_KEY_GEN] = "ACTI";
KeyGenMechanism[KeyGenMechanism["CAST"] = pkcs11.CKM_CAST_KEY_GEN] = "CAST";
KeyGenMechanism[KeyGenMechanism["CAST3"] = pkcs11.CKM_CAST3_KEY_GEN] = "CAST3";
KeyGenMechanism[KeyGenMechanism["CAST5"] = pkcs11.CKM_CAST5_KEY_GEN] = "CAST5";
KeyGenMechanism[KeyGenMechanism["CAST128"] = pkcs11.CKM_CAST128_KEY_GEN] = "CAST128";
(function (MechanismEnum) {
MechanismEnum[MechanismEnum["RSA_PKCS_KEY_PAIR_GEN"] = pkcs11.CKM_RSA_PKCS_KEY_PAIR_GEN] = "RSA_PKCS_KEY_PAIR_GEN";
MechanismEnum[MechanismEnum["RSA_PKCS"] = pkcs11.CKM_RSA_PKCS] = "RSA_PKCS";
MechanismEnum[MechanismEnum["RSA_9796"] = pkcs11.CKM_RSA_9796] = "RSA_9796";
MechanismEnum[MechanismEnum["RSA_X_509"] = pkcs11.CKM_RSA_X_509] = "RSA_X_509";
MechanismEnum[MechanismEnum["MD2_RSA_PKCS"] = pkcs11.CKM_MD2_RSA_PKCS] = "MD2_RSA_PKCS";
MechanismEnum[MechanismEnum["MD5_RSA_PKCS"] = pkcs11.CKM_MD5_RSA_PKCS] = "MD5_RSA_PKCS";
MechanismEnum[MechanismEnum["SHA1_RSA_PKCS"] = pkcs11.CKM_SHA1_RSA_PKCS] = "SHA1_RSA_PKCS";
MechanismEnum[MechanismEnum["RIPEMD128_RSA_PKCS"] = pkcs11.CKM_RIPEMD128_RSA_PKCS] = "RIPEMD128_RSA_PKCS";
MechanismEnum[MechanismEnum["RIPEMD160_RSA_PKCS"] = pkcs11.CKM_RIPEMD160_RSA_PKCS] = "RIPEMD160_RSA_PKCS";
MechanismEnum[MechanismEnum["RSA_PKCS_OAEP"] = pkcs11.CKM_RSA_PKCS_OAEP] = "RSA_PKCS_OAEP";
MechanismEnum[MechanismEnum["RSA_X9_31_KEY_PAIR_GEN"] = pkcs11.CKM_RSA_X9_31_KEY_PAIR_GEN] = "RSA_X9_31_KEY_PAIR_GEN";
MechanismEnum[MechanismEnum["RSA_X9_31"] = pkcs11.CKM_RSA_X9_31] = "RSA_X9_31";
MechanismEnum[MechanismEnum["SHA1_RSA_X9_31"] = pkcs11.CKM_SHA1_RSA_X9_31] = "SHA1_RSA_X9_31";
MechanismEnum[MechanismEnum["RSA_PKCS_PSS"] = pkcs11.CKM_RSA_PKCS_PSS] = "RSA_PKCS_PSS";
MechanismEnum[MechanismEnum["SHA1_RSA_PKCS_PSS"] = pkcs11.CKM_SHA1_RSA_PKCS_PSS] = "SHA1_RSA_PKCS_PSS";
MechanismEnum[MechanismEnum["DSA_KEY_PAIR_GEN"] = pkcs11.CKM_DSA_KEY_PAIR_GEN] = "DSA_KEY_PAIR_GEN";
MechanismEnum[MechanismEnum["DSA"] = pkcs11.CKM_DSA] = "DSA";
import * as pkcs11 from "pkcs11js";
export enum MechanismEnum {
RSA_PKCS_KEY_PAIR_GEN = pkcs11.CKM_RSA_PKCS_KEY_PAIR_GEN,
RSA_PKCS = pkcs11.CKM_RSA_PKCS,
RSA_9796 = pkcs11.CKM_RSA_9796,
RSA_X_509 = pkcs11.CKM_RSA_X_509,
MD2_RSA_PKCS = pkcs11.CKM_MD2_RSA_PKCS,
MD5_RSA_PKCS = pkcs11.CKM_MD5_RSA_PKCS,
SHA1_RSA_PKCS = pkcs11.CKM_SHA1_RSA_PKCS,
RIPEMD128_RSA_PKCS = pkcs11.CKM_RIPEMD128_RSA_PKCS,
RIPEMD160_RSA_PKCS = pkcs11.CKM_RIPEMD160_RSA_PKCS,
RSA_PKCS_OAEP = pkcs11.CKM_RSA_PKCS_OAEP,
RSA_X9_31_KEY_PAIR_GEN = pkcs11.CKM_RSA_X9_31_KEY_PAIR_GEN,
RSA_X9_31 = pkcs11.CKM_RSA_X9_31,
SHA1_RSA_X9_31 = pkcs11.CKM_SHA1_RSA_X9_31,
RSA_PKCS_PSS = pkcs11.CKM_RSA_PKCS_PSS,
SHA1_RSA_PKCS_PSS = pkcs11.CKM_SHA1_RSA_PKCS_PSS,
DSA_KEY_PAIR_GEN = pkcs11.CKM_DSA_KEY_PAIR_GEN,
DSA = pkcs11.CKM_DSA,