For RSA sake! Exposes openssl rsautl funtions via a C addon rather than shelling out.
$ npm install forsaken.b. all keys are Buffer instances
varforsake=require('forsake');// signvara=forsake.sign('this string',private_key);// with passphrasevarprotected_pkey={key: private_key,passphrase: 'hello'};varb=forsake.sign('this string',protected_pkey);// with paddingvarc=forsake.sign('this string',pkey,forsake.RSA_X931_PADDING);// errorstry{forsake.sign('this string',public_key);}catch(e){e.toString();//=> "RsaError: Unable to load private key"e.failures;//=> [ 'error:0906D06C:PEM routines:PEM_read_bio:no start line' ]}- The API for
encrypt,decrypt,signandverifyis identical - All errors are of type
RsaErrorwhich is exposed byforsake RsaError.failurescontains SSL error strings, which can help identify problems
The examples below show all possible types of supported key arguments:
varbuffer_from_file=fs.readFileSync('id_rsa');varutf8_string="-----BEGIN PUBLIC KEY-----\nblah\n-----END PUBLIC KEY-----";varprotected_buffer={key: buf_from_file,passphrase: 'opensesame'};varprotected_utf8={key: utf8_string,passphrase: 'Alohomora'};Forsake exposes the following padding constants:
RSA_NO_PADDINGRSA_PKCS1_OAEP_PADDINGRSA_PKCS1_PADDINGRSA_SSLV23_PADDINGRSA_X931_PADDING
Forsake is able to read PKCS#8, PKCS#1 and X.509 public keys, and PKCS#8 private keys. Passphrases can be used with private keys and the standard padding options are also available.
ISC