PKCS #11 Smartcard Sign
This module allows you to sign anything with a private key stored on PKCS #11 smartcard.
For example, you can upload your key to YubiKey and generate signatures.
How it works
It's using pkcs11-tool
from OpenSC to process signatures. If it's not installed, you will get an error.
Example
const signer = require('pkcs11-smartcard-sign');
signer.sign({
data: Buffer.from('something')
}).then(signature => {
console.log(signature.toString('hex'));
}).catch(err => {
console.error(err);
});
signer.sign({
data,
pin: '0000',
key: '03',
algo: 'sha512',
reader: 2,
verifyKey: fs.readFileSync('your-public-key.pem'),
module: '/usr/local/lib/libykcs11.1.dylib'
});