aboutsummaryrefslogtreecommitdiff
path: root/node_modules/crypto-browserify
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
commit0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch)
treef9864d4a4148621378958794cbbfdc2393733283 /node_modules/crypto-browserify
parent6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff)
downloadwallet-core-0469abd4a9c9270a1fdc962969e36e63699af8b4.tar.xz
upgrade dependencies
Diffstat (limited to 'node_modules/crypto-browserify')
-rw-r--r--node_modules/crypto-browserify/.npmignore1
-rw-r--r--node_modules/crypto-browserify/.travis.yml2
-rw-r--r--node_modules/crypto-browserify/index.js5
-rw-r--r--node_modules/crypto-browserify/package.json6
-rw-r--r--node_modules/crypto-browserify/test/index.js1
-rw-r--r--node_modules/crypto-browserify/test/random-fill.js53
6 files changed, 64 insertions, 4 deletions
diff --git a/node_modules/crypto-browserify/.npmignore b/node_modules/crypto-browserify/.npmignore
deleted file mode 100644
index 3c3629e64..000000000
--- a/node_modules/crypto-browserify/.npmignore
+++ /dev/null
@@ -1 +0,0 @@
-node_modules
diff --git a/node_modules/crypto-browserify/.travis.yml b/node_modules/crypto-browserify/.travis.yml
index 8f7bb60c5..5ad8439a8 100644
--- a/node_modules/crypto-browserify/.travis.yml
+++ b/node_modules/crypto-browserify/.travis.yml
@@ -17,7 +17,7 @@ matrix:
- node_js: '4'
env: TEST_SUITE=browser BROWSER_NAME=firefox BROWSER_VERSION="-2..latest"
- node_js: '4'
- env: TEST_SUITE=browser BROWSER_NAME=safari BROWSER_VERSION="5..latest"
+ env: TEST_SUITE=browser BROWSER_NAME=safari BROWSER_VERSION="7..latest"
- node_js: '4'
env: TEST_SUITE=browser BROWSER_NAME=android BROWSER_VERSION="5.0..latest"
script: "npm run-script $TEST_SUITE"
diff --git a/node_modules/crypto-browserify/index.js b/node_modules/crypto-browserify/index.js
index 3b48da3da..b6d4d24e1 100644
--- a/node_modules/crypto-browserify/index.js
+++ b/node_modules/crypto-browserify/index.js
@@ -65,6 +65,11 @@ exports.privateDecrypt = publicEncrypt.privateDecrypt
// }
// })
+var rf = require('randomfill')
+
+exports.randomFill = rf.randomFill
+exports.randomFillSync = rf.randomFillSync
+
exports.createCredentials = function () {
throw new Error([
'sorry, createCredentials is not implemented yet',
diff --git a/node_modules/crypto-browserify/package.json b/node_modules/crypto-browserify/package.json
index d7fe9a4a0..7de383b01 100644
--- a/node_modules/crypto-browserify/package.json
+++ b/node_modules/crypto-browserify/package.json
@@ -2,7 +2,7 @@
"author": "Dominic Tarr <dominic.tarr@gmail.com> (dominictarr.com)",
"name": "crypto-browserify",
"description": "implementation of crypto for the browser",
- "version": "3.11.1",
+ "version": "3.12.0",
"homepage": "https://github.com/crypto-browserify/crypto-browserify",
"repository": {
"type": "git",
@@ -27,11 +27,13 @@
"inherits": "^2.0.1",
"pbkdf2": "^3.0.3",
"public-encrypt": "^4.0.0",
- "randombytes": "^2.0.0"
+ "randombytes": "^2.0.0",
+ "randomfill": "^1.0.3"
},
"devDependencies": {
"hash-test-vectors": "~1.3.2",
"pseudorandombytes": "^2.0.0",
+ "safe-buffer": "^5.1.1",
"standard": "^5.0.2",
"tape": "~2.3.2",
"zuul": "^3.6.0"
diff --git a/node_modules/crypto-browserify/test/index.js b/node_modules/crypto-browserify/test/index.js
index 0a9d290b2..2ac709446 100644
--- a/node_modules/crypto-browserify/test/index.js
+++ b/node_modules/crypto-browserify/test/index.js
@@ -12,6 +12,7 @@ try {
require('./public-encrypt')
require('./random-bytes')
require('./sign')
+ require('./random-fill')
} catch (e) {
console.log('no secure rng avaiable')
}
diff --git a/node_modules/crypto-browserify/test/random-fill.js b/node_modules/crypto-browserify/test/random-fill.js
new file mode 100644
index 000000000..63c885add
--- /dev/null
+++ b/node_modules/crypto-browserify/test/random-fill.js
@@ -0,0 +1,53 @@
+var test = require('tape')
+var crypto = require('../')
+var Buffer = require('safe-buffer').Buffer
+
+test('get error message', function (t) {
+ try {
+ var b = crypto.randomFillSync(Buffer.alloc(10))
+ t.ok(Buffer.isBuffer(b))
+ t.end()
+ } catch (err) {
+ t.ok(/not supported/.test(err.message), '"not supported" is in error message')
+ t.end()
+ }
+})
+
+test('randomfill', function (t) {
+ t.plan(5)
+ t.equal(crypto.randomFillSync(Buffer.alloc(10)).length, 10)
+ t.ok(Buffer.isBuffer(crypto.randomFillSync(Buffer.alloc(10))))
+ crypto.randomFill(Buffer.alloc(10), function (ex, bytes) {
+ t.error(ex)
+ t.equal(bytes.length, 10)
+ t.ok(Buffer.isBuffer(bytes))
+ t.end()
+ })
+})
+
+test('seems random', function (t) {
+ var L = 1000
+ var b = crypto.randomFillSync(Buffer.alloc(L))
+
+ var mean = [].reduce.call(b, function (a, b) {
+ return a + b
+ }, 0) / L
+
+ // test that the random numbers are plausably random.
+ // Math.random() will pass this, but this will catch
+ // terrible mistakes such as this blunder:
+ // https://github.com/dominictarr/crypto-browserify/commit/3267955e1df7edd1680e52aeede9a89506ed2464#commitcomment-7916835
+
+ // this doesn't check that the bytes are in a random *order*
+ // but it's better than nothing.
+
+ var expected = 256 / 2
+ var smean = Math.sqrt(mean)
+
+ // console.log doesn't work right on testling, *grumble grumble*
+ console.log(JSON.stringify([expected - smean, mean, expected + smean]))
+ t.ok(mean < expected + smean)
+ t.ok(mean > expected - smean)
+
+ t.end()
+})