aboutsummaryrefslogtreecommitdiff
path: root/node_modules/cipher-base
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/cipher-base')
-rw-r--r--node_modules/cipher-base/.npmignore1
-rw-r--r--node_modules/cipher-base/LICENSE21
-rw-r--r--node_modules/cipher-base/README.md (renamed from node_modules/cipher-base/readme.md)0
-rw-r--r--node_modules/cipher-base/index.js39
-rw-r--r--node_modules/cipher-base/package.json6
-rw-r--r--node_modules/cipher-base/test.js17
6 files changed, 60 insertions, 24 deletions
diff --git a/node_modules/cipher-base/.npmignore b/node_modules/cipher-base/.npmignore
new file mode 100644
index 000000000..3c3629e64
--- /dev/null
+++ b/node_modules/cipher-base/.npmignore
@@ -0,0 +1 @@
+node_modules
diff --git a/node_modules/cipher-base/LICENSE b/node_modules/cipher-base/LICENSE
new file mode 100644
index 000000000..f06007ae3
--- /dev/null
+++ b/node_modules/cipher-base/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 crypto-browserify 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/cipher-base/readme.md b/node_modules/cipher-base/README.md
index db9a78141..db9a78141 100644
--- a/node_modules/cipher-base/readme.md
+++ b/node_modules/cipher-base/README.md
diff --git a/node_modules/cipher-base/index.js b/node_modules/cipher-base/index.js
index 1a661d626..6728005e9 100644
--- a/node_modules/cipher-base/index.js
+++ b/node_modules/cipher-base/index.js
@@ -1,8 +1,8 @@
+var Buffer = require('safe-buffer').Buffer
var Transform = require('stream').Transform
-var inherits = require('inherits')
var StringDecoder = require('string_decoder').StringDecoder
-module.exports = CipherBase
-inherits(CipherBase, Transform)
+var inherits = require('inherits')
+
function CipherBase (hashMode) {
Transform.call(this)
this.hashMode = typeof hashMode === 'string'
@@ -11,25 +11,31 @@ function CipherBase (hashMode) {
} else {
this.final = this._finalOrDigest
}
+ if (this._final) {
+ this.__final = this._final
+ this._final = null
+ }
this._decoder = null
this._encoding = null
}
+inherits(CipherBase, Transform)
+
CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
if (typeof data === 'string') {
- data = new Buffer(data, inputEnc)
+ data = Buffer.from(data, inputEnc)
}
+
var outData = this._update(data)
- if (this.hashMode) {
- return this
- }
+ if (this.hashMode) return this
+
if (outputEnc) {
outData = this._toString(outData, outputEnc)
}
+
return outData
}
CipherBase.prototype.setAutoPadding = function () {}
-
CipherBase.prototype.getAuthTag = function () {
throw new Error('trying to get auth tag in unsupported state')
}
@@ -59,15 +65,15 @@ CipherBase.prototype._transform = function (data, _, next) {
CipherBase.prototype._flush = function (done) {
var err
try {
- this.push(this._final())
+ this.push(this.__final())
} catch (e) {
err = e
- } finally {
- done(err)
}
+
+ done(err)
}
CipherBase.prototype._finalOrDigest = function (outputEnc) {
- var outData = this._final() || new Buffer('')
+ var outData = this.__final() || Buffer.alloc(0)
if (outputEnc) {
outData = this._toString(outData, outputEnc, true)
}
@@ -79,12 +85,15 @@ CipherBase.prototype._toString = function (value, enc, fin) {
this._decoder = new StringDecoder(enc)
this._encoding = enc
}
- if (this._encoding !== enc) {
- throw new Error('can\'t switch encodings')
- }
+
+ if (this._encoding !== enc) throw new Error('can\'t switch encodings')
+
var out = this._decoder.write(value)
if (fin) {
out += this._decoder.end()
}
+
return out
}
+
+module.exports = CipherBase
diff --git a/node_modules/cipher-base/package.json b/node_modules/cipher-base/package.json
index 1203f7d43..f3725994f 100644
--- a/node_modules/cipher-base/package.json
+++ b/node_modules/cipher-base/package.json
@@ -1,6 +1,6 @@
{
"name": "cipher-base",
- "version": "1.0.3",
+ "version": "1.0.4",
"description": "abstract base class for crypto-streams",
"main": "index.js",
"scripts": {
@@ -21,9 +21,11 @@
},
"homepage": "https://github.com/crypto-browserify/cipher-base#readme",
"dependencies": {
- "inherits": "^2.0.1"
+ "inherits": "^2.0.1",
+ "safe-buffer": "^5.0.1"
},
"devDependencies": {
+ "standard": "^10.0.2",
"tap-spec": "^4.1.0",
"tape": "^4.2.0"
}
diff --git a/node_modules/cipher-base/test.js b/node_modules/cipher-base/test.js
index 57d144a55..29d349239 100644
--- a/node_modules/cipher-base/test.js
+++ b/node_modules/cipher-base/test.js
@@ -1,12 +1,14 @@
-var test = require('tape')
+var Buffer = require('safe-buffer').Buffer
var CipherBase = require('./')
+
+var test = require('tape')
var inherits = require('inherits')
test('basic version', function (t) {
- inherits(Cipher, CipherBase)
function Cipher () {
CipherBase.call(this)
}
+ inherits(Cipher, CipherBase)
Cipher.prototype._update = function (input) {
t.ok(Buffer.isBuffer(input))
return input
@@ -17,16 +19,16 @@ test('basic version', function (t) {
var cipher = new Cipher()
var utf8 = 'abc123abcd'
var update = cipher.update(utf8, 'utf8', 'base64') + cipher.final('base64')
- var string = (new Buffer(update, 'base64')).toString()
+ var string = (Buffer.from(update, 'base64')).toString()
t.equals(utf8, string)
t.end()
})
test('hash mode', function (t) {
- inherits(Cipher, CipherBase)
function Cipher () {
CipherBase.call(this, 'finalName')
this._cache = []
}
+ inherits(Cipher, CipherBase)
Cipher.prototype._update = function (input) {
t.ok(Buffer.isBuffer(input))
this._cache.push(input)
@@ -37,17 +39,17 @@ test('hash mode', function (t) {
var cipher = new Cipher()
var utf8 = 'abc123abcd'
var update = cipher.update(utf8, 'utf8').finalName('base64')
- var string = (new Buffer(update, 'base64')).toString()
+ var string = (Buffer.from(update, 'base64')).toString()
t.equals(utf8, string)
t.end()
})
test('hash mode as stream', function (t) {
- inherits(Cipher, CipherBase)
function Cipher () {
CipherBase.call(this, 'finalName')
this._cache = []
}
+ inherits(Cipher, CipherBase)
Cipher.prototype._update = function (input) {
t.ok(Buffer.isBuffer(input))
this._cache.push(input)
@@ -62,11 +64,12 @@ test('hash mode as stream', function (t) {
var utf8 = 'abc123abcd'
cipher.end(utf8, 'utf8')
var update = cipher.read().toString('base64')
- var string = (new Buffer(update, 'base64')).toString()
+ var string = (Buffer.from(update, 'base64')).toString()
t.equals(utf8, string)
t.end()
})
+
test('encodings', function (t) {
inherits(Cipher, CipherBase)
function Cipher () {