Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ECDH1_COFACTOR_DERIVE = pkcs11.CKM_ECDH1_COFACTOR_DERIVE,
ECMQV_DERIVE = pkcs11.CKM_ECMQV_DERIVE,
JUNIPER_KEY_GEN = pkcs11.CKM_JUNIPER_KEY_GEN,
JUNIPER_ECB128 = pkcs11.CKM_JUNIPER_ECB128,
JUNIPER_CBC128 = pkcs11.CKM_JUNIPER_CBC128,
JUNIPER_COUNTER = pkcs11.CKM_JUNIPER_COUNTER,
JUNIPER_SHUFFLE = pkcs11.CKM_JUNIPER_SHUFFLE,
JUNIPER_WRAP = pkcs11.CKM_JUNIPER_WRAP,
FASTHASH = pkcs11.CKM_FASTHASH,
/* CKM_AES_KEY_GEN, CKM_AES_ECB, CKM_AES_CBC, CKM_AES_MAC,
* CKM_AES_MAC_GENERAL, CKM_AES_CBC_PAD, CKM_DSA_PARAMETER_GEN,
* CKM_DH_PKCS_PARAMETER_GEN, and CKM_X9_42_DH_PARAMETER_GEN are
* new for v2.11 */
AES_KEY_GEN = pkcs11.CKM_AES_KEY_GEN,
AES_ECB = pkcs11.CKM_AES_ECB,
AES_CBC = pkcs11.CKM_AES_CBC,
AES_MAC = pkcs11.CKM_AES_MAC,
AES_MAC_GENERAL = pkcs11.CKM_AES_MAC_GENERAL,
AES_CBC_PAD = pkcs11.CKM_AES_CBC_PAD,
/* AES counter mode is new for PKCS #11 v2.20 amendment 3 */
AES_CTR = pkcs11.CKM_AES_CTR,
AES_CMAC = pkcs11.CKM_AES_CMAC,
AES_CMAC_GENERAL = pkcs11.CKM_AES_CMAC_GENERAL,
/* BlowFish and TwoFish are new for v2.20 */
BLOWFISH_KEY_GEN = pkcs11.CKM_BLOWFISH_KEY_GEN,
BLOWFISH_CBC = pkcs11.CKM_BLOWFISH_CBC,
TWOFISH_KEY_GEN = pkcs11.CKM_TWOFISH_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";
CDMF = pkcs11.CKK_CDMF,
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,
MechanismEnum[MechanismEnum["ECDSA_SHA1"] = pkcs11.CKM_ECDSA_SHA1] = "ECDSA_SHA1";
MechanismEnum[MechanismEnum["ECDSA_SHA224"] = pkcs11.CKM_ECDSA_SHA224] = "ECDSA_SHA224";
MechanismEnum[MechanismEnum["ECDSA_SHA256"] = pkcs11.CKM_ECDSA_SHA256] = "ECDSA_SHA256";
MechanismEnum[MechanismEnum["ECDSA_SHA384"] = pkcs11.CKM_ECDSA_SHA384] = "ECDSA_SHA384";
MechanismEnum[MechanismEnum["ECDSA_SHA512"] = pkcs11.CKM_ECDSA_SHA512] = "ECDSA_SHA512";
MechanismEnum[MechanismEnum["ECDH1_DERIVE"] = pkcs11.CKM_ECDH1_DERIVE] = "ECDH1_DERIVE";
MechanismEnum[MechanismEnum["ECDH1_COFACTOR_DERIVE"] = pkcs11.CKM_ECDH1_COFACTOR_DERIVE] = "ECDH1_COFACTOR_DERIVE";
MechanismEnum[MechanismEnum["ECMQV_DERIVE"] = pkcs11.CKM_ECMQV_DERIVE] = "ECMQV_DERIVE";
MechanismEnum[MechanismEnum["JUNIPER_KEY_GEN"] = pkcs11.CKM_JUNIPER_KEY_GEN] = "JUNIPER_KEY_GEN";
MechanismEnum[MechanismEnum["JUNIPER_ECB128"] = pkcs11.CKM_JUNIPER_ECB128] = "JUNIPER_ECB128";
MechanismEnum[MechanismEnum["JUNIPER_CBC128"] = pkcs11.CKM_JUNIPER_CBC128] = "JUNIPER_CBC128";
MechanismEnum[MechanismEnum["JUNIPER_COUNTER"] = pkcs11.CKM_JUNIPER_COUNTER] = "JUNIPER_COUNTER";
MechanismEnum[MechanismEnum["JUNIPER_SHUFFLE"] = pkcs11.CKM_JUNIPER_SHUFFLE] = "JUNIPER_SHUFFLE";
MechanismEnum[MechanismEnum["JUNIPER_WRAP"] = pkcs11.CKM_JUNIPER_WRAP] = "JUNIPER_WRAP";
MechanismEnum[MechanismEnum["FASTHASH"] = pkcs11.CKM_FASTHASH] = "FASTHASH";
MechanismEnum[MechanismEnum["AES_KEY_GEN"] = pkcs11.CKM_AES_KEY_GEN] = "AES_KEY_GEN";
MechanismEnum[MechanismEnum["AES_ECB"] = pkcs11.CKM_AES_ECB] = "AES_ECB";
MechanismEnum[MechanismEnum["AES_CBC"] = pkcs11.CKM_AES_CBC] = "AES_CBC";
MechanismEnum[MechanismEnum["AES_MAC"] = pkcs11.CKM_AES_MAC] = "AES_MAC";
MechanismEnum[MechanismEnum["AES_MAC_GENERAL"] = pkcs11.CKM_AES_MAC_GENERAL] = "AES_MAC_GENERAL";
MechanismEnum[MechanismEnum["AES_CBC_PAD"] = pkcs11.CKM_AES_CBC_PAD] = "AES_CBC_PAD";
MechanismEnum[MechanismEnum["AES_CTR"] = pkcs11.CKM_AES_CTR] = "AES_CTR";
MechanismEnum[MechanismEnum["AES_CMAC"] = pkcs11.CKM_AES_CMAC] = "AES_CMAC";
MechanismEnum[MechanismEnum["AES_CMAC_GENERAL"] = pkcs11.CKM_AES_CMAC_GENERAL] = "AES_CMAC_GENERAL";
MechanismEnum[MechanismEnum["BLOWFISH_KEY_GEN"] = pkcs11.CKM_BLOWFISH_KEY_GEN] = "BLOWFISH_KEY_GEN";
MechanismEnum[MechanismEnum["BLOWFISH_CBC"] = pkcs11.CKM_BLOWFISH_CBC] = "BLOWFISH_CBC";
MechanismEnum[MechanismEnum["TWOFISH_KEY_GEN"] = pkcs11.CKM_TWOFISH_KEY_GEN] = "TWOFISH_KEY_GEN";
MechanismEnum[MechanismEnum["TWOFISH_CBC"] = pkcs11.CKM_TWOFISH_CBC] = "TWOFISH_CBC";
MechanismEnum[MechanismEnum["AES_GCM"] = pkcs11.CKM_AES_GCM] = "AES_GCM";
MechanismEnum[MechanismEnum["AES_CCM"] = pkcs11.CKM_AES_CCM] = "AES_CCM";
MechanismEnum[MechanismEnum["AES_KEY_WRAP"] = pkcs11.CKM_AES_KEY_WRAP] = "AES_KEY_WRAP";
MechanismEnum[MechanismEnum["AES_KEY_WRAP_PAD"] = pkcs11.CKM_AES_KEY_WRAP_PAD] = "AES_KEY_WRAP_PAD";
* - key will be public
* - key will be ephermal regardless of user request
*
* Note that public and private here means publically and privately
* accessible, respectively, and has nothing to do with public and
* private key pair.
*/
{type: pkcs11js.CKA_PRIVATE, value: this._pkcs11Login},
{type: pkcs11js.CKA_TOKEN, value: this._pkcs11Login && pkcs11Token}
];
/*
* Call PKCS11 API to generate the key.
*/
const handle = pkcs11.C_GenerateKey(
pkcs11Session, {mechanism: pkcs11js.CKM_AES_KEY_GEN},
secretKeyTemplate);
/*
* Template for querying key attributes (debug only).
*/
const objectTemplate = [
{type: pkcs11js.CKA_ID},
{type: pkcs11js.CKA_CLASS},
{type: pkcs11js.CKA_KEY_TYPE},
{type: pkcs11js.CKA_VALUE_LEN},
{type: pkcs11js.CKA_ENCRYPT},
{type: pkcs11js.CKA_DECRYPT},
{type: pkcs11js.CKA_PRIVATE},
{type: pkcs11js.CKA_TOKEN}
];
logger.debug(__func() + 'secretKey: ' + util.inspect(
this._pkcs11GetAttributeValue(