sdfsdfs
This commit is contained in:
6
node_modules/public-encrypt/.travis.yml
generated
vendored
Normal file
6
node_modules/public-encrypt/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.11"
|
||||
- "0.12"
|
||||
- iojs
|
19
node_modules/public-encrypt/LICENSE
generated
vendored
Normal file
19
node_modules/public-encrypt/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2017 Calvin Metcalf
|
||||
|
||||
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.
|
10
node_modules/public-encrypt/browser.js
generated
vendored
Normal file
10
node_modules/public-encrypt/browser.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
exports.publicEncrypt = require('./publicEncrypt')
|
||||
exports.privateDecrypt = require('./privateDecrypt')
|
||||
|
||||
exports.privateEncrypt = function privateEncrypt (key, buf) {
|
||||
return exports.publicEncrypt(key, buf, true)
|
||||
}
|
||||
|
||||
exports.publicDecrypt = function publicDecrypt (key, buf) {
|
||||
return exports.privateDecrypt(key, buf, true)
|
||||
}
|
18
node_modules/public-encrypt/index.js
generated
vendored
Normal file
18
node_modules/public-encrypt/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
var crypto = require('crypto')
|
||||
if (typeof crypto.publicEncrypt !== 'function') {
|
||||
crypto = require('./browser')
|
||||
}
|
||||
exports.publicEncrypt = crypto.publicEncrypt
|
||||
exports.privateDecrypt = crypto.privateDecrypt
|
||||
|
||||
if (typeof crypto.privateEncrypt !== 'function') {
|
||||
exports.privateEncrypt = require('./browser').privateEncrypt
|
||||
} else {
|
||||
exports.privateEncrypt = crypto.privateEncrypt
|
||||
}
|
||||
|
||||
if (typeof crypto.publicDecrypt !== 'function') {
|
||||
exports.publicDecrypt = require('./browser').publicDecrypt
|
||||
} else {
|
||||
exports.publicDecrypt = crypto.publicDecrypt
|
||||
}
|
19
node_modules/public-encrypt/mgf.js
generated
vendored
Normal file
19
node_modules/public-encrypt/mgf.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var createHash = require('create-hash')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
|
||||
module.exports = function (seed, len) {
|
||||
var t = Buffer.alloc(0)
|
||||
var i = 0
|
||||
var c
|
||||
while (t.length < len) {
|
||||
c = i2ops(i++)
|
||||
t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()])
|
||||
}
|
||||
return t.slice(0, len)
|
||||
}
|
||||
|
||||
function i2ops (c) {
|
||||
var out = Buffer.allocUnsafe(4)
|
||||
out.writeUInt32BE(c, 0)
|
||||
return out
|
||||
}
|
19
node_modules/public-encrypt/node_modules/bn.js/LICENSE
generated
vendored
Normal file
19
node_modules/public-encrypt/node_modules/bn.js/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright Fedor Indutny, 2015.
|
||||
|
||||
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.
|
200
node_modules/public-encrypt/node_modules/bn.js/README.md
generated
vendored
Normal file
200
node_modules/public-encrypt/node_modules/bn.js/README.md
generated
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
# <img src="./logo.png" alt="bn.js" width="160" height="160" />
|
||||
|
||||
> BigNum in pure javascript
|
||||
|
||||
[](http://travis-ci.org/indutny/bn.js)
|
||||
|
||||
## Install
|
||||
`npm install --save bn.js`
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const BN = require('bn.js');
|
||||
|
||||
var a = new BN('dead', 16);
|
||||
var b = new BN('101010', 2);
|
||||
|
||||
var res = a.add(b);
|
||||
console.log(res.toString(10)); // 57047
|
||||
```
|
||||
|
||||
**Note**: decimals are not supported in this library.
|
||||
|
||||
## Notation
|
||||
|
||||
### Prefixes
|
||||
|
||||
There are several prefixes to instructions that affect the way the work. Here
|
||||
is the list of them in the order of appearance in the function name:
|
||||
|
||||
* `i` - perform operation in-place, storing the result in the host object (on
|
||||
which the method was invoked). Might be used to avoid number allocation costs
|
||||
* `u` - unsigned, ignore the sign of operands when performing operation, or
|
||||
always return positive value. Second case applies to reduction operations
|
||||
like `mod()`. In such cases if the result will be negative - modulo will be
|
||||
added to the result to make it positive
|
||||
|
||||
### Postfixes
|
||||
|
||||
The only available postfix at the moment is:
|
||||
|
||||
* `n` - which means that the argument of the function must be a plain JavaScript
|
||||
Number. Decimals are not supported.
|
||||
|
||||
### Examples
|
||||
|
||||
* `a.iadd(b)` - perform addition on `a` and `b`, storing the result in `a`
|
||||
* `a.umod(b)` - reduce `a` modulo `b`, returning positive value
|
||||
* `a.iushln(13)` - shift bits of `a` left by 13
|
||||
|
||||
## Instructions
|
||||
|
||||
Prefixes/postfixes are put in parens at the of the line. `endian` - could be
|
||||
either `le` (little-endian) or `be` (big-endian).
|
||||
|
||||
### Utilities
|
||||
|
||||
* `a.clone()` - clone number
|
||||
* `a.toString(base, length)` - convert to base-string and pad with zeroes
|
||||
* `a.toNumber()` - convert to Javascript Number (limited to 53 bits)
|
||||
* `a.toJSON()` - convert to JSON compatible hex string (alias of `toString(16)`)
|
||||
* `a.toArray(endian, length)` - convert to byte `Array`, and optionally zero
|
||||
pad to length, throwing if already exceeding
|
||||
* `a.toArrayLike(type, endian, length)` - convert to an instance of `type`,
|
||||
which must behave like an `Array`
|
||||
* `a.toBuffer(endian, length)` - convert to Node.js Buffer (if available). For
|
||||
compatibility with browserify and similar tools, use this instead:
|
||||
`a.toArrayLike(Buffer, endian, length)`
|
||||
* `a.bitLength()` - get number of bits occupied
|
||||
* `a.zeroBits()` - return number of less-significant consequent zero bits
|
||||
(example: `1010000` has 4 zero bits)
|
||||
* `a.byteLength()` - return number of bytes occupied
|
||||
* `a.isNeg()` - true if the number is negative
|
||||
* `a.isEven()` - no comments
|
||||
* `a.isOdd()` - no comments
|
||||
* `a.isZero()` - no comments
|
||||
* `a.cmp(b)` - compare numbers and return `-1` (a `<` b), `0` (a `==` b), or `1` (a `>` b)
|
||||
depending on the comparison result (`ucmp`, `cmpn`)
|
||||
* `a.lt(b)` - `a` less than `b` (`n`)
|
||||
* `a.lte(b)` - `a` less than or equals `b` (`n`)
|
||||
* `a.gt(b)` - `a` greater than `b` (`n`)
|
||||
* `a.gte(b)` - `a` greater than or equals `b` (`n`)
|
||||
* `a.eq(b)` - `a` equals `b` (`n`)
|
||||
* `a.toTwos(width)` - convert to two's complement representation, where `width` is bit width
|
||||
* `a.fromTwos(width)` - convert from two's complement representation, where `width` is the bit width
|
||||
* `BN.isBN(object)` - returns true if the supplied `object` is a BN.js instance
|
||||
|
||||
### Arithmetics
|
||||
|
||||
* `a.neg()` - negate sign (`i`)
|
||||
* `a.abs()` - absolute value (`i`)
|
||||
* `a.add(b)` - addition (`i`, `n`, `in`)
|
||||
* `a.sub(b)` - subtraction (`i`, `n`, `in`)
|
||||
* `a.mul(b)` - multiply (`i`, `n`, `in`)
|
||||
* `a.sqr()` - square (`i`)
|
||||
* `a.pow(b)` - raise `a` to the power of `b`
|
||||
* `a.div(b)` - divide (`divn`, `idivn`)
|
||||
* `a.mod(b)` - reduct (`u`, `n`) (but no `umodn`)
|
||||
* `a.divRound(b)` - rounded division
|
||||
|
||||
### Bit operations
|
||||
|
||||
* `a.or(b)` - or (`i`, `u`, `iu`)
|
||||
* `a.and(b)` - and (`i`, `u`, `iu`, `andln`) (NOTE: `andln` is going to be replaced
|
||||
with `andn` in future)
|
||||
* `a.xor(b)` - xor (`i`, `u`, `iu`)
|
||||
* `a.setn(b)` - set specified bit to `1`
|
||||
* `a.shln(b)` - shift left (`i`, `u`, `iu`)
|
||||
* `a.shrn(b)` - shift right (`i`, `u`, `iu`)
|
||||
* `a.testn(b)` - test if specified bit is set
|
||||
* `a.maskn(b)` - clear bits with indexes higher or equal to `b` (`i`)
|
||||
* `a.bincn(b)` - add `1 << b` to the number
|
||||
* `a.notn(w)` - not (for the width specified by `w`) (`i`)
|
||||
|
||||
### Reduction
|
||||
|
||||
* `a.gcd(b)` - GCD
|
||||
* `a.egcd(b)` - Extended GCD results (`{ a: ..., b: ..., gcd: ... }`)
|
||||
* `a.invm(b)` - inverse `a` modulo `b`
|
||||
|
||||
## Fast reduction
|
||||
|
||||
When doing lots of reductions using the same modulo, it might be beneficial to
|
||||
use some tricks: like [Montgomery multiplication][0], or using special algorithm
|
||||
for [Mersenne Prime][1].
|
||||
|
||||
### Reduction context
|
||||
|
||||
To enable this tricks one should create a reduction context:
|
||||
|
||||
```js
|
||||
var red = BN.red(num);
|
||||
```
|
||||
where `num` is just a BN instance.
|
||||
|
||||
Or:
|
||||
|
||||
```js
|
||||
var red = BN.red(primeName);
|
||||
```
|
||||
|
||||
Where `primeName` is either of these [Mersenne Primes][1]:
|
||||
|
||||
* `'k256'`
|
||||
* `'p224'`
|
||||
* `'p192'`
|
||||
* `'p25519'`
|
||||
|
||||
Or:
|
||||
|
||||
```js
|
||||
var red = BN.mont(num);
|
||||
```
|
||||
|
||||
To reduce numbers with [Montgomery trick][0]. `.mont()` is generally faster than
|
||||
`.red(num)`, but slower than `BN.red(primeName)`.
|
||||
|
||||
### Converting numbers
|
||||
|
||||
Before performing anything in reduction context - numbers should be converted
|
||||
to it. Usually, this means that one should:
|
||||
|
||||
* Convert inputs to reducted ones
|
||||
* Operate on them in reduction context
|
||||
* Convert outputs back from the reduction context
|
||||
|
||||
Here is how one may convert numbers to `red`:
|
||||
|
||||
```js
|
||||
var redA = a.toRed(red);
|
||||
```
|
||||
Where `red` is a reduction context created using instructions above
|
||||
|
||||
Here is how to convert them back:
|
||||
|
||||
```js
|
||||
var a = redA.fromRed();
|
||||
```
|
||||
|
||||
### Red instructions
|
||||
|
||||
Most of the instructions from the very start of this readme have their
|
||||
counterparts in red context:
|
||||
|
||||
* `a.redAdd(b)`, `a.redIAdd(b)`
|
||||
* `a.redSub(b)`, `a.redISub(b)`
|
||||
* `a.redShl(num)`
|
||||
* `a.redMul(b)`, `a.redIMul(b)`
|
||||
* `a.redSqr()`, `a.redISqr()`
|
||||
* `a.redSqrt()` - square root modulo reduction context's prime
|
||||
* `a.redInvm()` - modular inverse of the number
|
||||
* `a.redNeg()`
|
||||
* `a.redPow(b)` - modular exponentiation
|
||||
|
||||
## LICENSE
|
||||
|
||||
This software is licensed under the MIT License.
|
||||
|
||||
[0]: https://en.wikipedia.org/wiki/Montgomery_modular_multiplication
|
||||
[1]: https://en.wikipedia.org/wiki/Mersenne_prime
|
3446
node_modules/public-encrypt/node_modules/bn.js/lib/bn.js
generated
vendored
Normal file
3446
node_modules/public-encrypt/node_modules/bn.js/lib/bn.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
36
node_modules/public-encrypt/node_modules/bn.js/package.json
generated
vendored
Normal file
36
node_modules/public-encrypt/node_modules/bn.js/package.json
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "bn.js",
|
||||
"version": "4.12.0",
|
||||
"description": "Big number implementation in pure javascript",
|
||||
"main": "lib/bn.js",
|
||||
"scripts": {
|
||||
"lint": "semistandard",
|
||||
"unit": "mocha --reporter=spec test/*-test.js",
|
||||
"test": "npm run lint && npm run unit"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:indutny/bn.js"
|
||||
},
|
||||
"keywords": [
|
||||
"BN",
|
||||
"BigNum",
|
||||
"Big number",
|
||||
"Modulo",
|
||||
"Montgomery"
|
||||
],
|
||||
"author": "Fedor Indutny <fedor@indutny.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/indutny/bn.js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/indutny/bn.js",
|
||||
"browser": {
|
||||
"buffer": false
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "^0.3.5",
|
||||
"mocha": "^2.1.0",
|
||||
"semistandard": "^7.0.4"
|
||||
}
|
||||
}
|
37
node_modules/public-encrypt/package.json
generated
vendored
Normal file
37
node_modules/public-encrypt/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "public-encrypt",
|
||||
"version": "4.0.3",
|
||||
"description": "browserify version of publicEncrypt & privateDecrypt",
|
||||
"main": "index.js",
|
||||
"browser": "browser.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/index.js | tspec",
|
||||
"lint": "standard"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/crypto-browserify/publicEncrypt.git"
|
||||
},
|
||||
"author": "Calvin Metcalf",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/crypto-browserify/publicEncrypt/issues"
|
||||
},
|
||||
"homepage": "https://github.com/crypto-browserify/publicEncrypt",
|
||||
"dependencies": {
|
||||
"bn.js": "^4.1.0",
|
||||
"browserify-rsa": "^4.0.0",
|
||||
"create-hash": "^1.1.0",
|
||||
"parse-asn1": "^5.0.0",
|
||||
"randombytes": "^2.0.1",
|
||||
"safe-buffer": "^5.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"standard": "^12.0.0",
|
||||
"tap-spec": "^2.1.2",
|
||||
"tape": "^3.0.3"
|
||||
}
|
||||
}
|
105
node_modules/public-encrypt/privateDecrypt.js
generated
vendored
Normal file
105
node_modules/public-encrypt/privateDecrypt.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
var parseKeys = require('parse-asn1')
|
||||
var mgf = require('./mgf')
|
||||
var xor = require('./xor')
|
||||
var BN = require('bn.js')
|
||||
var crt = require('browserify-rsa')
|
||||
var createHash = require('create-hash')
|
||||
var withPublic = require('./withPublic')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
|
||||
module.exports = function privateDecrypt (privateKey, enc, reverse) {
|
||||
var padding
|
||||
if (privateKey.padding) {
|
||||
padding = privateKey.padding
|
||||
} else if (reverse) {
|
||||
padding = 1
|
||||
} else {
|
||||
padding = 4
|
||||
}
|
||||
|
||||
var key = parseKeys(privateKey)
|
||||
var k = key.modulus.byteLength()
|
||||
if (enc.length > k || new BN(enc).cmp(key.modulus) >= 0) {
|
||||
throw new Error('decryption error')
|
||||
}
|
||||
var msg
|
||||
if (reverse) {
|
||||
msg = withPublic(new BN(enc), key)
|
||||
} else {
|
||||
msg = crt(enc, key)
|
||||
}
|
||||
var zBuffer = Buffer.alloc(k - msg.length)
|
||||
msg = Buffer.concat([zBuffer, msg], k)
|
||||
if (padding === 4) {
|
||||
return oaep(key, msg)
|
||||
} else if (padding === 1) {
|
||||
return pkcs1(key, msg, reverse)
|
||||
} else if (padding === 3) {
|
||||
return msg
|
||||
} else {
|
||||
throw new Error('unknown padding')
|
||||
}
|
||||
}
|
||||
|
||||
function oaep (key, msg) {
|
||||
var k = key.modulus.byteLength()
|
||||
var iHash = createHash('sha1').update(Buffer.alloc(0)).digest()
|
||||
var hLen = iHash.length
|
||||
if (msg[0] !== 0) {
|
||||
throw new Error('decryption error')
|
||||
}
|
||||
var maskedSeed = msg.slice(1, hLen + 1)
|
||||
var maskedDb = msg.slice(hLen + 1)
|
||||
var seed = xor(maskedSeed, mgf(maskedDb, hLen))
|
||||
var db = xor(maskedDb, mgf(seed, k - hLen - 1))
|
||||
if (compare(iHash, db.slice(0, hLen))) {
|
||||
throw new Error('decryption error')
|
||||
}
|
||||
var i = hLen
|
||||
while (db[i] === 0) {
|
||||
i++
|
||||
}
|
||||
if (db[i++] !== 1) {
|
||||
throw new Error('decryption error')
|
||||
}
|
||||
return db.slice(i)
|
||||
}
|
||||
|
||||
function pkcs1 (key, msg, reverse) {
|
||||
var p1 = msg.slice(0, 2)
|
||||
var i = 2
|
||||
var status = 0
|
||||
while (msg[i++] !== 0) {
|
||||
if (i >= msg.length) {
|
||||
status++
|
||||
break
|
||||
}
|
||||
}
|
||||
var ps = msg.slice(2, i - 1)
|
||||
|
||||
if ((p1.toString('hex') !== '0002' && !reverse) || (p1.toString('hex') !== '0001' && reverse)) {
|
||||
status++
|
||||
}
|
||||
if (ps.length < 8) {
|
||||
status++
|
||||
}
|
||||
if (status) {
|
||||
throw new Error('decryption error')
|
||||
}
|
||||
return msg.slice(i)
|
||||
}
|
||||
function compare (a, b) {
|
||||
a = Buffer.from(a)
|
||||
b = Buffer.from(b)
|
||||
var dif = 0
|
||||
var len = a.length
|
||||
if (a.length !== b.length) {
|
||||
dif++
|
||||
len = Math.min(a.length, b.length)
|
||||
}
|
||||
var i = -1
|
||||
while (++i < len) {
|
||||
dif += (a[i] ^ b[i])
|
||||
}
|
||||
return dif
|
||||
}
|
88
node_modules/public-encrypt/publicEncrypt.js
generated
vendored
Normal file
88
node_modules/public-encrypt/publicEncrypt.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
var parseKeys = require('parse-asn1')
|
||||
var randomBytes = require('randombytes')
|
||||
var createHash = require('create-hash')
|
||||
var mgf = require('./mgf')
|
||||
var xor = require('./xor')
|
||||
var BN = require('bn.js')
|
||||
var withPublic = require('./withPublic')
|
||||
var crt = require('browserify-rsa')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
|
||||
module.exports = function publicEncrypt (publicKey, msg, reverse) {
|
||||
var padding
|
||||
if (publicKey.padding) {
|
||||
padding = publicKey.padding
|
||||
} else if (reverse) {
|
||||
padding = 1
|
||||
} else {
|
||||
padding = 4
|
||||
}
|
||||
var key = parseKeys(publicKey)
|
||||
var paddedMsg
|
||||
if (padding === 4) {
|
||||
paddedMsg = oaep(key, msg)
|
||||
} else if (padding === 1) {
|
||||
paddedMsg = pkcs1(key, msg, reverse)
|
||||
} else if (padding === 3) {
|
||||
paddedMsg = new BN(msg)
|
||||
if (paddedMsg.cmp(key.modulus) >= 0) {
|
||||
throw new Error('data too long for modulus')
|
||||
}
|
||||
} else {
|
||||
throw new Error('unknown padding')
|
||||
}
|
||||
if (reverse) {
|
||||
return crt(paddedMsg, key)
|
||||
} else {
|
||||
return withPublic(paddedMsg, key)
|
||||
}
|
||||
}
|
||||
|
||||
function oaep (key, msg) {
|
||||
var k = key.modulus.byteLength()
|
||||
var mLen = msg.length
|
||||
var iHash = createHash('sha1').update(Buffer.alloc(0)).digest()
|
||||
var hLen = iHash.length
|
||||
var hLen2 = 2 * hLen
|
||||
if (mLen > k - hLen2 - 2) {
|
||||
throw new Error('message too long')
|
||||
}
|
||||
var ps = Buffer.alloc(k - mLen - hLen2 - 2)
|
||||
var dblen = k - hLen - 1
|
||||
var seed = randomBytes(hLen)
|
||||
var maskedDb = xor(Buffer.concat([iHash, ps, Buffer.alloc(1, 1), msg], dblen), mgf(seed, dblen))
|
||||
var maskedSeed = xor(seed, mgf(maskedDb, hLen))
|
||||
return new BN(Buffer.concat([Buffer.alloc(1), maskedSeed, maskedDb], k))
|
||||
}
|
||||
function pkcs1 (key, msg, reverse) {
|
||||
var mLen = msg.length
|
||||
var k = key.modulus.byteLength()
|
||||
if (mLen > k - 11) {
|
||||
throw new Error('message too long')
|
||||
}
|
||||
var ps
|
||||
if (reverse) {
|
||||
ps = Buffer.alloc(k - mLen - 3, 0xff)
|
||||
} else {
|
||||
ps = nonZero(k - mLen - 3)
|
||||
}
|
||||
return new BN(Buffer.concat([Buffer.from([0, reverse ? 1 : 2]), ps, Buffer.alloc(1), msg], k))
|
||||
}
|
||||
function nonZero (len) {
|
||||
var out = Buffer.allocUnsafe(len)
|
||||
var i = 0
|
||||
var cache = randomBytes(len * 2)
|
||||
var cur = 0
|
||||
var num
|
||||
while (i < len) {
|
||||
if (cur === cache.length) {
|
||||
cache = randomBytes(len * 2)
|
||||
cur = 0
|
||||
}
|
||||
num = cache[cur++]
|
||||
if (num) {
|
||||
out[i++] = num
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
8
node_modules/public-encrypt/readme.md
generated
vendored
Normal file
8
node_modules/public-encrypt/readme.md
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
publicEncrypt
|
||||
===
|
||||
|
||||
[](https://travis-ci.org/crypto-browserify/publicEncrypt)
|
||||
|
||||
publicEncrypt/privateDecrypt for browserify
|
||||
|
||||
[Blog post about the moving parts that have gone into this.](http://calvinmetcalf.com/post/109301244759/porting-nodejs-crypto-to-the-browser-part-3)
|
16
node_modules/public-encrypt/test/1024.priv
generated
vendored
Normal file
16
node_modules/public-encrypt/test/1024.priv
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKulUTZ8B1qccZ8c
|
||||
DXRGSY08gW8KvLlcxxxGC4gZHNT3CBUF8n5R4KE30aZyYZ/rtsQZu05juZJxaJ0q
|
||||
mbe75dlQ5d+Xc9BMXeQg/MpTZw5TAN7OIdGYYpFBe+1PLZ6wEfjkYrMqMUcfq2Lq
|
||||
hTLdAbvBJnuRcYZLqmBeOQ8FTrKrAgMBAAECgYEAnkHRbEPU3/WISSQrP36iyCb2
|
||||
S/SBZwKkzmvCrBxDWhPeDswp9c/2JY76rNWfLzy8iXgUG8WUzvHje61Qh3gmBcKe
|
||||
bUaTGl4Vy8Ha1YBADo5RfRrdm0FE4tvgvu/TkqFqpBBZweu54285hk5zlG7n/D7Y
|
||||
dnNXUpu5MlNb5x3gW0kCQQDUL//cwcXUxY/evaJP4jSe+ZwEQZo+zXRLiPUulBoV
|
||||
aw28CVMuxdgwqAo1X1IKefPeUaf7RQu8gCKaRnpGuEuXAkEAzxZTfMmvmCUDIew4
|
||||
5Gk6bK265XQWdhcgiq254lpBGOYmDj9yCE7yA+zmASQwMsXTdQOi1hOCEyrXuSJ5
|
||||
c++EDQJAFh3WrnzoEPByuYXMmET8tSFRWMQ5vpgNqh3haHR5b4gUC2hxaiunCBNL
|
||||
1RpVY9AoUiDywGcG/SPh93CnKB3niwJBAKP7AtsifZgVXtiizB4aMThTjVYaSZrz
|
||||
D0Kg9DuHylpkDChmFu77TGrNUQgAVuYtfhb/bRblVa/F0hJ4eQHT3JUCQBVT68tb
|
||||
OgRUk0aP9tC3021VN82X6+klowSQN8oBPX8+TfDWSUilp/+j24Hky+Z29Do7yR/R
|
||||
qutnL92CvBlVLV4=
|
||||
-----END PRIVATE KEY-----
|
6
node_modules/public-encrypt/test/1024.pub
generated
vendored
Normal file
6
node_modules/public-encrypt/test/1024.pub
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrpVE2fAdanHGfHA10RkmNPIFv
|
||||
Cry5XMccRguIGRzU9wgVBfJ+UeChN9GmcmGf67bEGbtOY7mScWidKpm3u+XZUOXf
|
||||
l3PQTF3kIPzKU2cOUwDeziHRmGKRQXvtTy2esBH45GKzKjFHH6ti6oUy3QG7wSZ7
|
||||
kXGGS6pgXjkPBU6yqwIDAQAB
|
||||
-----END PUBLIC KEY-----
|
7
node_modules/public-encrypt/test/ec.pass.priv
generated
vendored
Normal file
7
node_modules/public-encrypt/test/ec.pass.priv
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIHeMEkGCSqGSIb3DQEFDTA8MBsGCSqGSIb3DQEFDDAOBAi9LqZQx4JFXAICCAAw
|
||||
HQYJYIZIAWUDBAECBBA+js1fG4Rv/yRN7oZvxbgyBIGQ/D4yj86M1x8lMsnAHQ/K
|
||||
7/ryb/baDNHqN9LTZanEGBuyxgrTzt08SiL+h91yFGMoaly029K1VgEI8Lxu5Np/
|
||||
A+LK7ewh73ABzsbuxYdcXI+rKnrvLN9Tt6veDs4GlqTTsWwq5wF0C+6gaYRBXA74
|
||||
T1b6NykGh2UNL5U5pHZEYdOVLz+lRJL7gYqlweNHP/S3
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
5
node_modules/public-encrypt/test/ec.priv
generated
vendored
Normal file
5
node_modules/public-encrypt/test/ec.priv
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
-----BEGIN EC PRIVATE KEY-----
|
||||
MHQCAQEEIDF6Xv8Sv//wGUWD+c780ppGrU0QdZWCAzxAQPQX8r/uoAcGBSuBBAAK
|
||||
oUQDQgAEIZeowDylls4K/wfBjO18bYo7gGx8nYQRija4e/qEMikOHJai7geeUreU
|
||||
r5Xky/Ax7s2dGtegsPNsPgGe5MpQvg==
|
||||
-----END EC PRIVATE KEY-----
|
4
node_modules/public-encrypt/test/ec.pub
generated
vendored
Normal file
4
node_modules/public-encrypt/test/ec.pub
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEIZeowDylls4K/wfBjO18bYo7gGx8nYQR
|
||||
ija4e/qEMikOHJai7geeUreUr5Xky/Ax7s2dGtegsPNsPgGe5MpQvg==
|
||||
-----END PUBLIC KEY-----
|
113
node_modules/public-encrypt/test/index.js
generated
vendored
Normal file
113
node_modules/public-encrypt/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
var test = require('tape')
|
||||
var fs = require('fs')
|
||||
var parseKeys = require('parse-asn1')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var path = require('path')
|
||||
|
||||
require('./nodeTests')
|
||||
var rsa1024 = {
|
||||
private: fs.readFileSync(path.join(__dirname, 'rsa.1024.priv')),
|
||||
public: fs.readFileSync(path.join(__dirname, 'rsa.1024.pub'))
|
||||
}
|
||||
var rsa1024priv = {
|
||||
private: fs.readFileSync(path.join(__dirname, 'rsa.1024.priv')),
|
||||
public: fs.readFileSync(path.join(__dirname, 'rsa.1024.priv'))
|
||||
}
|
||||
|
||||
var rsa2028 = {
|
||||
private: fs.readFileSync(path.join(__dirname, 'rsa.2028.priv')),
|
||||
public: fs.readFileSync(path.join(__dirname, 'rsa.2028.pub'))
|
||||
}
|
||||
var nonrsa1024 = {
|
||||
private: fs.readFileSync(path.join(__dirname, '1024.priv')),
|
||||
public: fs.readFileSync(path.join(__dirname, '1024.pub'))
|
||||
}
|
||||
var nonrsa1024str = {
|
||||
private: fs.readFileSync(path.join(__dirname, '1024.priv')).toString(),
|
||||
public: fs.readFileSync(path.join(__dirname, '1024.pub')).toString()
|
||||
}
|
||||
var pass1024 = {
|
||||
private: {
|
||||
passphrase: 'fooo',
|
||||
key: fs.readFileSync(path.join(__dirname, 'pass.1024.priv'))
|
||||
},
|
||||
public: fs.readFileSync(path.join(__dirname, 'pass.1024.pub'))
|
||||
}
|
||||
var pass2028 = {
|
||||
private: {
|
||||
passphrase: 'password',
|
||||
key: fs.readFileSync(path.join(__dirname, 'rsa.pass.priv'))
|
||||
},
|
||||
public: fs.readFileSync(path.join(__dirname, 'rsa.pass.pub'))
|
||||
}
|
||||
|
||||
var nodeCrypto = require('../')
|
||||
var myCrypto = require('../browser')
|
||||
function _testIt (keys, message, t) {
|
||||
var pub = keys.public
|
||||
var priv = keys.private
|
||||
t.test(message.toString(), function (t) {
|
||||
t.plan(8)
|
||||
|
||||
var myEnc = myCrypto.publicEncrypt(pub, message)
|
||||
var nodeEnc = nodeCrypto.publicEncrypt(pub, message)
|
||||
t.equals(myCrypto.privateDecrypt(priv, myEnc).toString('hex'), message.toString('hex'), 'my decrypter my message')
|
||||
t.equals(myCrypto.privateDecrypt(priv, nodeEnc).toString('hex'), message.toString('hex'), 'my decrypter node\'s message')
|
||||
t.equals(nodeCrypto.privateDecrypt(priv, myEnc).toString('hex'), message.toString('hex'), 'node decrypter my message')
|
||||
t.equals(nodeCrypto.privateDecrypt(priv, nodeEnc).toString('hex'), message.toString('hex'), 'node decrypter node\'s message')
|
||||
myEnc = myCrypto.privateEncrypt(priv, message)
|
||||
nodeEnc = nodeCrypto.privateEncrypt(priv, message)
|
||||
t.equals(myCrypto.publicDecrypt(pub, myEnc).toString('hex'), message.toString('hex'), 'reverse methods my decrypter my message')
|
||||
t.equals(myCrypto.publicDecrypt(pub, nodeEnc).toString('hex'), message.toString('hex'), 'reverse methods my decrypter node\'s message')
|
||||
t.equals(nodeCrypto.publicDecrypt(pub, myEnc).toString('hex'), message.toString('hex'), 'reverse methods node decrypter my message')
|
||||
t.equals(nodeCrypto.publicDecrypt(pub, nodeEnc).toString('hex'), message.toString('hex'), 'reverse methods node decrypter node\'s message')
|
||||
})
|
||||
}
|
||||
function testIt (keys, message, t) {
|
||||
_testIt(keys, message, t)
|
||||
_testIt(paddingObject(keys, 1), Buffer.concat([message, Buffer.from(' with RSA_PKCS1_PADDING')]), t)
|
||||
var parsedKey = parseKeys(keys.public)
|
||||
var k = parsedKey.modulus.byteLength()
|
||||
var zBuf = Buffer.alloc(k)
|
||||
var msg = Buffer.concat([zBuf, message, Buffer.from(' with no padding')]).slice(-k)
|
||||
_testIt(paddingObject(keys, 3), msg, t)
|
||||
}
|
||||
function paddingObject (keys, padding) {
|
||||
return {
|
||||
public: addPadding(keys.public, padding),
|
||||
private: addPadding(keys.private, padding)
|
||||
}
|
||||
}
|
||||
function addPadding (key, padding) {
|
||||
if (typeof key === 'string' || Buffer.isBuffer(key)) {
|
||||
return {
|
||||
key: key,
|
||||
padding: padding
|
||||
}
|
||||
}
|
||||
var out = {
|
||||
key: key.key,
|
||||
padding: padding
|
||||
}
|
||||
if ('passphrase' in key) {
|
||||
out.passphrase = key.passphrase
|
||||
}
|
||||
return out
|
||||
}
|
||||
function testRun (i) {
|
||||
test('run ' + i, function (t) {
|
||||
testIt(rsa1024priv, Buffer.from('1024 2 private keys'), t)
|
||||
testIt(rsa1024, Buffer.from('1024 keys'), t)
|
||||
testIt(rsa2028, Buffer.from('2028 keys'), t)
|
||||
testIt(nonrsa1024, Buffer.from('1024 keys non-rsa key'), t)
|
||||
testIt(pass1024, Buffer.from('1024 keys and password'), t)
|
||||
testIt(nonrsa1024str, Buffer.from('1024 keys non-rsa key as a string'), t)
|
||||
testIt(pass2028, Buffer.from('2028 rsa key with variant passwords'), t)
|
||||
})
|
||||
}
|
||||
|
||||
var i = 0
|
||||
var num = 20
|
||||
while (++i <= num) {
|
||||
testRun(i)
|
||||
}
|
51
node_modules/public-encrypt/test/nodeTests.js
generated
vendored
Normal file
51
node_modules/public-encrypt/test/nodeTests.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
var crypto = require('../browser')
|
||||
var test = require('tape')
|
||||
var fs = require('fs')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var path = require('path')
|
||||
// Test RSA encryption/decryption
|
||||
test('node tests', function (t) {
|
||||
var keyPem = fs.readFileSync(path.join(__dirname, 'test_key.pem'), 'ascii')
|
||||
var rsaPubPem = fs.readFileSync(path.join(__dirname, 'test_rsa_pubkey.pem'),
|
||||
'ascii')
|
||||
var rsaKeyPem = fs.readFileSync(path.join(__dirname, 'test_rsa_privkey.pem'),
|
||||
'ascii')
|
||||
var rsaKeyPemEncrypted = fs.readFileSync(path.join(
|
||||
__dirname, 'test_rsa_privkey_encrypted.pem'), 'ascii')
|
||||
var input = 'I AM THE WALRUS'
|
||||
var bufferToEncrypt = Buffer.from(input)
|
||||
|
||||
var encryptedBuffer = crypto.publicEncrypt(rsaPubPem, bufferToEncrypt)
|
||||
|
||||
var decryptedBuffer = crypto.privateDecrypt(rsaKeyPem, encryptedBuffer)
|
||||
t.equal(input, decryptedBuffer.toString())
|
||||
|
||||
var decryptedBufferWithPassword = crypto.privateDecrypt({
|
||||
key: rsaKeyPemEncrypted,
|
||||
passphrase: 'password'
|
||||
}, encryptedBuffer)
|
||||
t.equal(input, decryptedBufferWithPassword.toString())
|
||||
|
||||
// encryptedBuffer = crypto.publicEncrypt(certPem, bufferToEncrypt);
|
||||
|
||||
// decryptedBuffer = crypto.privateDecrypt(keyPem, encryptedBuffer);
|
||||
// t.equal(input, decryptedBuffer.toString());
|
||||
|
||||
encryptedBuffer = crypto.publicEncrypt(keyPem, bufferToEncrypt)
|
||||
|
||||
decryptedBuffer = crypto.privateDecrypt(keyPem, encryptedBuffer)
|
||||
t.equal(input, decryptedBuffer.toString())
|
||||
|
||||
encryptedBuffer = crypto.privateEncrypt(keyPem, bufferToEncrypt)
|
||||
|
||||
decryptedBuffer = crypto.publicDecrypt(keyPem, encryptedBuffer)
|
||||
t.equal(input, decryptedBuffer.toString())
|
||||
|
||||
t.throws(function () {
|
||||
crypto.privateDecrypt({
|
||||
key: rsaKeyPemEncrypted,
|
||||
passphrase: 'wrong'
|
||||
}, encryptedBuffer)
|
||||
})
|
||||
t.end()
|
||||
})
|
18
node_modules/public-encrypt/test/pass.1024.priv
generated
vendored
Normal file
18
node_modules/public-encrypt/test/pass.1024.priv
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIICzzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIji3ZZ6JbsA4CAggA
|
||||
MB0GCWCGSAFlAwQBFgQQC6MKblq8zyX90/KmgotsMQSCAoDghNf+yxPC/KRh7F3O
|
||||
k0lMgtDkV+wCLDv7aBvUqy8Ry2zqFPIlfLb8XtSW943XEu6KUI13IZPEr8p9h1ve
|
||||
Iye6L0g6uAgbFxBE2DwBBSI7mYr7lokr4v0k+inMKf4JeRdI9XWgwOILKTGf1vH7
|
||||
PhvBnqLhOg6BIOuF426qpiyYlmRda74d0Th4o6ZyhyMSzPI1XbWSg719Ew3N/tLe
|
||||
OHdYl0eFrgNjq+xO4Ev+W7eNIh/XBMQtk9wo+mxeNdldRnX822HxTsL8fSSPs+9T
|
||||
W5M/2EBTJMSsswSjZyFkq8ehtxovI2u0IBX1IiPulyUZLnSNPDV1eUVClK6rk+q1
|
||||
kVsfJhUr2qvIjNlQWlbEXQj4VwGtgl0++l8vdpj59MuN2J3Nx5TNMLjA6BYAa/tr
|
||||
Bu928QoT7ET+SGx5XKCwKb5fwXmDlV5zZC4kZWTaF/d/Icvj5F+fDZuYFg1JOXNZ
|
||||
+q2oA1qMYaHGX6lF3pbO84ebg1iwQTDM8iIqFeSMGUJTnk/3a7sqfaWQbEQwGb+X
|
||||
fXnSTwkF+wO2rriPbFvWyzecWu67zDCP0ZWUgGb86sSJCM7xRGShESwCjOrb88F1
|
||||
5SZjyIqogrkc3IWiLH9gc5U8d86qoFjJnP6BfwYks1UIyXNGKfZTCqICpMphV+IS
|
||||
b0N2jprjLTkWR6nxYGSH1bkKMs7x1M0FBLWWLAZqPn9X3pe6JwIBds04O6XjF0un
|
||||
oxwDjcJdoxVs7PgRiM5d1Tubqu2zmpCCmXNiqi9B0+rV9/jHg9IA5gUfvYdCcEv+
|
||||
oAr90I+2+PuBFa9lgdbDV6DtZk4bSYluqamxVeLPg/vrewYfVfDv6jftfY1D0DEy
|
||||
69H0
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
6
node_modules/public-encrypt/test/pass.1024.pub
generated
vendored
Normal file
6
node_modules/public-encrypt/test/pass.1024.pub
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDSK/7i5BV0x+gmX16Wrm7kRkCZ
|
||||
y1QUt6wiM2g+SAZTYR0381VnSMX2cv7CpN3499lZj1rL5S7YTaZZwX3RvU5fz56/
|
||||
eDX6ciL/PZsbclN2KdkMWYgmcb9J1zUeoMQ3cjfFUCdQZ/ZvDWa+wY2Zg8os2Bow
|
||||
AoufHtYHm3eOly/cWwIDAQAB
|
||||
-----END PUBLIC KEY-----
|
15
node_modules/public-encrypt/test/rsa.1024.priv
generated
vendored
Normal file
15
node_modules/public-encrypt/test/rsa.1024.priv
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICVAIBAAJ/OwswbFo/uyC8ltGf/yA1A+gV5IGdnAgPbUSI3GzbHCA+x+TLG/tL
|
||||
vbRw3r1smppY/jkkpiVW1ErSMuN0uixp5gb78Z9rH1XpWb5WWgp3WaY/9EHMjMdO
|
||||
kQ/9LVZvRvl/M/Fi6owP+q+amJI1BEjECYfbhGL3rmlVdq4qXc40QwIDAQABAn8I
|
||||
VZ0BPoAOhyF33KFMHxy8r28fsVgxJUYgM3NqQgdv4fFawCYXjhJz9duU5YJGFJGJ
|
||||
WUGeHlkyYFlpi4f3m7tY7JawmQUWB0MNSoKHI3cgDX4/tfBN8ni+cO0eSoR5czBY
|
||||
EsAHBU47p1awNFAHwd+ZEuv9H4RmMn7p279rQTtpAkAH3Nqs2/vrRF2cZUN4fIXf
|
||||
4xHsQBByUayGq8a3J0UGaSFWv68zTUKFherr9uZotNp7NJ4jBXiARw0q8docXUG1
|
||||
AkAHgmOKHoORtAmikqpmFEJZOtsXMaLCIm4EszPo5ciYoLMBcVit09AdiQlt7ZJL
|
||||
DY02svU1b0agCZ97kDkmHDkXAkACa8M9JELuDs/P/vIGYDkMVatIFfW6bWF02eFG
|
||||
taWwMqCcSEsWvbw0xqYt34jURpNbCjmCyQVwYfAw/+TLhP9dAkAFwRjdwjw37qpj
|
||||
ddg1mNiu37b7swFxmkiMOXZRxaNNsfb56A14RpN3zob3QdGUybGodMIKTFbmU/lu
|
||||
CjqAxafJAkAG2yf6RWbwFIWfMyt7WYCh0VaGBCcgy574AinVieEo3ZZyFfC63+xm
|
||||
3uoaNy4iLoJv4GCjqUBz3ZfcVaO/DDWG
|
||||
-----END RSA PRIVATE KEY-----
|
5
node_modules/public-encrypt/test/rsa.1024.pub
generated
vendored
Normal file
5
node_modules/public-encrypt/test/rsa.1024.pub
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
-----BEGIN RSA PUBLIC KEY-----
|
||||
MIGGAn87CzBsWj+7ILyW0Z//IDUD6BXkgZ2cCA9tRIjcbNscID7H5Msb+0u9tHDe
|
||||
vWyamlj+OSSmJVbUStIy43S6LGnmBvvxn2sfVelZvlZaCndZpj/0QcyMx06RD/0t
|
||||
Vm9G+X8z8WLqjA/6r5qYkjUESMQJh9uEYveuaVV2ripdzjRDAgMBAAE=
|
||||
-----END RSA PUBLIC KEY-----
|
27
node_modules/public-encrypt/test/rsa.2028.priv
generated
vendored
Normal file
27
node_modules/public-encrypt/test/rsa.2028.priv
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEjwIBAAKB/gy7mjaWgPeFdVYDZWRCA9BNiv3pPb0es27+FKY0hszLaOw47ExC
|
||||
tAWpDsH48TXAfyHBYwBLguayfk4LGIupxb+CGMbRo3xEp0CbfY1Jby26T9vGjRC1
|
||||
foHDDUJG84uaRbyHqaf4i6zt4gVR+xlAEIjkaFAAK8cOoXAT1CVqGLLljUCchL8P
|
||||
jaHj/yriZ/S7rdwlI3LnABxwwmLrmR/v71WtpmO/aNG8N+1po+QwaghTkyQ59E/Z
|
||||
vAuOkFWHok2q/R6PYAa2jdZ9zim0FqOP+nkQaEDRbBFBmBqTv5fFGfk2WsAfKf/R
|
||||
G0/VFd+ZeM5251TeTvXH695nlSGauVl9AgMBAAECgf4LrWHY/l54ouThZWvvbrug
|
||||
pfz6sJX2g9l7yXmWlEWsPECVo/7SUbpYFpt6OZy99zSg+IKbGqWKfdhoKrTwIVtC
|
||||
L0YZ0NlmdnANSIz0roxQG7ZxkL5+vHSw/PmD9x4Uwf+Cz8hATCmNBv1qc60dkyuW
|
||||
4CLqe72qaTiVWRoO1iagQghNcLoo6vSy65ExLaCDTPha7yu2vw4hFZpWiEjW4dxf
|
||||
rFdLiix52BC86YlAlxME/rLg8IJVvilbyo9aWdXmxOaUTLRv6PkFD1/gVdw8V9Qr
|
||||
SLN9FlK2kkjiX0dzoibvZw3tMnt3yydAx0X87+sMRVahC1bp3kVPz4Hy0EWX4QJ/
|
||||
PM31vGiuITk2NCd51DXt1Ltn2OP5FaJSmCaEjh0XkU4qouYyjXWt8Bu6BTCl2vua
|
||||
Fg0Uji9C+IkPLmaUMbMIOwaTk8cWqLthSxsLe70J5OkGrgfKUM/w+BHH1Pt/Pjzj
|
||||
C++l0kiFaOVDVaAV9GpLPLCBoK/PC9Rb/rxMMoCCNwJ/NZuedIny2w3LMii77h/T
|
||||
zSvergNGhjY6Rnva8lLXJ6dlrkcPAyps3gWwxqj4NR0T+GM0bDUPVLb7M07XV7SX
|
||||
v7VJGm52JbRGwM1ss+r8XTTNemeGk+WRxG7TgtsMqYGXLfB8Qxk/f5/Mcc00Tl8u
|
||||
wXFNsfxJxmt6AbsTr3g36wJ/IhOnibz9Ad+nchlBnN3QeW3CKHqzaR18voqvtVm2
|
||||
kJfHK15prH/sSGmxmiEGgrCJTZxtDbaNCO7/VBjnKudUUIhCAwsLtuq0/zub9vAd
|
||||
8G1scfIpv5qaSNzmKoX8bOwArvrS6wP7yKrcTsuWIlHD8rJVI7IEDnQoTp5G8fK1
|
||||
hwJ/MIh8M5v0r5dUYEv6oIJWGcle6AH1JmsP5WIafgq72Z2288pHcCFHwNY8Dg9J
|
||||
76QswVLnUhPTlmm3EOOPGEtam2iAD5r0Afytlb4lbNoQsj2szeXONDXB+6oueajh
|
||||
VNELUr8HcSP5lgzRZjJW6aFIzj9LDRmQnUAOjGSXVOQtEwJ/MCQZ7N/v4dIKeDRA
|
||||
8d8UExZ3+gGHumziztGRJ0tQryZH2PakP5I7V+1l7qEUnJ2c3mF+e1v41Ep9LCvh
|
||||
bzrPKw9dxh18g4b+7bMpsWPnsraKh6ipxc7aaOaZV0Dxgez4zcZu0P1olO0cN3KM
|
||||
nxJ0Pds3R8bAhNCDdS2JZaRp5Q==
|
||||
-----END RSA PRIVATE KEY-----
|
8
node_modules/public-encrypt/test/rsa.2028.pub
generated
vendored
Normal file
8
node_modules/public-encrypt/test/rsa.2028.pub
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
-----BEGIN RSA PUBLIC KEY-----
|
||||
MIIBBgKB/gy7mjaWgPeFdVYDZWRCA9BNiv3pPb0es27+FKY0hszLaOw47ExCtAWp
|
||||
DsH48TXAfyHBYwBLguayfk4LGIupxb+CGMbRo3xEp0CbfY1Jby26T9vGjRC1foHD
|
||||
DUJG84uaRbyHqaf4i6zt4gVR+xlAEIjkaFAAK8cOoXAT1CVqGLLljUCchL8PjaHj
|
||||
/yriZ/S7rdwlI3LnABxwwmLrmR/v71WtpmO/aNG8N+1po+QwaghTkyQ59E/ZvAuO
|
||||
kFWHok2q/R6PYAa2jdZ9zim0FqOP+nkQaEDRbBFBmBqTv5fFGfk2WsAfKf/RG0/V
|
||||
Fd+ZeM5251TeTvXH695nlSGauVl9AgMBAAE=
|
||||
-----END RSA PUBLIC KEY-----
|
30
node_modules/public-encrypt/test/rsa.pass.priv
generated
vendored
Normal file
30
node_modules/public-encrypt/test/rsa.pass.priv
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: AES-256-CBC,7A6A055AD675947A657041422F06D439
|
||||
|
||||
HQdjzAKUuqqKhZHmpzzY/monfqFhiHnZ5c24jtR9fM4aQJXf/e1fz6MEhyIz6XON
|
||||
sb4CnXZstnxUuVWDkHEu6KWQ/dKALgiDUuT+UdMawVoVPGdgyWZp35pQPWi3fT2V
|
||||
XZn58YkG8bO3Y403eZPyhadOefD1VtuFuK6/f90jjzx6ZDnwveXpYgFV7Jy1/pFd
|
||||
cLLMf07C+hbk416nX6UVipWe4GH+ADFom5ZCfAaUotM7n8i149dULNF4YYi2wP31
|
||||
1YaDH5vf1CqiaieDY7xLzpEixwJz6ZEg3gLXaUvz2MpF8owiGI3eP0g7voWp3xt4
|
||||
TQx/qDURlaXiaRriWdWtpKyW1MFuJ5+KdNtR1/kXr2BLPB/ZLwyqtynUy8ZYpb4+
|
||||
WIRYpUGeb//ZHGhlCH7CRMdABsal4wTwnzi9fW4Ax96ecJ2SlwCuKxwS7iEq2y1/
|
||||
FAfGwsE+XufHhme5p6XjKfiHx+zJMIB2NMkrm+wm4PbMTrGVnw5/41/r6XxOB8fe
|
||||
iKi12Jth4dusc1vYGYfzKop9uEM6CZ6+Chqzb+Zyh/xUiZVlCX/BYnxr7yXUm9aR
|
||||
PHQgxkn2Act8FgQB3Kgs3jCiCRIJrlsnybeWzQ3YO9TjC4MxygmmwODDBpsOKnEi
|
||||
kXXS54+cZFjcsva4uJVwhAywRPVUkLzmTkH0tGiwCHjeQNECm+TLahkkEIXrVTb9
|
||||
c9creNXMgE6jVVz+R43HXsGvTcgMcBLyFRQJe2nVaj/dQ5JbF4uqNnQzRjAbD34K
|
||||
uTpFaJ/kmlgcmeScRLnwaoYwFlmhSC+bK0dfY1Jr6AQRA6IDP7nIjqWNDCHNBB8r
|
||||
Qj1v2KWoVQe3xNHaXhkbJPbA2DKlUIqffkBVtMKtt9KuG3Rccf3bVYAW6oid73/D
|
||||
z7DMAF5G/OpVR8VbGh1WxXuR7zEVDUwpwsp9ek5dqN8BnBz1ppdZNIKqzszneckU
|
||||
s2l/6mZBmgV1Nfy/cQU6U5s3S1Xc75UDQVLms3CIOpFTRIpecNTdfa31fYy/svy0
|
||||
M2lWTbCva0dOyuvMUhTgBL4I7Qa2dUMPXHMZatV5ooHYq/BZJA1r84C5cM5r+umE
|
||||
2LLv/BlUr7RaQHhaKGn4Qhpzo5yRDE9mEqDpLVkbg8SxMsdf/pEF5/VyUwA9t8RT
|
||||
fKVsInRd386tDqJSDbSFqKTvLztr/5YCyzZzvC2YB1voko/caOGd2d/G51Ij+bXU
|
||||
xEN8U4fHDBsHwPUGb31uZUhTXpL37KiOqZmXFoH2usmuvx882XvyGcV0F4tstMaR
|
||||
KLKzl2PwqzAYGFexLkYKMz0TYIeN6h3b86ETazPPU49nkaEU23Dx21J2Rb3UlH+I
|
||||
lDQF3wuH1QlYiTnlcVa/Zu4QQg0/iP8ALkZ06mvn9e9mOtnA8gsh4B2oLqc19VLU
|
||||
bcpv40dV1H3W9Lcx9B8JYUp0c/Oyno1D7Yj3tjGcwMKECmUpHi4kksehVo0/P933
|
||||
xmFmC6eyWYVdO9upvY/vKSB7b1dMt85iWr3gnMsSfRYc6jsbSxdjOPST46UsIzjx
|
||||
wa1DS6+Bv5tiaC4uC6X+0tCAZo+UOQMYUbTGRR/7g/c=
|
||||
-----END RSA PRIVATE KEY-----
|
9
node_modules/public-encrypt/test/rsa.pass.pub
generated
vendored
Normal file
9
node_modules/public-encrypt/test/rsa.pass.pub
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBHjANBgkqhkiG9w0BAQEFAAOCAQsAMIIBBgKB/gy7mjaWgPeFdVYDZWRCA9BN
|
||||
iv3pPb0es27+FKY0hszLaOw47ExCtAWpDsH48TXAfyHBYwBLguayfk4LGIupxb+C
|
||||
GMbRo3xEp0CbfY1Jby26T9vGjRC1foHDDUJG84uaRbyHqaf4i6zt4gVR+xlAEIjk
|
||||
aFAAK8cOoXAT1CVqGLLljUCchL8PjaHj/yriZ/S7rdwlI3LnABxwwmLrmR/v71Wt
|
||||
pmO/aNG8N+1po+QwaghTkyQ59E/ZvAuOkFWHok2q/R6PYAa2jdZ9zim0FqOP+nkQ
|
||||
aEDRbBFBmBqTv5fFGfk2WsAfKf/RG0/VFd+ZeM5251TeTvXH695nlSGauVl9AgMB
|
||||
AAE=
|
||||
-----END PUBLIC KEY-----
|
20
node_modules/public-encrypt/test/test_cert.pem
generated
vendored
Normal file
20
node_modules/public-encrypt/test/test_cert.pem
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDXDCCAsWgAwIBAgIJAKL0UG+mRkSPMA0GCSqGSIb3DQEBBQUAMH0xCzAJBgNV
|
||||
BAYTAlVLMRQwEgYDVQQIEwtBY2tuYWNrIEx0ZDETMBEGA1UEBxMKUmh5cyBKb25l
|
||||
czEQMA4GA1UEChMHbm9kZS5qczEdMBsGA1UECxMUVGVzdCBUTFMgQ2VydGlmaWNh
|
||||
dGUxEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0wOTExMTEwOTUyMjJaFw0yOTExMDYw
|
||||
OTUyMjJaMH0xCzAJBgNVBAYTAlVLMRQwEgYDVQQIEwtBY2tuYWNrIEx0ZDETMBEG
|
||||
A1UEBxMKUmh5cyBKb25lczEQMA4GA1UEChMHbm9kZS5qczEdMBsGA1UECxMUVGVz
|
||||
dCBUTFMgQ2VydGlmaWNhdGUxEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG
|
||||
9w0BAQEFAAOBjQAwgYkCgYEA8d8Hc6atq78Jt1HLp9agA/wpQfsFvkYUdZ1YsdvO
|
||||
kL2janjwHQgMMCy/Njal3FUEW0OLPebKZUJ8L44JBXSlVxU4zyiiSOWld8EkTetR
|
||||
AVT3WKQq3ud+cnxv7g8rGRQp1UHZwmdbZ1wEfAYq8QjYx6m1ciMgRo7DaDQhD29k
|
||||
d+UCAwEAAaOB4zCB4DAdBgNVHQ4EFgQUL9miTJn+HKNuTmx/oMWlZP9cd4QwgbAG
|
||||
A1UdIwSBqDCBpYAUL9miTJn+HKNuTmx/oMWlZP9cd4ShgYGkfzB9MQswCQYDVQQG
|
||||
EwJVSzEUMBIGA1UECBMLQWNrbmFjayBMdGQxEzARBgNVBAcTClJoeXMgSm9uZXMx
|
||||
EDAOBgNVBAoTB25vZGUuanMxHTAbBgNVBAsTFFRlc3QgVExTIENlcnRpZmljYXRl
|
||||
MRIwEAYDVQQDEwlsb2NhbGhvc3SCCQCi9FBvpkZEjzAMBgNVHRMEBTADAQH/MA0G
|
||||
CSqGSIb3DQEBBQUAA4GBADRXXA2xSUK5W1i3oLYWW6NEDVWkTQ9RveplyeS9MOkP
|
||||
e7yPcpz0+O0ZDDrxR9chAiZ7fmdBBX1Tr+pIuCrG/Ud49SBqeS5aMJGVwiSd7o1n
|
||||
dhU2Sz3Q60DwJEL1VenQHiVYlWWtqXBThe9ggqRPnCfsCRTP8qifKkjk45zWPcpN
|
||||
-----END CERTIFICATE-----
|
15
node_modules/public-encrypt/test/test_key.pem
generated
vendored
Normal file
15
node_modules/public-encrypt/test/test_key.pem
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXQIBAAKBgQDx3wdzpq2rvwm3Ucun1qAD/ClB+wW+RhR1nVix286QvaNqePAd
|
||||
CAwwLL82NqXcVQRbQ4s95splQnwvjgkFdKVXFTjPKKJI5aV3wSRN61EBVPdYpCre
|
||||
535yfG/uDysZFCnVQdnCZ1tnXAR8BirxCNjHqbVyIyBGjsNoNCEPb2R35QIDAQAB
|
||||
AoGBAJNem9C4ftrFNGtQ2DB0Udz7uDuucepkErUy4MbFsc947GfENjDKJXr42Kx0
|
||||
kYx09ImS1vUpeKpH3xiuhwqe7tm4FsCBg4TYqQle14oxxm7TNeBwwGC3OB7hiokb
|
||||
aAjbPZ1hAuNs6ms3Ybvvj6Lmxzx42m8O5DXCG2/f+KMvaNUhAkEA/ekrOsWkNoW9
|
||||
2n3m+msdVuxeek4B87EoTOtzCXb1dybIZUVv4J48VAiM43hhZHWZck2boD/hhwjC
|
||||
M5NWd4oY6QJBAPPcgBVNdNZSZ8hR4ogI4nzwWrQhl9MRbqqtfOn2TK/tjMv10ALg
|
||||
lPmn3SaPSNRPKD2hoLbFuHFERlcS79pbCZ0CQQChX3PuIna/gDitiJ8oQLOg7xEM
|
||||
wk9TRiDK4kl2lnhjhe6PDpaQN4E4F0cTuwqLAoLHtrNWIcOAQvzKMrYdu1MhAkBm
|
||||
Et3qDMnjDAs05lGT72QeN90/mPAcASf5eTTYGahv21cb6IBxM+AnwAPpqAAsHhYR
|
||||
9h13Y7uYbaOjvuF23LRhAkBoI9eaSMn+l81WXOVUHnzh3ZwB4GuTyxMXXNOhuiFd
|
||||
0z4LKAMh99Z4xQmqSoEkXsfM4KPpfhYjF/bwIcP5gOei
|
||||
-----END RSA PRIVATE KEY-----
|
15
node_modules/public-encrypt/test/test_rsa_privkey.pem
generated
vendored
Normal file
15
node_modules/public-encrypt/test/test_rsa_privkey.pem
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXgIBAAKBgQDCFENGw33yGihy92pDjZQhl0C36rPJj+CvfSC8+q28hxA161QF
|
||||
NUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6Z4UMR7EOcpfdUE9Hf3m/hs+F
|
||||
UR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJwoYi+1hqp1fIekaxsyQIDAQAB
|
||||
AoGBAJR8ZkCUvx5kzv+utdl7T5MnordT1TvoXXJGXK7ZZ+UuvMNUCdN2QPc4sBiA
|
||||
QWvLw1cSKt5DsKZ8UETpYPy8pPYnnDEz2dDYiaew9+xEpubyeW2oH4Zx71wqBtOK
|
||||
kqwrXa/pzdpiucRRjk6vE6YY7EBBs/g7uanVpGibOVAEsqH1AkEA7DkjVH28WDUg
|
||||
f1nqvfn2Kj6CT7nIcE3jGJsZZ7zlZmBmHFDONMLUrXR/Zm3pR5m0tCmBqa5RK95u
|
||||
412jt1dPIwJBANJT3v8pnkth48bQo/fKel6uEYyboRtA5/uHuHkZ6FQF7OUkGogc
|
||||
mSJluOdc5t6hI1VsLn0QZEjQZMEOWr+wKSMCQQCC4kXJEsHAve77oP6HtG/IiEn7
|
||||
kpyUXRNvFsDE0czpJJBvL/aRFUJxuRK91jhjC68sA7NsKMGg5OXb5I5Jj36xAkEA
|
||||
gIT7aFOYBFwGgQAQkWNKLvySgKbAZRTeLBacpHMuQdl1DfdntvAyqpAZ0lY0RKmW
|
||||
G6aFKaqQfOXKCyWoUiVknQJAXrlgySFci/2ueKlIE1QqIiLSZ8V8OlpFLRnb1pzI
|
||||
7U1yQXnTAEFYM560yJlzUpOb1V4cScGd365tiSMvxLOvTA==
|
||||
-----END RSA PRIVATE KEY-----
|
18
node_modules/public-encrypt/test/test_rsa_privkey_encrypted.pem
generated
vendored
Normal file
18
node_modules/public-encrypt/test/test_rsa_privkey_encrypted.pem
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: AES-128-CBC,9D916E00476DFF9E70FA4BA9E3A6CB0E
|
||||
|
||||
oj0VC35ShSEqlfJ0rLGgkqJCyIK+mXSsa/X/xAur+lI/RVOVTWd7oQQGTdI/0rLX
|
||||
PdQR02Na3X9Rptezh6J04PfMGeFysxdT6RpC+rkHRPVbN0F4TqxSNNXzkwK70+EF
|
||||
dSuDMyVKv9YN4wWDf0g6VKe4ShAH/sqICQBrVyzWyYLvH/hwZmZZ1QEab6ylIKtb
|
||||
EJunwu9BxVVA04bbuATKkKjJOqDn0fG8hb4bYbyD02dJwgLePzzn36F31kcBCEHI
|
||||
tESlD3RsS+EtfpfgPkplXNOhqYzkD9auDb7Zy+ZwL20fjnJb75OSGu8gOg3KTljt
|
||||
mApZOg0nJ5Jk9ATAdyzyVSFOM1Hhcw12ws06Dq9KRnXgO6bbuadLTFRDdvSYDFvD
|
||||
ijUb+97UolQfYIXQMqXli3EIvHr7CTWe/3mpoDgK1mtr0+923Bm97XgE7KSr0L46
|
||||
n5QpNjCZf1vbXldNmW+TRifiJMgtVdS7x0N4vqDPNEe+FelVv3U4Pz3HIOtFuWLr
|
||||
ZCxlgVxJY4IsyYlV0ItQjIv8fJiAyemZdO2lA9K6h0eEF+9Apr3i79JGWUi74p5D
|
||||
Ooak4le0Va9O34f6FxCGn/a54A6bhKu24Ub/0gr/e4WRa7693euEdgIAZXhtMu2Z
|
||||
taU5SKjjXPzjmRCM2kINHTCENlaU4oFzTmj3TYY/jdKyNP1bHa07NhlomladkIHK
|
||||
GD6HaYkcbuwvh8hOPsopSwuS+NqjnGPq9Vv4ecBC+9veDEmpIE1iR6FK9Hjrre88
|
||||
kLoMQNmA+vuc8jG4/FIHM3SauQiR1ZJ6+zkz97kcmOf+X7LRaS4j6lfFR6qHiJ6y
|
||||
-----END RSA PRIVATE KEY-----
|
6
node_modules/public-encrypt/test/test_rsa_pubkey.pem
generated
vendored
Normal file
6
node_modules/public-encrypt/test/test_rsa_pubkey.pem
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCFENGw33yGihy92pDjZQhl0C3
|
||||
6rPJj+CvfSC8+q28hxA161QFNUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6
|
||||
Z4UMR7EOcpfdUE9Hf3m/hs+FUR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJw
|
||||
oYi+1hqp1fIekaxsyQIDAQAB
|
||||
-----END PUBLIC KEY-----
|
12
node_modules/public-encrypt/withPublic.js
generated
vendored
Normal file
12
node_modules/public-encrypt/withPublic.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var BN = require('bn.js')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
|
||||
function withPublic (paddedMsg, key) {
|
||||
return Buffer.from(paddedMsg
|
||||
.toRed(BN.mont(key.modulus))
|
||||
.redPow(new BN(key.publicExponent))
|
||||
.fromRed()
|
||||
.toArray())
|
||||
}
|
||||
|
||||
module.exports = withPublic
|
8
node_modules/public-encrypt/xor.js
generated
vendored
Normal file
8
node_modules/public-encrypt/xor.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = function xor (a, b) {
|
||||
var len = a.length
|
||||
var i = -1
|
||||
while (++i < len) {
|
||||
a[i] ^= b[i]
|
||||
}
|
||||
return a
|
||||
}
|
Reference in New Issue
Block a user