[Pkg-javascript-commits] [node-diffie-hellman] 16/88: rm fast primes

Bastien Roucariès rouca at moszumanska.debian.org
Thu May 4 10:19:13 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-diffie-hellman.

commit 08779de3f58bf83ef7b135b867a503154cf9c472
Author: Calvin Metcalf <cmetcalf at appgeo.com>
Date:   Wed Nov 5 09:32:38 2014 -0500

    rm fast primes
---
 dh.js            |  9 ++-------
 generatePrime.js | 15 +--------------
 test.js          |  9 +++------
 3 files changed, 6 insertions(+), 27 deletions(-)

diff --git a/dh.js b/dh.js
index ddcd441..ba43d7e 100644
--- a/dh.js
+++ b/dh.js
@@ -4,13 +4,8 @@ module.exports = DH;
 
 function DH(prime, crypto) {
 	this.setGenerator(new Buffer([2]));
-	if (typeof prime === 'string') {
-		this.__prime = BN._prime(prime).p;
-		this._prime = BN.red(prime);
-	} else {
-		this.__prime = new BN(prime);
-		this._prime = BN.mont(this.__prime);
-	}
+	this.__prime = new BN(prime);
+	this._prime = BN.mont(this.__prime);
 	this._pub = void 0;
 	this._priv = void 0;
 	this._makeNum = function makeNum() {
diff --git a/generatePrime.js b/generatePrime.js
index 6d9da55..d720dca 100644
--- a/generatePrime.js
+++ b/generatePrime.js
@@ -1,19 +1,6 @@
 
-module.exports = generatePrime;
+module.exports = findPrime;
 
-var goodPrimes = {
-  256: 'k256',
-  224: 'p224',
-  192: 'p192',
-  25519: 'p25519'
-};
-function generatePrime(len, crypto) {
-  if (len in goodPrimes) {
-    return goodPrimes[len];
-  } else { 
-    return findPrime(len, crypto);
-  }
-}
 // based on find-prime by Kenan Yildirim
 // https://github.com/KenanY/find-prime
 
diff --git a/test.js b/test.js
index fac89c4..d025763 100644
--- a/test.js
+++ b/test.js
@@ -5,11 +5,8 @@ var myCrypto = require('./');
 var mods = [
    'modp1', 'modp2', 'modp5', 'modp14', 'modp15', 'modp16'/*, 'modp17', 'modp18'*/
 ];
-var lens = [
-  64, 128, 384, 512, 1024, //slow
-  192, 224, 256, 25519  //fast
- ];
- var lens2 = [
+
+ var lens = [
   64, 128, 384, 512, 1024,
   192, 224, 256];
 function run(i) {
@@ -84,7 +81,7 @@ if (process.version && process.version.split('.').length === 3 && parseInt(proce
 }
 test('create primes other way', function (t) {
 		var f = bylen2(t);
-		lens2.forEach(f);
+		lens.forEach(f);
 	});
 var i = 0;
 while (++i < 2) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-diffie-hellman.git



More information about the Pkg-javascript-commits mailing list