aboutsummaryrefslogtreecommitdiff
path: root/node_modules/browserify-des
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/browserify-des
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
downloadwallet-core-bbff7403fbf46f9ad92240ac213df8d30ef31b64.tar.xz
update packages
Diffstat (limited to 'node_modules/browserify-des')
-rw-r--r--node_modules/browserify-des/index.js11
-rw-r--r--node_modules/browserify-des/package.json5
-rw-r--r--node_modules/browserify-des/readme.md2
-rw-r--r--node_modules/browserify-des/test.js33
4 files changed, 47 insertions, 4 deletions
diff --git a/node_modules/browserify-des/index.js b/node_modules/browserify-des/index.js
index 2889bb77c..f6943674f 100644
--- a/node_modules/browserify-des/index.js
+++ b/node_modules/browserify-des/index.js
@@ -1,6 +1,7 @@
var CipherBase = require('cipher-base')
var des = require('des.js')
var inherits = require('inherits')
+var Buffer = require('safe-buffer').Buffer
var modes = {
'des-ede3-cbc': des.CBC.instantiate(des.EDE),
@@ -25,10 +26,16 @@ function DES (opts) {
type = 'encrypt'
}
var key = opts.key
+ if (!Buffer.isBuffer(key)) {
+ key = Buffer.from(key)
+ }
if (modeName === 'des-ede' || modeName === 'des-ede-cbc') {
key = Buffer.concat([key, key.slice(0, 8)])
}
var iv = opts.iv
+ if (!Buffer.isBuffer(iv)) {
+ iv = Buffer.from(iv)
+ }
this._des = mode.create({
key: key,
iv: iv,
@@ -36,8 +43,8 @@ function DES (opts) {
})
}
DES.prototype._update = function (data) {
- return new Buffer(this._des.update(data))
+ return Buffer.from(this._des.update(data))
}
DES.prototype._final = function () {
- return new Buffer(this._des.final())
+ return Buffer.from(this._des.final())
}
diff --git a/node_modules/browserify-des/package.json b/node_modules/browserify-des/package.json
index fdc9a8f63..fa46daa58 100644
--- a/node_modules/browserify-des/package.json
+++ b/node_modules/browserify-des/package.json
@@ -1,6 +1,6 @@
{
"name": "browserify-des",
- "version": "1.0.0",
+ "version": "1.0.2",
"description": "",
"main": "index.js",
"scripts": {
@@ -19,7 +19,8 @@
"dependencies": {
"cipher-base": "^1.0.1",
"des.js": "^1.0.0",
- "inherits": "^2.0.1"
+ "inherits": "^2.0.1",
+ "safe-buffer": "^5.1.2"
},
"devDependencies": {
"standard": "^5.3.1",
diff --git a/node_modules/browserify-des/readme.md b/node_modules/browserify-des/readme.md
index c29c1b212..b9b469d3f 100644
--- a/node_modules/browserify-des/readme.md
+++ b/node_modules/browserify-des/readme.md
@@ -1,4 +1,6 @@
browserify-des
===
+[![Build Status](https://travis-ci.org/crypto-browserify/browserify-des.svg)](https://travis-ci.org/crypto-browserify/browserify-des)
+
DES for browserify
diff --git a/node_modules/browserify-des/test.js b/node_modules/browserify-des/test.js
index 6324f43b5..072926247 100644
--- a/node_modules/browserify-des/test.js
+++ b/node_modules/browserify-des/test.js
@@ -43,6 +43,39 @@ Object.keys(modes).forEach(function (mode) {
var plainText = Buffer.concat([ourDecrypt.update(ourCipherText), ourDecrypt.final()])
t.equals(text.toString('hex'), plainText.toString('hex'))
})
+ t.test('run text: ' + i, function (t) {
+ t.plan(2)
+ var key = crypto.randomBytes(32).toString('base64').slice(0, modes[mode].key)
+ var iv = crypto.randomBytes(32).toString('base64').slice(0, modes[mode].iv)
+ var text = crypto.randomBytes(200)
+ var ourEncrypt
+ try {
+ ourEncrypt = new DES({
+ mode: mode,
+ key: key,
+ iv: iv
+ })
+ } catch (e) {
+ t.notOk(e, e.stack)
+ }
+ var nodeEncrypt
+ try {
+ nodeEncrypt = crypto.createCipheriv(mode, key, iv)
+ } catch (e) {
+ t.notOk(e, e.stack)
+ }
+ var ourCipherText = Buffer.concat([ourEncrypt.update(text), ourEncrypt.final()])
+ var nodeCipherText = Buffer.concat([nodeEncrypt.update(text), nodeEncrypt.final()])
+ t.equals(nodeCipherText.toString('hex'), ourCipherText.toString('hex'))
+ var ourDecrypt = new DES({
+ mode: mode,
+ key: key,
+ iv: iv,
+ decrypt: true
+ })
+ var plainText = Buffer.concat([ourDecrypt.update(ourCipherText), ourDecrypt.final()])
+ t.equals(text.toString('hex'), plainText.toString('hex'))
+ })
}
})
})