browserify-sign
Advanced tools
Comparing version 2.2.0 to 2.3.0
{ | ||
"name": "browserify-sign", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,3 +13,3 @@ browserify-sign [![Build Status](https://travis-ci.org/calvinmetcalf/browserify-sign.svg)](https://travis-ci.org/calvinmetcalf/browserify-sign) | ||
- ~~tests to make sure we actually did it~~ | ||
- chinese remainder theorom? | ||
- ~~chinese remainder theorom?~~ | ||
- eliptical curve signing | ||
@@ -16,0 +16,0 @@ - publicEncrypt and privateDecrypt? |
23
sign.js
@@ -17,8 +17,4 @@ // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js | ||
} | ||
hash = pad; | ||
var red = bn.mont(priv.modulus); | ||
hash = new bn(hash).toRed(red); | ||
hash = hash.redPow(priv.privateExponent); | ||
var out = new Buffer(hash.fromRed().toArray()); | ||
var out = crt(pad, priv); | ||
if (out.length < len) { | ||
@@ -30,2 +26,17 @@ var prefix = new Buffer(len - out.length); | ||
return out; | ||
} | ||
function crt(msg, priv) { | ||
var c1 = new bn(msg).toRed(bn.mont(priv.prime1)); | ||
var c2 = new bn(msg).toRed(bn.mont(priv.prime2)); | ||
var qinv = new bn(priv.coefficient); | ||
var p = new bn(priv.prime1); | ||
var q = new bn(priv.prime2); | ||
var m1 = c1.redPow(priv.exponent1) | ||
var m2 = c2.redPow(priv.exponent2); | ||
m1 = m1.fromRed(); | ||
m2 = m2.fromRed(); | ||
var h = m1.isub(m2).imul(qinv).mod(p); | ||
h.imul(q); | ||
m2.iadd(h); | ||
return new Buffer(m2.toArray()); | ||
} |
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
19274
356