Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

diffie-hellman

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diffie-hellman - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

perf.js

2

dh.js

@@ -105,3 +105,3 @@ var BN = require('bn.js');

this._makeNum = function makeNum() {
return crypto.randomBytes(192);
return crypto.randomBytes(prime.length);
};

@@ -108,0 +108,0 @@ }

@@ -47,4 +47,9 @@

for (var i = 0; i < primes.length; i++)
if (p.modn(primes[i]) === 0)
return false;
if (p.modn(primes[i]) === 0) {
if (p.cmpn(primes[i]) === 0) {
return true;
} else {
return false;
}
}

@@ -58,2 +63,10 @@ return true;

function findPrime(bits, gen ,crypto) {
if (bits < 16) {
// this is what openssl does
if (gen === 2 || gen === 5) {
return new BN([0x8c, 0x7b]);
} else {
return new BN([0x8c, 0x27]);
}
}
gen = new BN(gen);

@@ -63,7 +76,12 @@ var runs, comp;

runs = -1;
var r = crypto.randomBytes(Math.ceil(bits / 8));
r[0] |= 0xc0;
r[r.length - 1] |= 3;
var rem;
var out = new BN(r);
var out = new BN(crypto.randomBytes(Math.ceil(bits / 8)));
while (out.bitLength() > bits) {
out.ishrn(1);
}
if (out.isEven()) {
out.iadd(ONE);
}
if (!out.testn(1)) {
out.iadd(TWO);
}
if (!gen.cmp(TWO)) {

@@ -91,3 +109,3 @@ while (out.mod(TWENTYFOUR).cmp(ELEVEN)) {

minor: [TWO]
}
};
}

@@ -103,3 +121,3 @@ return out;

while (true) {
if (num.bitLength() > bits) {
while (num.bitLength() > bits) {
num = generateRandom(bits);

@@ -106,0 +124,0 @@ n2 = num.shrn(1);

{
"name": "diffie-hellman",
"version": "2.2.0",
"version": "2.2.1",
"description": "pure js diffie-hellman",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -12,6 +12,6 @@ var test = require('tape');

var lens = [
64, 65, 128, 384, 512, 1024,
2, 8, 16, 17, 18, 20, 21, 22, 64, 65, 128, 384, 512, 1024,
192, 224, 256];
var lens2 = [
64, 65, 128];
16, 17, 18, 20, 21, 22,64, 65, 128];
function run(i) {

@@ -49,3 +49,2 @@ mods.forEach(function (mod) {

var dh1 = nodeCrypto.createDiffieHellman(prime2, generator);
//console.log('error', dh1.verifyError)
var p1 = dh1.getPrime().toString('hex');

@@ -52,0 +51,0 @@ t.equals(typeof dh1.setPublicKey, typeof dh2.setPublicKey, 'same methods');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc