aboutsummaryrefslogtreecommitdiff
path: root/node_modules/pbkdf2
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/pbkdf2')
-rw-r--r--node_modules/pbkdf2/LICENSE21
-rw-r--r--node_modules/pbkdf2/README.md28
-rw-r--r--node_modules/pbkdf2/browser.js68
-rw-r--r--node_modules/pbkdf2/index.js7
-rw-r--r--node_modules/pbkdf2/package.json55
-rw-r--r--node_modules/pbkdf2/precondition.js18
6 files changed, 197 insertions, 0 deletions
diff --git a/node_modules/pbkdf2/LICENSE b/node_modules/pbkdf2/LICENSE
new file mode 100644
index 000000000..a115b5242
--- /dev/null
+++ b/node_modules/pbkdf2/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Daniel Cousens
+
+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/pbkdf2/README.md b/node_modules/pbkdf2/README.md
new file mode 100644
index 000000000..05757828e
--- /dev/null
+++ b/node_modules/pbkdf2/README.md
@@ -0,0 +1,28 @@
+# pbkdf2
+
+[![NPM Package](https://img.shields.io/npm/v/pbkdf2.svg?style=flat-square)](https://www.npmjs.org/package/pbkdf2)
+[![Build Status](https://img.shields.io/travis/crypto-browserify/pbkdf2.svg?branch=master&style=flat-square)](https://travis-ci.org/crypto-browserify/pbkdf2)
+[![Dependency status](https://img.shields.io/david/crypto-browserify/pbkdf2.svg?style=flat-square)](https://david-dm.org/crypto-browserify/pbkdf2#info=dependencies)
+
+[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
+
+This library provides the functionality of PBKDF2 with the ability to use any supported hashing algorithm returned from `crypto.getHashes()`
+
+
+## Usage
+
+```js
+var pbkdf2 = require('pbkdf2')
+var derivedKey = pbkdf2.pbkdf2Sync('password', 'salt', 1, 32, 'sha512')
+
+...
+```
+
+For more information on the API, please see the relevant [Node documentation](https://nodejs.org/api/crypto.html#crypto_crypto_pbkdf2_password_salt_iterations_keylen_digest_callback).
+
+
+## Credits
+
+This module is a derivative of [cryptocoinjs/pbkdf2-sha256](https://github.com/cryptocoinjs/pbkdf2-sha256/), so thanks to [JP Richardson](https://github.com/jprichardson/) for laying the ground work.
+
+Thank you to [FangDun Cai](https://github.com/fundon) for donating the package name on npm, if you're looking for his previous module it is located at [fundon/pbkdf2](https://github.com/fundon/pbkdf2).
diff --git a/node_modules/pbkdf2/browser.js b/node_modules/pbkdf2/browser.js
new file mode 100644
index 000000000..e07b5ad5a
--- /dev/null
+++ b/node_modules/pbkdf2/browser.js
@@ -0,0 +1,68 @@
+var createHmac = require('create-hmac')
+var checkParameters = require('./precondition')
+
+exports.pbkdf2 = function (password, salt, iterations, keylen, digest, callback) {
+ if (typeof digest === 'function') {
+ callback = digest
+ digest = undefined
+ }
+
+ checkParameters(iterations, keylen)
+ if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')
+
+ setTimeout(function () {
+ callback(null, exports.pbkdf2Sync(password, salt, iterations, keylen, digest))
+ })
+}
+
+var defaultEncoding
+if (process.browser) {
+ defaultEncoding = 'utf-8'
+} else {
+ var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10)
+
+ defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary'
+}
+
+exports.pbkdf2Sync = function (password, salt, iterations, keylen, digest) {
+ if (!Buffer.isBuffer(password)) password = new Buffer(password, defaultEncoding)
+ if (!Buffer.isBuffer(salt)) salt = new Buffer(salt, defaultEncoding)
+
+ checkParameters(iterations, keylen)
+
+ digest = digest || 'sha1'
+
+ var hLen
+ var l = 1
+ var DK = new Buffer(keylen)
+ var block1 = new Buffer(salt.length + 4)
+ salt.copy(block1, 0, 0, salt.length)
+
+ var r
+ var T
+
+ for (var i = 1; i <= l; i++) {
+ block1.writeUInt32BE(i, salt.length)
+ var U = createHmac(digest, password).update(block1).digest()
+
+ if (!hLen) {
+ hLen = U.length
+ T = new Buffer(hLen)
+ l = Math.ceil(keylen / hLen)
+ r = keylen - (l - 1) * hLen
+ }
+
+ U.copy(T, 0, 0, hLen)
+
+ for (var j = 1; j < iterations; j++) {
+ U = createHmac(digest, password).update(U).digest()
+ for (var k = 0; k < hLen; k++) T[k] ^= U[k]
+ }
+
+ var destPos = (i - 1) * hLen
+ var len = (i === l ? r : hLen)
+ T.copy(DK, destPos, 0, len)
+ }
+
+ return DK
+}
diff --git a/node_modules/pbkdf2/index.js b/node_modules/pbkdf2/index.js
new file mode 100644
index 000000000..2dc6c39fb
--- /dev/null
+++ b/node_modules/pbkdf2/index.js
@@ -0,0 +1,7 @@
+var crypto = require('crypto')
+if (crypto.pbkdf2Sync.toString().indexOf('keylen, digest') === -1) {
+ throw new Error('Unsupported crypto version')
+}
+
+exports.pbkdf2Sync = crypto.pbkdf2Sync
+exports.pbkdf2 = crypto.pbkdf2
diff --git a/node_modules/pbkdf2/package.json b/node_modules/pbkdf2/package.json
new file mode 100644
index 000000000..9d4f40abe
--- /dev/null
+++ b/node_modules/pbkdf2/package.json
@@ -0,0 +1,55 @@
+{
+ "name": "pbkdf2",
+ "version": "3.0.9",
+ "description": "This library provides the functionality of PBKDF2 with the ability to use any supported hashing algorithm returned from crypto.getHashes()",
+ "keywords": [
+ "pbkdf2",
+ "kdf",
+ "salt",
+ "hash"
+ ],
+ "homepage": "https://github.com/crypto-browserify/pbkdf2",
+ "bugs": {
+ "url": "https://github.com/crypto-browserify/pbkdf2/issues"
+ },
+ "license": "MIT",
+ "author": "Daniel Cousens",
+ "browser": "browser.js",
+ "files": [
+ "browser.js",
+ "index.js",
+ "node-shim-async.js",
+ "node-shim.js",
+ "precondition.js"
+ ],
+ "main": "index.js",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/crypto-browserify/pbkdf2.git"
+ },
+ "scripts": {
+ "prepublish": "npm run test",
+ "coverage": "nyc --check-coverage --branches 90 --functions 100 tape test/*.js",
+ "lint": "standard",
+ "test": "npm run lint && npm run unit",
+ "bundle-test": "browserify test/index.js > test/bundle.js",
+ "unit": "tape test/*.js"
+ },
+ "devDependencies": {
+ "browserify": "*",
+ "nyc": "^6.4.0",
+ "standard": "*",
+ "tape": "^4.5.1"
+ },
+ "dependencies": {
+ "create-hmac": "^1.1.2"
+ },
+ "standard": {
+ "ignore": [
+ "test/bundle.js"
+ ]
+ },
+ "engines": {
+ "node": ">=0.12"
+ }
+}
diff --git a/node_modules/pbkdf2/precondition.js b/node_modules/pbkdf2/precondition.js
new file mode 100644
index 000000000..1519b0092
--- /dev/null
+++ b/node_modules/pbkdf2/precondition.js
@@ -0,0 +1,18 @@
+var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs
+module.exports = function (iterations, keylen) {
+ if (typeof iterations !== 'number') {
+ throw new TypeError('Iterations not a number')
+ }
+
+ if (iterations < 0) {
+ throw new TypeError('Bad iterations')
+ }
+
+ if (typeof keylen !== 'number') {
+ throw new TypeError('Key length not a number')
+ }
+
+ if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */
+ throw new TypeError('Bad key length')
+ }
+}