Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
token: !!process.env.WEBCRYPTO_PKCS11_TOKEN,
sensitive: !!process.env.WEBCRYPTO_PKCS11_SENSITIVE,
class: ObjectClass.PRIVATE_KEY,
keyType,
private: true,
label,
id: idKey,
extractable,
derive: keyUsages.indexOf("deriveKey") !== -1 || keyUsages.indexOf("deriveBits") !== -1,
sign: keyUsages.indexOf("sign") !== -1,
decrypt: keyUsages.indexOf("decrypt") !== -1,
unwrap: keyUsages.indexOf("unwrapKey") !== -1,
},
publicKey: {
token: !!process.env.WEBCRYPTO_PKCS11_TOKEN,
class: ObjectClass.PUBLIC_KEY,
keyType,
private: false,
label,
id: idKey,
derive: keyUsages.indexOf("deriveKey") !== -1 || keyUsages.indexOf("deriveBits") !== -1,
verify: keyUsages.indexOf("verify") !== -1,
encrypt: keyUsages.indexOf("encrypt") !== -1,
wrap: keyUsages.indexOf("wrapKey") !== -1,
},
};
}
constructor(key: Key, alg: T) {
super();
this.p11Object = key;
switch (key.class) {
case ObjectClass.PUBLIC_KEY:
this.initPublicKey(key.toType());
break;
case ObjectClass.PRIVATE_KEY:
this.initPrivateKey(key.toType());
break;
case ObjectClass.SECRET_KEY:
this.initSecretKey(key.toType());
break;
default:
throw new core.CryptoError(`Wrong incoming session object '${ObjectClass[key.class]}'`);
}
this.algorithm = alg;
this.id = CryptoKey.getID(key);
this.onAssign();
}
token: !!process.env.WEBCRYPTO_PKCS11_TOKEN,
sensitive: !!process.env.WEBCRYPTO_PKCS11_SENSITIVE,
class: ObjectClass.PRIVATE_KEY,
keyType: KeyType.RSA,
private: true,
label,
id: idKey,
extractable,
derive: false,
sign: keyUsages.indexOf("sign") > -1,
decrypt: keyUsages.indexOf("decrypt") > -1,
unwrap: keyUsages.indexOf("unwrapKey") > -1,
},
publicKey: {
token: !!process.env.WEBCRYPTO_PKCS11_TOKEN,
class: ObjectClass.PUBLIC_KEY,
keyType: KeyType.RSA,
private: false,
label,
id: idKey,
verify: keyUsages.indexOf("verify") > -1,
encrypt: keyUsages.indexOf("encrypt") > -1,
wrap: keyUsages.indexOf("wrapKey") > -1,
},
};
}
token: !!process.env.WEBCRYPTO_PKCS11_TOKEN,
sensitive: !!process.env.WEBCRYPTO_PKCS11_SENSITIVE,
class: ObjectClass.PRIVATE_KEY,
keyType: KeyType.RSA,
private: true,
label,
id: idKey,
extractable,
derive: false,
sign: keyUsages.indexOf("sign") > -1,
decrypt: keyUsages.indexOf("decrypt") > -1,
unwrap: keyUsages.indexOf("unwrapKey") > -1,
},
publicKey: {
token: !!process.env.WEBCRYPTO_PKCS11_TOKEN,
class: ObjectClass.PUBLIC_KEY,
keyType: KeyType.RSA,
private: false,
label,
id: idKey,
verify: keyUsages.indexOf("verify") > -1,
encrypt: keyUsages.indexOf("encrypt") > -1,
wrap: keyUsages.indexOf("wrapKey") > -1,
},
};
}