diff --git a/package.json b/package.json index 17c069e..595a2fd 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "ecc-jsbn": "0.0.1", "node-forge": "^0.6.20", "polyfill-promise": "^4.0.1", - "sjcl": "^1.0.3" + "sjcl": "^1.0.3", + "ursa": "^0.9.3" }, "optionalDependencies":{ "ecc-qj" : "git+https://github.com/rynomad/ecc.git" diff --git a/src/node/algorithms/shared/RSA.js b/src/node/algorithms/shared/RSA.js index bd444f4..58ddce2 100644 --- a/src/node/algorithms/shared/RSA.js +++ b/src/node/algorithms/shared/RSA.js @@ -1,4 +1,5 @@ var forge = require("node-forge") + , ursa = require("ursa") , pkcsPad1 = new Buffer([48, 130]) , pkcsPad2 = new Buffer([2, 1, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 4, 130]) @@ -35,7 +36,11 @@ function generate(algorithm){ pos++; } - return forge.rsa.generateKeyPair({bits: algorithm.modulousLength , e: exp}); + var keyPair = ursa.generatePrivateKey(algorithm.modulousLength, exp); + return { + privateKey: forge.pki.privateKeyFromPem(keyPair.toPrivatePem('utf8')), + publicKey: forge.pki.publicKeyFromPem(keyPair.toPublicPem('utf8')) + } }