Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
subject: { v: pkcs11.CKA_SUBJECT, t: TYPE_BUFFER },
id: { v: pkcs11.CKA_ID, t: TYPE_BUFFER },
sensitive: { v: pkcs11.CKA_SENSITIVE, t: TYPE_BOOL },
encrypt: { v: pkcs11.CKA_ENCRYPT, t: TYPE_BOOL },
decrypt: { v: pkcs11.CKA_DECRYPT, t: TYPE_BOOL },
wrap: { v: pkcs11.CKA_WRAP, t: TYPE_BOOL },
unwrap: { v: pkcs11.CKA_UNWRAP, t: TYPE_BOOL },
sign: { v: pkcs11.CKA_SIGN, t: TYPE_BOOL },
signRecover: { v: pkcs11.CKA_SIGN_RECOVER, t: TYPE_BOOL },
verify: { v: pkcs11.CKA_VERIFY, t: TYPE_BOOL },
verifyRecover: { v: pkcs11.CKA_VERIFY_RECOVER, t: TYPE_BOOL },
derive: { v: pkcs11.CKA_DERIVE, t: TYPE_BOOL },
startDate: { v: pkcs11.CKA_START_DATE, t: TYPE_DATE },
endDate: { v: pkcs11.CKA_END_DATE, t: TYPE_DATE },
modulus: { v: pkcs11.CKA_MODULUS, t: TYPE_BUFFER },
modulusBits: { v: pkcs11.CKA_MODULUS_BITS, t: TYPE_NUMBER },
publicExponent: { v: pkcs11.CKA_PUBLIC_EXPONENT, t: TYPE_BUFFER },
privateExponent: { v: pkcs11.CKA_PRIVATE_EXPONENT, t: TYPE_BUFFER },
prime1: { v: pkcs11.CKA_PRIME_1, t: TYPE_BUFFER },
prime2: { v: pkcs11.CKA_PRIME_2, t: TYPE_BUFFER },
exp1: { v: pkcs11.CKA_EXPONENT_1, t: TYPE_BUFFER },
exp2: { v: pkcs11.CKA_EXPONENT_2, t: TYPE_BUFFER },
coefficient: { v: pkcs11.CKA_COEFFICIENT, t: TYPE_BUFFER },
prime: { v: pkcs11.CKA_PRIME, t: TYPE_BUFFER },
subprime: { v: pkcs11.CKA_SUBPRIME, t: TYPE_BUFFER },
base: { v: pkcs11.CKA_BASE, t: TYPE_BUFFER },
/* CKA_PRIME_BITS and CKA_SUB_PRIME_BITS are new for v2.11 */
primeBits: { v: pkcs11.CKA_PRIME_BITS, t: TYPE_NUMBER },
subprimeBits: { v: pkcs11.CKA_SUBPRIME_BITS, t: TYPE_NUMBER },
/* (To retain backwards-compatibility) */
it("#1", () => {
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 }
]);
});
});
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;
});
subject: { v: pkcs11.CKA_SUBJECT, t: TYPE_BUFFER },
id: { v: pkcs11.CKA_ID, t: TYPE_BUFFER },
sensitive: { v: pkcs11.CKA_SENSITIVE, t: TYPE_BOOL },
encrypt: { v: pkcs11.CKA_ENCRYPT, t: TYPE_BOOL },
decrypt: { v: pkcs11.CKA_DECRYPT, t: TYPE_BOOL },
wrap: { v: pkcs11.CKA_WRAP, t: TYPE_BOOL },
unwrap: { v: pkcs11.CKA_UNWRAP, t: TYPE_BOOL },
sign: { v: pkcs11.CKA_SIGN, t: TYPE_BOOL },
signRecover: { v: pkcs11.CKA_SIGN_RECOVER, t: TYPE_BOOL },
verify: { v: pkcs11.CKA_VERIFY, t: TYPE_BOOL },
verifyRecover: { v: pkcs11.CKA_VERIFY_RECOVER, t: TYPE_BOOL },
derive: { v: pkcs11.CKA_DERIVE, t: TYPE_BOOL },
startDate: { v: pkcs11.CKA_START_DATE, t: TYPE_DATE },
endDate: { v: pkcs11.CKA_END_DATE, t: TYPE_DATE },
modulus: { v: pkcs11.CKA_MODULUS, t: TYPE_BUFFER },
modulusBits: { v: pkcs11.CKA_MODULUS_BITS, t: TYPE_NUMBER },
publicExponent: { v: pkcs11.CKA_PUBLIC_EXPONENT, t: TYPE_BUFFER },
privateExponent: { v: pkcs11.CKA_PRIVATE_EXPONENT, t: TYPE_BUFFER },
prime1: { v: pkcs11.CKA_PRIME_1, t: TYPE_BUFFER },
prime2: { v: pkcs11.CKA_PRIME_2, t: TYPE_BUFFER },
exp1: { v: pkcs11.CKA_EXPONENT_1, t: TYPE_BUFFER },
exp2: { v: pkcs11.CKA_EXPONENT_2, t: TYPE_BUFFER },
coefficient: { v: pkcs11.CKA_COEFFICIENT, t: TYPE_BUFFER },
prime: { v: pkcs11.CKA_PRIME, t: TYPE_BUFFER },
subprime: { v: pkcs11.CKA_SUBPRIME, t: TYPE_BUFFER },
base: { v: pkcs11.CKA_BASE, t: TYPE_BUFFER },
primeBits: { v: pkcs11.CKA_PRIME_BITS, t: TYPE_NUMBER },
subprimeBits: { v: pkcs11.CKA_SUBPRIME_BITS, t: TYPE_NUMBER },
valueBits: { v: pkcs11.CKA_VALUE_BITS, t: TYPE_NUMBER },
valueLen: { v: pkcs11.CKA_VALUE_LEN, t: TYPE_NUMBER },
extractable: { v: pkcs11.CKA_EXTRACTABLE, t: TYPE_BOOL },
local: { v: pkcs11.CKA_LOCAL, t: TYPE_BOOL },