browserify-rsa
Advanced tools
Comparing version 1.1.1 to 2.0.0
15
index.js
var bn = require('bn.js'); | ||
var randomBytes = require('randombytes'); | ||
module.exports = crt; | ||
function blind(priv, crypto) { | ||
var r = getr(priv, crypto); | ||
function blind(priv) { | ||
var r = getr(priv); | ||
var blinder = r.toRed(bn.mont(priv.modulus)) | ||
@@ -12,4 +13,4 @@ .redPow(new bn(priv.publicExponent)).fromRed(); | ||
} | ||
function crt(msg, priv, crypto) { | ||
var blinds = blind(priv, crypto); | ||
function crt(msg, priv) { | ||
var blinds = blind(priv); | ||
var len = priv.modulus.byteLength(); | ||
@@ -39,9 +40,9 @@ var mod = bn.mont(priv.modulus); | ||
crt.getr = getr; | ||
function getr(priv, crypto) { | ||
function getr(priv) { | ||
var len = priv.modulus.byteLength(); | ||
var r = new bn(crypto.randomBytes(len)); | ||
var r = new bn(randomBytes(len)); | ||
while (r.cmp(priv.modulus) >= 0 || !r.mod(priv.prime1) || !r.mod(priv.prime2)) { | ||
r = new bn(crypto.randomBytes(len)); | ||
r = new bn(randomBytes(len)); | ||
} | ||
return r; | ||
} |
{ | ||
"name": "browserify-rsa", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"description": "", | ||
@@ -12,3 +12,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"bn.js": "^1.0.0" | ||
"bn.js": "^1.0.0", | ||
"randombytes": "^2.0.1" | ||
}, | ||
@@ -22,4 +23,4 @@ "repository": { | ||
"tape": "^3.0.3", | ||
"parse-asn1": "^1.2.0" | ||
"parse-asn1": "^3.0.0" | ||
} | ||
} |
@@ -19,3 +19,3 @@ var keys = [ | ||
while(i++ < len) { | ||
var r = crt.getr(priv, crypto); | ||
var r = crt.getr(priv); | ||
t.equals(r.gcd(priv.modulus).toString(), '1', 'are coprime run ' + i); | ||
@@ -49,3 +49,3 @@ } | ||
}, buf).toString('hex'); | ||
var myEncrypt = crt(buf, priv, crypto).toString('hex'); | ||
var myEncrypt = crt(buf, priv).toString('hex'); | ||
t.equals(nodeEncrypt, myEncrypt, 'equal encrypts'); | ||
@@ -52,0 +52,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10741
121
2
+ Addedrandombytes@^2.0.1
+ Addedrandombytes@2.1.0(transitive)
+ Addedsafe-buffer@5.2.1(transitive)