https://github.com/antelle/pkcs15-smartcard-sign
Signatures from PKCS #15 smartcard in node.js
https://github.com/antelle/pkcs15-smartcard-sign
cryptography nodejs pkcs15 signature smartcard
Last synced: 2 months ago
JSON representation
Signatures from PKCS #15 smartcard in node.js
- Host: GitHub
- URL: https://github.com/antelle/pkcs15-smartcard-sign
- Owner: antelle
- License: mit
- Created: 2017-06-10T20:24:03.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-11T12:59:39.000Z (almost 8 years ago)
- Last Synced: 2025-02-11T15:42:11.960Z (4 months ago)
- Topics: cryptography, nodejs, pkcs15, signature, smartcard
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PKCS #15 Smartcard Sign
This module allows you to sign anything with a private key stored on PKCS #15 smartcard.
For example, you can upload your key to YubiKey and generate signatures.## How it works
It's using [`pkcs15-crypt`](https://linux.die.net/man/1/pkcs15-crypt) to process signatures. If it's not installed, you will get an error.
## Example
```javascript
const signer = require('pkcs15-smartcard-sign');// Basic usage:
// - SHA-256
// - Read key with ID 02
// - Prompt for PIN
signer.sign({
data: Buffer.from('something')
}).then(signature => {
console.log(signature.toString('hex'));
}).catch(err => {
console.error(err);
});// Advanced options
signer.sign({
data,
// predefined PIN
pin: '0000',
// ID of the key to use (on the smart card)
key: '03',
// algo: sha256 or sha512
algo: 'sha512',
// select N-th smart card reader configured by the system
reader: 2,
// verify with this public key after sign
verifyKey: fs.readFileSync('your-public-key.pem')
});
```