diff options
Diffstat (limited to 'node_modules/browserify-rsa')
-rw-r--r-- | node_modules/browserify-rsa/LICENSE | 21 | ||||
-rw-r--r-- | node_modules/browserify-rsa/README.md | 17 | ||||
-rw-r--r-- | node_modules/browserify-rsa/index.js | 35 | ||||
-rw-r--r-- | node_modules/browserify-rsa/package.json | 58 |
4 files changed, 131 insertions, 0 deletions
diff --git a/node_modules/browserify-rsa/LICENSE b/node_modules/browserify-rsa/LICENSE new file mode 100644 index 0000000..c1dd3c5 --- /dev/null +++ b/node_modules/browserify-rsa/LICENSE @@ -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. diff --git a/node_modules/browserify-rsa/README.md b/node_modules/browserify-rsa/README.md new file mode 100644 index 0000000..70e3c02 --- /dev/null +++ b/node_modules/browserify-rsa/README.md @@ -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 diff --git a/node_modules/browserify-rsa/index.js b/node_modules/browserify-rsa/index.js new file mode 100644 index 0000000..c3ff8e9 --- /dev/null +++ b/node_modules/browserify-rsa/index.js @@ -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 diff --git a/node_modules/browserify-rsa/package.json b/node_modules/browserify-rsa/package.json new file mode 100644 index 0000000..679331d --- /dev/null +++ b/node_modules/browserify-rsa/package.json @@ -0,0 +1,58 @@ +{ + "_from": "browserify-rsa@^4.0.1", + "_id": "browserify-rsa@4.1.0", + "_inBundle": false, + "_integrity": "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==", + "_location": "/browserify-rsa", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "browserify-rsa@^4.0.1", + "name": "browserify-rsa", + "escapedName": "browserify-rsa", + "rawSpec": "^4.0.1", + "saveSpec": null, + "fetchSpec": "^4.0.1" + }, + "_requiredBy": [ + "/browserify-sign", + "/public-encrypt" + ], + "_resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz", + "_shasum": "b2fd06b5b75ae297f7ce2dc651f918f5be158c8d", + "_spec": "browserify-rsa@^4.0.1", + "_where": "/home/pruss/Dev/3-minute-website/node_modules/browserify-sign", + "bugs": { + "url": "https://github.com/crypto-browserify/browserify-rsa/issues" + }, + "bundleDependencies": false, + "dependencies": { + "bn.js": "^5.0.0", + "randombytes": "^2.0.1" + }, + "deprecated": false, + "description": "RSA for browserify", + "devDependencies": { + "parse-asn1": "^5.0.0", + "standard": "^6.0.8", + "tape": "^4.5.1" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/crypto-browserify/browserify-rsa#readme", + "license": "MIT", + "main": "index.js", + "name": "browserify-rsa", + "repository": { + "type": "git", + "url": "git+https://github.com/crypto-browserify/browserify-rsa.git" + }, + "scripts": { + "lint": "standard", + "test": "npm run lint && npm run unit", + "unit": "tape test/*.js" + }, + "version": "4.1.0" +} |