[Pkg-javascript-commits] [node-diffie-hellman] 12/88: generate primes
Bastien Roucariès
rouca at moszumanska.debian.org
Thu May 4 10:19:12 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 f1d7cc3257525be9e1a34338271dc4de27a0196d
Author: Calvin Metcalf <cmetcalf at appgeo.com>
Date: Wed Nov 5 07:18:46 2014 -0500
generate primes
---
.travis.yml | 4 ++++
generatePrime.js | 6 +++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..18ae2d8
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - "0.11"
+ - "0.10"
diff --git a/generatePrime.js b/generatePrime.js
index 368eeef..42bb142 100644
--- a/generatePrime.js
+++ b/generatePrime.js
@@ -114,7 +114,11 @@ function findPrime(bits, crypto) {
function generateRandom(bits) {
var bytes = bits >> 3;
bytes = bytes || 1;
- return new BN(crypto.randomBytes(bits/8));
+ var out = new BN(crypto.randomBytes(bits/8));
+ while (out.bitLength() > bits) {
+ out.ishrn(1);
+ }
+ return out;
}
var num = generateRandom(bits);
--
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