From 1dbdd877c967e47403ddfdecf79fac10346baf94 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 31 Jul 2016 01:23:10 -0400 Subject: [PATCH] Update README.md --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index d6d3dbf..28f3026 100644 --- a/README.md +++ b/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 ---