[Pkg-javascript-commits] [node-diffie-hellman] 18/88: fix up tests
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 87ba011c0a0755f91228b0d922ac4feed00d4851
Author: Calvin Metcalf <cmetcalf at appgeo.com>
Date: Thu Nov 6 09:25:17 2014 -0500
fix up tests
---
dh.js | 4 +++-
test.js | 8 ++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/dh.js b/dh.js
index ba43d7e..f30786e 100644
--- a/dh.js
+++ b/dh.js
@@ -13,7 +13,9 @@ function DH(prime, crypto) {
};
}
DH.prototype.generateKeys = function () {
- this.setPrivateKey(this._makeNum());
+ if (!this._priv) {
+ this.setPrivateKey(this._makeNum());
+ }
this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed();
return this.getPublicKey();
};
diff --git a/test.js b/test.js
index d025763..f39ef32 100644
--- a/test.js
+++ b/test.js
@@ -7,7 +7,7 @@ var mods = [
];
var lens = [
- 64, 128, 384, 512, 1024,
+ 64, 65, 128, 384, 512, 1024,
192, 224, 256];
function run(i) {
mods.forEach(function (mod) {
@@ -22,7 +22,7 @@ function run(i) {
t.equals(p1, p2, 'equal primes');
var pubk1 = dh1.getPublicKey();
var pubk2 = dh2.getPublicKey();
- t.notEquals(pubk1, pubk2, 'diff public keys');
+ t.notEquals(pubk1.toString('hex'), pubk2.toString('hex'), 'diff public keys');
var pub1 = dh1.computeSecret(pubk2).toString('hex');
var pub2 = dh2.computeSecret(pubk1).toString('hex');
t.equals(pub1, pub2, 'equal secrets');
@@ -45,7 +45,7 @@ function bylen(t) {
t.equals(p1, p2, 'equal primes');
var pubk1 = dh1.getPublicKey();
var pubk2 = dh2.getPublicKey();
- t.notEquals(pubk1, pubk2, 'diff public keys');
+ t.notEquals(pubk1.toString('hex'), pubk2.toString('hex'), 'diff public keys');
var pub1 = dh1.computeSecret(pubk2).toString('hex');
var pub2 = dh2.computeSecret(dh1.getPublicKey()).toString('hex');
t.equals(pub1, pub2, 'equal secrets');
@@ -66,7 +66,7 @@ function bylen2(t) {
t.equals(p1, p2, 'equal primes');
var pubk1 = dh1.getPublicKey();
var pubk2 = dh2.getPublicKey();
- t.notEquals(pubk1, pubk2, 'diff public keys');
+ t.notEquals(pubk1.toString('hex'), pubk2.toString('hex'), 'diff public keys');
var pub1 = dh1.computeSecret(pubk2).toString('hex');
var pub2 = dh2.computeSecret(dh1.getPublicKey()).toString('hex');
t.equals(pub1, pub2, 'equal secrets');
--
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