Merge branch 'master' of github.com:Daplie/rsa-compat.js

This commit is contained in:
AJ ONeal 2016-08-01 04:03:59 -04:00
commit a9f8186dd4
1 changed files with 17 additions and 17 deletions

View File

@ -13,51 +13,51 @@ Examples
Generate an RSA Keypair: Generate an RSA Keypair:
```javascript ```javascript
var PromiseA = require('bluebird'); var RSA = require('rsa-compat').RSA;
var RSA = PromiseA.promisify(require('rsa-compat').RSA);
var bitlen = 1024; var bitlen = 1024;
var exp = 65537; var exp = 65537;
var options = { public: true, pem: true, internal: true }; var options = { public: true, pem: true, internal: true };
RSA.generateKeypair(bitlen, exp, options).then(function (keypair) { RSA.generateKeypair(bitlen, exp, options, function (err, keypair) {
console.log(keypair); console.log(keypair);
}); });
``` ```
Here's what the object might look like:
`console.log(keypair)`: `console.log(keypair)`:
```javascript ```javascript
{ publicKeyPem: '-----BEGIN RSA PUBLIC KEY-----\n/*base64 pem-encoded string*/' { publicKeyPem: '-----BEGIN RSA PUBLIC KEY-----\n/*base64 pem-encoded string*/'
, privateKeyPem: '-----BEGIN RSA PRIVATE KEY-----\n/*base64 pem-encoded string*/' , privateKeyPem: '-----BEGIN RSA PRIVATE KEY-----\n/*base64 pem-encoded string*/'
// http://crypto.stackexchange.com/questions/6593/what-data-is-saved-in-rsa-private-key
, privateKeyJwk: { , privateKeyJwk: {
kty: "RSA" kty: "RSA"
, n: '/*base64 modulus n = pq*/' , n: '/*base64 modulus n = pq*/'
, e: '/*base64 exponent (usually 65537)*/' , e: '/*base64 exponent (usually 65537)*/'
, d: '/*base64 private exponent (d = e^1 (mod ϕ(n))/' , d: '/*base64 private exponent (d = e^1 (mod ϕ(n))/'
, p: '/*base64 first prime*/' , p: '/*base64 first prime*/'
, q: /*base64 second prime*/ , q: '/*base64 second prime*/'
, dp: /*base64 first exponent for Chinese remainder theorem (dP = d (mod p1))*/ , dp: '/*base64 first exponent for Chinese remainder theorem (dP = d (mod p1))*/'
, dq: /*base64 Second exponent, used for CRT (dQ = d (mod q1))/ , dq: '/*base64 Second exponent, used for CRT (dQ = d (mod q1))/'
, qi: /*base64 Coefficient, used for CRT (qinv = q^1 (mod p))*/ , qi: '/*base64 Coefficient, used for CRT (qinv = q^1 (mod p))*/'
} }
, publicKeyJwk: { , publicKeyJwk: {
kty: "RSA" kty: "RSA"
, n: /*base64 modulus n = pq*/ , n: '/*base64 modulus n = pq*/'
, e: /base64 exponent (usually 65537)*/ , e: '/*base64 exponent (usually 65537)*/'
} }
, _ursa: /*undefined or intermediate ursa object*/ , _ursa: '/*undefined or intermediate ursa object*/'
, _ursaPublic: /*undefined or intermediate ursa object*/ , _ursaPublic: '/*undefined or intermediate ursa object*/'
, _forge: /*undefined or intermediate forge object*/ , _forge: '/*undefined or intermediate forge object*/'
, _forgePublic: /*undefined or intermediate forge object*/ , _forgePublic: '/*undefined or intermediate forge object*/'
} }
// NOTE: this object is JSON safe as _ursa and _forge will be ignored
``` ```
NOTE: this object is JSON safe as _ursa and _forge will be ignored
See http://crypto.stackexchange.com/questions/6593/what-data-is-saved-in-rsa-private-key to learn a little more about the meaning of the specific fields in the JWK.
API API
--- ---