aboutsummaryrefslogtreecommitdiffstats
path: root/backend/node_modules/buffer-equal-constant-time
diff options
context:
space:
mode:
Diffstat (limited to 'backend/node_modules/buffer-equal-constant-time')
-rw-r--r--backend/node_modules/buffer-equal-constant-time/.npmignore2
-rw-r--r--backend/node_modules/buffer-equal-constant-time/.travis.yml4
-rw-r--r--backend/node_modules/buffer-equal-constant-time/LICENSE.txt12
-rw-r--r--backend/node_modules/buffer-equal-constant-time/README.md50
-rw-r--r--backend/node_modules/buffer-equal-constant-time/index.js41
-rw-r--r--backend/node_modules/buffer-equal-constant-time/package.json21
-rw-r--r--backend/node_modules/buffer-equal-constant-time/test.js42
7 files changed, 172 insertions, 0 deletions
diff --git a/backend/node_modules/buffer-equal-constant-time/.npmignore b/backend/node_modules/buffer-equal-constant-time/.npmignore
new file mode 100644
index 0000000..34e4f5c
--- /dev/null
+++ b/backend/node_modules/buffer-equal-constant-time/.npmignore
@@ -0,0 +1,2 @@
+.*.sw[mnop]
+node_modules/
diff --git a/backend/node_modules/buffer-equal-constant-time/.travis.yml b/backend/node_modules/buffer-equal-constant-time/.travis.yml
new file mode 100644
index 0000000..78e1c01
--- /dev/null
+++ b/backend/node_modules/buffer-equal-constant-time/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+- "0.11"
+- "0.10"
diff --git a/backend/node_modules/buffer-equal-constant-time/LICENSE.txt b/backend/node_modules/buffer-equal-constant-time/LICENSE.txt
new file mode 100644
index 0000000..9a064f3
--- /dev/null
+++ b/backend/node_modules/buffer-equal-constant-time/LICENSE.txt
@@ -0,0 +1,12 @@
+Copyright (c) 2013, GoInstant Inc., a salesforce.com company
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+* Neither the name of salesforce.com, nor GoInstant, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/backend/node_modules/buffer-equal-constant-time/README.md b/backend/node_modules/buffer-equal-constant-time/README.md
new file mode 100644
index 0000000..4f227f5
--- /dev/null
+++ b/backend/node_modules/buffer-equal-constant-time/README.md
@@ -0,0 +1,50 @@
+# buffer-equal-constant-time
+
+Constant-time `Buffer` comparison for node.js. Should work with browserify too.
+
+[![Build Status](https://travis-ci.org/goinstant/buffer-equal-constant-time.png?branch=master)](https://travis-ci.org/goinstant/buffer-equal-constant-time)
+
+```sh
+ npm install buffer-equal-constant-time
+```
+
+# Usage
+
+```js
+ var bufferEq = require('buffer-equal-constant-time');
+
+ var a = new Buffer('asdf');
+ var b = new Buffer('asdf');
+ if (bufferEq(a,b)) {
+ // the same!
+ } else {
+ // different in at least one byte!
+ }
+```
+
+If you'd like to install an `.equal()` method onto the node.js `Buffer` and
+`SlowBuffer` prototypes:
+
+```js
+ require('buffer-equal-constant-time').install();
+
+ var a = new Buffer('asdf');
+ var b = new Buffer('asdf');
+ if (a.equal(b)) {
+ // the same!
+ } else {
+ // different in at least one byte!
+ }
+```
+
+To get rid of the installed `.equal()` method, call `.restore()`:
+
+```js
+ require('buffer-equal-constant-time').restore();
+```
+
+# Legal
+
+© 2013 GoInstant Inc., a salesforce.com company
+
+Licensed under the BSD 3-clause license.
diff --git a/backend/node_modules/buffer-equal-constant-time/index.js b/backend/node_modules/buffer-equal-constant-time/index.js
new file mode 100644
index 0000000..5462c1f
--- /dev/null
+++ b/backend/node_modules/buffer-equal-constant-time/index.js
@@ -0,0 +1,41 @@
+/*jshint node:true */
+'use strict';
+var Buffer = require('buffer').Buffer; // browserify
+var SlowBuffer = require('buffer').SlowBuffer;
+
+module.exports = bufferEq;
+
+function bufferEq(a, b) {
+
+ // shortcutting on type is necessary for correctness
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
+ return false;
+ }
+
+ // buffer sizes should be well-known information, so despite this
+ // shortcutting, it doesn't leak any information about the *contents* of the
+ // buffers.
+ if (a.length !== b.length) {
+ return false;
+ }
+
+ var c = 0;
+ for (var i = 0; i < a.length; i++) {
+ /*jshint bitwise:false */
+ c |= a[i] ^ b[i]; // XOR
+ }
+ return c === 0;
+}
+
+bufferEq.install = function() {
+ Buffer.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
+ return bufferEq(this, that);
+ };
+};
+
+var origBufEqual = Buffer.prototype.equal;
+var origSlowBufEqual = SlowBuffer.prototype.equal;
+bufferEq.restore = function() {
+ Buffer.prototype.equal = origBufEqual;
+ SlowBuffer.prototype.equal = origSlowBufEqual;
+};
diff --git a/backend/node_modules/buffer-equal-constant-time/package.json b/backend/node_modules/buffer-equal-constant-time/package.json
new file mode 100644
index 0000000..17c7de2
--- /dev/null
+++ b/backend/node_modules/buffer-equal-constant-time/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "buffer-equal-constant-time",
+ "version": "1.0.1",
+ "description": "Constant-time comparison of Buffers",
+ "main": "index.js",
+ "scripts": {
+ "test": "mocha test.js"
+ },
+ "repository": "git@github.com:goinstant/buffer-equal-constant-time.git",
+ "keywords": [
+ "buffer",
+ "equal",
+ "constant-time",
+ "crypto"
+ ],
+ "author": "GoInstant Inc., a salesforce.com company",
+ "license": "BSD-3-Clause",
+ "devDependencies": {
+ "mocha": "~1.15.1"
+ }
+}
diff --git a/backend/node_modules/buffer-equal-constant-time/test.js b/backend/node_modules/buffer-equal-constant-time/test.js
new file mode 100644
index 0000000..0bc972d
--- /dev/null
+++ b/backend/node_modules/buffer-equal-constant-time/test.js
@@ -0,0 +1,42 @@
+/*jshint node:true */
+'use strict';
+
+var bufferEq = require('./index');
+var assert = require('assert');
+
+describe('buffer-equal-constant-time', function() {
+ var a = new Buffer('asdfasdf123456');
+ var b = new Buffer('asdfasdf123456');
+ var c = new Buffer('asdfasdf');
+
+ describe('bufferEq', function() {
+ it('says a == b', function() {
+ assert.strictEqual(bufferEq(a, b), true);
+ });
+
+ it('says a != c', function() {
+ assert.strictEqual(bufferEq(a, c), false);
+ });
+ });
+
+ describe('install/restore', function() {
+ before(function() {
+ bufferEq.install();
+ });
+ after(function() {
+ bufferEq.restore();
+ });
+
+ it('installed an .equal method', function() {
+ var SlowBuffer = require('buffer').SlowBuffer;
+ assert.ok(Buffer.prototype.equal);
+ assert.ok(SlowBuffer.prototype.equal);
+ });
+
+ it('infected existing Buffers', function() {
+ assert.strictEqual(a.equal(b), true);
+ assert.strictEqual(a.equal(c), false);
+ });
+ });
+
+});