From ce9d19a8b0daf850e9e32d53bf0e5e0324f38dd9 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 19 Dec 2015 02:16:21 -0800 Subject: [PATCH] remove unused deps (now in letiny-core and letsencrypt-express) --- lib/crypto-utils-ursa.js | 76 ---------------------------------------- package.json | 5 +-- 2 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 lib/crypto-utils-ursa.js diff --git a/lib/crypto-utils-ursa.js b/lib/crypto-utils-ursa.js deleted file mode 100644 index f9e9de6..0000000 --- a/lib/crypto-utils-ursa.js +++ /dev/null @@ -1,76 +0,0 @@ -'use strict'; - -var crypto = require('crypto'); -var ursa = require('ursa'); -var forge = require('node-forge'); - -function binstr2b64(binstr) { - return new Buffer(binstr, 'binary').toString('base64'); -} - -function toAcmePrivateKey(privkeyPem) { - var forgePrivkey = forge.pki.privateKeyFromPem(privkeyPem); - - return { - kty: "RSA" - , n: binstr2b64(forgePrivkey.n) - , e: binstr2b64(forgePrivkey.e) - , d: binstr2b64(forgePrivkey.d) - , p: binstr2b64(forgePrivkey.p) - , q: binstr2b64(forgePrivkey.q) - , dp: binstr2b64(forgePrivkey.dP) - , dq: binstr2b64(forgePrivkey.dQ) - , qi: binstr2b64(forgePrivkey.qInv) - }; -} - -function generateRsaKeypair(bitlen, exp, cb) { - var keypair = ursa.generatePrivateKey(bitlen /*|| 2048*/, exp /*65537*/); - var pems = { - publicKeyPem: keypair.toPublicPem().toString('ascii') // ascii PEM: ----BEGIN... - , privateKeyPem: keypair.toPrivatePem().toString('ascii') // ascii PEM: ----BEGIN... - }; - - // I would have chosen sha1 or sha2... but whatever - pems.publicKeyMd5 = crypto.createHash('md5').update(pems.publicKeyPem).digest('hex'); - // json { n: ..., e: ..., iq: ..., etc } - pems.privateKeyJwk = toAcmePrivateKey(pems.privateKeyPem); - pems.privateKeyJson = pems.privateKeyJwk; - - // TODO thumbprint - - cb(null, pems); -} - -function parseAccountPrivateKey(pkj, cb) { - Object.keys(pkj).forEach(function (key) { - pkj[key] = new Buffer(pkj[key], 'base64'); - }); - - var priv; - - try { - priv = ursa.createPrivateKeyFromComponents( - pkj.n // modulus - , pkj.e // exponent - , pkj.p - , pkj.q - , pkj.dp - , pkj.dq - , pkj.qi - , pkj.d - ); - } catch(e) { - cb(e); - return; - } - - cb(null, { - privateKeyPem: priv.toPrivatePem.toString('ascii') - , publicKeyPem: priv.toPublicPem.toString('ascii') - }); -} - -module.exports.parseAccountPrivateKey = parseAccountPrivateKey; -module.exports.generateRsaKeypair = generateRsaKeypair; -module.exports.toAcmePrivateKey = toAcmePrivateKey; diff --git a/package.json b/package.json index 38e33e9..938298e 100644 --- a/package.json +++ b/package.json @@ -34,17 +34,14 @@ "localhost.daplie.com-certificates": "^1.1.2" }, "optionalDependencies": { - "ursa": "^0.9.1" }, "dependencies": { "bluebird": "^3.0.6", "homedir": "^0.6.0", "letiny-core": "^1.0.1", "mkdirp": "^0.5.1", - "node-forge": "^0.6.38", "pyconf": "^1.0.0", "request": "^2.67.0", - "safe-replace": "^1.0.2", - "serve-static": "^1.10.0" + "safe-replace": "^1.0.2" } }