sdfsdfs
This commit is contained in:
21
node_modules/browserify-rsa/LICENSE
generated
vendored
Normal file
21
node_modules/browserify-rsa/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2016 Calvin Metcalf & contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
17
node_modules/browserify-rsa/README.md
generated
vendored
Normal file
17
node_modules/browserify-rsa/README.md
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# browserify-rsa
|
||||
|
||||
[](https://www.npmjs.org/package/browserify-rsa)
|
||||
[](https://travis-ci.org/crypto-browserify/browserify-rsa)
|
||||
[](https://david-dm.org/crypto-browserify/browserify-rsa#info=dependencies)
|
||||
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
RSA private decryption/signing using chinese remainder and blinding.
|
||||
|
||||
## API
|
||||
|
||||
Give it a message as a Buffer and a private key (as decoded by `ASN.1`) and it returns encrypted data as a Buffer.
|
||||
|
||||
## LICENSE
|
||||
|
||||
MIT
|
35
node_modules/browserify-rsa/index.js
generated
vendored
Normal file
35
node_modules/browserify-rsa/index.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
var BN = require('bn.js')
|
||||
var randomBytes = require('randombytes')
|
||||
|
||||
function blind (priv) {
|
||||
var r = getr(priv)
|
||||
var blinder = r.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed()
|
||||
return { blinder: blinder, unblinder: r.invm(priv.modulus) }
|
||||
}
|
||||
|
||||
function getr (priv) {
|
||||
var len = priv.modulus.byteLength()
|
||||
var r
|
||||
do {
|
||||
r = new BN(randomBytes(len))
|
||||
} while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2))
|
||||
return r
|
||||
}
|
||||
|
||||
function crt (msg, priv) {
|
||||
var blinds = blind(priv)
|
||||
var len = priv.modulus.byteLength()
|
||||
var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus)
|
||||
var c1 = blinded.toRed(BN.mont(priv.prime1))
|
||||
var c2 = blinded.toRed(BN.mont(priv.prime2))
|
||||
var qinv = priv.coefficient
|
||||
var p = priv.prime1
|
||||
var q = priv.prime2
|
||||
var m1 = c1.redPow(priv.exponent1).fromRed()
|
||||
var m2 = c2.redPow(priv.exponent2).fromRed()
|
||||
var h = m1.isub(m2).imul(qinv).umod(p).imul(q)
|
||||
return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer, 'be', len)
|
||||
}
|
||||
crt.getr = getr
|
||||
|
||||
module.exports = crt
|
31
node_modules/browserify-rsa/package.json
generated
vendored
Normal file
31
node_modules/browserify-rsa/package.json
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "browserify-rsa",
|
||||
"version": "4.1.0",
|
||||
"description": "RSA for browserify",
|
||||
"bugs": {
|
||||
"url": "https://github.com/crypto-browserify/browserify-rsa/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com:crypto-browserify/browserify-rsa.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"test": "npm run lint && npm run unit",
|
||||
"unit": "tape test/*.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"bn.js": "^5.0.0",
|
||||
"randombytes": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"parse-asn1": "^5.0.0",
|
||||
"standard": "^6.0.8",
|
||||
"tape": "^4.5.1"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user