browserify-rsa
Advanced tools
Comparing version 2.0.1 to 3.0.0
16
index.js
@@ -17,3 +17,3 @@ var bn = require('bn.js'); | ||
var mod = bn.mont(priv.modulus); | ||
var blinded = new bn(msg).mul(blinds.blinder).mod(priv.modulus); | ||
var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus); | ||
var c1 = blinded.toRed(bn.mont(priv.prime1)); | ||
@@ -28,12 +28,6 @@ var c2 = blinded.toRed(bn.mont(priv.prime2)); | ||
m2 = m2.fromRed(); | ||
var h = m1.isub(m2).imul(qinv).mod(p); | ||
var h = m1.isub(m2).imul(qinv).umod(p); | ||
h.imul(q); | ||
m2.iadd(h); | ||
var out = new Buffer(m2.imul(blinds.unblinder).mod(priv.modulus).toArray()); | ||
if (out.length < len) { | ||
var prefix = new Buffer(len - out.length); | ||
prefix.fill(0); | ||
out = Buffer.concat([prefix, out], len); | ||
} | ||
return out; | ||
return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len)); | ||
} | ||
@@ -44,6 +38,6 @@ crt.getr = getr; | ||
var r = new bn(randomBytes(len)); | ||
while (r.cmp(priv.modulus) >= 0 || !r.mod(priv.prime1) || !r.mod(priv.prime2)) { | ||
while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) { | ||
r = new bn(randomBytes(len)); | ||
} | ||
return r; | ||
} | ||
} |
{ | ||
"name": "browserify-rsa", | ||
"version": "2.0.1", | ||
"description": "", | ||
"version": "3.0.0", | ||
"description": "RSA for browserify", | ||
"main": "index.js", | ||
@@ -12,3 +12,3 @@ "scripts": { | ||
"dependencies": { | ||
"bn.js": "^2.0.0", | ||
"bn.js": "^3.0.0", | ||
"randombytes": "^2.0.1" | ||
@@ -15,0 +15,0 @@ }, |
@@ -49,6 +49,6 @@ var keys = [ | ||
var myEncrypt = crt(buf, priv).toString('hex'); | ||
t.equals(nodeEncrypt, myEncrypt, 'equal encrypts'); | ||
t.equals(myEncrypt, nodeEncrypt, 'equal encrypts'); | ||
}); | ||
} | ||
} | ||
keys.forEach(testMessage); | ||
keys.forEach(testMessage); |
11632
6
117
+ Addedbn.js@3.3.0(transitive)
- Removedbn.js@2.2.0(transitive)
Updatedbn.js@^3.0.0