Merge branch 'master' of github.com:Daplie/rsa-compat.js
This commit is contained in:
commit
a9f8186dd4
34
README.md
34
README.md
|
@ -13,51 +13,51 @@ Examples
|
|||
Generate an RSA Keypair:
|
||||
|
||||
```javascript
|
||||
var PromiseA = require('bluebird');
|
||||
var RSA = PromiseA.promisify(require('rsa-compat').RSA);
|
||||
var RSA = require('rsa-compat').RSA;
|
||||
|
||||
var bitlen = 1024;
|
||||
var exp = 65537;
|
||||
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);
|
||||
});
|
||||
```
|
||||
|
||||
Here's what the object might look like:
|
||||
|
||||
`console.log(keypair)`:
|
||||
```javascript
|
||||
|
||||
{ publicKeyPem: '-----BEGIN RSA PUBLIC 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: {
|
||||
kty: "RSA"
|
||||
, n: '/*base64 modulus n = pq*/'
|
||||
, e: '/*base64 exponent (usually 65537)*/'
|
||||
, d: '/*base64 private exponent (d = e^−1 (mod ϕ(n))/'
|
||||
, p: '/*base64 first prime*/'
|
||||
, q: /*base64 second prime*/
|
||||
, dp: /*base64 first exponent for Chinese remainder theorem (dP = d (mod p−1))*/
|
||||
, dq: /*base64 Second exponent, used for CRT (dQ = d (mod q−1))/
|
||||
, qi: /*base64 Coefficient, used for CRT (qinv = q^−1 (mod p))*/
|
||||
, q: '/*base64 second prime*/'
|
||||
, dp: '/*base64 first exponent for Chinese remainder theorem (dP = d (mod p−1))*/'
|
||||
, dq: '/*base64 Second exponent, used for CRT (dQ = d (mod q−1))/'
|
||||
, qi: '/*base64 Coefficient, used for CRT (qinv = q^−1 (mod p))*/'
|
||||
}
|
||||
, publicKeyJwk: {
|
||||
kty: "RSA"
|
||||
, n: /*base64 modulus n = pq*/
|
||||
, e: /base64 exponent (usually 65537)*/
|
||||
, n: '/*base64 modulus n = pq*/'
|
||||
, e: '/*base64 exponent (usually 65537)*/'
|
||||
}
|
||||
|
||||
, _ursa: /*undefined or intermediate ursa object*/
|
||||
, _ursaPublic: /*undefined or intermediate ursa object*/
|
||||
, _forge: /*undefined or intermediate forge object*/
|
||||
, _forgePublic: /*undefined or intermediate forge object*/
|
||||
, _ursa: '/*undefined or intermediate ursa object*/'
|
||||
, _ursaPublic: '/*undefined or intermediate ursa object*/'
|
||||
, _forge: '/*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
|
||||
---
|
||||
|
|
Loading…
Reference in New Issue