Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
SKIPJACK_CFB8 = pkcs11.CKM_SKIPJACK_CFB8,
SKIPJACK_WRAP = pkcs11.CKM_SKIPJACK_WRAP,
SKIPJACK_PRIVATE_WRAP = pkcs11.CKM_SKIPJACK_PRIVATE_WRAP,
SKIPJACK_RELAYX = pkcs11.CKM_SKIPJACK_RELAYX,
KEA_KEY_PAIR_GEN = pkcs11.CKM_KEA_KEY_PAIR_GEN,
KEA_KEY_DERIVE = pkcs11.CKM_KEA_KEY_DERIVE,
FORTEZZA_TIMESTAMP = pkcs11.CKM_FORTEZZA_TIMESTAMP,
BATON_KEY_GEN = pkcs11.CKM_BATON_KEY_GEN,
BATON_ECB128 = pkcs11.CKM_BATON_ECB128,
BATON_ECB96 = pkcs11.CKM_BATON_ECB96,
BATON_CBC128 = pkcs11.CKM_BATON_CBC128,
BATON_COUNTER = pkcs11.CKM_BATON_COUNTER,
BATON_SHUFFLE = pkcs11.CKM_BATON_SHUFFLE,
BATON_WRAP = pkcs11.CKM_BATON_WRAP,
ECDSA_KEY_PAIR_GEN = pkcs11.CKM_ECDSA_KEY_PAIR_GEN,
EC_KEY_PAIR_GEN = pkcs11.CKM_EC_KEY_PAIR_GEN,
ECDSA = pkcs11.CKM_ECDSA,
ECDSA_SHA1 = pkcs11.CKM_ECDSA_SHA1,
ECDSA_SHA224 = pkcs11.CKM_ECDSA_SHA224,
ECDSA_SHA256 = pkcs11.CKM_ECDSA_SHA256,
ECDSA_SHA384 = pkcs11.CKM_ECDSA_SHA384,
ECDSA_SHA512 = pkcs11.CKM_ECDSA_SHA512,
/* CKM_ECDH1_DERIVE, CKM_ECDH1_COFACTOR_DERIVE, and CKM_ECMQV_DERIVE
* are new for v2.11 */
ECDH1_DERIVE = pkcs11.CKM_ECDH1_DERIVE,
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,
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";
KeyGenMechanism[KeyGenMechanism["RC5"] = pkcs11.CKM_RC5_KEY_GEN] = "RC5";
KeyGenMechanism[KeyGenMechanism["IDEA"] = pkcs11.CKM_IDEA_KEY_GEN] = "IDEA";
KeyGenMechanism[KeyGenMechanism["GENERIC_SECRET"] = pkcs11.CKM_GENERIC_SECRET_KEY_GEN] = "GENERIC_SECRET";
KeyGenMechanism[KeyGenMechanism["SSL3_PRE_MASTER"] = pkcs11.CKM_SSL3_PRE_MASTER_KEY_GEN] = "SSL3_PRE_MASTER";
KeyGenMechanism[KeyGenMechanism["CAMELLIA"] = pkcs11.CKM_CAMELLIA_KEY_GEN] = "CAMELLIA";
KeyGenMechanism[KeyGenMechanism["ARIA"] = pkcs11.CKM_ARIA_KEY_GEN] = "ARIA";
KeyGenMechanism[KeyGenMechanism["SKIPJACK"] = pkcs11.CKM_SKIPJACK_KEY_GEN] = "SKIPJACK";
KeyGenMechanism[KeyGenMechanism["KEA"] = pkcs11.CKM_KEA_KEY_PAIR_GEN] = "KEA";
KeyGenMechanism[KeyGenMechanism["BATON"] = pkcs11.CKM_BATON_KEY_GEN] = "BATON";
KeyGenMechanism[KeyGenMechanism["ECDSA"] = pkcs11.CKM_ECDSA_KEY_PAIR_GEN] = "ECDSA";
KeyGenMechanism[KeyGenMechanism["EC"] = pkcs11.CKM_EC_KEY_PAIR_GEN] = "EC";
KeyGenMechanism[KeyGenMechanism["JUNIPER"] = pkcs11.CKM_JUNIPER_KEY_GEN] = "JUNIPER";
KeyGenMechanism[KeyGenMechanism["TWOFISH"] = pkcs11.CKM_TWOFISH_KEY_GEN] = "TWOFISH";
})(exports.KeyGenMechanism || (exports.KeyGenMechanism = {}));
var KeyGenMechanism = exports.KeyGenMechanism;
MechanismEnum[MechanismEnum["SKIPJACK_CFB8"] = pkcs11.CKM_SKIPJACK_CFB8] = "SKIPJACK_CFB8";
MechanismEnum[MechanismEnum["SKIPJACK_WRAP"] = pkcs11.CKM_SKIPJACK_WRAP] = "SKIPJACK_WRAP";
MechanismEnum[MechanismEnum["SKIPJACK_PRIVATE_WRAP"] = pkcs11.CKM_SKIPJACK_PRIVATE_WRAP] = "SKIPJACK_PRIVATE_WRAP";
MechanismEnum[MechanismEnum["SKIPJACK_RELAYX"] = pkcs11.CKM_SKIPJACK_RELAYX] = "SKIPJACK_RELAYX";
MechanismEnum[MechanismEnum["KEA_KEY_PAIR_GEN"] = pkcs11.CKM_KEA_KEY_PAIR_GEN] = "KEA_KEY_PAIR_GEN";
MechanismEnum[MechanismEnum["KEA_KEY_DERIVE"] = pkcs11.CKM_KEA_KEY_DERIVE] = "KEA_KEY_DERIVE";
MechanismEnum[MechanismEnum["FORTEZZA_TIMESTAMP"] = pkcs11.CKM_FORTEZZA_TIMESTAMP] = "FORTEZZA_TIMESTAMP";
MechanismEnum[MechanismEnum["BATON_KEY_GEN"] = pkcs11.CKM_BATON_KEY_GEN] = "BATON_KEY_GEN";
MechanismEnum[MechanismEnum["BATON_ECB128"] = pkcs11.CKM_BATON_ECB128] = "BATON_ECB128";
MechanismEnum[MechanismEnum["BATON_ECB96"] = pkcs11.CKM_BATON_ECB96] = "BATON_ECB96";
MechanismEnum[MechanismEnum["BATON_CBC128"] = pkcs11.CKM_BATON_CBC128] = "BATON_CBC128";
MechanismEnum[MechanismEnum["BATON_COUNTER"] = pkcs11.CKM_BATON_COUNTER] = "BATON_COUNTER";
MechanismEnum[MechanismEnum["BATON_SHUFFLE"] = pkcs11.CKM_BATON_SHUFFLE] = "BATON_SHUFFLE";
MechanismEnum[MechanismEnum["BATON_WRAP"] = pkcs11.CKM_BATON_WRAP] = "BATON_WRAP";
MechanismEnum[MechanismEnum["ECDSA_KEY_PAIR_GEN"] = pkcs11.CKM_ECDSA_KEY_PAIR_GEN] = "ECDSA_KEY_PAIR_GEN";
MechanismEnum[MechanismEnum["EC_KEY_PAIR_GEN"] = pkcs11.CKM_EC_KEY_PAIR_GEN] = "EC_KEY_PAIR_GEN";
MechanismEnum[MechanismEnum["ECDSA"] = pkcs11.CKM_ECDSA] = "ECDSA";
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";
{type: pkcs11js.CKA_PRIVATE, value: false},
{type: pkcs11js.CKA_TOKEN, value: this._pkcs11Login && pkcs11Token},
{type: pkcs11js.CKA_VERIFY, value: true},
{
type: pkcs11js.CKA_EC_PARAMS,
value: Buffer.from(_pkcs11ParamsSizeToOid[this._keySize], 'hex')
}
];
/*
* Call PKCS11 API to generate the key pair.
*
* Return public and private key handles.
*/
const handles = pkcs11.C_GenerateKeyPair(
pkcs11Session, {mechanism: pkcs11js.CKM_EC_KEY_PAIR_GEN},
publicKeyTemplate, privateKeyTemplate);
/*
* 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_PRIVATE},
{type: pkcs11js.CKA_TOKEN}
];
logger.debug(__func() + 'privateKey: ' + util.inspect(
this._pkcs11GetAttributeValue(
pkcs11, pkcs11Session, handles.privateKey,
objectTemplate),
{depth: null}));
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,
RC5 = pkcs11.CKM_RC5_KEY_GEN,
IDEA = pkcs11.CKM_IDEA_KEY_GEN,
GENERIC_SECRET = pkcs11.CKM_GENERIC_SECRET_KEY_GEN,
SSL3_PRE_MASTER = pkcs11.CKM_SSL3_PRE_MASTER_KEY_GEN,
CAMELLIA = pkcs11.CKM_CAMELLIA_KEY_GEN,
ARIA = pkcs11.CKM_ARIA_KEY_GEN,
SKIPJACK = pkcs11.CKM_SKIPJACK_KEY_GEN,
KEA = pkcs11.CKM_KEA_KEY_PAIR_GEN,
BATON = pkcs11.CKM_BATON_KEY_GEN,
ECDSA = pkcs11.CKM_ECDSA_KEY_PAIR_GEN,
EC = pkcs11.CKM_EC_KEY_PAIR_GEN,
JUNIPER = pkcs11.CKM_JUNIPER_KEY_GEN,
TWOFISH = pkcs11.CKM_TWOFISH_KEY_GEN,
}
/**
* Definition for the base key object class
* - defines the object class `CKO_PUBLIC_KEY`, `CKO_PRIVATE_KEY` and `CKO_SECRET_KEY` for type `CK_OBJECT_CLASS`
* as used in the `CKA_CLASS` attribute of objects
*/
export class Key extends Storage {
/**
* Type of key
* - Must be specified when object is created with `C_CreateObject`
* - Must be specified when object is unwrapped with `C_UnwrapKey`
*/