From e3993e7bd80dbe16fc11476044f59848a73e33bd Mon Sep 17 00:00:00 2001 From: Alanscut Date: Thu, 10 Oct 2019 10:40:21 +0800 Subject: [PATCH 1/5] Initialize repository based on CryptoJS 3.1.9-1 --- .babelrc | 7 + .eslintignore | 2 + .eslintrc.js | 36 + .gitignore | 6 +- .jshintrc | 33 - .travis.yml | 15 - CONTRIBUTING.md | 28 - Gruntfile.js | 51 - LICENSE | 24 - README.md | 210 - docs/QuickStartGuide.wiki | 470 -- grunt/config/clean.js | 9 - grunt/config/copy.js | 19 - grunt/config/jshint.js | 20 - grunt/config/jsonlint.js | 15 - grunt/config/modularize.js | 227 - grunt/config/update_json.js | 42 - grunt/tasks/modularize.js | 95 - jest.config.js | 188 + package-lock.json | 7478 ++++++++++++++++++++++++++ package.json | 67 +- src/aes.js | 214 - src/cipher-core.js | 1779 +++--- src/core.js | 1529 +++--- src/enc-base64.js | 201 +- src/enc-utf16.js | 129 - src/evpkdf.js | 225 +- src/format-hex.js | 46 - src/hmac.js | 128 +- src/index.js | 80 + src/lib-typedarrays.js | 56 - src/md5.js | 495 +- src/mode-cfb.js | 60 - src/mode-ctr-gladman.js | 96 - src/mode-ctr.js | 38 - src/mode-ecb.js | 20 - src/mode-ofb.js | 34 - src/pad-ansix923.js | 29 - src/pad-iso10126.js | 24 - src/pad-iso97971.js | 20 - src/pad-nopadding.js | 10 - src/pad-zeropadding.js | 27 - src/pbkdf2.js | 125 - src/rabbit-legacy.js | 170 - src/rabbit.js | 172 - src/rc4.js | 119 - src/ripemd160.js | 247 - src/sha1.js | 130 - src/sha224.js | 60 - src/sha256.js | 179 - src/sha3.js | 306 -- src/sha384.js | 63 - src/sha512.js | 306 -- src/tripledes.js | 750 --- src/x64-core.js | 397 +- test/aes-profile.js | 31 - test/aes-test.js | 80 - test/cipher-test.js | 522 -- test/des-profile.js | 31 - test/des-test.js | 104 - test/enc-base64-test.js | 71 - test/enc-hex-test.js | 15 - test/enc-latin1-test.js | 15 - test/enc-utf16-test.js | 55 - test/enc-utf8-test.js | 39 - test/evpkdf-profile.js | 11 - test/evpkdf-test.js | 32 - test/format-openssl-test.js | 37 - test/hmac-md5-profile.js | 30 - test/hmac-md5-test.js | 59 - test/hmac-sha224-test.js | 59 - test/hmac-sha256-test.js | 59 - test/hmac-sha384-test.js | 59 - test/hmac-sha512-test.js | 59 - test/kdf-openssl-test.js | 15 - test/lib-base-test.js | 92 - test/lib-cipherparams-test.js | 59 - test/lib-passwordbasedcipher-test.js | 25 - test/lib-serializablecipher-test.js | 51 - test/lib-typedarrays-test.js | 57 - test/lib-wordarray-test.js | 85 - test/md5-profile.js | 24 - test/md5-test.js | 70 - test/md5.profile.test.js | 27 + test/md5.test.js | 63 + test/mode-cbc-test.js | 49 - test/mode-cfb-test.js | 51 - test/mode-ctr-test.js | 55 - test/mode-ecb-test.js | 38 - test/mode-ofb-test.js | 50 - test/pad-ansix923-test.js | 28 - test/pad-iso10126-test.js | 50 - test/pad-iso97971-test.js | 35 - test/pad-pkcs7-test.js | 28 - test/pad-zeropadding-test.js | 28 - test/pbkdf2-profile.js | 11 - test/pbkdf2-test.js | 80 - test/profile.html | 281 - test/rabbit-legacy-test.js | 80 - test/rabbit-profile.js | 30 - test/rabbit-test.js | 84 - test/rc4-profile.js | 30 - test/rc4-test.js | 68 - test/ripemd160-test.js | 19 - test/sha1-profile.js | 24 - test/sha1-test.js | 70 - test/sha224-test.js | 19 - test/sha256-profile.js | 24 - test/sha256-test.js | 70 - test/sha3-profile.js | 24 - test/sha3-test.js | 69 - test/sha384-test.js | 54 - test/sha512-profile.js | 24 - test/sha512-test.js | 54 - test/test.html | 135 - test/tripledes-profile.js | 31 - test/tripledes-test.js | 88 - test/x64-word-test.js | 99 - test/x64-wordarray-test.js | 38 - 119 files changed, 10197 insertions(+), 10963 deletions(-) create mode 100644 .babelrc create mode 100644 .eslintignore create mode 100644 .eslintrc.js delete mode 100644 .jshintrc delete mode 100644 .travis.yml delete mode 100644 CONTRIBUTING.md delete mode 100644 Gruntfile.js delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 docs/QuickStartGuide.wiki delete mode 100644 grunt/config/clean.js delete mode 100644 grunt/config/copy.js delete mode 100644 grunt/config/jshint.js delete mode 100644 grunt/config/jsonlint.js delete mode 100644 grunt/config/modularize.js delete mode 100644 grunt/config/update_json.js delete mode 100644 grunt/tasks/modularize.js create mode 100644 jest.config.js create mode 100644 package-lock.json delete mode 100644 src/aes.js delete mode 100644 src/enc-utf16.js delete mode 100644 src/format-hex.js create mode 100644 src/index.js delete mode 100644 src/lib-typedarrays.js delete mode 100644 src/mode-cfb.js delete mode 100644 src/mode-ctr-gladman.js delete mode 100644 src/mode-ctr.js delete mode 100644 src/mode-ecb.js delete mode 100644 src/mode-ofb.js delete mode 100644 src/pad-ansix923.js delete mode 100644 src/pad-iso10126.js delete mode 100644 src/pad-iso97971.js delete mode 100644 src/pad-nopadding.js delete mode 100644 src/pad-zeropadding.js delete mode 100644 src/pbkdf2.js delete mode 100644 src/rabbit-legacy.js delete mode 100644 src/rabbit.js delete mode 100644 src/rc4.js delete mode 100644 src/ripemd160.js delete mode 100644 src/sha1.js delete mode 100644 src/sha224.js delete mode 100644 src/sha256.js delete mode 100644 src/sha3.js delete mode 100644 src/sha384.js delete mode 100644 src/sha512.js delete mode 100644 src/tripledes.js delete mode 100644 test/aes-profile.js delete mode 100644 test/aes-test.js delete mode 100644 test/cipher-test.js delete mode 100644 test/des-profile.js delete mode 100644 test/des-test.js delete mode 100644 test/enc-base64-test.js delete mode 100644 test/enc-hex-test.js delete mode 100644 test/enc-latin1-test.js delete mode 100644 test/enc-utf16-test.js delete mode 100644 test/enc-utf8-test.js delete mode 100644 test/evpkdf-profile.js delete mode 100644 test/evpkdf-test.js delete mode 100644 test/format-openssl-test.js delete mode 100644 test/hmac-md5-profile.js delete mode 100644 test/hmac-md5-test.js delete mode 100644 test/hmac-sha224-test.js delete mode 100644 test/hmac-sha256-test.js delete mode 100644 test/hmac-sha384-test.js delete mode 100644 test/hmac-sha512-test.js delete mode 100644 test/kdf-openssl-test.js delete mode 100644 test/lib-base-test.js delete mode 100644 test/lib-cipherparams-test.js delete mode 100644 test/lib-passwordbasedcipher-test.js delete mode 100644 test/lib-serializablecipher-test.js delete mode 100644 test/lib-typedarrays-test.js delete mode 100644 test/lib-wordarray-test.js delete mode 100644 test/md5-profile.js delete mode 100644 test/md5-test.js create mode 100644 test/md5.profile.test.js create mode 100644 test/md5.test.js delete mode 100644 test/mode-cbc-test.js delete mode 100644 test/mode-cfb-test.js delete mode 100644 test/mode-ctr-test.js delete mode 100644 test/mode-ecb-test.js delete mode 100644 test/mode-ofb-test.js delete mode 100644 test/pad-ansix923-test.js delete mode 100644 test/pad-iso10126-test.js delete mode 100644 test/pad-iso97971-test.js delete mode 100644 test/pad-pkcs7-test.js delete mode 100644 test/pad-zeropadding-test.js delete mode 100644 test/pbkdf2-profile.js delete mode 100644 test/pbkdf2-test.js delete mode 100644 test/profile.html delete mode 100644 test/rabbit-legacy-test.js delete mode 100644 test/rabbit-profile.js delete mode 100644 test/rabbit-test.js delete mode 100644 test/rc4-profile.js delete mode 100644 test/rc4-test.js delete mode 100644 test/ripemd160-test.js delete mode 100644 test/sha1-profile.js delete mode 100644 test/sha1-test.js delete mode 100644 test/sha224-test.js delete mode 100644 test/sha256-profile.js delete mode 100644 test/sha256-test.js delete mode 100644 test/sha3-profile.js delete mode 100644 test/sha3-test.js delete mode 100644 test/sha384-test.js delete mode 100644 test/sha512-profile.js delete mode 100644 test/sha512-test.js delete mode 100644 test/test.html delete mode 100644 test/tripledes-profile.js delete mode 100644 test/tripledes-test.js delete mode 100644 test/x64-word-test.js delete mode 100644 test/x64-wordarray-test.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..338f075 --- /dev/null +++ b/.babelrc @@ -0,0 +1,7 @@ +{ + "env": { + "test": { + "plugins": ["@babel/plugin-transform-modules-commonjs"] + } + } +} \ No newline at end of file diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..2d4f994 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +/lib +/build \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..790536b --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,36 @@ +module.exports = { + "env": { + "browser": true, + "es6": true, + "node": true, + "jest": true + }, + "parser": "babel-eslint", + "extends": "eslint:recommended", + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module", + "ecmaFeatures": { + "impliedStrict": true + } + }, + "rules": { + "quotes": ['warn', "single"], + "linebreak-style": [0, "error", "windows"], + "indent": ["error", 2], + "semi": ["error", "always"], + "comma-dangle": ["error", "always"], + "no-cond-assign": ["error", "always"], + "no-console": "off", + "accessor-pairs": "error", + "default-case":"error", + "no-eval": "error", + "no-use-before-define": "warn", + "max-len": "off", + "comma-dangle": ["error", "never"] + } +}; \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3bd5f35..a9a3f50 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ node_modules -build -.svn \ No newline at end of file +/build +/lib +.svn +coverage \ No newline at end of file diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 7672d3a..0000000 --- a/.jshintrc +++ /dev/null @@ -1,33 +0,0 @@ -{ - "bitwise" : false, // Prohibits the use of bitwise operators (not confuse & with &&) - "curly" : true, // Requires to always put curly braces around blocks in loops and conditionals - "eqeqeq" : false, // Prohibits the use of == and != in favor of === and !== - "eqnull" : true, // Suppresses warnings about == null comparisons - "immed" : true, // Requires immediate invocations to be wrapped in parens e.g. `(function () { } ());` - "latedef" : true, // Prohibits the use of a variable before it was defined - "newcap" : false, // Requires to capitalize names of constructor functions - "noarg" : true, // Prohibits the use of arguments.caller and arguments.callee - "strict" : false, // Requires all functions to run in ECMAScript 5's strict mode - "undef" : true, // Require non-global variables to be declared (prevents global leaks) - "asi" : true, // Suppresses warnings about missing semicolons - "funcscope" : false, - "shadow" : true, - "expr" : true, - "-W041" : true, - "-W018" : true, - "globals": { - "CryptoJS" : true, - "escape" : true, - "unescape" : true, - "Int8Array" : true, - "Int16Array" : true, - "Int32Array" : true, - "Uint8Array" : true, - "Uint16Array" : true, - "Uint32Array" : true, - "Uint8ClampedArray" : true, - "ArrayBuffer" : true, - "Float32Array" : true, - "Float64Array" : true - } -} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cca89fb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -dist: trusty -sudo: false - -language: node_js -node_js: - - "6" - - "7" - -before_script: - - npm install -g grunt-cli - - npm install build - -cache: - directories: - - "node_modules" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 09bf774..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,28 +0,0 @@ -# Contribution - -# Git Flow - -The crypto-js project uses [git flow](https://github.com/nvie/gitflow) to manage branches. -Do your changes on the `develop` or even better on a `feature/*` branch. Don't do any changes on the `master` branch. - -# Pull request - -Target your pull request on `develop` branch. Other pull request won't be accepted. - -# How to build - -1. Clone - -2. Run - - ```sh - npm install - ``` - -3. Run - - ```sh - npm run build - ``` - -4. Check `build` folder \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index e083f92..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,51 +0,0 @@ -/*jshint node: true*/ - -'use strict'; - -var path = require('path'); - -module.exports = function (grunt) { - - // Load all grunt tasks from node_modules, and config from /grunt/config - require('load-grunt-config')(grunt, { - configPath: path.join(process.cwd(), 'grunt/config'), - config: { - pkg: grunt.file.readJSON('package.json'), - meta: { - cwd: '', - cwdAll: '**/*', - - source: 'src/', - sourceAll: 'src/**/*', - - build: 'build/', - buildAll: 'build/**/*', - - test: 'test/', - testAll: 'test/**/*', - - npm: 'node_modules/', - npmAll: 'node_modules/**/*' - } - } - }); - - - - // Will load the custom tasks - grunt.loadTasks('./grunt/tasks'); - - grunt.registerTask('build', 'Build a bundle', [ - 'clean:build', - 'modularize:build', - 'copy:build', - 'update_json:npm', - 'update_json:bower' - ]); - - grunt.registerTask('default', 'Run code checker', [ - 'jsonlint', - 'jshint' - ]); - -}; diff --git a/LICENSE b/LICENSE deleted file mode 100644 index b0828e5..0000000 --- a/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -# License - -[The MIT License (MIT)](http://opensource.org/licenses/MIT) - -Copyright (c) 2009-2013 Jeff Mott -Copyright (c) 2013-2016 Evan Vosberg - -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/README.md b/README.md deleted file mode 100644 index bccfad7..0000000 --- a/README.md +++ /dev/null @@ -1,210 +0,0 @@ -# crypto-js [![Build Status](https://travis-ci.org/brix/crypto-js.svg?branch=develop)](https://travis-ci.org/brix/crypto-js) - -JavaScript library of crypto standards. - -## Node.js (Install) - -Requirements: - -- Node.js -- npm (Node.js package manager) - -```bash -npm install crypto-js -``` - -### Usage - -ES6 import for typical API call signing use case: - -```javascript -import sha256 from 'crypto-js/sha256'; -import hmacSHA512 from 'crypto-js/hmac-sha512'; -import Base64 from 'crypto-js/enc-base64'; - -const message, nonce, path, privateKey; // ... -const hashDigest = sha256(nonce + message); -const hmacDigest = Base64.stringify(hmacSHA512(path + hashDigest, privateKey)); -``` - -Modular include: - -```javascript -var AES = require("crypto-js/aes"); -var SHA256 = require("crypto-js/sha256"); -... -console.log(SHA256("Message")); -``` - -Including all libraries, for access to extra methods: - -```javascript -var CryptoJS = require("crypto-js"); -console.log(CryptoJS.HmacSHA1("Message", "Key")); -``` - -## Client (browser) - -Requirements: - -- Node.js -- Bower (package manager for frontend) - -```bash -bower install crypto-js -``` - -### Usage - -Modular include: - -```javascript -require.config({ - packages: [ - { - name: 'crypto-js', - location: 'path-to/bower_components/crypto-js', - main: 'index' - } - ] -}); - -require(["crypto-js/aes", "crypto-js/sha256"], function (AES, SHA256) { - console.log(SHA256("Message")); -}); -``` - -Including all libraries, for access to extra methods: - -```javascript -// Above-mentioned will work or use this simple form -require.config({ - paths: { - 'crypto-js': 'path-to/bower_components/crypto-js/crypto-js' - } -}); - -require(["crypto-js"], function (CryptoJS) { - console.log(CryptoJS.HmacSHA1("Message", "Key")); -}); -``` - -### Usage without RequireJS - -```html - - -``` - -## API - -See: https://cryptojs.gitbook.io/docs/ - -### AES Encryption - -#### Plain text encryption - -```javascript -var CryptoJS = require("crypto-js"); - -// Encrypt -var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123').toString(); - -// Decrypt -var bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123'); -var originalText = bytes.toString(CryptoJS.enc.Utf8); - -console.log(originalText); // 'my message' -``` - -#### Object encryption - -```javascript -var CryptoJS = require("crypto-js"); - -var data = [{id: 1}, {id: 2}] - -// Encrypt -var ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123').toString(); - -// Decrypt -var bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123'); -var decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8)); - -console.log(decryptedData); // [{id: 1}, {id: 2}] -``` - -### List of modules - - -- ```crypto-js/core``` -- ```crypto-js/x64-core``` -- ```crypto-js/lib-typedarrays``` - ---- - -- ```crypto-js/md5``` -- ```crypto-js/sha1``` -- ```crypto-js/sha256``` -- ```crypto-js/sha224``` -- ```crypto-js/sha512``` -- ```crypto-js/sha384``` -- ```crypto-js/sha3``` -- ```crypto-js/ripemd160``` - ---- - -- ```crypto-js/hmac-md5``` -- ```crypto-js/hmac-sha1``` -- ```crypto-js/hmac-sha256``` -- ```crypto-js/hmac-sha224``` -- ```crypto-js/hmac-sha512``` -- ```crypto-js/hmac-sha384``` -- ```crypto-js/hmac-sha3``` -- ```crypto-js/hmac-ripemd160``` - ---- - -- ```crypto-js/pbkdf2``` - ---- - -- ```crypto-js/aes``` -- ```crypto-js/tripledes``` -- ```crypto-js/rc4``` -- ```crypto-js/rabbit``` -- ```crypto-js/rabbit-legacy``` -- ```crypto-js/evpkdf``` - ---- - -- ```crypto-js/format-openssl``` -- ```crypto-js/format-hex``` - ---- - -- ```crypto-js/enc-latin1``` -- ```crypto-js/enc-utf8``` -- ```crypto-js/enc-hex``` -- ```crypto-js/enc-utf16``` -- ```crypto-js/enc-base64``` - ---- - -- ```crypto-js/mode-cfb``` -- ```crypto-js/mode-ctr``` -- ```crypto-js/mode-ctr-gladman``` -- ```crypto-js/mode-ofb``` -- ```crypto-js/mode-ecb``` - ---- - -- ```crypto-js/pad-pkcs7``` -- ```crypto-js/pad-ansix923``` -- ```crypto-js/pad-iso10126``` -- ```crypto-js/pad-iso97971``` -- ```crypto-js/pad-zeropadding``` -- ```crypto-js/pad-nopadding``` diff --git a/docs/QuickStartGuide.wiki b/docs/QuickStartGuide.wiki deleted file mode 100644 index 6b20199..0000000 --- a/docs/QuickStartGuide.wiki +++ /dev/null @@ -1,470 +0,0 @@ - - ----- - -= Quick-start Guide = - -== Hashers == - -=== The Hasher Algorithms === - -==== MD5 ==== - -MD5 is a widely used hash function. It's been used in a variety of security applications and is also commonly used to check the integrity of files. Though, MD5 is not collision resistant, and it isn't suitable for applications like SSL certificates or digital signatures that rely on this property. - -{{{ - - -}}} - -==== SHA-1 ==== - -The SHA hash functions were designed by the National Security Agency (NSA). SHA-1 is the most established of the existing SHA hash functions, and it's used in a variety of security applications and protocols. Though, SHA-1's collision resistance has been weakening as new attacks are discovered or improved. - -{{{ - - -}}} - -==== SHA-2 ==== - -SHA-256 is one of the four variants in the SHA-2 set. It isn't as widely used as SHA-1, though it appears to provide much better security. - -{{{ - - -}}} - -SHA-512 is largely identical to SHA-256 but operates on 64-bit words rather than 32. - -{{{ - - -}}} - -CryptoJS also supports SHA-224 and SHA-384, which are largely identical but truncated versions of SHA-256 and SHA-512 respectively. - -==== SHA-3 ==== - -SHA-3 is the winner of a five-year competition to select a new cryptographic hash algorithm where 64 competing designs were evaluated. - -{{{ - - -}}} - -SHA-3 can be configured to output hash lengths of one of 224, 256, 384, or 512 bits. The default is 512 bits. - -{{{ - - -}}} - -==== RIPEMD-160 ==== - -{{{ - - -}}} - -=== The Hasher Input === - -The hash algorithms accept either strings or instances of CryptoJS.lib.WordArray. A WordArray object represents an array of 32-bit words. When you pass a string, it's automatically converted to a WordArray encoded as UTF-8. - -=== The Hasher Output === - -The hash you get back isn't a string yet. It's a WordArray object. When you use a WordArray object in a string context, it's automatically converted to a hex string. - -{{{ - - -}}} - -You can convert a WordArray object to other formats by explicitly calling the toString method and passing an encoder. - -{{{ - - - -}}} - -=== Progressive Hashing === - -{{{ - - -}}} - -== HMAC == - -Keyed-hash message authentication codes (HMAC) is a mechanism for message authentication using cryptographic hash functions. - -HMAC can be used in combination with any iterated cryptographic hash function. - -{{{ - - - - - -}}} - -=== Progressive HMAC Hashing === - -{{{ - - -}}} - -== PBKDF2 == - -PBKDF2 is a password-based key derivation function. In many applications of cryptography, user security is ultimately dependent on a password, and because a password usually can't be used directly as a cryptographic key, some processing is required. - -A salt provides a large set of keys for any given password, and an iteration count increases the cost of producing keys from a password, thereby also increasing the difficulty of attack. - -{{{ - - -}}} - -== Ciphers == - -=== The Cipher Algorithms === - -==== AES ==== - -The Advanced Encryption Standard (AES) is a U.S. Federal Information Processing Standard (FIPS). It was selected after a 5-year process where 15 competing designs were evaluated. - -{{{ - - -}}} - -CryptoJS supports AES-128, AES-192, and AES-256. It will pick the variant by the size of the key you pass in. If you use a passphrase, then it will generate a 256-bit key. - -==== DES, Triple DES ==== - -DES is a previously dominant algorithm for encryption, and was published as an official Federal Information Processing Standard (FIPS). DES is now considered to be insecure due to the small key size. - -{{{ - - -}}} - -Triple DES applies DES three times to each block to increase the key size. The algorithm is believed to be secure in this form. - -{{{ - - -}}} - -==== Rabbit ==== - -Rabbit is a high-performance stream cipher and a finalist in the eSTREAM Portfolio. It is one of the four designs selected after a 3 1/2-year process where 22 designs were evaluated. - -{{{ - - -}}} - -==== RC4, RC4Drop ==== - -RC4 is a widely-used stream cipher. It's used in popular protocols such as SSL and WEP. Although remarkable for its simplicity and speed, the algorithm's history doesn't inspire confidence in its security. - -{{{ - - -}}} - -It was discovered that the first few bytes of keystream are strongly non-random and leak information about the key. We can defend against this attack by discarding the initial portion of the keystream. This modified algorithm is traditionally called RC4-drop. - -By default, 192 words (768 bytes) are dropped, but you can configure the algorithm to drop any number of words. - -{{{ - - -}}} - -=== Custom Key and IV === - -{{{ - - -}}} - -=== Block Modes and Padding === - -{{{ - - - - -}}} - -CryptoJS supports the following modes: - - * CBC (the default) - * CFB - * CTR - * OFB - * ECB - -And CryptoJS supports the following padding schemes: - - * Pkcs7 (the default) - * Iso97971 - * AnsiX923 - * Iso10126 - * ZeroPadding - * NoPadding - -=== The Cipher Input === - -For the plaintext message, the cipher algorithms accept either strings or instances of CryptoJS.lib.WordArray. - -For the key, when you pass a string, it's treated as a passphrase and used to derive an actual key and IV. Or you can pass a WordArray that represents the actual key. If you pass the actual key, you must also pass the actual IV. - -For the ciphertext, the cipher algorithms accept either strings or instances of CryptoJS.lib.CipherParams. A CipherParams object represents a collection of parameters such as the IV, a salt, and the raw ciphertext itself. When you pass a string, it's automatically converted to a CipherParams object according to a configurable format strategy. - -=== The Cipher Output === - -The plaintext you get back after decryption is a WordArray object. See Hashers' Output for more detail. - -The ciphertext you get back after encryption isn't a string yet. It's a CipherParams object. A CipherParams object gives you access to all the parameters used during encryption. When you use a CipherParams object in a string context, it's automatically converted to a string according to a format strategy. The default is an OpenSSL-compatible format. - -{{{ - - -}}} - -You can define your own formats in order to be compatible with other crypto implementations. A format is an object with two methods—stringify and parse—that converts between CipherParams objects and ciphertext strings. - -Here's how you might write a JSON formatter: - -{{{ - - -}}} - -=== Progressive Ciphering === - -{{{ - - -}}} - -=== Interoperability === - -==== With OpenSSL ==== - -Encrypt with OpenSSL: - -{{{ -openssl enc -aes-256-cbc -in infile -out outfile -pass pass:"Secret Passphrase" -e -base64 -}}} - -Decrypt with CryptoJS: - -{{{ - - -}}} - -== Encoders == - -CryptoJS can convert from encoding formats such as Base64, Latin1 or Hex to WordArray objects and vica versa. - -{{{ - - - - -}}} \ No newline at end of file diff --git a/grunt/config/clean.js b/grunt/config/clean.js deleted file mode 100644 index 6c83318..0000000 --- a/grunt/config/clean.js +++ /dev/null @@ -1,9 +0,0 @@ -/*jshint node: true*/ - -'use strict'; - -module.exports = { - build: [ - '<%= meta.build %>' - ] -}; diff --git a/grunt/config/copy.js b/grunt/config/copy.js deleted file mode 100644 index 2aa74e2..0000000 --- a/grunt/config/copy.js +++ /dev/null @@ -1,19 +0,0 @@ -/*jshint node: true*/ - -'use strict'; - -module.exports = { - build: { - files: [{ - expand: false, - cwd: '<%= meta.cwd %>', - src: [ - 'README.md', - 'CONTRIBUTING.md', - 'LICENSE', - 'docs/**/*' - ], - dest: '<%= meta.build %>' - }] - } -}; diff --git a/grunt/config/jshint.js b/grunt/config/jshint.js deleted file mode 100644 index 1c3cb23..0000000 --- a/grunt/config/jshint.js +++ /dev/null @@ -1,20 +0,0 @@ -/*jshint node: true*/ - -'use strict'; - -module.exports = { - dev: { - options: { - jshintrc: process.cwd() + '/.jshintrc', - reporterOutput: '' - }, - files: { - src: [ - '<%= meta.cwdAll %>.js', - '!<%= meta.buildAll %>', - '!<%= meta.testAll %>', - '!<%= meta.npmAll %>' - ] - } - } -}; diff --git a/grunt/config/jsonlint.js b/grunt/config/jsonlint.js deleted file mode 100644 index f5405c1..0000000 --- a/grunt/config/jsonlint.js +++ /dev/null @@ -1,15 +0,0 @@ -/*jshint node: true*/ - -'use strict'; - -module.exports = { - all: { - files: { - src: [ - '<%= meta.cwdAll %>.json', - '!<%= meta.buildAll %>', - '!<%= meta.npmAll %>' - ] - } - } -}; diff --git a/grunt/config/modularize.js b/grunt/config/modularize.js deleted file mode 100644 index 2b4f2cc..0000000 --- a/grunt/config/modularize.js +++ /dev/null @@ -1,227 +0,0 @@ -/*jshint node: true*/ - -module.exports = { - build: { - files: [{ - expand: false, - cwd: '<%= meta.cwd %>', - src: ['<%= meta.source %>'], - dest: '<%= meta.build %>' - }], - options: { - // all - "index": { - "global": "CryptoJS", - "exports": "CryptoJS", - "components": ["core", "x64-core", "lib-typedarrays", "enc-utf16", "enc-base64", "md5", "sha1", "sha256", "sha224", "sha512", "sha384", "sha3", "ripemd160", "hmac", "pbkdf2", "evpkdf", "cipher-core", "mode-cfb", "mode-ctr", "mode-ctr-gladman", "mode-ofb", "mode-ecb", "pad-ansix923", "pad-iso10126", "pad-iso97971", "pad-zeropadding", "pad-nopadding", "format-hex", "aes", "tripledes", "rc4", "rabbit", "rabbit-legacy"] - }, - "crypto-js": { - "pack": true, - "global": "CryptoJS", - "exports": "CryptoJS", - "components": ["core", "x64-core", "lib-typedarrays", "enc-utf16", "enc-base64", "md5", "sha1", "sha256", "sha224", "sha512", "sha384", "sha3", "ripemd160", "hmac", "pbkdf2", "evpkdf", "cipher-core", "mode-cfb", "mode-ctr", "mode-ctr-gladman", "mode-ofb", "mode-ecb", "pad-ansix923", "pad-iso10126", "pad-iso97971", "pad-zeropadding", "pad-nopadding", "format-hex", "aes", "tripledes", "rc4", "rabbit", "rabbit-legacy"] - }, - - // hash - "md5": { - "exports": "CryptoJS.MD5", - "components": ["core", "md5"] - }, - "sha1": { - "exports": "CryptoJS.SHA1", - "components": ["core", "sha1"] - }, - "sha256": { - "exports": "CryptoJS.SHA256", - "components": ["core", "sha256"] - }, - "sha224": { - "exports": "CryptoJS.SHA224", - "components": ["core", "sha256", "sha224"] - }, - "sha512": { - "exports": "CryptoJS.SHA512", - "components": ["core", "x64-core", "sha512"] - }, - "sha384": { - "exports": "CryptoJS.SHA384", - "components": ["core", "x64-core", "sha512", "sha384"] - }, - "sha3": { - "exports": "CryptoJS.SHA3", - "components": ["core", "x64-core", "sha3"] - }, - "ripemd160": { - "exports": "CryptoJS.RIPEMD160", - "components": ["core", "ripemd160"] - }, - - // hmac hash - "hmac-md5": { - "exports": "CryptoJS.HmacMD5", - "components": ["core", "md5", "hmac"] - }, - "hmac-sha1": { - "exports": "CryptoJS.HmacSHA1", - "components": ["core", "sha1", "hmac"] - }, - "hmac-sha256": { - "exports": "CryptoJS.HmacSHA256", - "components": ["core", "sha256", "hmac"] - }, - "hmac-sha224": { - "exports": "CryptoJS.HmacSHA224", - "components": ["core", "sha256", "sha224", "hmac"] - }, - "hmac-sha512": { - "exports": "CryptoJS.HmacSHA512", - "components": ["core", "x64-core", "sha512", "hmac"] - }, - "hmac-sha384": { - "exports": "CryptoJS.HmacSHA384", - "components": ["core", "x64-core", "sha512", "sha384", "hmac"] - }, - "hmac-sha3": { - "exports": "CryptoJS.HmacSHA3", - "components": ["core", "x64-core", "sha3", "hmac"] - }, - "hmac-ripemd160": { - "exports": "CryptoJS.HmacRIPEMD160", - "components": ["core", "ripemd160", "hmac"] - }, - "pbkdf2": { - "exports": "CryptoJS.PBKDF2", - "components": ["core", "sha1", "hmac", "pbkdf2"] - }, - "evpkdf": { - "exports": "CryptoJS.EvpKDF", - "components": ["core", "sha1", "hmac", "evpkdf"] - }, - - // cipher - "aes": { - "exports": "CryptoJS.AES", - "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "aes"] - }, - "tripledes": { - "exports": "CryptoJS.TripleDES", - "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "tripledes"] - }, - "rc4": { - "exports": "CryptoJS.RC4", - "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "rc4"] - }, - "rabbit": { - "exports": "CryptoJS.Rabbit", - "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "rabbit"] - }, - "rabbit-legacy": { - "exports": "CryptoJS.RabbitLegacy", - "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "rabbit-legacy"] - }, - - // core - "core": { - "exports": "CryptoJS", - "components": ["core"], - "global": "CryptoJS" - }, - "x64-core": { - "exports": "CryptoJS", - "components": ["core", "x64-core"] - }, - "hmac": { - "components": ["core", "hmac"] - }, - "cipher-core": { - "components": ["core", "evpkdf", "cipher-core"] - }, - - // lib - "lib-typedarrays": { - "exports": "CryptoJS.lib.WordArray", - "components": ["core", "lib-typedarrays"] - }, - - // format - "format-openssl": { - "exports": "CryptoJS.format.OpenSSL", - "components": ["core", "cipher-core"] - }, - "format-hex": { - "exports": "CryptoJS.format.Hex", - "components": ["core", "cipher-core", "format-hex"] - }, - - // enc - "enc-latin1": { - "exports": "CryptoJS.enc.Latin1", - "components": ["core"] - }, - "enc-utf8": { - "exports": "CryptoJS.enc.Utf8", - "components": ["core"] - }, - "enc-hex": { - "exports": "CryptoJS.enc.Hex", - "components": ["core"] - }, - "enc-utf16": { - "exports": "CryptoJS.enc.Utf16", - "components": ["core", "enc-utf16"] - }, - "enc-base64": { - "exports": "CryptoJS.enc.Base64", - "components": ["core", "enc-base64"] - }, - - // mode - "mode-cfb": { - "exports": "CryptoJS.mode.CFB", - "components": ["core", "cipher-core", "mode-cfb"] - }, - "mode-ctr": { - "exports": "CryptoJS.mode.CTR", - "components": ["core", "cipher-core", "mode-ctr"] - }, - "mode-ctr-gladman": { - "exports": "CryptoJS.mode.CTRGladman", - "components": ["core", "cipher-core", "mode-ctr-gladman"] - }, - "mode-ofb": { - "exports": "CryptoJS.mode.OFB", - "components": ["core", "cipher-core", "mode-ofb"] - }, - "mode-ecb": { - "exports": "CryptoJS.mode.ECB", - "components": ["core", "cipher-core", "mode-ecb"] - }, - - // pad - "pad-pkcs7": { - "exports": "CryptoJS.pad.Pkcs7", - "components": ["core", "cipher-core", "pad-pkcs7"] - }, - "pad-ansix923": { - "exports": "CryptoJS.pad.Ansix923", - "components": ["core", "cipher-core", "pad-ansix923"] - }, - "pad-iso10126": { - "exports": "CryptoJS.pad.Iso10126", - "components": ["core", "cipher-core", "pad-iso10126"] - }, - "pad-iso97971": { - "exports": "CryptoJS.pad.Iso97971", - "components": ["core", "cipher-core", "pad-iso97971"] - }, - "pad-zeropadding": { - "exports": "CryptoJS.pad.ZeroPadding", - "components": ["core", "cipher-core", "pad-zeropadding"] - }, - "pad-nopadding": { - "exports": "CryptoJS.pad.NoPadding", - "components": ["core", "cipher-core", "pad-nopadding"] - } - } - } -}; diff --git a/grunt/config/update_json.js b/grunt/config/update_json.js deleted file mode 100644 index 46a5656..0000000 --- a/grunt/config/update_json.js +++ /dev/null @@ -1,42 +0,0 @@ -/*jshint node: true*/ - -'use strict'; - -module.exports = { - options: { - indent: ' ' - }, - npm: { - src: '<%= meta.cwd %>package.json', - dest: '<%= meta.build %>package.json', - fields: { - 'name': null, - 'version': null, - 'description': null, - 'license': null, - 'author': null, - 'homepage': null, - 'repository': null, - 'keywords': null, - 'main': null, - 'dependencies': null - } - }, - bower: { - src: '<%= meta.cwd %>package.json', - dest: '<%= meta.build %>bower.json', - fields: { - 'name': null, - 'version': null, - 'description': null, - 'license': null, - 'author': 'authors', - 'homepage': null, - 'repository': null, - 'keywords': null, - 'main': null, - 'dependencies': null, - 'ignore': [] - } - } -}; diff --git a/grunt/tasks/modularize.js b/grunt/tasks/modularize.js deleted file mode 100644 index f97d57b..0000000 --- a/grunt/tasks/modularize.js +++ /dev/null @@ -1,95 +0,0 @@ -/*jshint node: true*/ - -var _ = require("lodash"), - - fmd = require("fmd"); - -module.exports = function (grunt) { - - grunt.registerMultiTask('modularize', function () { - var options = this.options(), - - done = this.async(), - - modules = {}, - - config = { - target: this.target + '/', - factories: ["commonjs", "amd", "global"], - trim_whitespace: true, - new_line: "unix", - indent: "\t" - }; - - // Prepare Factory-Module-Definition settings - _.each(options, function (conf, name) { - var sources = [], - - opts = { - depends: {} - }, - - deps = []; - - if (conf.exports) { - opts.exports = conf.exports; - } - - if (conf.global) { - opts.global = conf.global; - } - - // Find and add self as source - _.each(this.filesSrc, function (source) { - if (grunt.file.exists(source + name + ".js")) { - sources.push(source + name + ".js"); - } - }, this); - - if (conf.pack) { - // Collect all components - deps = _.chain(conf.components) - .map(function (depName) { - return options[depName].components; - }) - .flatten() - .uniq() - .without(name) - .sort(function (a, b) { - return options[a].components.indexOf(b) === -1 ? -1 : 1; - }) - .value(); - - // Add components as source files -> results a single file - _.each(this.filesSrc, function (source) { - _.each(deps, function (depName) { - if (grunt.file.exists(source + depName + ".js")) { - sources.push(source + depName + ".js"); - } - }); - }, this); - } else { - // Read components and add them as dependecies - _.each(_.without(conf.components, name), function (value, i) { - opts.depends['./' + value] = value === "core" ? "CryptoJS" : null; - }); - } - - // Remove duplicates - sources = _.uniq(sources); - - // Add module settings to fmd definition - modules[name] = [sources, opts]; - }, this); - - // Build packege modules - fmd(config) - .define(modules) - .build(function (createdFiles) { - - done(); - }); - - }); - -}; diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..4dd9141 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,188 @@ +// For a detailed explanation regarding each configuration property, visit: +// https://jestjs.io/docs/en/configuration.html + +module.exports = { + // All imported modules in your tests should be mocked automatically + // automock: false, + + // Stop running tests after `n` failures + // bail: 0, + + // Respect "browser" field in package.json when resolving modules + // browser: false, + + // The directory where Jest should store its cached dependency information + // cacheDirectory: "C:\\Users\\Administrator\\AppData\\Local\\Temp\\3\\jest", + + // Automatically clear mock calls and instances between every test + clearMocks: true, + + // Indicates whether the coverage information should be collected while executing the test + // collectCoverage: false, + + // An array of glob patterns indicating a set of files for which coverage information should be collected + // collectCoverageFrom: null, + + // The directory where Jest should output its coverage files + coverageDirectory: "coverage", + + // An array of regexp pattern strings used to skip coverage collection + // coveragePathIgnorePatterns: [ + // "\\\\node_modules\\\\" + // ], + + // A list of reporter names that Jest uses when writing coverage reports + // coverageReporters: [ + // "json", + // "text", + // "lcov", + // "clover" + // ], + + // An object that configures minimum threshold enforcement for coverage results + // coverageThreshold: null, + + // A path to a custom dependency extractor + // dependencyExtractor: null, + + // Make calling deprecated APIs throw helpful error messages + // errorOnDeprecated: false, + + // Force coverage collection from ignored files using an array of glob patterns + // forceCoverageMatch: [], + + // A path to a module which exports an async function that is triggered once before all test suites + // globalSetup: null, + + // A path to a module which exports an async function that is triggered once after all test suites + // globalTeardown: null, + + // A set of global variables that need to be available in all test environments + // globals: {}, + + // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. + // maxWorkers: "50%", + + // An array of directory names to be searched recursively up from the requiring module's location + // moduleDirectories: [ + // "node_modules" + // ], + + // An array of file extensions your modules use + // moduleFileExtensions: [ + // "js", + // "json", + // "jsx", + // "ts", + // "tsx", + // "node" + // ], + + // A map from regular expressions to module names that allow to stub out resources with a single module + // moduleNameMapper: {}, + + // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader + // modulePathIgnorePatterns: [], + + // Activates notifications for test results + // notify: false, + + // An enum that specifies notification mode. Requires { notify: true } + // notifyMode: "failure-change", + + // A preset that is used as a base for Jest's configuration + // preset: null, + + // Run tests from one or more projects + // projects: null, + + // Use this configuration option to add custom reporters to Jest + // reporters: undefined, + + // Automatically reset mock state between every test + // resetMocks: false, + + // Reset the module registry before running each individual test + // resetModules: false, + + // A path to a custom resolver + // resolver: null, + + // Automatically restore mock state between every test + // restoreMocks: false, + + // The root directory that Jest should scan for tests and modules within + // rootDir: null, + + // A list of paths to directories that Jest should use to search for files in + // roots: [ + // "" + // ], + + // Allows you to use a custom runner instead of Jest's default test runner + // runner: "jest-runner", + + // The paths to modules that run some code to configure or set up the testing environment before each test + // setupFiles: [], + + // A list of paths to modules that run some code to configure or set up the testing framework before each test + // setupFilesAfterEnv: [], + + // A list of paths to snapshot serializer modules Jest should use for snapshot testing + // snapshotSerializers: [], + + // The test environment that will be used for testing + testEnvironment: "node", + + // Options that will be passed to the testEnvironment + // testEnvironmentOptions: {}, + + // Adds a location field to test results + // testLocationInResults: false, + + // The glob patterns Jest uses to detect test files + // testMatch: [ + // "**/__tests__/**/*.[jt]s?(x)", + // "**/?(*.)+(spec|test).[tj]s?(x)" + // ], + + // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped + // testPathIgnorePatterns: [ + // "\\\\node_modules\\\\" + // ], + + // The regexp pattern or array of patterns that Jest uses to detect test files + // testRegex: [], + + // This option allows the use of a custom results processor + // testResultsProcessor: null, + + // This option allows use of a custom test runner + // testRunner: "jasmine2", + + // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href + // testURL: "http://localhost", + + // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" + // timers: "real", + + // A map from regular expressions to paths to transformers + // transform: null, + + // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation + // transformIgnorePatterns: [ + // "\\\\node_modules\\\\" + // ], + + // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them + // unmockedModulePathPatterns: undefined, + + // Indicates whether each individual test should be reported during the run + // verbose: null, + + // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode + // watchPathIgnorePatterns: [], + + // Whether to use watchman for file crawling + // watchman: true, +}; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..c2710b1 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,7478 @@ +{ + "name": "crypto-js", + "version": "3.1.9", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/code-frame": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/core": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.6.3.tgz", + "integrity": "sha512-QfQ5jTBgXLzJuo7Mo8bZK/ePywmgNRgk/UQykiKwEtZPiFIn8ZqE6jB+AnD1hbB1S2xQyL4//it5vuAUOVAMTw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.6.3", + "@babel/helpers": "^7.6.2", + "@babel/parser": "^7.6.3", + "@babel/template": "^7.6.0", + "@babel/traverse": "^7.6.3", + "@babel/types": "^7.6.3", + "convert-source-map": "^1.1.0", + "debug": "^4.1.0", + "json5": "^2.1.0", + "lodash": "^4.17.13", + "resolve": "^1.3.2", + "semver": "^5.4.1", + "source-map": "^0.6.1" + } + }, + "@babel/generator": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.6.3.tgz", + "integrity": "sha512-hLhYbAb3pHwxjlijC4AQ7mqZdcoujiNaW7izCT04CIowHK8psN0IN8QjDv0iyFtycF5FowUOTwDloIheI25aMw==", + "dev": true, + "requires": { + "@babel/types": "^7.6.3", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.6.1" + } + }, + "@babel/helper-annotate-as-pure": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz", + "integrity": "sha512-3UYcJUj9kvSLbLbUIfQTqzcy5VX7GRZ/CCDrnOaZorFFM01aXp1+GJwuFGV4NDDoAS+mOUyHcO6UD/RfqOks3Q==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-builder-binary-assignment-operator-visitor": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.1.0.tgz", + "integrity": "sha512-qNSR4jrmJ8M1VMM9tibvyRAHXQs2PmaksQF7c1CGJNipfe3D8p+wgNwgso/P2A2r2mdgBWAXljNWR0QRZAMW8w==", + "dev": true, + "requires": { + "@babel/helper-explode-assignable-expression": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-call-delegate": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-call-delegate/-/helper-call-delegate-7.4.4.tgz", + "integrity": "sha512-l79boDFJ8S1c5hvQvG+rc+wHw6IuH7YldmRKsYtpbawsxURu/paVy57FZMomGK22/JckepaikOkY0MoAmdyOlQ==", + "dev": true, + "requires": { + "@babel/helper-hoist-variables": "^7.4.4", + "@babel/traverse": "^7.4.4", + "@babel/types": "^7.4.4" + } + }, + "@babel/helper-define-map": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/helper-define-map/-/helper-define-map-7.5.5.tgz", + "integrity": "sha512-fTfxx7i0B5NJqvUOBBGREnrqbTxRh7zinBANpZXAVDlsZxYdclDp467G1sQ8VZYMnAURY3RpBUAgOYT9GfzHBg==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.1.0", + "@babel/types": "^7.5.5", + "lodash": "^4.17.13" + } + }, + "@babel/helper-explode-assignable-expression": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.1.0.tgz", + "integrity": "sha512-NRQpfHrJ1msCHtKjbzs9YcMmJZOg6mQMmGRB+hbamEdG5PNpaSm95275VD92DvJKuyl0s2sFiDmMZ+EnnvufqA==", + "dev": true, + "requires": { + "@babel/traverse": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-function-name": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz", + "integrity": "sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.0.0", + "@babel/template": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz", + "integrity": "sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-hoist-variables": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.4.4.tgz", + "integrity": "sha512-VYk2/H/BnYbZDDg39hr3t2kKyifAm1W6zHRfhx8jGjIHpQEBv9dry7oQ2f3+J703TLu69nYdxsovl0XYfcnK4w==", + "dev": true, + "requires": { + "@babel/types": "^7.4.4" + } + }, + "@babel/helper-member-expression-to-functions": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.5.5.tgz", + "integrity": "sha512-5qZ3D1uMclSNqYcXqiHoA0meVdv+xUEex9em2fqMnrk/scphGlGgg66zjMrPJESPwrFJ6sbfFQYUSa0Mz7FabA==", + "dev": true, + "requires": { + "@babel/types": "^7.5.5" + } + }, + "@babel/helper-module-imports": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.0.0.tgz", + "integrity": "sha512-aP/hlLq01DWNEiDg4Jn23i+CXxW/owM4WpDLFUbpjxe4NS3BhLVZQ5i7E0ZrxuQ/vwekIeciyamgB1UIYxxM6A==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-module-transforms": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.5.5.tgz", + "integrity": "sha512-jBeCvETKuJqeiaCdyaheF40aXnnU1+wkSiUs/IQg3tB85up1LyL8x77ClY8qJpuRJUcXQo+ZtdNESmZl4j56Pw==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.0.0", + "@babel/helper-simple-access": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/template": "^7.4.4", + "@babel/types": "^7.5.5", + "lodash": "^4.17.13" + } + }, + "@babel/helper-optimise-call-expression": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.0.0.tgz", + "integrity": "sha512-u8nd9NQePYNQV8iPWu/pLLYBqZBa4ZaY1YWRFMuxrid94wKI1QNt67NEZ7GAe5Kc/0LLScbim05xZFWkAdrj9g==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-plugin-utils": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz", + "integrity": "sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==", + "dev": true + }, + "@babel/helper-regex": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/helper-regex/-/helper-regex-7.5.5.tgz", + "integrity": "sha512-CkCYQLkfkiugbRDO8eZn6lRuR8kzZoGXCg3149iTk5se7g6qykSpy3+hELSwquhu+TgHn8nkLiBwHvNX8Hofcw==", + "dev": true, + "requires": { + "lodash": "^4.17.13" + } + }, + "@babel/helper-remap-async-to-generator": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.1.0.tgz", + "integrity": "sha512-3fOK0L+Fdlg8S5al8u/hWE6vhufGSn0bN09xm2LXMy//REAF8kDCrYoOBKYmA8m5Nom+sV9LyLCwrFynA8/slg==", + "dev": true, + "requires": { + "@babel/helper-annotate-as-pure": "^7.0.0", + "@babel/helper-wrap-function": "^7.1.0", + "@babel/template": "^7.1.0", + "@babel/traverse": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-replace-supers": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.5.5.tgz", + "integrity": "sha512-XvRFWrNnlsow2u7jXDuH4jDDctkxbS7gXssrP4q2nUD606ukXHRvydj346wmNg+zAgpFx4MWf4+usfC93bElJg==", + "dev": true, + "requires": { + "@babel/helper-member-expression-to-functions": "^7.5.5", + "@babel/helper-optimise-call-expression": "^7.0.0", + "@babel/traverse": "^7.5.5", + "@babel/types": "^7.5.5" + } + }, + "@babel/helper-simple-access": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.1.0.tgz", + "integrity": "sha512-Vk+78hNjRbsiu49zAPALxTb+JUQCz1aolpd8osOF16BGnLtseD21nbHgLPGUwrXEurZgiCOUmvs3ExTu4F5x6w==", + "dev": true, + "requires": { + "@babel/template": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", + "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", + "dev": true, + "requires": { + "@babel/types": "^7.4.4" + } + }, + "@babel/helper-wrap-function": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.2.0.tgz", + "integrity": "sha512-o9fP1BZLLSrYlxYEYyl2aS+Flun5gtjTIG8iln+XuEzQTs0PLagAGSXUcqruJwD5fM48jzIEggCKpIfWTcR7pQ==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.1.0", + "@babel/template": "^7.1.0", + "@babel/traverse": "^7.1.0", + "@babel/types": "^7.2.0" + } + }, + "@babel/helpers": { + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.6.2.tgz", + "integrity": "sha512-3/bAUL8zZxYs1cdX2ilEE0WobqbCmKWr/889lf2SS0PpDcpEIY8pb1CCyz0pEcX3pEb+MCbks1jIokz2xLtGTA==", + "dev": true, + "requires": { + "@babel/template": "^7.6.0", + "@babel/traverse": "^7.6.2", + "@babel/types": "^7.6.0" + } + }, + "@babel/highlight": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@babel/parser": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.6.3.tgz", + "integrity": "sha512-sUZdXlva1dt2Vw2RqbMkmfoImubO0D0gaCrNngV6Hi0DA4x3o4mlrq0tbfY0dZEUIccH8I6wQ4qgEtwcpOR6Qg==", + "dev": true + }, + "@babel/plugin-proposal-async-generator-functions": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.2.0.tgz", + "integrity": "sha512-+Dfo/SCQqrwx48ptLVGLdE39YtWRuKc/Y9I5Fy0P1DDBB9lsAHpjcEJQt+4IifuSOSTLBKJObJqMvaO1pIE8LQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-remap-async-to-generator": "^7.1.0", + "@babel/plugin-syntax-async-generators": "^7.2.0" + } + }, + "@babel/plugin-proposal-dynamic-import": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.5.0.tgz", + "integrity": "sha512-x/iMjggsKTFHYC6g11PL7Qy58IK8H5zqfm9e6hu4z1iH2IRyAp9u9dL80zA6R76yFovETFLKz2VJIC2iIPBuFw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-dynamic-import": "^7.2.0" + } + }, + "@babel/plugin-proposal-json-strings": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.2.0.tgz", + "integrity": "sha512-MAFV1CA/YVmYwZG0fBQyXhmj0BHCB5egZHCKWIFVv/XCxAeVGIHfos3SwDck4LvCllENIAg7xMKOG5kH0dzyUg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-json-strings": "^7.2.0" + } + }, + "@babel/plugin-proposal-object-rest-spread": { + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.6.2.tgz", + "integrity": "sha512-LDBXlmADCsMZV1Y9OQwMc0MyGZ8Ta/zlD9N67BfQT8uYwkRswiu2hU6nJKrjrt/58aH/vqfQlR/9yId/7A2gWw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-object-rest-spread": "^7.2.0" + } + }, + "@babel/plugin-proposal-optional-catch-binding": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.2.0.tgz", + "integrity": "sha512-mgYj3jCcxug6KUcX4OBoOJz3CMrwRfQELPQ5560F70YQUBZB7uac9fqaWamKR1iWUzGiK2t0ygzjTScZnVz75g==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-optional-catch-binding": "^7.2.0" + } + }, + "@babel/plugin-proposal-unicode-property-regex": { + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.6.2.tgz", + "integrity": "sha512-NxHETdmpeSCtiatMRYWVJo7266rrvAC3DTeG5exQBIH/fMIUK7ejDNznBbn3HQl/o9peymRRg7Yqkx6PdUXmMw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-regex": "^7.4.4", + "regexpu-core": "^4.6.0" + } + }, + "@babel/plugin-syntax-async-generators": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.2.0.tgz", + "integrity": "sha512-1ZrIRBv2t0GSlcwVoQ6VgSLpLgiN/FVQUzt9znxo7v2Ov4jJrs8RY8tv0wvDmFN3qIdMKWrmMMW6yZ0G19MfGg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-syntax-dynamic-import": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.2.0.tgz", + "integrity": "sha512-mVxuJ0YroI/h/tbFTPGZR8cv6ai+STMKNBq0f8hFxsxWjl94qqhsb+wXbpNMDPU3cfR1TIsVFzU3nXyZMqyK4w==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-syntax-json-strings": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.2.0.tgz", + "integrity": "sha512-5UGYnMSLRE1dqqZwug+1LISpA403HzlSfsg6P9VXU6TBjcSHeNlw4DxDx7LgpF+iKZoOG/+uzqoRHTdcUpiZNg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-syntax-object-rest-spread": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.2.0.tgz", + "integrity": "sha512-t0JKGgqk2We+9may3t0xDdmneaXmyxq0xieYcKHxIsrJO64n1OiMWNUtc5gQK1PA0NpdCRrtZp4z+IUaKugrSA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-syntax-optional-catch-binding": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.2.0.tgz", + "integrity": "sha512-bDe4xKNhb0LI7IvZHiA13kff0KEfaGX/Hv4lMA9+7TEc63hMNvfKo6ZFpXhKuEp+II/q35Gc4NoMeDZyaUbj9w==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-arrow-functions": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.2.0.tgz", + "integrity": "sha512-ER77Cax1+8/8jCB9fo4Ud161OZzWN5qawi4GusDuRLcDbDG+bIGYY20zb2dfAFdTRGzrfq2xZPvF0R64EHnimg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-async-to-generator": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.5.0.tgz", + "integrity": "sha512-mqvkzwIGkq0bEF1zLRRiTdjfomZJDV33AH3oQzHVGkI2VzEmXLpKKOBvEVaFZBJdN0XTyH38s9j/Kiqr68dggg==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-remap-async-to-generator": "^7.1.0" + } + }, + "@babel/plugin-transform-block-scoped-functions": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.2.0.tgz", + "integrity": "sha512-ntQPR6q1/NKuphly49+QiQiTN0O63uOwjdD6dhIjSWBI5xlrbUFh720TIpzBhpnrLfv2tNH/BXvLIab1+BAI0w==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-block-scoping": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.6.3.tgz", + "integrity": "sha512-7hvrg75dubcO3ZI2rjYTzUrEuh1E9IyDEhhB6qfcooxhDA33xx2MasuLVgdxzcP6R/lipAC6n9ub9maNW6RKdw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "lodash": "^4.17.13" + } + }, + "@babel/plugin-transform-classes": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.5.5.tgz", + "integrity": "sha512-U2htCNK/6e9K7jGyJ++1p5XRU+LJjrwtoiVn9SzRlDT2KubcZ11OOwy3s24TjHxPgxNwonCYP7U2K51uVYCMDg==", + "dev": true, + "requires": { + "@babel/helper-annotate-as-pure": "^7.0.0", + "@babel/helper-define-map": "^7.5.5", + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-optimise-call-expression": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-replace-supers": "^7.5.5", + "@babel/helper-split-export-declaration": "^7.4.4", + "globals": "^11.1.0" + } + }, + "@babel/plugin-transform-computed-properties": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.2.0.tgz", + "integrity": "sha512-kP/drqTxY6Xt3NNpKiMomfgkNn4o7+vKxK2DDKcBG9sHj51vHqMBGy8wbDS/J4lMxnqs153/T3+DmCEAkC5cpA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-destructuring": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.6.0.tgz", + "integrity": "sha512-2bGIS5P1v4+sWTCnKNDZDxbGvEqi0ijeqM/YqHtVGrvG2y0ySgnEEhXErvE9dA0bnIzY9bIzdFK0jFA46ASIIQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-dotall-regex": { + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.6.2.tgz", + "integrity": "sha512-KGKT9aqKV+9YMZSkowzYoYEiHqgaDhGmPNZlZxX6UeHC4z30nC1J9IrZuGqbYFB1jaIGdv91ujpze0exiVK8bA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-regex": "^7.4.4", + "regexpu-core": "^4.6.0" + } + }, + "@babel/plugin-transform-duplicate-keys": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.5.0.tgz", + "integrity": "sha512-igcziksHizyQPlX9gfSjHkE2wmoCH3evvD2qR5w29/Dk0SMKE/eOI7f1HhBdNhR/zxJDqrgpoDTq5YSLH/XMsQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-exponentiation-operator": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.2.0.tgz", + "integrity": "sha512-umh4hR6N7mu4Elq9GG8TOu9M0bakvlsREEC+ialrQN6ABS4oDQ69qJv1VtR3uxlKMCQMCvzk7vr17RHKcjx68A==", + "dev": true, + "requires": { + "@babel/helper-builder-binary-assignment-operator-visitor": "^7.1.0", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-for-of": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.4.4.tgz", + "integrity": "sha512-9T/5Dlr14Z9TIEXLXkt8T1DU7F24cbhwhMNUziN3hB1AXoZcdzPcTiKGRn/6iOymDqtTKWnr/BtRKN9JwbKtdQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-function-name": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.4.4.tgz", + "integrity": "sha512-iU9pv7U+2jC9ANQkKeNF6DrPy4GBa4NWQtl6dHB4Pb3izX2JOEvDTFarlNsBj/63ZEzNNIAMs3Qw4fNCcSOXJA==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-literals": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.2.0.tgz", + "integrity": "sha512-2ThDhm4lI4oV7fVQ6pNNK+sx+c/GM5/SaML0w/r4ZB7sAneD/piDJtwdKlNckXeyGK7wlwg2E2w33C/Hh+VFCg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-member-expression-literals": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.2.0.tgz", + "integrity": "sha512-HiU3zKkSU6scTidmnFJ0bMX8hz5ixC93b4MHMiYebmk2lUVNGOboPsqQvx5LzooihijUoLR/v7Nc1rbBtnc7FA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-modules-amd": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.5.0.tgz", + "integrity": "sha512-n20UsQMKnWrltocZZm24cRURxQnWIvsABPJlw/fvoy9c6AgHZzoelAIzajDHAQrDpuKFFPPcFGd7ChsYuIUMpg==", + "dev": true, + "requires": { + "@babel/helper-module-transforms": "^7.1.0", + "@babel/helper-plugin-utils": "^7.0.0", + "babel-plugin-dynamic-import-node": "^2.3.0" + } + }, + "@babel/plugin-transform-modules-commonjs": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.6.0.tgz", + "integrity": "sha512-Ma93Ix95PNSEngqomy5LSBMAQvYKVe3dy+JlVJSHEXZR5ASL9lQBedMiCyVtmTLraIDVRE3ZjTZvmXXD2Ozw3g==", + "dev": true, + "requires": { + "@babel/helper-module-transforms": "^7.4.4", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-simple-access": "^7.1.0", + "babel-plugin-dynamic-import-node": "^2.3.0" + } + }, + "@babel/plugin-transform-modules-systemjs": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.5.0.tgz", + "integrity": "sha512-Q2m56tyoQWmuNGxEtUyeEkm6qJYFqs4c+XyXH5RAuYxObRNz9Zgj/1g2GMnjYp2EUyEy7YTrxliGCXzecl/vJg==", + "dev": true, + "requires": { + "@babel/helper-hoist-variables": "^7.4.4", + "@babel/helper-plugin-utils": "^7.0.0", + "babel-plugin-dynamic-import-node": "^2.3.0" + } + }, + "@babel/plugin-transform-modules-umd": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.2.0.tgz", + "integrity": "sha512-BV3bw6MyUH1iIsGhXlOK6sXhmSarZjtJ/vMiD9dNmpY8QXFFQTj+6v92pcfy1iqa8DeAfJFwoxcrS/TUZda6sw==", + "dev": true, + "requires": { + "@babel/helper-module-transforms": "^7.1.0", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-named-capturing-groups-regex": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.6.3.tgz", + "integrity": "sha512-jTkk7/uE6H2s5w6VlMHeWuH+Pcy2lmdwFoeWCVnvIrDUnB5gQqTVI8WfmEAhF2CDEarGrknZcmSFg1+bkfCoSw==", + "dev": true, + "requires": { + "regexpu-core": "^4.6.0" + } + }, + "@babel/plugin-transform-new-target": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.4.4.tgz", + "integrity": "sha512-r1z3T2DNGQwwe2vPGZMBNjioT2scgWzK9BCnDEh+46z8EEwXBq24uRzd65I7pjtugzPSj921aM15RpESgzsSuA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-object-super": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.5.5.tgz", + "integrity": "sha512-un1zJQAhSosGFBduPgN/YFNvWVpRuHKU7IHBglLoLZsGmruJPOo6pbInneflUdmq7YvSVqhpPs5zdBvLnteltQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-replace-supers": "^7.5.5" + } + }, + "@babel/plugin-transform-parameters": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.4.4.tgz", + "integrity": "sha512-oMh5DUO1V63nZcu/ZVLQFqiihBGo4OpxJxR1otF50GMeCLiRx5nUdtokd+u9SuVJrvvuIh9OosRFPP4pIPnwmw==", + "dev": true, + "requires": { + "@babel/helper-call-delegate": "^7.4.4", + "@babel/helper-get-function-arity": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-property-literals": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.2.0.tgz", + "integrity": "sha512-9q7Dbk4RhgcLp8ebduOpCbtjh7C0itoLYHXd9ueASKAG/is5PQtMR5VJGka9NKqGhYEGn5ITahd4h9QeBMylWQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-regenerator": { + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.4.5.tgz", + "integrity": "sha512-gBKRh5qAaCWntnd09S8QC7r3auLCqq5DI6O0DlfoyDjslSBVqBibrMdsqO+Uhmx3+BlOmE/Kw1HFxmGbv0N9dA==", + "dev": true, + "requires": { + "regenerator-transform": "^0.14.0" + } + }, + "@babel/plugin-transform-reserved-words": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.2.0.tgz", + "integrity": "sha512-fz43fqW8E1tAB3DKF19/vxbpib1fuyCwSPE418ge5ZxILnBhWyhtPgz8eh1RCGGJlwvksHkyxMxh0eenFi+kFw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-shorthand-properties": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.2.0.tgz", + "integrity": "sha512-QP4eUM83ha9zmYtpbnyjTLAGKQritA5XW/iG9cjtuOI8s1RuL/3V6a3DeSHfKutJQ+ayUfeZJPcnCYEQzaPQqg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-spread": { + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.6.2.tgz", + "integrity": "sha512-DpSvPFryKdK1x+EDJYCy28nmAaIMdxmhot62jAXF/o99iA33Zj2Lmcp3vDmz+MUh0LNYVPvfj5iC3feb3/+PFg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-sticky-regex": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.2.0.tgz", + "integrity": "sha512-KKYCoGaRAf+ckH8gEL3JHUaFVyNHKe3ASNsZ+AlktgHevvxGigoIttrEJb8iKN03Q7Eazlv1s6cx2B2cQ3Jabw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-regex": "^7.0.0" + } + }, + "@babel/plugin-transform-template-literals": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.4.4.tgz", + "integrity": "sha512-mQrEC4TWkhLN0z8ygIvEL9ZEToPhG5K7KDW3pzGqOfIGZ28Jb0POUkeWcoz8HnHvhFy6dwAT1j8OzqN8s804+g==", + "dev": true, + "requires": { + "@babel/helper-annotate-as-pure": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-typeof-symbol": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.2.0.tgz", + "integrity": "sha512-2LNhETWYxiYysBtrBTqL8+La0jIoQQnIScUJc74OYvUGRmkskNY4EzLCnjHBzdmb38wqtTaixpo1NctEcvMDZw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-unicode-regex": { + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.6.2.tgz", + "integrity": "sha512-orZI6cWlR3nk2YmYdb0gImrgCUwb5cBUwjf6Ks6dvNVvXERkwtJWOQaEOjPiu0Gu1Tq6Yq/hruCZZOOi9F34Dw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-regex": "^7.4.4", + "regexpu-core": "^4.6.0" + } + }, + "@babel/preset-env": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.6.3.tgz", + "integrity": "sha512-CWQkn7EVnwzlOdR5NOm2+pfgSNEZmvGjOhlCHBDq0J8/EStr+G+FvPEiz9B56dR6MoiUFjXhfE4hjLoAKKJtIQ==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-proposal-async-generator-functions": "^7.2.0", + "@babel/plugin-proposal-dynamic-import": "^7.5.0", + "@babel/plugin-proposal-json-strings": "^7.2.0", + "@babel/plugin-proposal-object-rest-spread": "^7.6.2", + "@babel/plugin-proposal-optional-catch-binding": "^7.2.0", + "@babel/plugin-proposal-unicode-property-regex": "^7.6.2", + "@babel/plugin-syntax-async-generators": "^7.2.0", + "@babel/plugin-syntax-dynamic-import": "^7.2.0", + "@babel/plugin-syntax-json-strings": "^7.2.0", + "@babel/plugin-syntax-object-rest-spread": "^7.2.0", + "@babel/plugin-syntax-optional-catch-binding": "^7.2.0", + "@babel/plugin-transform-arrow-functions": "^7.2.0", + "@babel/plugin-transform-async-to-generator": "^7.5.0", + "@babel/plugin-transform-block-scoped-functions": "^7.2.0", + "@babel/plugin-transform-block-scoping": "^7.6.3", + "@babel/plugin-transform-classes": "^7.5.5", + "@babel/plugin-transform-computed-properties": "^7.2.0", + "@babel/plugin-transform-destructuring": "^7.6.0", + "@babel/plugin-transform-dotall-regex": "^7.6.2", + "@babel/plugin-transform-duplicate-keys": "^7.5.0", + "@babel/plugin-transform-exponentiation-operator": "^7.2.0", + "@babel/plugin-transform-for-of": "^7.4.4", + "@babel/plugin-transform-function-name": "^7.4.4", + "@babel/plugin-transform-literals": "^7.2.0", + "@babel/plugin-transform-member-expression-literals": "^7.2.0", + "@babel/plugin-transform-modules-amd": "^7.5.0", + "@babel/plugin-transform-modules-commonjs": "^7.6.0", + "@babel/plugin-transform-modules-systemjs": "^7.5.0", + "@babel/plugin-transform-modules-umd": "^7.2.0", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.6.3", + "@babel/plugin-transform-new-target": "^7.4.4", + "@babel/plugin-transform-object-super": "^7.5.5", + "@babel/plugin-transform-parameters": "^7.4.4", + "@babel/plugin-transform-property-literals": "^7.2.0", + "@babel/plugin-transform-regenerator": "^7.4.5", + "@babel/plugin-transform-reserved-words": "^7.2.0", + "@babel/plugin-transform-shorthand-properties": "^7.2.0", + "@babel/plugin-transform-spread": "^7.6.2", + "@babel/plugin-transform-sticky-regex": "^7.2.0", + "@babel/plugin-transform-template-literals": "^7.4.4", + "@babel/plugin-transform-typeof-symbol": "^7.2.0", + "@babel/plugin-transform-unicode-regex": "^7.6.2", + "@babel/types": "^7.6.3", + "browserslist": "^4.6.0", + "core-js-compat": "^3.1.1", + "invariant": "^2.2.2", + "js-levenshtein": "^1.1.3", + "semver": "^5.5.0" + } + }, + "@babel/template": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.6.0.tgz", + "integrity": "sha512-5AEH2EXD8euCk446b7edmgFdub/qfH1SN6Nii3+fyXP807QRx9Q73A2N5hNwRRslC2H9sNzaFhsPubkS4L8oNQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.6.0", + "@babel/types": "^7.6.0" + } + }, + "@babel/traverse": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.6.3.tgz", + "integrity": "sha512-unn7P4LGsijIxaAJo/wpoU11zN+2IaClkQAxcJWBNCMS6cmVh802IyLHNkAjQ0iYnRS3nnxk5O3fuXW28IMxTw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.6.3", + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/parser": "^7.6.3", + "@babel/types": "^7.6.3", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.6.3.tgz", + "integrity": "sha512-CqbcpTxMcpuQTMhjI37ZHVgjBkysg5icREQIEZ0eG1yCNwg3oy+5AaLiOKmjsCj6nqOsa6Hf0ObjRVwokb7srA==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "@cnakazawa/watch": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@cnakazawa/watch/-/watch-1.0.3.tgz", + "integrity": "sha512-r5160ogAvGyHsal38Kux7YYtodEKOj89RGb28ht1jh3SJb08VwRwAKKJL0bGb04Zd/3r9FL3BFIc3bBidYffCA==", + "dev": true, + "requires": { + "exec-sh": "^0.3.2", + "minimist": "^1.2.0" + } + }, + "@jest/console": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-24.9.0.tgz", + "integrity": "sha512-Zuj6b8TnKXi3q4ymac8EQfc3ea/uhLeCGThFqXeC8H9/raaH8ARPUTdId+XyGd03Z4In0/VjD2OYFcBF09fNLQ==", + "dev": true, + "requires": { + "@jest/source-map": "^24.9.0", + "chalk": "^2.0.1", + "slash": "^2.0.0" + } + }, + "@jest/core": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-24.9.0.tgz", + "integrity": "sha512-Fogg3s4wlAr1VX7q+rhV9RVnUv5tD7VuWfYy1+whMiWUrvl7U3QJSJyWcDio9Lq2prqYsZaeTv2Rz24pWGkJ2A==", + "dev": true, + "requires": { + "@jest/console": "^24.7.1", + "@jest/reporters": "^24.9.0", + "@jest/test-result": "^24.9.0", + "@jest/transform": "^24.9.0", + "@jest/types": "^24.9.0", + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.1", + "exit": "^0.1.2", + "graceful-fs": "^4.1.15", + "jest-changed-files": "^24.9.0", + "jest-config": "^24.9.0", + "jest-haste-map": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-regex-util": "^24.3.0", + "jest-resolve": "^24.9.0", + "jest-resolve-dependencies": "^24.9.0", + "jest-runner": "^24.9.0", + "jest-runtime": "^24.9.0", + "jest-snapshot": "^24.9.0", + "jest-util": "^24.9.0", + "jest-validate": "^24.9.0", + "jest-watcher": "^24.9.0", + "micromatch": "^3.1.10", + "p-each-series": "^1.0.0", + "realpath-native": "^1.1.0", + "rimraf": "^2.5.4", + "slash": "^2.0.0", + "strip-ansi": "^5.0.0" + }, + "dependencies": { + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } + } + }, + "@jest/environment": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-24.9.0.tgz", + "integrity": "sha512-5A1QluTPhvdIPFYnO3sZC3smkNeXPVELz7ikPbhUj0bQjB07EoE9qtLrem14ZUYWdVayYbsjVwIiL4WBIMV4aQ==", + "dev": true, + "requires": { + "@jest/fake-timers": "^24.9.0", + "@jest/transform": "^24.9.0", + "@jest/types": "^24.9.0", + "jest-mock": "^24.9.0" + } + }, + "@jest/fake-timers": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-24.9.0.tgz", + "integrity": "sha512-eWQcNa2YSwzXWIMC5KufBh3oWRIijrQFROsIqt6v/NS9Io/gknw1jsAC9c+ih/RQX4A3O7SeWAhQeN0goKhT9A==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-mock": "^24.9.0" + } + }, + "@jest/reporters": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-24.9.0.tgz", + "integrity": "sha512-mu4X0yjaHrffOsWmVLzitKmmmWSQ3GGuefgNscUSWNiUNcEOSEQk9k3pERKEQVBb0Cnn88+UESIsZEMH3o88Gw==", + "dev": true, + "requires": { + "@jest/environment": "^24.9.0", + "@jest/test-result": "^24.9.0", + "@jest/transform": "^24.9.0", + "@jest/types": "^24.9.0", + "chalk": "^2.0.1", + "exit": "^0.1.2", + "glob": "^7.1.2", + "istanbul-lib-coverage": "^2.0.2", + "istanbul-lib-instrument": "^3.0.1", + "istanbul-lib-report": "^2.0.4", + "istanbul-lib-source-maps": "^3.0.1", + "istanbul-reports": "^2.2.6", + "jest-haste-map": "^24.9.0", + "jest-resolve": "^24.9.0", + "jest-runtime": "^24.9.0", + "jest-util": "^24.9.0", + "jest-worker": "^24.6.0", + "node-notifier": "^5.4.2", + "slash": "^2.0.0", + "source-map": "^0.6.0", + "string-length": "^2.0.0" + } + }, + "@jest/source-map": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-24.9.0.tgz", + "integrity": "sha512-/Xw7xGlsZb4MJzNDgB7PW5crou5JqWiBQaz6xyPd3ArOg2nfn/PunV8+olXbbEZzNl591o5rWKE9BRDaFAuIBg==", + "dev": true, + "requires": { + "callsites": "^3.0.0", + "graceful-fs": "^4.1.15", + "source-map": "^0.6.0" + } + }, + "@jest/test-result": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-24.9.0.tgz", + "integrity": "sha512-XEFrHbBonBJ8dGp2JmF8kP/nQI/ImPpygKHwQ/SY+es59Z3L5PI4Qb9TQQMAEeYsThG1xF0k6tmG0tIKATNiiA==", + "dev": true, + "requires": { + "@jest/console": "^24.9.0", + "@jest/types": "^24.9.0", + "@types/istanbul-lib-coverage": "^2.0.0" + } + }, + "@jest/test-sequencer": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-24.9.0.tgz", + "integrity": "sha512-6qqsU4o0kW1dvA95qfNog8v8gkRN9ph6Lz7r96IvZpHdNipP2cBcb07J1Z45mz/VIS01OHJ3pY8T5fUY38tg4A==", + "dev": true, + "requires": { + "@jest/test-result": "^24.9.0", + "jest-haste-map": "^24.9.0", + "jest-runner": "^24.9.0", + "jest-runtime": "^24.9.0" + } + }, + "@jest/transform": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-24.9.0.tgz", + "integrity": "sha512-TcQUmyNRxV94S0QpMOnZl0++6RMiqpbH/ZMccFB/amku6Uwvyb1cjYX7xkp5nGNkbX4QPH/FcB6q1HBTHynLmQ==", + "dev": true, + "requires": { + "@babel/core": "^7.1.0", + "@jest/types": "^24.9.0", + "babel-plugin-istanbul": "^5.1.0", + "chalk": "^2.0.1", + "convert-source-map": "^1.4.0", + "fast-json-stable-stringify": "^2.0.0", + "graceful-fs": "^4.1.15", + "jest-haste-map": "^24.9.0", + "jest-regex-util": "^24.9.0", + "jest-util": "^24.9.0", + "micromatch": "^3.1.10", + "pirates": "^4.0.1", + "realpath-native": "^1.1.0", + "slash": "^2.0.0", + "source-map": "^0.6.1", + "write-file-atomic": "2.4.1" + } + }, + "@jest/types": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-24.9.0.tgz", + "integrity": "sha512-XKK7ze1apu5JWQ5eZjHITP66AX+QsLlbaJRBGYr8pNzwcAE2JVkwnf0yqjHTsDRcjR0mujy/NmZMXw5kl+kGBw==", + "dev": true, + "requires": { + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^1.1.1", + "@types/yargs": "^13.0.0" + } + }, + "@nodelib/fs.scandir": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", + "integrity": "sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "2.0.3", + "run-parallel": "^1.1.9" + } + }, + "@nodelib/fs.stat": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.3.tgz", + "integrity": "sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA==", + "dev": true + }, + "@nodelib/fs.walk": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.4.tgz", + "integrity": "sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ==", + "dev": true, + "requires": { + "@nodelib/fs.scandir": "2.1.3", + "fastq": "^1.6.0" + } + }, + "@samverschueren/stream-to-observable": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz", + "integrity": "sha512-MI4Xx6LHs4Webyvi6EbspgyAb4D2Q2VtnCQ1blOJcoLS6mVa8lNN2rkIy1CVxfTUpoyIbCTkXES1rLXztFD1lg==", + "dev": true, + "requires": { + "any-observable": "^0.3.0" + } + }, + "@types/babel__core": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.3.tgz", + "integrity": "sha512-8fBo0UR2CcwWxeX7WIIgJ7lXjasFxoYgRnFHUj+hRvKkpiBJbxhdAPTCY6/ZKM0uxANFVzt4yObSLuTiTnazDA==", + "dev": true, + "requires": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "@types/babel__generator": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.0.tgz", + "integrity": "sha512-c1mZUu4up5cp9KROs/QAw0gTeHrw/x7m52LcnvMxxOZ03DmLwPV0MlGmlgzV3cnSdjhJOZsj7E7FHeioai+egw==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@types/babel__template": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.0.2.tgz", + "integrity": "sha512-/K6zCpeW7Imzgab2bLkLEbz0+1JlFSrUMdw7KoIIu+IUdu51GWaBZpd3y1VXGVXzynvGa4DaIaxNZHiON3GXUg==", + "dev": true, + "requires": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@types/babel__traverse": { + "version": "7.0.7", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.7.tgz", + "integrity": "sha512-CeBpmX1J8kWLcDEnI3Cl2Eo6RfbGvzUctA+CjZUhOKDFbLfcr7fc4usEqLNWetrlJd7RhAkyYe2czXop4fICpw==", + "dev": true, + "requires": { + "@babel/types": "^7.3.0" + } + }, + "@types/estree": { + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", + "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", + "dev": true + }, + "@types/events": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", + "integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==", + "dev": true + }, + "@types/glob": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz", + "integrity": "sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w==", + "dev": true, + "requires": { + "@types/events": "*", + "@types/minimatch": "*", + "@types/node": "*" + } + }, + "@types/istanbul-lib-coverage": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", + "integrity": "sha512-hRJD2ahnnpLgsj6KWMYSrmXkM3rm2Dl1qkx6IOFD5FnuNPXJIG5L0dhgKXCYTRMGzU4n0wImQ/xfmRc4POUFlg==", + "dev": true + }, + "@types/istanbul-lib-report": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-1.1.1.tgz", + "integrity": "sha512-3BUTyMzbZa2DtDI2BkERNC6jJw2Mr2Y0oGI7mRxYNBPxppbtEK1F66u3bKwU2g+wxwWI7PAoRpJnOY1grJqzHg==", + "dev": true, + "requires": { + "@types/istanbul-lib-coverage": "*" + } + }, + "@types/istanbul-reports": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-1.1.1.tgz", + "integrity": "sha512-UpYjBi8xefVChsCoBpKShdxTllC9pwISirfoZsUa2AAdQg/Jd2KQGtSbw+ya7GPo7x/wAPlH6JBhKhAsXUEZNA==", + "dev": true, + "requires": { + "@types/istanbul-lib-coverage": "*", + "@types/istanbul-lib-report": "*" + } + }, + "@types/minimatch": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", + "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==", + "dev": true + }, + "@types/node": { + "version": "12.7.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.12.tgz", + "integrity": "sha512-KPYGmfD0/b1eXurQ59fXD1GBzhSQfz6/lKBxkaHX9dKTzjXbK68Zt7yGUxUsCS1jeTy/8aL+d9JEr+S54mpkWQ==", + "dev": true + }, + "@types/normalize-package-data": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz", + "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", + "dev": true + }, + "@types/resolve": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", + "integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/stack-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz", + "integrity": "sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==", + "dev": true + }, + "@types/yargs": { + "version": "13.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-13.0.3.tgz", + "integrity": "sha512-K8/LfZq2duW33XW/tFwEAfnZlqIfVsoyRB3kfXdPXYhl0nfM8mmh7GS0jg7WrX2Dgq/0Ha/pR1PaR+BvmWwjiQ==", + "dev": true, + "requires": { + "@types/yargs-parser": "*" + } + }, + "@types/yargs-parser": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-13.1.0.tgz", + "integrity": "sha512-gCubfBUZ6KxzoibJ+SCUc/57Ms1jz5NjHe4+dI2krNmU5zCPAphyLJYyTOg06ueIyfj+SaCUqmzun7ImlxDcKg==", + "dev": true + }, + "abab": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.2.tgz", + "integrity": "sha512-2scffjvioEmNz0OyDSLGWDfKCVwaKc6l9Pm9kOIREU13ClXZvHpg/nRL5xyjSSSLhOnXqft2HpsAzNEEA8cFFg==", + "dev": true + }, + "acorn": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", + "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "dev": true + }, + "acorn-globals": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.3.4.tgz", + "integrity": "sha512-clfQEh21R+D0leSbUdWf3OcfqyaCSAQ8Ryq00bofSekfr9W8u1jyYZo6ir0xu9Gtcf7BjcHJpnbZH7JOCpP60A==", + "dev": true, + "requires": { + "acorn": "^6.0.1", + "acorn-walk": "^6.0.1" + }, + "dependencies": { + "acorn": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz", + "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==", + "dev": true + } + } + }, + "acorn-jsx": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.2.tgz", + "integrity": "sha512-tiNTrP1MP0QrChmD2DdupCr6HWSFeKVw5d/dHTu4Y7rkAkRhU/Dt7dphAfIUyxtHpl/eBVip5uTNSpQJHylpAw==", + "dev": true + }, + "acorn-walk": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.2.0.tgz", + "integrity": "sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==", + "dev": true + }, + "aggregate-error": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.0.1.tgz", + "integrity": "sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA==", + "dev": true, + "requires": { + "clean-stack": "^2.0.0", + "indent-string": "^4.0.0" + } + }, + "ajv": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-escapes": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", + "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", + "dev": true + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "any-observable": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/any-observable/-/any-observable-0.3.0.tgz", + "integrity": "sha512-/FQM1EDkTsf63Ub2C6O7GuYFDsSXUwsaZDurV0np41ocwq0jthUAYCmhBX9f+KwlaCgIuWyr/4WlUQUBfKfZog==", + "dev": true + }, + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "dev": true, + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, + "array-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz", + "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=", + "dev": true + }, + "array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "dev": true, + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true + }, + "astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", + "dev": true + }, + "async-limiter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + }, + "atob": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", + "dev": true + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "dev": true + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", + "dev": true + }, + "babel-eslint": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.0.3.tgz", + "integrity": "sha512-z3U7eMY6r/3f3/JB9mTsLjyxrv0Yb1zb8PCWCLpguxfCzBIZUwy23R1t/XKewP+8mEN2Ck8Dtr4q20z6ce6SoA==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.0.0", + "@babel/traverse": "^7.0.0", + "@babel/types": "^7.0.0", + "eslint-visitor-keys": "^1.0.0", + "resolve": "^1.12.0" + } + }, + "babel-jest": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-24.9.0.tgz", + "integrity": "sha512-ntuddfyiN+EhMw58PTNL1ph4C9rECiQXjI4nMMBKBaNjXvqLdkXpPRcMSr4iyBrJg/+wz9brFUD6RhOAT6r4Iw==", + "dev": true, + "requires": { + "@jest/transform": "^24.9.0", + "@jest/types": "^24.9.0", + "@types/babel__core": "^7.1.0", + "babel-plugin-istanbul": "^5.1.0", + "babel-preset-jest": "^24.9.0", + "chalk": "^2.4.2", + "slash": "^2.0.0" + } + }, + "babel-plugin-dynamic-import-node": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz", + "integrity": "sha512-o6qFkpeQEBxcqt0XYlWzAVxNCSCZdUgcR8IRlhD/8DylxjjO4foPcvTW0GGKa/cVt3rvxZ7o5ippJ+/0nvLhlQ==", + "dev": true, + "requires": { + "object.assign": "^4.1.0" + } + }, + "babel-plugin-istanbul": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-5.2.0.tgz", + "integrity": "sha512-5LphC0USA8t4i1zCtjbbNb6jJj/9+X6P37Qfirc/70EQ34xKlMW+a1RHGwxGI+SwWpNwZ27HqvzAobeqaXwiZw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "find-up": "^3.0.0", + "istanbul-lib-instrument": "^3.3.0", + "test-exclude": "^5.2.3" + } + }, + "babel-plugin-jest-hoist": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-24.9.0.tgz", + "integrity": "sha512-2EMA2P8Vp7lG0RAzr4HXqtYwacfMErOuv1U3wrvxHX6rD1sV6xS3WXG3r8TRQ2r6w8OhvSdWt+z41hQNwNm3Xw==", + "dev": true, + "requires": { + "@types/babel__traverse": "^7.0.6" + } + }, + "babel-preset-jest": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-24.9.0.tgz", + "integrity": "sha512-izTUuhE4TMfTRPF92fFwD2QfdXaZW08qvWTFCI51V8rW5x00UuPgc3ajRoWofXOuxjfcOM5zzSYsQS3H8KGCAg==", + "dev": true, + "requires": { + "@babel/plugin-syntax-object-rest-spread": "^7.0.0", + "babel-plugin-jest-hoist": "^24.9.0" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "dev": true, + "requires": { + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "dev": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "browser-process-hrtime": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz", + "integrity": "sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==", + "dev": true + }, + "browser-resolve": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", + "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", + "dev": true, + "requires": { + "resolve": "1.1.7" + }, + "dependencies": { + "resolve": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "dev": true + } + } + }, + "browserslist": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.7.0.tgz", + "integrity": "sha512-9rGNDtnj+HaahxiVV38Gn8n8Lr8REKsel68v1sPFfIGEK6uSXTY3h9acgiT1dZVtOOUtifo/Dn8daDQ5dUgVsA==", + "dev": true, + "requires": { + "caniuse-lite": "^1.0.30000989", + "electron-to-chromium": "^1.3.247", + "node-releases": "^1.1.29" + } + }, + "bser": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.0.tgz", + "integrity": "sha512-8zsjWrQkkBoLK6uxASk1nJ2SKv97ltiGDo6A3wA0/yRPz+CwmEyDo0hUrhIuukG2JHpAl3bvFIixw2/3Hi0DOg==", + "dev": true, + "requires": { + "node-int64": "^0.4.0" + } + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "builtin-modules": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", + "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", + "dev": true + }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, + "requires": { + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "unset-value": "^1.0.0" + } + }, + "caller-callsite": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz", + "integrity": "sha1-hH4PzgoiN1CpoCfFSzNzGtMVQTQ=", + "dev": true, + "requires": { + "callsites": "^2.0.0" + }, + "dependencies": { + "callsites": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", + "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=", + "dev": true + } + } + }, + "caller-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-2.0.0.tgz", + "integrity": "sha1-Ro+DBE42mrIBD6xfBs7uFbsssfQ=", + "dev": true, + "requires": { + "caller-callsite": "^2.0.0" + } + }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "caniuse-lite": { + "version": "1.0.30000999", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000999.tgz", + "integrity": "sha512-1CUyKyecPeksKwXZvYw0tEoaMCo/RwBlXmEtN5vVnabvO0KPd9RQLcaAuR9/1F+KDMv6esmOFWlsXuzDk+8rxg==", + "dev": true + }, + "capture-exit": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/capture-exit/-/capture-exit-2.0.0.tgz", + "integrity": "sha512-PiT/hQmTonHhl/HFGN+Lx3JJUznrVYJ3+AQsnthneZbvW7x+f08Tk7yLJTLEOUvBTbduLeeBkxEaYXUOUrRq6g==", + "dev": true, + "requires": { + "rsvp": "^4.8.4" + } + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true + }, + "ci-info": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", + "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==", + "dev": true + }, + "class-utils": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "dev": true + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "cli-spinners": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.2.0.tgz", + "integrity": "sha512-tgU3fKwzYjiLEQgPMD9Jt+JjHVL9kW93FiIMX/l7rivvOD4/LL0Mf7gda3+4U2KJBloybwgj5KEoQgGRioMiKQ==", + "dev": true + }, + "cli-truncate": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-0.2.1.tgz", + "integrity": "sha1-nxXPuwcFAFNpIWxiasfQWrkN1XQ=", + "dev": true, + "requires": { + "slice-ansi": "0.0.4", + "string-width": "^1.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "slice-ansi": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", + "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", + "dev": true + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + }, + "dependencies": { + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + } + } + }, + "clone": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", + "dev": true + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "commander": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "dev": true + }, + "component-emitter": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "convert-source-map": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", + "integrity": "sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } + }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, + "core-js-compat": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.2.1.tgz", + "integrity": "sha512-MwPZle5CF9dEaMYdDeWm73ao/IflDH+FjeJCWEADcEgFSE9TLimFKwJsfmkwzI8eC0Aj0mgvMDjeQjrElkz4/A==", + "dev": true, + "requires": { + "browserslist": "^4.6.6", + "semver": "^6.3.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "cosmiconfig": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", + "integrity": "sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA==", + "dev": true, + "requires": { + "import-fresh": "^2.0.0", + "is-directory": "^0.3.1", + "js-yaml": "^3.13.1", + "parse-json": "^4.0.0" + }, + "dependencies": { + "import-fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-2.0.0.tgz", + "integrity": "sha1-2BNVwVYS04bGH53dOSLUMEgipUY=", + "dev": true, + "requires": { + "caller-path": "^2.0.0", + "resolve-from": "^3.0.0" + } + }, + "resolve-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", + "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", + "dev": true + } + } + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "cssom": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", + "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", + "dev": true + }, + "cssstyle": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-1.4.0.tgz", + "integrity": "sha512-GBrLZYZ4X4x6/QEoBnIrqb8B/f5l4+8me2dkom/j1Gtbxy0kBv6OGzKuAsGM75bkGwGAFkt56Iwg28S3XTZgSA==", + "dev": true, + "requires": { + "cssom": "0.3.x" + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "data-urls": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-1.1.0.tgz", + "integrity": "sha512-YTWYI9se1P55u58gL5GkQHW4P6VJBJ5iBT+B5a7i2Tjadhv52paJG0qHX4A0OR6/t52odI64KP2YvFpkDOi3eQ==", + "dev": true, + "requires": { + "abab": "^2.0.0", + "whatwg-mimetype": "^2.2.0", + "whatwg-url": "^7.0.0" + }, + "dependencies": { + "whatwg-url": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.0.0.tgz", + "integrity": "sha512-37GeVSIJ3kn1JgKyjiYNmSLP1yzbpb29jdmwBSgkD9h40/hyrR/OifpVUndji3tmwGgD8qpw7iQu3RSbCrBpsQ==", + "dev": true, + "requires": { + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.1", + "webidl-conversions": "^4.0.2" + } + } + } + }, + "date-fns": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.30.1.tgz", + "integrity": "sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==", + "dev": true + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "decode-uri-component": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", + "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "dev": true + }, + "dedent": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", + "integrity": "sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=", + "dev": true + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "defaults": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", + "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", + "dev": true, + "requires": { + "clone": "^1.0.2" + } + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "del": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/del/-/del-5.1.0.tgz", + "integrity": "sha512-wH9xOVHnczo9jN2IW68BabcecVPxacIA3g/7z6vhSU/4stOKQzeCRK0yD0A24WiAAUJmmVpWqrERcTxnLo3AnA==", + "dev": true, + "requires": { + "globby": "^10.0.1", + "graceful-fs": "^4.2.2", + "is-glob": "^4.0.1", + "is-path-cwd": "^2.2.0", + "is-path-inside": "^3.0.1", + "p-map": "^3.0.0", + "rimraf": "^3.0.0", + "slash": "^3.0.0" + }, + "dependencies": { + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + } + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "detect-newline": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz", + "integrity": "sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=", + "dev": true + }, + "diff-sequences": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-24.9.0.tgz", + "integrity": "sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew==", + "dev": true + }, + "dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "requires": { + "path-type": "^4.0.0" + }, + "dependencies": { + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true + } + } + }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "dom-walk": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz", + "integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg=" + }, + "domexception": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/domexception/-/domexception-1.0.1.tgz", + "integrity": "sha512-raigMkn7CJNNo6Ihro1fzG7wr3fHuYVytzquZKX5n0yizGsTcYgzdIUwj1X9pK0VvjeihV+XiclP+DjwbsSKug==", + "dev": true, + "requires": { + "webidl-conversions": "^4.0.2" + } + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "dev": true, + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "electron-to-chromium": { + "version": "1.3.280", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.280.tgz", + "integrity": "sha512-qYWNMjKLEfQAWZF2Sarvo+ahigu0EArnpCFSoUuZJS3W5wIeVfeEvsgmT2mgIrieQkeQ0+xFmykK3nx2ezekPQ==", + "dev": true + }, + "elegant-spinner": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/elegant-spinner/-/elegant-spinner-1.0.1.tgz", + "integrity": "sha1-2wQ1IcldfjA/2PNFvtwzSc+wcp4=", + "dev": true + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es-abstract": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.15.0.tgz", + "integrity": "sha512-bhkEqWJ2t2lMeaJDuk7okMkJWI/yqgH/EoGwpcvv0XW9RWQsRspI4wt6xuyuvMvvQE3gg/D9HXppgk21w78GyQ==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.0", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-inspect": "^1.6.0", + "object-keys": "^1.1.1", + "string.prototype.trimleft": "^2.1.0", + "string.prototype.trimright": "^2.1.0" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "escodegen": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.12.0.tgz", + "integrity": "sha512-TuA+EhsanGcme5T3R0L80u4t8CpbXQjegRmf7+FPTJrtCTErXFeelblRgHQa1FofEzqYYJmJ/OqjTwREp9qgmg==", + "dev": true, + "requires": { + "esprima": "^3.1.3", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.6.1" + }, + "dependencies": { + "esprima": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", + "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", + "dev": true + } + } + }, + "eslint": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.5.1.tgz", + "integrity": "sha512-32h99BoLYStT1iq1v2P9uwpyznQ4M2jRiFB6acitKz52Gqn+vPaMDUTB1bYi1WN4Nquj2w+t+bimYUG83DC55A==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.10.0", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^1.4.2", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.1", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^5.0.0", + "globals": "^11.7.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^6.4.1", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.14", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "eslint-scope": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", + "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.2.tgz", + "integrity": "sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.0.0" + } + }, + "eslint-visitor-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz", + "integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==", + "dev": true + }, + "espree": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.1.tgz", + "integrity": "sha512-EYbr8XZUhWbYCqQRW0duU5LxzL5bETN6AjKBGy1302qqzPaCH10QbRg3Wvco79Z8x9WbiE8HYB4e75xl6qUYvQ==", + "dev": true, + "requires": { + "acorn": "^7.0.0", + "acorn-jsx": "^5.0.2", + "eslint-visitor-keys": "^1.1.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "dev": true, + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "dev": true, + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + }, + "estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, + "exec-sh": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/exec-sh/-/exec-sh-0.3.2.tgz", + "integrity": "sha512-9sLAvzhI5nc8TpuQUh4ahMdCrWT00wPWz7j47/emR5+2qEfoZP5zzUXvx+vdx+H6ohhnsYC31iX04QLYJK8zTg==", + "dev": true + }, + "execa": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", + "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "expect": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-24.9.0.tgz", + "integrity": "sha512-wvVAx8XIol3Z5m9zvZXiyZOQ+sRJqNTIm6sGjdWlaZIeupQGO3WbYI+15D/AmEwZywL6wtJkbAbJtzkOfBuR0Q==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "ansi-styles": "^3.2.0", + "jest-get-type": "^24.9.0", + "jest-matcher-utils": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-regex-util": "^24.9.0" + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "external-editor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "dev": true, + "requires": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + } + }, + "extglob": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "dev": true + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "fast-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.1.0.tgz", + "integrity": "sha512-TrUz3THiq2Vy3bjfQUB2wNyPdGBeGmdjbzzBLhfHN4YFurYptCKwGq/TfiRavbGywFRzY6U2CdmQ1zmsY5yYaw==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.0", + "merge2": "^1.3.0", + "micromatch": "^4.0.2" + }, + "dependencies": { + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "micromatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", + "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", + "dev": true, + "requires": { + "braces": "^3.0.1", + "picomatch": "^2.0.5" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + } + } + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "fastq": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.6.0.tgz", + "integrity": "sha512-jmxqQ3Z/nXoeyDmWAzF9kH1aGZSis6e/SbfPmJpUnyZ0ogr6iscHQaml4wsEepEWSdtmpy+eVXmCRIMpxaXqOA==", + "dev": true, + "requires": { + "reusify": "^1.0.0" + } + }, + "fb-watchman": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.0.tgz", + "integrity": "sha1-VOmr99+i8mzZsWNsWIwa/AXeXVg=", + "dev": true, + "requires": { + "bser": "^2.0.0" + } + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "dev": true, + "requires": { + "flat-cache": "^2.0.1" + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "flat-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "dev": true, + "requires": { + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" + }, + "dependencies": { + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } + } + }, + "flatted": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", + "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", + "dev": true + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "dev": true, + "requires": { + "map-cache": "^0.2.2" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", + "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", + "dev": true, + "optional": true, + "requires": { + "nan": "^2.12.1", + "node-pre-gyp": "^0.12.0" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "brace-expansion": { + "version": "1.1.11", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "chownr": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "debug": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "^2.1.1" + } + }, + "deep-extend": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "fs-minipass": { + "version": "1.2.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "glob": { + "version": "7.1.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "iconv-lite": { + "version": "0.4.24", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore-walk": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "ini": { + "version": "1.3.5", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true, + "optional": true + }, + "minipass": { + "version": "2.3.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "needle": { + "version": "2.3.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "^4.1.0", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, + "node-pre-gyp": { + "version": "0.12.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "npm-bundled": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "optional": true + }, + "npm-packlist": { + "version": "1.4.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "wrappy": "1" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rimraf": { + "version": "2.6.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sax": { + "version": "1.2.4", + "bundled": true, + "dev": true, + "optional": true + }, + "semver": { + "version": "5.7.0", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "4.4.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.4", + "minizlib": "^1.1.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "wide-align": { + "version": "1.1.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "yallist": { + "version": "3.0.3", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "get-own-enumerable-property-symbols": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.1.tgz", + "integrity": "sha512-09/VS4iek66Dh2bctjRkowueRJbY1JDGR1L/zRxO1Qk8Uxs6PnqaNSqalpizPT+CDjre3hnEsuzvhgomz9qYrA==", + "dev": true + }, + "get-stdin": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-7.0.0.tgz", + "integrity": "sha512-zRKcywvrXlXsA0v0i9Io4KDRaAw7+a1ZpjRwl9Wox8PFlVCCHra7E9c4kqXCoCM9nR5tBkaTTZRBoCm60bFqTQ==", + "dev": true + }, + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "get-value": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "global": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/global/-/global-4.4.0.tgz", + "integrity": "sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w==", + "requires": { + "min-document": "^2.19.0", + "process": "^0.11.10" + } + }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, + "globby": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-10.0.1.tgz", + "integrity": "sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==", + "dev": true, + "requires": { + "@types/glob": "^7.1.1", + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.0.3", + "glob": "^7.1.3", + "ignore": "^5.1.1", + "merge2": "^1.2.3", + "slash": "^3.0.0" + }, + "dependencies": { + "ignore": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.4.tgz", + "integrity": "sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==", + "dev": true + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + } + } + }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==", + "dev": true + }, + "growly": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", + "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=", + "dev": true + }, + "handlebars": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.3.tgz", + "integrity": "sha512-B0W4A2U1ww3q7VVthTKfh+epHx+q4mCt6iK+zEAzbMBpWQAwxCeKxEGpj/1oQTpzPXDNSOG7hmG14TsISH50yw==", + "dev": true, + "requires": { + "neo-async": "^2.6.0", + "optimist": "^0.6.1", + "source-map": "^0.6.1", + "uglify-js": "^3.1.4" + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "dev": true + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "dev": true, + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + } + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "dev": true + }, + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "kind-of": "^4.0.0" + }, + "dependencies": { + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "hosted-git-info": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", + "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==", + "dev": true + }, + "html-encoding-sniffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz", + "integrity": "sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==", + "dev": true, + "requires": { + "whatwg-encoding": "^1.0.1" + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "husky": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/husky/-/husky-3.0.8.tgz", + "integrity": "sha512-HFOsgcyrX3qe/rBuqyTt+P4Gxn5P0seJmr215LAZ/vnwK3jWB3r0ck7swbzGRUbufCf9w/lgHPVbF/YXQALgfQ==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "cosmiconfig": "^5.2.1", + "execa": "^1.0.0", + "get-stdin": "^7.0.0", + "is-ci": "^2.0.0", + "opencollective-postinstall": "^2.0.2", + "pkg-dir": "^4.2.0", + "please-upgrade-node": "^3.2.0", + "read-pkg": "^5.1.1", + "run-node": "^1.0.0", + "slash": "^3.0.0" + }, + "dependencies": { + "parse-json": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.0.0.tgz", + "integrity": "sha512-OOY5b7PAEFV0E2Fir1KOkxchnZNCdowAJgQ5NuxjpBKTRP3pQhwkrkxqQjeoKJ+fO7bCpmIZaogI4eZGDMEGOw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1", + "lines-and-columns": "^1.1.6" + } + }, + "read-pkg": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", + "dev": true, + "requires": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + } + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + } + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "import-fresh": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.1.0.tgz", + "integrity": "sha512-PpuksHKGt8rXfWEr9m9EHIpgyyaltBy8+eF6GJM0QCAxMgxCfucMF3mjecK2QsJr0amJW7gTqh5/wht0z2UhEQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "import-local": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-2.0.0.tgz", + "integrity": "sha512-b6s04m3O+s3CGSbqDIyP4R6aAwAeYlVq9+WUWep6iHa8ETRf9yei1U48C5MmfJmV9AiLYYBKPMq/W+/WRpQmCQ==", + "dev": true, + "requires": { + "pkg-dir": "^3.0.0", + "resolve-cwd": "^2.0.0" + }, + "dependencies": { + "pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "dev": true, + "requires": { + "find-up": "^3.0.0" + } + } + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "inquirer": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.2.tgz", + "integrity": "sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==", + "dev": true, + "requires": { + "ansi-escapes": "^3.2.0", + "chalk": "^2.4.2", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^3.0.3", + "figures": "^2.0.0", + "lodash": "^4.17.12", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rxjs": "^6.4.0", + "string-width": "^2.1.0", + "strip-ansi": "^5.1.0", + "through": "^2.3.6" + } + }, + "invariant": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", + "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "dev": true, + "requires": { + "loose-envify": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "dev": true + }, + "is-ci": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", + "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", + "dev": true, + "requires": { + "ci-info": "^2.0.0" + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "is-directory": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz", + "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=", + "dev": true + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-generator-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "dev": true + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", + "dev": true + }, + "is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "dev": true + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", + "dev": true + }, + "is-observable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-observable/-/is-observable-1.1.0.tgz", + "integrity": "sha512-NqCa4Sa2d+u7BWc6CukaObG3Fh+CU9bvixbpcXYhy2VvYS7vVGIdAgnIS5Ks3A/cqk4rebLJ9s8zBstT2aKnIA==", + "dev": true, + "requires": { + "symbol-observable": "^1.1.0" + } + }, + "is-path-cwd": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz", + "integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==", + "dev": true + }, + "is-path-inside": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.2.tgz", + "integrity": "sha512-/2UGPSgmtqwo1ktx8NDHjuPwZWmHhO+gj0f93EkhLB5RgW9RZevWYYlIkS6zePc6U2WpOdQYIwHe9YC4DWEBVg==", + "dev": true + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "dev": true, + "requires": { + "has": "^1.0.1" + } + }, + "is-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", + "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=", + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.0" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "is-wsl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", + "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true + }, + "istanbul-lib-coverage": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz", + "integrity": "sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA==", + "dev": true + }, + "istanbul-lib-instrument": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-3.3.0.tgz", + "integrity": "sha512-5nnIN4vo5xQZHdXno/YDXJ0G+I3dAm4XgzfSVTPLQpj/zAV2dV6Juy0yaf10/zrJOJeHoN3fraFe+XRq2bFVZA==", + "dev": true, + "requires": { + "@babel/generator": "^7.4.0", + "@babel/parser": "^7.4.3", + "@babel/template": "^7.4.0", + "@babel/traverse": "^7.4.3", + "@babel/types": "^7.4.0", + "istanbul-lib-coverage": "^2.0.5", + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "istanbul-lib-report": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-2.0.8.tgz", + "integrity": "sha512-fHBeG573EIihhAblwgxrSenp0Dby6tJMFR/HvlerBsrCTD5bkUuoNtn3gVh29ZCS824cGGBPn7Sg7cNk+2xUsQ==", + "dev": true, + "requires": { + "istanbul-lib-coverage": "^2.0.5", + "make-dir": "^2.1.0", + "supports-color": "^6.1.0" + }, + "dependencies": { + "supports-color": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "istanbul-lib-source-maps": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-3.0.6.tgz", + "integrity": "sha512-R47KzMtDJH6X4/YW9XTx+jrLnZnscW4VpNN+1PViSYTejLVPWv7oov+Duf8YQSPyVRUvueQqz1TcsC6mooZTXw==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^2.0.5", + "make-dir": "^2.1.0", + "rimraf": "^2.6.3", + "source-map": "^0.6.1" + }, + "dependencies": { + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } + } + }, + "istanbul-reports": { + "version": "2.2.6", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-2.2.6.tgz", + "integrity": "sha512-SKi4rnMyLBKe0Jy2uUdx28h8oG7ph2PPuQPvIAh31d+Ci+lSiEu4C+h3oBPuJ9+mPKhOyW0M8gY4U5NM1WLeXA==", + "dev": true, + "requires": { + "handlebars": "^4.1.2" + } + }, + "jest": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest/-/jest-24.9.0.tgz", + "integrity": "sha512-YvkBL1Zm7d2B1+h5fHEOdyjCG+sGMz4f8D86/0HiqJ6MB4MnDc8FgP5vdWsGnemOQro7lnYo8UakZ3+5A0jxGw==", + "dev": true, + "requires": { + "import-local": "^2.0.0", + "jest-cli": "^24.9.0" + }, + "dependencies": { + "jest-cli": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-24.9.0.tgz", + "integrity": "sha512-+VLRKyitT3BWoMeSUIHRxV/2g8y9gw91Jh5z2UmXZzkZKpbC08CSehVxgHUwTpy+HwGcns/tqafQDJW7imYvGg==", + "dev": true, + "requires": { + "@jest/core": "^24.9.0", + "@jest/test-result": "^24.9.0", + "@jest/types": "^24.9.0", + "chalk": "^2.0.1", + "exit": "^0.1.2", + "import-local": "^2.0.0", + "is-ci": "^2.0.0", + "jest-config": "^24.9.0", + "jest-util": "^24.9.0", + "jest-validate": "^24.9.0", + "prompts": "^2.0.1", + "realpath-native": "^1.1.0", + "yargs": "^13.3.0" + } + } + } + }, + "jest-changed-files": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-24.9.0.tgz", + "integrity": "sha512-6aTWpe2mHF0DhL28WjdkO8LyGjs3zItPET4bMSeXU6T3ub4FPMw+mcOcbdGXQOAfmLcxofD23/5Bl9Z4AkFwqg==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "execa": "^1.0.0", + "throat": "^4.0.0" + } + }, + "jest-config": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-24.9.0.tgz", + "integrity": "sha512-RATtQJtVYQrp7fvWg6f5y3pEFj9I+H8sWw4aKxnDZ96mob5i5SD6ZEGWgMLXQ4LE8UurrjbdlLWdUeo+28QpfQ==", + "dev": true, + "requires": { + "@babel/core": "^7.1.0", + "@jest/test-sequencer": "^24.9.0", + "@jest/types": "^24.9.0", + "babel-jest": "^24.9.0", + "chalk": "^2.0.1", + "glob": "^7.1.1", + "jest-environment-jsdom": "^24.9.0", + "jest-environment-node": "^24.9.0", + "jest-get-type": "^24.9.0", + "jest-jasmine2": "^24.9.0", + "jest-regex-util": "^24.3.0", + "jest-resolve": "^24.9.0", + "jest-util": "^24.9.0", + "jest-validate": "^24.9.0", + "micromatch": "^3.1.10", + "pretty-format": "^24.9.0", + "realpath-native": "^1.1.0" + } + }, + "jest-diff": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-24.9.0.tgz", + "integrity": "sha512-qMfrTs8AdJE2iqrTp0hzh7kTd2PQWrsFyj9tORoKmu32xjPjeE4NyjVRDz8ybYwqS2ik8N4hsIpiVTyFeo2lBQ==", + "dev": true, + "requires": { + "chalk": "^2.0.1", + "diff-sequences": "^24.9.0", + "jest-get-type": "^24.9.0", + "pretty-format": "^24.9.0" + } + }, + "jest-docblock": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-24.9.0.tgz", + "integrity": "sha512-F1DjdpDMJMA1cN6He0FNYNZlo3yYmOtRUnktrT9Q37njYzC5WEaDdmbynIgy0L/IvXvvgsG8OsqhLPXTpfmZAA==", + "dev": true, + "requires": { + "detect-newline": "^2.1.0" + } + }, + "jest-each": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-24.9.0.tgz", + "integrity": "sha512-ONi0R4BvW45cw8s2Lrx8YgbeXL1oCQ/wIDwmsM3CqM/nlblNCPmnC3IPQlMbRFZu3wKdQ2U8BqM6lh3LJ5Bsog==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "chalk": "^2.0.1", + "jest-get-type": "^24.9.0", + "jest-util": "^24.9.0", + "pretty-format": "^24.9.0" + } + }, + "jest-environment-jsdom": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-24.9.0.tgz", + "integrity": "sha512-Zv9FV9NBRzLuALXjvRijO2351DRQeLYXtpD4xNvfoVFw21IOKNhZAEUKcbiEtjTkm2GsJ3boMVgkaR7rN8qetA==", + "dev": true, + "requires": { + "@jest/environment": "^24.9.0", + "@jest/fake-timers": "^24.9.0", + "@jest/types": "^24.9.0", + "jest-mock": "^24.9.0", + "jest-util": "^24.9.0", + "jsdom": "^11.5.1" + } + }, + "jest-environment-node": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-24.9.0.tgz", + "integrity": "sha512-6d4V2f4nxzIzwendo27Tr0aFm+IXWa0XEUnaH6nU0FMaozxovt+sfRvh4J47wL1OvF83I3SSTu0XK+i4Bqe7uA==", + "dev": true, + "requires": { + "@jest/environment": "^24.9.0", + "@jest/fake-timers": "^24.9.0", + "@jest/types": "^24.9.0", + "jest-mock": "^24.9.0", + "jest-util": "^24.9.0" + } + }, + "jest-get-type": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-24.9.0.tgz", + "integrity": "sha512-lUseMzAley4LhIcpSP9Jf+fTrQ4a1yHQwLNeeVa2cEmbCGeoZAtYPOIv8JaxLD/sUpKxetKGP+gsHl8f8TSj8Q==", + "dev": true + }, + "jest-haste-map": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-24.9.0.tgz", + "integrity": "sha512-kfVFmsuWui2Sj1Rp1AJ4D9HqJwE4uwTlS/vO+eRUaMmd54BFpli2XhMQnPC2k4cHFVbB2Q2C+jtI1AGLgEnCjQ==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "anymatch": "^2.0.0", + "fb-watchman": "^2.0.0", + "fsevents": "^1.2.7", + "graceful-fs": "^4.1.15", + "invariant": "^2.2.4", + "jest-serializer": "^24.9.0", + "jest-util": "^24.9.0", + "jest-worker": "^24.9.0", + "micromatch": "^3.1.10", + "sane": "^4.0.3", + "walker": "^1.0.7" + } + }, + "jest-jasmine2": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-24.9.0.tgz", + "integrity": "sha512-Cq7vkAgaYKp+PsX+2/JbTarrk0DmNhsEtqBXNwUHkdlbrTBLtMJINADf2mf5FkowNsq8evbPc07/qFO0AdKTzw==", + "dev": true, + "requires": { + "@babel/traverse": "^7.1.0", + "@jest/environment": "^24.9.0", + "@jest/test-result": "^24.9.0", + "@jest/types": "^24.9.0", + "chalk": "^2.0.1", + "co": "^4.6.0", + "expect": "^24.9.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^24.9.0", + "jest-matcher-utils": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-runtime": "^24.9.0", + "jest-snapshot": "^24.9.0", + "jest-util": "^24.9.0", + "pretty-format": "^24.9.0", + "throat": "^4.0.0" + } + }, + "jest-leak-detector": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-24.9.0.tgz", + "integrity": "sha512-tYkFIDsiKTGwb2FG1w8hX9V0aUb2ot8zY/2nFg087dUageonw1zrLMP4W6zsRO59dPkTSKie+D4rhMuP9nRmrA==", + "dev": true, + "requires": { + "jest-get-type": "^24.9.0", + "pretty-format": "^24.9.0" + } + }, + "jest-matcher-utils": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-24.9.0.tgz", + "integrity": "sha512-OZz2IXsu6eaiMAwe67c1T+5tUAtQyQx27/EMEkbFAGiw52tB9em+uGbzpcgYVpA8wl0hlxKPZxrly4CXU/GjHA==", + "dev": true, + "requires": { + "chalk": "^2.0.1", + "jest-diff": "^24.9.0", + "jest-get-type": "^24.9.0", + "pretty-format": "^24.9.0" + } + }, + "jest-message-util": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-24.9.0.tgz", + "integrity": "sha512-oCj8FiZ3U0hTP4aSui87P4L4jC37BtQwUMqk+zk/b11FR19BJDeZsZAvIHutWnmtw7r85UmR3CEWZ0HWU2mAlw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@jest/test-result": "^24.9.0", + "@jest/types": "^24.9.0", + "@types/stack-utils": "^1.0.1", + "chalk": "^2.0.1", + "micromatch": "^3.1.10", + "slash": "^2.0.0", + "stack-utils": "^1.0.1" + } + }, + "jest-mock": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-24.9.0.tgz", + "integrity": "sha512-3BEYN5WbSq9wd+SyLDES7AHnjH9A/ROBwmz7l2y+ol+NtSFO8DYiEBzoO1CeFc9a8DYy10EO4dDFVv/wN3zl1w==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0" + } + }, + "jest-pnp-resolver": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.1.tgz", + "integrity": "sha512-pgFw2tm54fzgYvc/OHrnysABEObZCUNFnhjoRjaVOCN8NYc032/gVjPaHD4Aq6ApkSieWtfKAFQtmDKAmhupnQ==", + "dev": true + }, + "jest-regex-util": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-24.9.0.tgz", + "integrity": "sha512-05Cmb6CuxaA+Ys6fjr3PhvV3bGQmO+2p2La4hFbU+W5uOc479f7FdLXUWXw4pYMAhhSZIuKHwSXSu6CsSBAXQA==", + "dev": true + }, + "jest-resolve": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-24.9.0.tgz", + "integrity": "sha512-TaLeLVL1l08YFZAt3zaPtjiVvyy4oSA6CRe+0AFPPVX3Q/VI0giIWWoAvoS5L96vj9Dqxj4fB5p2qrHCmTU/MQ==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "browser-resolve": "^1.11.3", + "chalk": "^2.0.1", + "jest-pnp-resolver": "^1.2.1", + "realpath-native": "^1.1.0" + } + }, + "jest-resolve-dependencies": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-24.9.0.tgz", + "integrity": "sha512-Fm7b6AlWnYhT0BXy4hXpactHIqER7erNgIsIozDXWl5dVm+k8XdGVe1oTg1JyaFnOxarMEbax3wyRJqGP2Pq+g==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "jest-regex-util": "^24.3.0", + "jest-snapshot": "^24.9.0" + } + }, + "jest-runner": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-24.9.0.tgz", + "integrity": "sha512-KksJQyI3/0mhcfspnxxEOBueGrd5E4vV7ADQLT9ESaCzz02WnbdbKWIf5Mkaucoaj7obQckYPVX6JJhgUcoWWg==", + "dev": true, + "requires": { + "@jest/console": "^24.7.1", + "@jest/environment": "^24.9.0", + "@jest/test-result": "^24.9.0", + "@jest/types": "^24.9.0", + "chalk": "^2.4.2", + "exit": "^0.1.2", + "graceful-fs": "^4.1.15", + "jest-config": "^24.9.0", + "jest-docblock": "^24.3.0", + "jest-haste-map": "^24.9.0", + "jest-jasmine2": "^24.9.0", + "jest-leak-detector": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-resolve": "^24.9.0", + "jest-runtime": "^24.9.0", + "jest-util": "^24.9.0", + "jest-worker": "^24.6.0", + "source-map-support": "^0.5.6", + "throat": "^4.0.0" + } + }, + "jest-runtime": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-24.9.0.tgz", + "integrity": "sha512-8oNqgnmF3v2J6PVRM2Jfuj8oX3syKmaynlDMMKQ4iyzbQzIG6th5ub/lM2bCMTmoTKM3ykcUYI2Pw9xwNtjMnw==", + "dev": true, + "requires": { + "@jest/console": "^24.7.1", + "@jest/environment": "^24.9.0", + "@jest/source-map": "^24.3.0", + "@jest/transform": "^24.9.0", + "@jest/types": "^24.9.0", + "@types/yargs": "^13.0.0", + "chalk": "^2.0.1", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.1.15", + "jest-config": "^24.9.0", + "jest-haste-map": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-mock": "^24.9.0", + "jest-regex-util": "^24.3.0", + "jest-resolve": "^24.9.0", + "jest-snapshot": "^24.9.0", + "jest-util": "^24.9.0", + "jest-validate": "^24.9.0", + "realpath-native": "^1.1.0", + "slash": "^2.0.0", + "strip-bom": "^3.0.0", + "yargs": "^13.3.0" + } + }, + "jest-serializer": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-serializer/-/jest-serializer-24.9.0.tgz", + "integrity": "sha512-DxYipDr8OvfrKH3Kel6NdED3OXxjvxXZ1uIY2I9OFbGg+vUkkg7AGvi65qbhbWNPvDckXmzMPbK3u3HaDO49bQ==", + "dev": true + }, + "jest-snapshot": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-24.9.0.tgz", + "integrity": "sha512-uI/rszGSs73xCM0l+up7O7a40o90cnrk429LOiK3aeTvfC0HHmldbd81/B7Ix81KSFe1lwkbl7GnBGG4UfuDew==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0", + "@jest/types": "^24.9.0", + "chalk": "^2.0.1", + "expect": "^24.9.0", + "jest-diff": "^24.9.0", + "jest-get-type": "^24.9.0", + "jest-matcher-utils": "^24.9.0", + "jest-message-util": "^24.9.0", + "jest-resolve": "^24.9.0", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "pretty-format": "^24.9.0", + "semver": "^6.2.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "jest-util": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-24.9.0.tgz", + "integrity": "sha512-x+cZU8VRmOJxbA1K5oDBdxQmdq0OIdADarLxk0Mq+3XS4jgvhG/oKGWcIDCtPG0HgjxOYvF+ilPJQsAyXfbNOg==", + "dev": true, + "requires": { + "@jest/console": "^24.9.0", + "@jest/fake-timers": "^24.9.0", + "@jest/source-map": "^24.9.0", + "@jest/test-result": "^24.9.0", + "@jest/types": "^24.9.0", + "callsites": "^3.0.0", + "chalk": "^2.0.1", + "graceful-fs": "^4.1.15", + "is-ci": "^2.0.0", + "mkdirp": "^0.5.1", + "slash": "^2.0.0", + "source-map": "^0.6.0" + } + }, + "jest-validate": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-24.9.0.tgz", + "integrity": "sha512-HPIt6C5ACwiqSiwi+OfSSHbK8sG7akG8eATl+IPKaeIjtPOeBUd/g3J7DghugzxrGjI93qS/+RPKe1H6PqvhRQ==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "camelcase": "^5.3.1", + "chalk": "^2.0.1", + "jest-get-type": "^24.9.0", + "leven": "^3.1.0", + "pretty-format": "^24.9.0" + } + }, + "jest-watcher": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-24.9.0.tgz", + "integrity": "sha512-+/fLOfKPXXYJDYlks62/4R4GoT+GU1tYZed99JSCOsmzkkF7727RqKrjNAxtfO4YpGv11wybgRvCjR73lK2GZw==", + "dev": true, + "requires": { + "@jest/test-result": "^24.9.0", + "@jest/types": "^24.9.0", + "@types/yargs": "^13.0.0", + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.1", + "jest-util": "^24.9.0", + "string-length": "^2.0.0" + } + }, + "jest-worker": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.9.0.tgz", + "integrity": "sha512-51PE4haMSXcHohnSMdM42anbvZANYTqMrr52tVKPqqsPJMzoP6FYYDVqahX/HrAoKEKz3uUPzSvKs9A3qR4iVw==", + "dev": true, + "requires": { + "merge-stream": "^2.0.0", + "supports-color": "^6.1.0" + }, + "dependencies": { + "supports-color": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "js-levenshtein": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz", + "integrity": "sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true + }, + "jsdom": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-11.12.0.tgz", + "integrity": "sha512-y8Px43oyiBM13Zc1z780FrfNLJCXTL40EWlty/LXUtcjykRBNgLlCjWXpfSPBl2iv+N7koQN+dvqszHZgT/Fjw==", + "dev": true, + "requires": { + "abab": "^2.0.0", + "acorn": "^5.5.3", + "acorn-globals": "^4.1.0", + "array-equal": "^1.0.0", + "cssom": ">= 0.3.2 < 0.4.0", + "cssstyle": "^1.0.0", + "data-urls": "^1.0.0", + "domexception": "^1.0.1", + "escodegen": "^1.9.1", + "html-encoding-sniffer": "^1.0.2", + "left-pad": "^1.3.0", + "nwsapi": "^2.0.7", + "parse5": "4.0.0", + "pn": "^1.1.0", + "request": "^2.87.0", + "request-promise-native": "^1.0.5", + "sax": "^1.2.4", + "symbol-tree": "^3.2.2", + "tough-cookie": "^2.3.4", + "w3c-hr-time": "^1.0.1", + "webidl-conversions": "^4.0.2", + "whatwg-encoding": "^1.0.3", + "whatwg-mimetype": "^2.1.0", + "whatwg-url": "^6.4.1", + "ws": "^5.2.0", + "xml-name-validator": "^3.0.0" + }, + "dependencies": { + "acorn": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", + "dev": true + } + } + }, + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true + }, + "json-parse-better-errors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", + "dev": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true + }, + "json5": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.1.tgz", + "integrity": "sha512-l+3HXD0GEI3huGq1njuqtzYK8OYJyXMkOLtQ53pjWh89tvWS2h6l+1zMkYWqlb57+SiQodKZyvMEFb2X+KrFhQ==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "dev": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + }, + "kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true + }, + "left-pad": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz", + "integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==", + "dev": true + }, + "leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "lines-and-columns": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", + "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", + "dev": true + }, + "lint-staged": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-9.4.2.tgz", + "integrity": "sha512-OFyGokJSWTn2M6vngnlLXjaHhi8n83VIZZ5/1Z26SULRUWgR3ITWpAEQC9Pnm3MC/EpCxlwts/mQWDHNji2+zA==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "commander": "^2.20.0", + "cosmiconfig": "^5.2.1", + "debug": "^4.1.1", + "dedent": "^0.7.0", + "del": "^5.0.0", + "execa": "^2.0.3", + "listr": "^0.14.3", + "log-symbols": "^3.0.0", + "micromatch": "^4.0.2", + "normalize-path": "^3.0.0", + "please-upgrade-node": "^3.1.1", + "string-argv": "^0.3.0", + "stringify-object": "^3.3.0" + }, + "dependencies": { + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "cross-spawn": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.1.tgz", + "integrity": "sha512-u7v4o84SwFpD32Z8IIcPZ6z1/ie24O6RU3RbtL5Y316l3KuHVPx9ItBgWQ6VlfAFnRnTtMUrsQ9MUUTuEZjogg==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "execa": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-2.1.0.tgz", + "integrity": "sha512-Y/URAVapfbYy2Xp/gb6A0E7iR8xeqOCXsuuaoMn7A5PzrXUK84E1gyiEfq0wQd/GHA6GsoHWwhNq8anb0mleIw==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.0", + "get-stream": "^5.0.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^3.0.0", + "onetime": "^5.1.0", + "p-finally": "^2.0.0", + "signal-exit": "^3.0.2", + "strip-final-newline": "^2.0.0" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "get-stream": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.1.0.tgz", + "integrity": "sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", + "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", + "dev": true + }, + "micromatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", + "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", + "dev": true, + "requires": { + "braces": "^3.0.1", + "picomatch": "^2.0.5" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "npm-run-path": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-3.1.0.tgz", + "integrity": "sha512-Dbl4A/VfiVGLgQv29URL9xshU8XDY1GeLy+fsaZ1AA8JDSfjvr5P5+pzRbWqRSBxk6/DW7MIh8lTM/PaGnP2kg==", + "dev": true, + "requires": { + "path-key": "^3.0.0" + } + }, + "onetime": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "dev": true, + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "p-finally": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-2.0.1.tgz", + "integrity": "sha512-vpm09aKwq6H9phqRQzecoDpD8TmVyGw70qmWlyq5onxY7tqyTTFVvxMykxQSQKILBSFlbXpypIw2T1Ml7+DDtw==", + "dev": true + }, + "path-key": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.0.tgz", + "integrity": "sha512-8cChqz0RP6SHJkMt48FW0A7+qUOn+OsnOsVtzI59tZ8m+5bCSk7hzwET0pulwOM2YMn9J1efb07KB9l9f30SGg==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "which": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.1.tgz", + "integrity": "sha512-N7GBZOTswtB9lkQBZA4+zAXrjEIWAUOB93AvzUiudRzRxhUdLURQ7D/gAIMY1gatT/LTbmbcv8SiYazy3eYB7w==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "listr": { + "version": "0.14.3", + "resolved": "https://registry.npmjs.org/listr/-/listr-0.14.3.tgz", + "integrity": "sha512-RmAl7su35BFd/xoMamRjpIE4j3v+L28o8CT5YhAXQJm1fD+1l9ngXY8JAQRJ+tFK2i5njvi0iRUKV09vPwA0iA==", + "dev": true, + "requires": { + "@samverschueren/stream-to-observable": "^0.3.0", + "is-observable": "^1.1.0", + "is-promise": "^2.1.0", + "is-stream": "^1.1.0", + "listr-silent-renderer": "^1.1.1", + "listr-update-renderer": "^0.5.0", + "listr-verbose-renderer": "^0.5.0", + "p-map": "^2.0.0", + "rxjs": "^6.3.3" + }, + "dependencies": { + "p-map": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz", + "integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==", + "dev": true + } + } + }, + "listr-silent-renderer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/listr-silent-renderer/-/listr-silent-renderer-1.1.1.tgz", + "integrity": "sha1-kktaN1cVN3C/Go4/v3S4u/P5JC4=", + "dev": true + }, + "listr-update-renderer": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/listr-update-renderer/-/listr-update-renderer-0.5.0.tgz", + "integrity": "sha512-tKRsZpKz8GSGqoI/+caPmfrypiaq+OQCbd+CovEC24uk1h952lVj5sC7SqyFUm+OaJ5HN/a1YLt5cit2FMNsFA==", + "dev": true, + "requires": { + "chalk": "^1.1.3", + "cli-truncate": "^0.2.1", + "elegant-spinner": "^1.0.1", + "figures": "^1.7.0", + "indent-string": "^3.0.0", + "log-symbols": "^1.0.2", + "log-update": "^2.3.0", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5", + "object-assign": "^4.1.0" + } + }, + "indent-string": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", + "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", + "dev": true + }, + "log-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-1.0.2.tgz", + "integrity": "sha1-N2/3tY6jCGoPCfrMdGF+ylAeGhg=", + "dev": true, + "requires": { + "chalk": "^1.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "listr-verbose-renderer": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/listr-verbose-renderer/-/listr-verbose-renderer-0.5.0.tgz", + "integrity": "sha512-04PDPqSlsqIOaaaGZ+41vq5FejI9auqTInicFRndCBgE3bXG8D6W1I+mWhk+1nqbHmyhla/6BUrd5OSiHwKRXw==", + "dev": true, + "requires": { + "chalk": "^2.4.1", + "cli-cursor": "^2.1.0", + "date-fns": "^1.27.2", + "figures": "^2.0.0" + } + }, + "load-json-file": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^4.0.0", + "pify": "^3.0.0", + "strip-bom": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + }, + "lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", + "dev": true + }, + "log-symbols": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz", + "integrity": "sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==", + "dev": true, + "requires": { + "chalk": "^2.4.2" + } + }, + "log-update": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/log-update/-/log-update-2.3.0.tgz", + "integrity": "sha1-iDKP19HOeTiykoN0bwsbwSayRwg=", + "dev": true, + "requires": { + "ansi-escapes": "^3.0.0", + "cli-cursor": "^2.0.0", + "wrap-ansi": "^3.0.1" + }, + "dependencies": { + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "wrap-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-3.0.1.tgz", + "integrity": "sha1-KIoE2H7aXChuBg3+jxNc6NAH+Lo=", + "dev": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0" + } + } + } + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "make-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "dev": true, + "requires": { + "pify": "^4.0.1", + "semver": "^5.6.0" + }, + "dependencies": { + "pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "dev": true + } + } + }, + "makeerror": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.11.tgz", + "integrity": "sha1-4BpckQnyr3lmDk6LlYd5AYT1qWw=", + "dev": true, + "requires": { + "tmpl": "1.0.x" + } + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "^1.0.0" + } + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "merge2": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.3.0.tgz", + "integrity": "sha512-2j4DAdlBOkiSZIsaXk4mTE3sRS02yBHAtfy127xRV3bQUFqXkjHCHLW6Scv7DwNRbIWNHH8zpnz9zMaKXIdvYw==", + "dev": true + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", + "dev": true + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "dev": true, + "requires": { + "mime-db": "1.40.0" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + }, + "min-document": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", + "integrity": "sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=", + "requires": { + "dom-walk": "^0.1.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "mixin-deep": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", + "dev": true, + "requires": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + } + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "dev": true, + "optional": true + }, + "nanomatch": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + } + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "neo-async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", + "dev": true + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs=", + "dev": true + }, + "node-modules-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz", + "integrity": "sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=", + "dev": true + }, + "node-notifier": { + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.4.3.tgz", + "integrity": "sha512-M4UBGcs4jeOK9CjTsYwkvH6/MzuUmGCyTW+kCY7uO+1ZVr0+FHGdPdIf5CCLqAaxnRrWidyoQlNkMIIVwbKB8Q==", + "dev": true, + "requires": { + "growly": "^1.3.0", + "is-wsl": "^1.1.0", + "semver": "^5.5.0", + "shellwords": "^0.1.1", + "which": "^1.3.0" + } + }, + "node-releases": { + "version": "1.1.35", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.35.tgz", + "integrity": "sha512-JGcM/wndCN/2elJlU0IGdVEJQQnJwsLbgPCFd2pY7V0mxf17bZ0Gb/lgOtL29ZQhvEX5shnVhxQyZz3ex94N8w==", + "dev": true, + "requires": { + "semver": "^6.3.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "nwsapi": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.1.4.tgz", + "integrity": "sha512-iGfd9Y6SFdTNldEy2L0GUhcarIutFmk+MPWIn9dmj8NMIup03G08uUF2KGbbmv/Ux4RT0VZJoP/sVbWA6d/VIw==", + "dev": true + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "object-inspect": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", + "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", + "dev": true + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "^3.0.0" + } + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.getownpropertydescriptors": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", + "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.5.1" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "opencollective-postinstall": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.2.tgz", + "integrity": "sha512-pVOEP16TrAO2/fjej1IdOyupJY8KDUM1CvsaScRbw6oddvpQoOfGk4ywha0HKKVAD6RkW4x6Q+tNBwhf3Bgpuw==", + "dev": true + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "dev": true, + "requires": { + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" + }, + "dependencies": { + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + } + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + } + }, + "ora": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/ora/-/ora-4.0.2.tgz", + "integrity": "sha512-YUOZbamht5mfLxPmk4M35CD/5DuOkAacxlEUbStVXpBAt4fyhBf+vZHI/HRkI++QUp3sNoeA2Gw4C+hi4eGSig==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.2.0", + "is-interactive": "^1.0.0", + "log-symbols": "^3.0.0", + "strip-ansi": "^5.2.0", + "wcwidth": "^1.0.1" + }, + "dependencies": { + "cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dev": true, + "requires": { + "restore-cursor": "^3.1.0" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, + "onetime": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "dev": true, + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dev": true, + "requires": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + } + } + } + }, + "os-shim": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz", + "integrity": "sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=", + "dev": true + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "p-each-series": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-each-series/-/p-each-series-1.0.0.tgz", + "integrity": "sha1-kw89Et0fUOdDRFeiLNbwSsatf3E=", + "dev": true, + "requires": { + "p-reduce": "^1.0.0" + } + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true + }, + "p-limit": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-map": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", + "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", + "dev": true, + "requires": { + "aggregate-error": "^3.0.0" + } + }, + "p-reduce": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-reduce/-/p-reduce-1.0.0.tgz", + "integrity": "sha1-GMKw3ZNqRpClKfgjH1ig/bakffo=", + "dev": true + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, + "requires": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + } + }, + "parse5": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-4.0.0.tgz", + "integrity": "sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==", + "dev": true + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "dev": true, + "requires": { + "pify": "^3.0.0" + } + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "dev": true + }, + "picomatch": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.0.7.tgz", + "integrity": "sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA==", + "dev": true + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + }, + "pirates": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.1.tgz", + "integrity": "sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA==", + "dev": true, + "requires": { + "node-modules-regexp": "^1.0.0" + } + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + } + } + }, + "please-upgrade-node": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", + "integrity": "sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==", + "dev": true, + "requires": { + "semver-compare": "^1.0.0" + } + }, + "pn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz", + "integrity": "sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==", + "dev": true + }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true + }, + "pre-commit": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/pre-commit/-/pre-commit-1.2.2.tgz", + "integrity": "sha1-287g7p3nI15X95xW186UZBpp7sY=", + "dev": true, + "requires": { + "cross-spawn": "^5.0.1", + "spawn-sync": "^1.0.15", + "which": "1.2.x" + }, + "dependencies": { + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "which": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", + "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "pretty-format": { + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-24.9.0.tgz", + "integrity": "sha512-00ZMZUiHaJrNfk33guavqgvfJS30sLYf0f8+Srklv0AMPodGGHcoHgksZ3OThYnIvOd+8yMCn0YiEOogjlgsnA==", + "dev": true, + "requires": { + "@jest/types": "^24.9.0", + "ansi-regex": "^4.0.0", + "ansi-styles": "^3.2.0", + "react-is": "^16.8.4" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + } + } + }, + "private": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==", + "dev": true + }, + "process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, + "prompts": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.2.1.tgz", + "integrity": "sha512-VObPvJiWPhpZI6C5m60XOzTfnYg/xc/an+r9VYymj9WJW3B/DIH+REzjpAACPf8brwPeP+7vz3bIim3S+AaMjw==", + "dev": true, + "requires": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.3" + } + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, + "psl": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz", + "integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw==", + "dev": true + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "dev": true + }, + "react-is": { + "version": "16.10.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.10.2.tgz", + "integrity": "sha512-INBT1QEgtcCCgvccr5/86CfD71fw9EPmDxgiJX4I2Ddr6ZsV6iFXsuby+qWJPtmNuMY0zByTsG4468P7nHuNWA==", + "dev": true + }, + "read-pkg": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "dev": true, + "requires": { + "load-json-file": "^4.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^3.0.0" + } + }, + "read-pkg-up": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-4.0.0.tgz", + "integrity": "sha512-6etQSH7nJGsK0RbG/2TeDzZFa8shjQ1um+SwQQ5cwKy0dhSXdOncEhb1CPpvQG4h7FyOV6EB6YlV0yJvZQNAkA==", + "dev": true, + "requires": { + "find-up": "^3.0.0", + "read-pkg": "^3.0.0" + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "realpath-native": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/realpath-native/-/realpath-native-1.1.0.tgz", + "integrity": "sha512-wlgPA6cCIIg9gKz0fgAPjnzh4yR/LnXovwuo9hvyGvx3h8nX4+/iLZplfUWasXpqD8BdnGnP5njOFjkUwPzvjA==", + "dev": true, + "requires": { + "util.promisify": "^1.0.0" + } + }, + "regenerate": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", + "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==", + "dev": true + }, + "regenerate-unicode-properties": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz", + "integrity": "sha512-LGZzkgtLY79GeXLm8Dp0BVLdQlWICzBnJz/ipWUgo59qBaZ+BHtq51P2q1uVZlppMuUAT37SDk39qUbjTWB7bA==", + "dev": true, + "requires": { + "regenerate": "^1.4.0" + } + }, + "regenerator-transform": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.14.1.tgz", + "integrity": "sha512-flVuee02C3FKRISbxhXl9mGzdbWUVHubl1SMaknjxkFB1/iqpJhArQUvRxOOPEc/9tAiX0BaQ28FJH10E4isSQ==", + "dev": true, + "requires": { + "private": "^0.1.6" + } + }, + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.2", + "safe-regex": "^1.1.0" + } + }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true + }, + "regexpu-core": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.6.0.tgz", + "integrity": "sha512-YlVaefl8P5BnFYOITTNzDvan1ulLOiXJzCNZxduTIosN17b87h3bvG9yHMoHaRuo88H4mQ06Aodj5VtYGGGiTg==", + "dev": true, + "requires": { + "regenerate": "^1.4.0", + "regenerate-unicode-properties": "^8.1.0", + "regjsgen": "^0.5.0", + "regjsparser": "^0.6.0", + "unicode-match-property-ecmascript": "^1.0.4", + "unicode-match-property-value-ecmascript": "^1.1.0" + } + }, + "regjsgen": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.5.0.tgz", + "integrity": "sha512-RnIrLhrXCX5ow/E5/Mh2O4e/oa1/jW0eaBKTSy3LaCj+M3Bqvm97GWDp2yUtzIs4LEn65zR2yiYGFqb2ApnzDA==", + "dev": true + }, + "regjsparser": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.6.0.tgz", + "integrity": "sha512-RQ7YyokLiQBomUJuUG8iGVvkgOLxwyZM8k6d3q5SAXpg4r5TZJZigKFvC6PpD+qQ98bCDC5YelPeA3EucDoNeQ==", + "dev": true, + "requires": { + "jsesc": "~0.5.0" + }, + "dependencies": { + "jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", + "dev": true + } + } + }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, + "repeat-element": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "dev": true, + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + } + } + } + }, + "request-promise-core": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.2.tgz", + "integrity": "sha512-UHYyq1MO8GsefGEt7EprS8UrXsm1TxEvFUX1IMTuSLU2Rh7fTIdFtl8xD7JiEYiWU2dl+NYAjCTksTehQUxPag==", + "dev": true, + "requires": { + "lodash": "^4.17.11" + } + }, + "request-promise-native": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.7.tgz", + "integrity": "sha512-rIMnbBdgNViL37nZ1b3L/VfPOpSi0TqVDQPAvO6U14lMzOLrt5nilxCQqtDKhZeDiW0/hkCXGoQjhgJd/tCh6w==", + "dev": true, + "requires": { + "request-promise-core": "1.1.2", + "stealthy-require": "^1.1.1", + "tough-cookie": "^2.3.3" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "resolve": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-cwd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-2.0.0.tgz", + "integrity": "sha1-AKn3OHVW4nA46uIyyqNypqWbZlo=", + "dev": true, + "requires": { + "resolve-from": "^3.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", + "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", + "dev": true + } + } + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true + }, + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true + }, + "rimraf": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.0.tgz", + "integrity": "sha512-NDGVxTsjqfunkds7CqsOiEnxln4Bo7Nddl3XhS4pXg5OzwkLqJ971ZVAAnB+DDLnF76N+VnDEiBHaVV8I06SUg==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "rollup": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.22.0.tgz", + "integrity": "sha512-x4l4ZrV/Mr/x/jvFTmwROdEAhbZjx16yDRTVSKWh/i4oJDuW2dVEbECT853mybYCz7BAitU8ElGlhx7dNjw3qQ==", + "dev": true, + "requires": { + "@types/estree": "*", + "@types/node": "*", + "acorn": "^7.1.0" + } + }, + "rollup-plugin-node-resolve": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz", + "integrity": "sha512-jUlyaDXts7TW2CqQ4GaO5VJ4PwwaV8VUGA7+km3n6k6xtOEacf61u0VXwN80phY/evMcaS+9eIeJ9MOyDxt5Zw==", + "dev": true, + "requires": { + "@types/resolve": "0.0.8", + "builtin-modules": "^3.1.0", + "is-module": "^1.0.0", + "resolve": "^1.11.1", + "rollup-pluginutils": "^2.8.1" + } + }, + "rollup-pluginutils": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", + "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", + "dev": true, + "requires": { + "estree-walker": "^0.6.1" + } + }, + "rsvp": { + "version": "4.8.5", + "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", + "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", + "dev": true + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "^2.1.0" + } + }, + "run-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/run-node/-/run-node-1.0.0.tgz", + "integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==", + "dev": true + }, + "run-parallel": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", + "integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==", + "dev": true + }, + "rxjs": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz", + "integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "~0.1.10" + } + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "sane": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/sane/-/sane-4.1.0.tgz", + "integrity": "sha512-hhbzAgTIX8O7SHfp2c8/kREfEn4qO/9q8C9beyY6+tvZ87EpoZ3i1RIEvp27YBswnNbY9mWd6paKVmKbAgLfZA==", + "dev": true, + "requires": { + "@cnakazawa/watch": "^1.0.3", + "anymatch": "^2.0.0", + "capture-exit": "^2.0.0", + "exec-sh": "^0.3.2", + "execa": "^1.0.0", + "fb-watchman": "^2.0.0", + "micromatch": "^3.1.4", + "minimist": "^1.1.1", + "walker": "~1.0.5" + } + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "dev": true + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "semver-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=", + "dev": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "set-value": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "shellwords": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", + "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "sisteransi": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.3.tgz", + "integrity": "sha512-SbEG75TzH8G7eVXFSN5f9EExILKfly7SUvVY5DhhYLvfhKqhDFY0OzevWa/zwak0RLRfWS5AvfMWpd9gJvr5Yg==", + "dev": true + }, + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + }, + "slice-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", + "is-fullwidth-code-point": "^2.0.0" + } + }, + "snapdragon": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "dev": true, + "requires": { + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, + "requires": { + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "dev": true, + "requires": { + "kind-of": "^3.2.0" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "source-map-resolve": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "dev": true, + "requires": { + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } + }, + "source-map-support": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + }, + "spawn-sync": { + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/spawn-sync/-/spawn-sync-1.0.15.tgz", + "integrity": "sha1-sAeZVX63+wyDdsKdROih6mfldHY=", + "dev": true, + "requires": { + "concat-stream": "^1.4.7", + "os-shim": "^0.1.2" + } + }, + "spdx-correct": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", + "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", + "dev": true + }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.0" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "dev": true, + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "stack-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-1.0.2.tgz", + "integrity": "sha512-MTX+MeG5U994cazkjd/9KNAapsHnibjMLnfXodlkXw76JEea0UiNzrqidzo1emMwk7w5Qhc9jd4Bn9TBb1MFwA==", + "dev": true + }, + "static-extend": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "requires": { + "define-property": "^0.2.5", + "object-copy": "^0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "stealthy-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", + "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", + "dev": true + }, + "string-argv": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", + "integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==", + "dev": true + }, + "string-length": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/string-length/-/string-length-2.0.0.tgz", + "integrity": "sha1-1A27aGo6zpYMHP/KVivyxF+DY+0=", + "dev": true, + "requires": { + "astral-regex": "^1.0.0", + "strip-ansi": "^4.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "string.prototype.trimleft": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz", + "integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string.prototype.trimright": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz", + "integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "stringify-object": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz", + "integrity": "sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==", + "dev": true, + "requires": { + "get-own-enumerable-property-symbols": "^3.0.0", + "is-obj": "^1.0.1", + "is-regexp": "^1.0.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + } + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true + }, + "strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true + }, + "strip-json-comments": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", + "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "symbol-observable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", + "dev": true + }, + "symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", + "dev": true + }, + "table": { + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", + "dev": true, + "requires": { + "ajv": "^6.10.2", + "lodash": "^4.17.14", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" + }, + "dependencies": { + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + } + } + }, + "terser": { + "version": "4.3.8", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.3.8.tgz", + "integrity": "sha512-otmIRlRVmLChAWsnSFNO0Bfk6YySuBp6G9qrHiJwlLDd4mxe2ta4sjI7TzIR+W1nBMjilzrMcPOz9pSusgx3hQ==", + "dev": true, + "requires": { + "commander": "^2.20.0", + "source-map": "~0.6.1", + "source-map-support": "~0.5.12" + } + }, + "test-exclude": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-5.2.3.tgz", + "integrity": "sha512-M+oxtseCFO3EDtAaGH7iiej3CBkzXqFMbzqYAACdzKui4eZA+pq3tZEwChvOdNfa7xxy8BfbmgJSIr43cC/+2g==", + "dev": true, + "requires": { + "glob": "^7.1.3", + "minimatch": "^3.0.4", + "read-pkg-up": "^4.0.0", + "require-main-filename": "^2.0.0" + } + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "throat": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/throat/-/throat-4.1.0.tgz", + "integrity": "sha1-iQN8vJLFarGJJua6TLsgDhVnKmo=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "~1.0.2" + } + }, + "tmpl": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz", + "integrity": "sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE=", + "dev": true + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + }, + "to-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "dev": true, + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + }, + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "dev": true, + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + }, + "tr46": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", + "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "tslib": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "dev": true + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "uglify-js": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.1.tgz", + "integrity": "sha512-+dSJLJpXBb6oMHP+Yvw8hUgElz4gLTh82XuX68QiJVTXaE5ibl6buzhNkQdYhBlIhozWOC9ge16wyRmjG4TwVQ==", + "dev": true, + "optional": true, + "requires": { + "commander": "2.20.0", + "source-map": "~0.6.1" + } + }, + "unicode-canonical-property-names-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", + "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==", + "dev": true + }, + "unicode-match-property-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz", + "integrity": "sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg==", + "dev": true, + "requires": { + "unicode-canonical-property-names-ecmascript": "^1.0.4", + "unicode-property-aliases-ecmascript": "^1.0.4" + } + }, + "unicode-match-property-value-ecmascript": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.1.0.tgz", + "integrity": "sha512-hDTHvaBk3RmFzvSl0UVrUmC3PuW9wKVnpoUDYH0JDkSIovzw+J5viQmeYHxVSBptubnr7PbH2e0fnpDRQnQl5g==", + "dev": true + }, + "unicode-property-aliases-ecmascript": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.5.tgz", + "integrity": "sha512-L5RAqCfXqAwR3RriF8pM0lU0w4Ryf/GgzONwi6KnL1taJQa7x1TCxdJnILX59WIGOwR57IVxn7Nej0fz1Ny6fw==", + "dev": true + }, + "union-value": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^2.0.1" + } + }, + "unset-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "^0.3.1", + "isobject": "^3.0.0" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + } + } + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "dev": true + }, + "use": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", + "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "util.promisify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz", + "integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "object.getownpropertydescriptors": "^2.0.3" + } + }, + "uuid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", + "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==", + "dev": true + }, + "v8-compile-cache": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", + "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", + "dev": true + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "w3c-hr-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz", + "integrity": "sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=", + "dev": true, + "requires": { + "browser-process-hrtime": "^0.1.2" + } + }, + "walker": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.7.tgz", + "integrity": "sha1-L3+bj9ENZ3JisYqITijRlhjgKPs=", + "dev": true, + "requires": { + "makeerror": "1.0.x" + } + }, + "wcwidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", + "integrity": "sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=", + "dev": true, + "requires": { + "defaults": "^1.0.3" + } + }, + "webidl-conversions": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", + "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", + "dev": true + }, + "whatwg-encoding": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", + "integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==", + "dev": true, + "requires": { + "iconv-lite": "0.4.24" + } + }, + "whatwg-mimetype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz", + "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==", + "dev": true + }, + "whatwg-url": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-6.5.0.tgz", + "integrity": "sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ==", + "dev": true, + "requires": { + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.1", + "webidl-conversions": "^4.0.2" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "dependencies": { + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, + "write-file-atomic": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.1.tgz", + "integrity": "sha512-TGHFeZEZMnv+gBFRfjAcxL5bPHrsGKtnb4qsFAws7/vlh+QfwAaySIw4AXP9ZskTTh5GWu3FLuJhsWVdiJPGvg==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + }, + "ws": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz", + "integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==", + "dev": true, + "requires": { + "async-limiter": "~1.0.0" + } + }, + "xml-name-validator": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", + "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", + "dev": true + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + }, + "yargs": { + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", + "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.1" + }, + "dependencies": { + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + } + } + }, + "yargs-parser": { + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", + "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "zlib": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/zlib/-/zlib-1.0.5.tgz", + "integrity": "sha1-bnyXL8NxxkWmr7A6sUdp3vEU/MA=", + "dev": true + } + } +} diff --git a/package.json b/package.json index ef49d55..6fa8c56 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,27 @@ { "name": "crypto-js", - "title": "crypto-js", - "description": "JavaScript library of crypto standards.", "version": "3.1.9", - "homepage": "http://github.com/brix/crypto-js", + "description": "JavaScript library of crypto standards.", + "main": "index.js", + "scripts": { + "build": "npm run clean && node build/build.js", + "clean": "rimraf lib", + "test": "jest", + "coverage": "jest --coverage", + "lint": "eslint src test", + "lint-fix": "eslint --fix src test" + }, + "lint-staged": { + "*.js": [ + "eslint --fix", + "git add" + ] + }, + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, "author": { "name": "Evan Vosberg", "url": "http://github.com/evanvosberg" @@ -15,24 +33,10 @@ "bugs": { "url": "http://github.com/brix/crypto-js/issues" }, - "license": "MIT", - "scripts": { - "build": "grunt build", - "test": "grunt default" - }, - "main": "index.js", - "dependencies": {}, - "devDependencies": { - "fmd": "~0.0.3", - "grunt": "^0.4.5", - "grunt-contrib-clean": "^0.6.0", - "grunt-contrib-copy": "^0.6.0", - "grunt-contrib-jshint": "^0.10.0", - "grunt-jsonlint": "^1.0.4", - "grunt-update-json": "^0.2.0", - "load-grunt-config": "^0.16.0", - "lodash": "^4.17.11" + "jest": { + "jestRegex": "(/test/.*\\.(test|spec)\\.js)$" }, + "license": "MIT", "keywords": [ "security", "crypto", @@ -53,5 +57,26 @@ "CTR", "CBC", "Base64" - ] + ], + "devDependencies": { + "@babel/core": "^7.6.3", + "@babel/plugin-transform-modules-commonjs": "^7.6.0", + "@babel/preset-env": "^7.6.3", + "babel-eslint": "^10.0.3", + "babel-jest": "^24.9.0", + "chalk": "^2.4.2", + "eslint": "^6.5.1", + "husky": "^3.0.8", + "jest": "^24.9.0", + "lint-staged": "^9.4.2", + "ora": "^4.0.2", + "pre-commit": "^1.2.2", + "rimraf": "^3.0.0", + "rollup": "1.22.0", + "terser": "^4.3.8", + "zlib": "^1.0.5" + }, + "dependencies": { + "global": "^4.4.0" + } } diff --git a/src/aes.js b/src/aes.js deleted file mode 100644 index 2d033c0..0000000 --- a/src/aes.js +++ /dev/null @@ -1,214 +0,0 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var BlockCipher = C_lib.BlockCipher; - var C_algo = C.algo; - - // Lookup tables - var SBOX = []; - var INV_SBOX = []; - var SUB_MIX_0 = []; - var SUB_MIX_1 = []; - var SUB_MIX_2 = []; - var SUB_MIX_3 = []; - var INV_SUB_MIX_0 = []; - var INV_SUB_MIX_1 = []; - var INV_SUB_MIX_2 = []; - var INV_SUB_MIX_3 = []; - - // Compute lookup tables - (function () { - // Compute double table - var d = []; - for (var i = 0; i < 256; i++) { - if (i < 128) { - d[i] = i << 1; - } else { - d[i] = (i << 1) ^ 0x11b; - } - } - - // Walk GF(2^8) - var x = 0; - var xi = 0; - for (var i = 0; i < 256; i++) { - // Compute sbox - var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4); - sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63; - SBOX[x] = sx; - INV_SBOX[sx] = x; - - // Compute multiplication - var x2 = d[x]; - var x4 = d[x2]; - var x8 = d[x4]; - - // Compute sub bytes, mix columns tables - var t = (d[sx] * 0x101) ^ (sx * 0x1010100); - SUB_MIX_0[x] = (t << 24) | (t >>> 8); - SUB_MIX_1[x] = (t << 16) | (t >>> 16); - SUB_MIX_2[x] = (t << 8) | (t >>> 24); - SUB_MIX_3[x] = t; - - // Compute inv sub bytes, inv mix columns tables - var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100); - INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8); - INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16); - INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24); - INV_SUB_MIX_3[sx] = t; - - // Compute next counter - if (!x) { - x = xi = 1; - } else { - x = x2 ^ d[d[d[x8 ^ x2]]]; - xi ^= d[d[xi]]; - } - } - }()); - - // Precomputed Rcon lookup - var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]; - - /** - * AES block cipher algorithm. - */ - var AES = C_algo.AES = BlockCipher.extend({ - _doReset: function () { - var t; - - // Skip reset of nRounds has been set before and key did not change - if (this._nRounds && this._keyPriorReset === this._key) { - return; - } - - // Shortcuts - var key = this._keyPriorReset = this._key; - var keyWords = key.words; - var keySize = key.sigBytes / 4; - - // Compute number of rounds - var nRounds = this._nRounds = keySize + 6; - - // Compute number of key schedule rows - var ksRows = (nRounds + 1) * 4; - - // Compute key schedule - var keySchedule = this._keySchedule = []; - for (var ksRow = 0; ksRow < ksRows; ksRow++) { - if (ksRow < keySize) { - keySchedule[ksRow] = keyWords[ksRow]; - } else { - t = keySchedule[ksRow - 1]; - - if (!(ksRow % keySize)) { - // Rot word - t = (t << 8) | (t >>> 24); - - // Sub word - t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; - - // Mix Rcon - t ^= RCON[(ksRow / keySize) | 0] << 24; - } else if (keySize > 6 && ksRow % keySize == 4) { - // Sub word - t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; - } - - keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; - } - } - - // Compute inv key schedule - var invKeySchedule = this._invKeySchedule = []; - for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { - var ksRow = ksRows - invKsRow; - - if (invKsRow % 4) { - var t = keySchedule[ksRow]; - } else { - var t = keySchedule[ksRow - 4]; - } - - if (invKsRow < 4 || ksRow <= 4) { - invKeySchedule[invKsRow] = t; - } else { - invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^ - INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]]; - } - } - }, - - encryptBlock: function (M, offset) { - this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); - }, - - decryptBlock: function (M, offset) { - // Swap 2nd and 4th rows - var t = M[offset + 1]; - M[offset + 1] = M[offset + 3]; - M[offset + 3] = t; - - this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); - - // Inv swap 2nd and 4th rows - var t = M[offset + 1]; - M[offset + 1] = M[offset + 3]; - M[offset + 3] = t; - }, - - _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) { - // Shortcut - var nRounds = this._nRounds; - - // Get input, add round key - var s0 = M[offset] ^ keySchedule[0]; - var s1 = M[offset + 1] ^ keySchedule[1]; - var s2 = M[offset + 2] ^ keySchedule[2]; - var s3 = M[offset + 3] ^ keySchedule[3]; - - // Key schedule row counter - var ksRow = 4; - - // Rounds - for (var round = 1; round < nRounds; round++) { - // Shift rows, sub bytes, mix columns, add round key - var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++]; - var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++]; - var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++]; - var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++]; - - // Update state - s0 = t0; - s1 = t1; - s2 = t2; - s3 = t3; - } - - // Shift rows, sub bytes, add round key - var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]; - var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]; - var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]; - var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]; - - // Set output - M[offset] = t0; - M[offset + 1] = t1; - M[offset + 2] = t2; - M[offset + 3] = t3; - }, - - keySize: 256/32 - }); - - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg); - * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg); - */ - C.AES = BlockCipher._createHelper(AES); -}()); diff --git a/src/cipher-core.js b/src/cipher-core.js index 0fe6136..85e910a 100644 --- a/src/cipher-core.js +++ b/src/cipher-core.js @@ -1,872 +1,907 @@ -/** - * Cipher core components. - */ -CryptoJS.lib.Cipher || (function (undefined) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var WordArray = C_lib.WordArray; - var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm; - var C_enc = C.enc; - var Utf8 = C_enc.Utf8; - var Base64 = C_enc.Base64; - var C_algo = C.algo; - var EvpKDF = C_algo.EvpKDF; - - /** - * Abstract base cipher template. - * - * @property {number} keySize This cipher's key size. Default: 4 (128 bits) - * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits) - * @property {number} _ENC_XFORM_MODE A constant representing encryption mode. - * @property {number} _DEC_XFORM_MODE A constant representing decryption mode. - */ - var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({ - /** - * Configuration options. - * - * @property {WordArray} iv The IV to use for this operation. - */ - cfg: Base.extend(), - - /** - * Creates this cipher in encryption mode. - * - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {Cipher} A cipher instance. - * - * @static - * - * @example - * - * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); - */ - createEncryptor: function (key, cfg) { - return this.create(this._ENC_XFORM_MODE, key, cfg); - }, - - /** - * Creates this cipher in decryption mode. - * - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {Cipher} A cipher instance. - * - * @static - * - * @example - * - * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); - */ - createDecryptor: function (key, cfg) { - return this.create(this._DEC_XFORM_MODE, key, cfg); - }, - - /** - * Initializes a newly created cipher. - * - * @param {number} xformMode Either the encryption or decryption transormation mode constant. - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @example - * - * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); - */ - init: function (xformMode, key, cfg) { - // Apply config defaults - this.cfg = this.cfg.extend(cfg); - - // Store transform mode and key - this._xformMode = xformMode; - this._key = key; - - // Set initial values - this.reset(); - }, - - /** - * Resets this cipher to its initial state. - * - * @example - * - * cipher.reset(); - */ - reset: function () { - // Reset data buffer - BufferedBlockAlgorithm.reset.call(this); - - // Perform concrete-cipher logic - this._doReset(); - }, - - /** - * Adds data to be encrypted or decrypted. - * - * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. - * - * @return {WordArray} The data after processing. - * - * @example - * - * var encrypted = cipher.process('data'); - * var encrypted = cipher.process(wordArray); - */ - process: function (dataUpdate) { - // Append - this._append(dataUpdate); - - // Process available blocks - return this._process(); - }, - - /** - * Finalizes the encryption or decryption process. - * Note that the finalize operation is effectively a destructive, read-once operation. - * - * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. - * - * @return {WordArray} The data after final processing. - * - * @example - * - * var encrypted = cipher.finalize(); - * var encrypted = cipher.finalize('data'); - * var encrypted = cipher.finalize(wordArray); - */ - finalize: function (dataUpdate) { - // Final data update - if (dataUpdate) { - this._append(dataUpdate); - } - - // Perform concrete-cipher logic - var finalProcessedData = this._doFinalize(); - - return finalProcessedData; - }, - - keySize: 128/32, - - ivSize: 128/32, - - _ENC_XFORM_MODE: 1, - - _DEC_XFORM_MODE: 2, - - /** - * Creates shortcut functions to a cipher's object interface. - * - * @param {Cipher} cipher The cipher to create a helper for. - * - * @return {Object} An object with encrypt and decrypt shortcut functions. - * - * @static - * - * @example - * - * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); - */ - _createHelper: (function () { - function selectCipherStrategy(key) { - if (typeof key == 'string') { - return PasswordBasedCipher; - } else { - return SerializableCipher; - } - } - - return function (cipher) { - return { - encrypt: function (message, key, cfg) { - return selectCipherStrategy(key).encrypt(cipher, message, key, cfg); - }, - - decrypt: function (ciphertext, key, cfg) { - return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); - } - }; - }; - }()) - }); - - /** - * Abstract base stream cipher template. - * - * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits) - */ - var StreamCipher = C_lib.StreamCipher = Cipher.extend({ - _doFinalize: function () { - // Process partial blocks - var finalProcessedBlocks = this._process(!!'flush'); - - return finalProcessedBlocks; - }, - - blockSize: 1 - }); - - /** - * Mode namespace. - */ - var C_mode = C.mode = {}; - - /** - * Abstract base block cipher mode template. - */ - var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({ - /** - * Creates this mode for encryption. - * - * @param {Cipher} cipher A block cipher instance. - * @param {Array} iv The IV words. - * - * @static - * - * @example - * - * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); - */ - createEncryptor: function (cipher, iv) { - return this.Encryptor.create(cipher, iv); - }, - - /** - * Creates this mode for decryption. - * - * @param {Cipher} cipher A block cipher instance. - * @param {Array} iv The IV words. - * - * @static - * - * @example - * - * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); - */ - createDecryptor: function (cipher, iv) { - return this.Decryptor.create(cipher, iv); - }, - - /** - * Initializes a newly created mode. - * - * @param {Cipher} cipher A block cipher instance. - * @param {Array} iv The IV words. - * - * @example - * - * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); - */ - init: function (cipher, iv) { - this._cipher = cipher; - this._iv = iv; - } - }); - - /** - * Cipher Block Chaining mode. - */ - var CBC = C_mode.CBC = (function () { - /** - * Abstract base CBC mode. - */ - var CBC = BlockCipherMode.extend(); - - /** - * CBC encryptor. - */ - CBC.Encryptor = CBC.extend({ - /** - * Processes the data block at offset. - * - * @param {Array} words The data words to operate on. - * @param {number} offset The offset where the block starts. - * - * @example - * - * mode.processBlock(data.words, offset); - */ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher; - var blockSize = cipher.blockSize; - - // XOR and encrypt - xorBlock.call(this, words, offset, blockSize); - cipher.encryptBlock(words, offset); - - // Remember this block to use with next block - this._prevBlock = words.slice(offset, offset + blockSize); - } - }); - - /** - * CBC decryptor. - */ - CBC.Decryptor = CBC.extend({ - /** - * Processes the data block at offset. - * - * @param {Array} words The data words to operate on. - * @param {number} offset The offset where the block starts. - * - * @example - * - * mode.processBlock(data.words, offset); - */ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher; - var blockSize = cipher.blockSize; - - // Remember this block to use with next block - var thisBlock = words.slice(offset, offset + blockSize); - - // Decrypt and XOR - cipher.decryptBlock(words, offset); - xorBlock.call(this, words, offset, blockSize); - - // This block becomes the previous block - this._prevBlock = thisBlock; - } - }); - - function xorBlock(words, offset, blockSize) { - var block; - - // Shortcut - var iv = this._iv; - - // Choose mixing block - if (iv) { - block = iv; - - // Remove IV for subsequent blocks - this._iv = undefined; - } else { - block = this._prevBlock; - } - - // XOR blocks - for (var i = 0; i < blockSize; i++) { - words[offset + i] ^= block[i]; - } - } - - return CBC; - }()); - - /** - * Padding namespace. - */ - var C_pad = C.pad = {}; - - /** - * PKCS #5/7 padding strategy. - */ - var Pkcs7 = C_pad.Pkcs7 = { - /** - * Pads data using the algorithm defined in PKCS #5/7. - * - * @param {WordArray} data The data to pad. - * @param {number} blockSize The multiple that the data should be padded to. - * - * @static - * - * @example - * - * CryptoJS.pad.Pkcs7.pad(wordArray, 4); - */ - pad: function (data, blockSize) { - // Shortcut - var blockSizeBytes = blockSize * 4; - - // Count padding bytes - var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; - - // Create padding word - var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes; - - // Create padding - var paddingWords = []; - for (var i = 0; i < nPaddingBytes; i += 4) { - paddingWords.push(paddingWord); - } - var padding = WordArray.create(paddingWords, nPaddingBytes); - - // Add padding - data.concat(padding); - }, - - /** - * Unpads data that had been padded using the algorithm defined in PKCS #5/7. - * - * @param {WordArray} data The data to unpad. - * - * @static - * - * @example - * - * CryptoJS.pad.Pkcs7.unpad(wordArray); - */ - unpad: function (data) { - // Get number of padding bytes from last byte - var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; - - // Remove padding - data.sigBytes -= nPaddingBytes; - } - }; - - /** - * Abstract base block cipher template. - * - * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits) - */ - var BlockCipher = C_lib.BlockCipher = Cipher.extend({ - /** - * Configuration options. - * - * @property {Mode} mode The block mode to use. Default: CBC - * @property {Padding} padding The padding strategy to use. Default: Pkcs7 - */ - cfg: Cipher.cfg.extend({ - mode: CBC, - padding: Pkcs7 - }), - - reset: function () { - var modeCreator; - - // Reset cipher - Cipher.reset.call(this); - - // Shortcuts - var cfg = this.cfg; - var iv = cfg.iv; - var mode = cfg.mode; - - // Reset block mode - if (this._xformMode == this._ENC_XFORM_MODE) { - modeCreator = mode.createEncryptor; - } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { - modeCreator = mode.createDecryptor; - // Keep at least one block in the buffer for unpadding - this._minBufferSize = 1; - } - - if (this._mode && this._mode.__creator == modeCreator) { - this._mode.init(this, iv && iv.words); - } else { - this._mode = modeCreator.call(mode, this, iv && iv.words); - this._mode.__creator = modeCreator; - } - }, - - _doProcessBlock: function (words, offset) { - this._mode.processBlock(words, offset); - }, - - _doFinalize: function () { - var finalProcessedBlocks; - - // Shortcut - var padding = this.cfg.padding; - - // Finalize - if (this._xformMode == this._ENC_XFORM_MODE) { - // Pad data - padding.pad(this._data, this.blockSize); - - // Process final blocks - finalProcessedBlocks = this._process(!!'flush'); - } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { - // Process final blocks - finalProcessedBlocks = this._process(!!'flush'); - - // Unpad data - padding.unpad(finalProcessedBlocks); - } - - return finalProcessedBlocks; - }, - - blockSize: 128/32 - }); - - /** - * A collection of cipher parameters. - * - * @property {WordArray} ciphertext The raw ciphertext. - * @property {WordArray} key The key to this ciphertext. - * @property {WordArray} iv The IV used in the ciphering operation. - * @property {WordArray} salt The salt used with a key derivation function. - * @property {Cipher} algorithm The cipher algorithm. - * @property {Mode} mode The block mode used in the ciphering operation. - * @property {Padding} padding The padding scheme used in the ciphering operation. - * @property {number} blockSize The block size of the cipher. - * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string. - */ - var CipherParams = C_lib.CipherParams = Base.extend({ - /** - * Initializes a newly created cipher params object. - * - * @param {Object} cipherParams An object with any of the possible cipher parameters. - * - * @example - * - * var cipherParams = CryptoJS.lib.CipherParams.create({ - * ciphertext: ciphertextWordArray, - * key: keyWordArray, - * iv: ivWordArray, - * salt: saltWordArray, - * algorithm: CryptoJS.algo.AES, - * mode: CryptoJS.mode.CBC, - * padding: CryptoJS.pad.PKCS7, - * blockSize: 4, - * formatter: CryptoJS.format.OpenSSL - * }); - */ - init: function (cipherParams) { - this.mixIn(cipherParams); - }, - - /** - * Converts this cipher params object to a string. - * - * @param {Format} formatter (Optional) The formatting strategy to use. - * - * @return {string} The stringified cipher params. - * - * @throws Error If neither the formatter nor the default formatter is set. - * - * @example - * - * var string = cipherParams + ''; - * var string = cipherParams.toString(); - * var string = cipherParams.toString(CryptoJS.format.OpenSSL); - */ - toString: function (formatter) { - return (formatter || this.formatter).stringify(this); - } - }); - - /** - * Format namespace. - */ - var C_format = C.format = {}; - - /** - * OpenSSL formatting strategy. - */ - var OpenSSLFormatter = C_format.OpenSSL = { - /** - * Converts a cipher params object to an OpenSSL-compatible string. - * - * @param {CipherParams} cipherParams The cipher params object. - * - * @return {string} The OpenSSL-compatible string. - * - * @static - * - * @example - * - * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); - */ - stringify: function (cipherParams) { - var wordArray; - - // Shortcuts - var ciphertext = cipherParams.ciphertext; - var salt = cipherParams.salt; - - // Format - if (salt) { - wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); - } else { - wordArray = ciphertext; - } - - return wordArray.toString(Base64); - }, - - /** - * Converts an OpenSSL-compatible string to a cipher params object. - * - * @param {string} openSSLStr The OpenSSL-compatible string. - * - * @return {CipherParams} The cipher params object. - * - * @static - * - * @example - * - * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); - */ - parse: function (openSSLStr) { - var salt; - - // Parse base64 - var ciphertext = Base64.parse(openSSLStr); - - // Shortcut - var ciphertextWords = ciphertext.words; - - // Test for salt - if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) { - // Extract salt - salt = WordArray.create(ciphertextWords.slice(2, 4)); - - // Remove salt from ciphertext - ciphertextWords.splice(0, 4); - ciphertext.sigBytes -= 16; - } - - return CipherParams.create({ ciphertext: ciphertext, salt: salt }); - } - }; - - /** - * A cipher wrapper that returns ciphertext as a serializable cipher params object. - */ - var SerializableCipher = C_lib.SerializableCipher = Base.extend({ - /** - * Configuration options. - * - * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL - */ - cfg: Base.extend({ - format: OpenSSLFormatter - }), - - /** - * Encrypts a message. - * - * @param {Cipher} cipher The cipher algorithm to use. - * @param {WordArray|string} message The message to encrypt. - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {CipherParams} A cipher params object. - * - * @static - * - * @example - * - * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); - * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); - * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); - */ - encrypt: function (cipher, message, key, cfg) { - // Apply config defaults - cfg = this.cfg.extend(cfg); - - // Encrypt - var encryptor = cipher.createEncryptor(key, cfg); - var ciphertext = encryptor.finalize(message); - - // Shortcut - var cipherCfg = encryptor.cfg; - - // Create and return serializable cipher params - return CipherParams.create({ - ciphertext: ciphertext, - key: key, - iv: cipherCfg.iv, - algorithm: cipher, - mode: cipherCfg.mode, - padding: cipherCfg.padding, - blockSize: cipher.blockSize, - formatter: cfg.format - }); - }, - - /** - * Decrypts serialized ciphertext. - * - * @param {Cipher} cipher The cipher algorithm to use. - * @param {CipherParams|string} ciphertext The ciphertext to decrypt. - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {WordArray} The plaintext. - * - * @static - * - * @example - * - * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); - * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); - */ - decrypt: function (cipher, ciphertext, key, cfg) { - // Apply config defaults - cfg = this.cfg.extend(cfg); - - // Convert string to CipherParams - ciphertext = this._parse(ciphertext, cfg.format); - - // Decrypt - var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext); - - return plaintext; - }, - - /** - * Converts serialized ciphertext to CipherParams, - * else assumed CipherParams already and returns ciphertext unchanged. - * - * @param {CipherParams|string} ciphertext The ciphertext. - * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. - * - * @return {CipherParams} The unserialized ciphertext. - * - * @static - * - * @example - * - * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format); - */ - _parse: function (ciphertext, format) { - if (typeof ciphertext == 'string') { - return format.parse(ciphertext, this); - } else { - return ciphertext; - } - } - }); - - /** - * Key derivation function namespace. - */ - var C_kdf = C.kdf = {}; - - /** - * OpenSSL key derivation function. - */ - var OpenSSLKdf = C_kdf.OpenSSL = { - /** - * Derives a key and IV from a password. - * - * @param {string} password The password to derive from. - * @param {number} keySize The size in words of the key to generate. - * @param {number} ivSize The size in words of the IV to generate. - * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. - * - * @return {CipherParams} A cipher params object with the key, IV, and salt. - * - * @static - * - * @example - * - * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); - * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); - */ - execute: function (password, keySize, ivSize, salt) { - // Generate random salt - if (!salt) { - salt = WordArray.random(64/8); - } - - // Derive key and IV - var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt); - - // Separate key and IV - var iv = WordArray.create(key.words.slice(keySize), ivSize * 4); - key.sigBytes = keySize * 4; - - // Return params - return CipherParams.create({ key: key, iv: iv, salt: salt }); - } - }; - - /** - * A serializable cipher wrapper that derives the key from a password, - * and returns ciphertext as a serializable cipher params object. - */ - var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({ - /** - * Configuration options. - * - * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL - */ - cfg: SerializableCipher.cfg.extend({ - kdf: OpenSSLKdf - }), - - /** - * Encrypts a message using a password. - * - * @param {Cipher} cipher The cipher algorithm to use. - * @param {WordArray|string} message The message to encrypt. - * @param {string} password The password. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {CipherParams} A cipher params object. - * - * @static - * - * @example - * - * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password'); - * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); - */ - encrypt: function (cipher, message, password, cfg) { - // Apply config defaults - cfg = this.cfg.extend(cfg); - - // Derive key and other params - var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize); - - // Add IV to config - cfg.iv = derivedParams.iv; - - // Encrypt - var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg); - - // Mix in derived params - ciphertext.mixIn(derivedParams); - - return ciphertext; - }, - - /** - * Decrypts serialized ciphertext using a password. - * - * @param {Cipher} cipher The cipher algorithm to use. - * @param {CipherParams|string} ciphertext The ciphertext to decrypt. - * @param {string} password The password. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {WordArray} The plaintext. - * - * @static - * - * @example - * - * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL }); - * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL }); - */ - decrypt: function (cipher, ciphertext, password, cfg) { - // Apply config defaults - cfg = this.cfg.extend(cfg); - - // Convert string to CipherParams - ciphertext = this._parse(ciphertext, cfg.format); - - // Derive key and other params - var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt); - - // Add IV to config - cfg.iv = derivedParams.iv; - - // Decrypt - var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg); - - return plaintext; - } - }); -}()); +/* eslint-disable no-use-before-define */ + +import { + Base, + WordArray, + BufferedBlockAlgorithm +} from './core.js'; +import { + Base64 +} from './enc-base64.js'; +import { + EvpKDFAlgo +} from './evpkdf.js'; + +/** + * Abstract base cipher template. + * + * @property {number} keySize This cipher's key size. Default: 4 (128 bits) + * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits) + * @property {number} _ENC_XFORM_MODE A constant representing encryption mode. + * @property {number} _DEC_XFORM_MODE A constant representing decryption mode. + */ +export class Cipher extends BufferedBlockAlgorithm { + /** + * Initializes a newly created cipher. + * + * @param {number} xformMode Either the encryption or decryption transormation mode constant. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @example + * + * const cipher = CryptoJS.algo.AES.create( + * CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray } + * ); + */ + constructor(xformMode, key, cfg) { + super(); + + this.keySize = 128 / 32; + this.ivSize = 128 / 32; + + /** + * Configuration options. + * + * @property {WordArray} iv The IV to use for this operation. + */ + this.cfg = Object.assign(new Base(), cfg); + + // Store transform mode and key + this._xformMode = xformMode; + this._key = key; + + // Set initial values + this.reset(); + } + + /** + * Creates this cipher in encryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * const cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); + */ + static createEncryptor(key, cfg) { + return this.create(this._ENC_XFORM_MODE, key, cfg); + } + + /** + * Creates this cipher in decryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * const cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); + */ + static createDecryptor(key, cfg) { + return this.create(this._DEC_XFORM_MODE, key, cfg); + } + + /** + * Creates shortcut functions to a cipher's object interface. + * + * @param {Cipher} cipher The cipher to create a helper for. + * + * @return {Object} An object with encrypt and decrypt shortcut functions. + * + * @static + * + * @example + * + * const AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); + */ + static _createHelper(SubCipher) { + const selectCipherStrategy = (key) => { + if (typeof key === 'string') { + return PasswordBasedCipher; + } + return SerializableCipher; + }; + + return { + encrypt(message, key, cfg) { + return selectCipherStrategy(key).encrypt(SubCipher, message, key, cfg); + }, + + decrypt(ciphertext, key, cfg) { + return selectCipherStrategy(key).decrypt(SubCipher, ciphertext, key, cfg); + } + }; + } + + /** + * Resets this cipher to its initial state. + * + * @example + * + * cipher.reset(); + */ + reset() { + // Reset data buffer + super.reset.call(this); + + // Perform concrete-cipher logic + this._doReset(); + } + + /** + * Adds data to be encrypted or decrypted. + * + * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. + * + * @return {WordArray} The data after processing. + * + * @example + * + * const encrypted = cipher.process('data'); + * const encrypted = cipher.process(wordArray); + */ + process(dataUpdate) { + // Append + this._append(dataUpdate); + + // Process available blocks + return this._process(); + } + + /** + * Finalizes the encryption or decryption process. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. + * + * @return {WordArray} The data after final processing. + * + * @example + * + * const encrypted = cipher.finalize(); + * const encrypted = cipher.finalize('data'); + * const encrypted = cipher.finalize(wordArray); + */ + finalize(dataUpdate) { + // Final data update + if (dataUpdate) { + this._append(dataUpdate); + } + + // Perform concrete-cipher logic + const finalProcessedData = this._doFinalize(); + + return finalProcessedData; + } +} +Cipher._ENC_XFORM_MODE = 1; +Cipher._DEC_XFORM_MODE = 2; + +/** + * Abstract base stream cipher template. + * + * @property {number} blockSize + * + * The number of 32-bit words this cipher operates on. Default: 1 (32 bits) + */ +export class StreamCipher extends Cipher { + constructor(...args) { + super(...args); + + this.blockSize = 1; + } + + _doFinalize() { + // Process partial blocks + const finalProcessedBlocks = this._process(!!'flush'); + + return finalProcessedBlocks; + } +} + +/** + * Abstract base block cipher mode template. + */ +export class BlockCipherMode extends Base { + /** + * Initializes a newly created mode. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @example + * + * const mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); + */ + constructor(cipher, iv) { + super(); + + this._cipher = cipher; + this._iv = iv; + } + + /** + * Creates this mode for encryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * const mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); + */ + static createEncryptor(cipher, iv) { + return this.Encryptor.create(cipher, iv); + } + + /** + * Creates this mode for decryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * const mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); + */ + static createDecryptor(cipher, iv) { + return this.Decryptor.create(cipher, iv); + } +} + +function xorBlock(words, offset, blockSize) { + const _words = words; + let block; + + // Shortcut + const iv = this._iv; + + // Choose mixing block + if (iv) { + block = iv; + + // Remove IV for subsequent blocks + this._iv = undefined; + } else { + block = this._prevBlock; + } + + // XOR blocks + for (let i = 0; i < blockSize; i += 1) { + _words[offset + i] ^= block[i]; + } +} + +/** + * Cipher Block Chaining mode. + */ + +/** + * Abstract base CBC mode. + */ +export class CBC extends BlockCipherMode {} +/** + * CBC encryptor. + */ +CBC.Encryptor = class extends CBC { + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock(words, offset) { + // Shortcuts + const cipher = this._cipher; + const { + blockSize + } = cipher; + + // XOR and encrypt + xorBlock.call(this, words, offset, blockSize); + cipher.encryptBlock(words, offset); + + // Remember this block to use with next block + this._prevBlock = words.slice(offset, offset + blockSize); + } +}; +/** + * CBC decryptor. + */ +CBC.Decryptor = class extends CBC { + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock(words, offset) { + // Shortcuts + const cipher = this._cipher; + const { + blockSize + } = cipher; + + // Remember this block to use with next block + const thisBlock = words.slice(offset, offset + blockSize); + + // Decrypt and XOR + cipher.decryptBlock(words, offset); + xorBlock.call(this, words, offset, blockSize); + + // This block becomes the previous block + this._prevBlock = thisBlock; + } +}; + +/** + * PKCS #5/7 padding strategy. + */ +export const Pkcs7 = { + /** + * Pads data using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to pad. + * @param {number} blockSize The multiple that the data should be padded to. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.pad(wordArray, 4); + */ + pad(data, blockSize) { + // Shortcut + const blockSizeBytes = blockSize * 4; + + // Count padding bytes + const nPaddingBytes = blockSizeBytes - (data.sigBytes % blockSizeBytes); + + // Create padding word + const paddingWord = (nPaddingBytes << 24) | + (nPaddingBytes << 16) | + (nPaddingBytes << 8) | + nPaddingBytes; + + // Create padding + const paddingWords = []; + for (let i = 0; i < nPaddingBytes; i += 4) { + paddingWords.push(paddingWord); + } + const padding = WordArray.create(paddingWords, nPaddingBytes); + + // Add padding + data.concat(padding); + }, + + /** + * Unpads data that had been padded using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to unpad. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.unpad(wordArray); + */ + unpad(data) { + const _data = data; + + // Get number of padding bytes from last byte + const nPaddingBytes = _data.words[(_data.sigBytes - 1) >>> 2] & 0xff; + + // Remove padding + _data.sigBytes -= nPaddingBytes; + } +}; + +/** + * Abstract base block cipher template. + * + * @property {number} blockSize + * + * The number of 32-bit words this cipher operates on. Default: 4 (128 bits) + */ +export class BlockCipher extends Cipher { + constructor(xformMode, key, cfg) { + /** + * Configuration options. + * + * @property {Mode} mode The block mode to use. Default: CBC + * @property {Padding} padding The padding strategy to use. Default: Pkcs7 + */ + super(xformMode, key, Object.assign({ + mode: CBC, + padding: Pkcs7 + }, + cfg, + )); + + this.blockSize = 128 / 32; + } + + reset() { + let modeCreator; + + // Reset cipher + super.reset.call(this); + + // Shortcuts + const { + cfg + } = this; + const { + iv, + mode + } = cfg; + + // Reset block mode + if (this._xformMode === this.constructor._ENC_XFORM_MODE) { + modeCreator = mode.createEncryptor; + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { + modeCreator = mode.createDecryptor; + // Keep at least one block in the buffer for unpadding + this._minBufferSize = 1; + } + + this._mode = modeCreator.call(mode, this, iv && iv.words); + this._mode.__creator = modeCreator; + } + + _doProcessBlock(words, offset) { + this._mode.processBlock(words, offset); + } + + _doFinalize() { + let finalProcessedBlocks; + + // Shortcut + const { + padding + } = this.cfg; + + // Finalize + if (this._xformMode === this.constructor._ENC_XFORM_MODE) { + // Pad data + padding.pad(this._data, this.blockSize); + + // Process final blocks + finalProcessedBlocks = this._process(!!'flush'); + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { + // Process final blocks + finalProcessedBlocks = this._process(!!'flush'); + + // Unpad data + padding.unpad(finalProcessedBlocks); + } + + return finalProcessedBlocks; + } +} + +/** + * A collection of cipher parameters. + * + * @property {WordArray} ciphertext The raw ciphertext. + * @property {WordArray} key The key to this ciphertext. + * @property {WordArray} iv The IV used in the ciphering operation. + * @property {WordArray} salt The salt used with a key derivation function. + * @property {Cipher} algorithm The cipher algorithm. + * @property {Mode} mode The block mode used in the ciphering operation. + * @property {Padding} padding The padding scheme used in the ciphering operation. + * @property {number} blockSize The block size of the cipher. + * @property {Format} formatter + * The default formatting strategy to convert this cipher params object to a string. + */ +export class CipherParams extends Base { + /** + * Initializes a newly created cipher params object. + * + * @param {Object} cipherParams An object with any of the possible cipher parameters. + * + * @example + * + * var cipherParams = CryptoJS.lib.CipherParams.create({ + * ciphertext: ciphertextWordArray, + * key: keyWordArray, + * iv: ivWordArray, + * salt: saltWordArray, + * algorithm: CryptoJS.algo.AES, + * mode: CryptoJS.mode.CBC, + * padding: CryptoJS.pad.PKCS7, + * blockSize: 4, + * formatter: CryptoJS.format.OpenSSL + * }); + */ + constructor(cipherParams) { + super(); + + this.mixIn(cipherParams); + } + + /** + * Converts this cipher params object to a string. + * + * @param {Format} formatter (Optional) The formatting strategy to use. + * + * @return {string} The stringified cipher params. + * + * @throws Error If neither the formatter nor the default formatter is set. + * + * @example + * + * var string = cipherParams + ''; + * var string = cipherParams.toString(); + * var string = cipherParams.toString(CryptoJS.format.OpenSSL); + */ + toString(formatter) { + return (formatter || this.formatter).stringify(this); + } +} + +/** + * OpenSSL formatting strategy. + */ +export const OpenSSLFormatter = { + /** + * Converts a cipher params object to an OpenSSL-compatible string. + * + * @param {CipherParams} cipherParams The cipher params object. + * + * @return {string} The OpenSSL-compatible string. + * + * @static + * + * @example + * + * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); + */ + stringify(cipherParams) { + let wordArray; + + // Shortcuts + const { + ciphertext, + salt + } = cipherParams; + + // Format + if (salt) { + wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); + } else { + wordArray = ciphertext; + } + + return wordArray.toString(Base64); + }, + + /** + * Converts an OpenSSL-compatible string to a cipher params object. + * + * @param {string} openSSLStr The OpenSSL-compatible string. + * + * @return {CipherParams} The cipher params object. + * + * @static + * + * @example + * + * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); + */ + parse(openSSLStr) { + let salt; + + // Parse base64 + const ciphertext = Base64.parse(openSSLStr); + + // Shortcut + const ciphertextWords = ciphertext.words; + + // Test for salt + if (ciphertextWords[0] === 0x53616c74 && ciphertextWords[1] === 0x65645f5f) { + // Extract salt + salt = WordArray.create(ciphertextWords.slice(2, 4)); + + // Remove salt from ciphertext + ciphertextWords.splice(0, 4); + ciphertext.sigBytes -= 16; + } + + return CipherParams.create({ + ciphertext, + salt + }); + } +}; + +/** + * A cipher wrapper that returns ciphertext as a serializable cipher params object. + */ +export class SerializableCipher extends Base { + /** + * Encrypts a message. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher + * .encrypt(CryptoJS.algo.AES, message, key); + * var ciphertextParams = CryptoJS.lib.SerializableCipher + * .encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); + * var ciphertextParams = CryptoJS.lib.SerializableCipher + * .encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + static encrypt(cipher, message, key, cfg) { + // Apply config defaults + const _cfg = Object.assign(new Base(), this.cfg, cfg); + + // Encrypt + const encryptor = cipher.createEncryptor(key, _cfg); + const ciphertext = encryptor.finalize(message); + + // Shortcut + const cipherCfg = encryptor.cfg; + + // Create and return serializable cipher params + return CipherParams.create({ + ciphertext, + key, + iv: cipherCfg.iv, + algorithm: cipher, + mode: cipherCfg.mode, + padding: cipherCfg.padding, + blockSize: encryptor.blockSize, + formatter: _cfg.format + }); + } + + /** + * Decrypts serialized ciphertext. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.SerializableCipher + * .decrypt(CryptoJS.algo.AES, formattedCiphertext, key, + * { iv: iv, format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.SerializableCipher + * .decrypt(CryptoJS.algo.AES, ciphertextParams, key, + * { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + static decrypt(cipher, ciphertext, key, cfg) { + let _ciphertext = ciphertext; + + // Apply config defaults + const _cfg = Object.assign(new Base(), this.cfg, cfg); + + // Convert string to CipherParams + _ciphertext = this._parse(_ciphertext, _cfg.format); + + // Decrypt + const plaintext = cipher.createDecryptor(key, _cfg).finalize(_ciphertext.ciphertext); + + return plaintext; + } + + /** + * Converts serialized ciphertext to CipherParams, + * else assumed CipherParams already and returns ciphertext unchanged. + * + * @param {CipherParams|string} ciphertext The ciphertext. + * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. + * + * @return {CipherParams} The unserialized ciphertext. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher + * ._parse(ciphertextStringOrParams, format); + */ + static _parse(ciphertext, format) { + if (typeof ciphertext === 'string') { + return format.parse(ciphertext, this); + } + return ciphertext; + } +} +/** + * Configuration options. + * + * @property {Formatter} format + * + * The formatting strategy to convert cipher param objects to and from a string. + * Default: OpenSSL + */ +SerializableCipher.cfg = Object.assign( + new Base(), { + format: OpenSSLFormatter + }, +); + +/** + * OpenSSL key derivation function. + */ +export const OpenSSLKdf = { + /** + * Derives a key and IV from a password. + * + * @param {string} password The password to derive from. + * @param {number} keySize The size in words of the key to generate. + * @param {number} ivSize The size in words of the IV to generate. + * @param {WordArray|string} salt + * (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. + * + * @return {CipherParams} A cipher params object with the key, IV, and salt. + * + * @static + * + * @example + * + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); + */ + execute(password, keySize, ivSize, salt) { + let _salt = salt; + + // Generate random salt + if (!_salt) { + _salt = WordArray.random(64 / 8); + } + + // Derive key and IV + const key = EvpKDFAlgo.create({ + keySize: keySize + ivSize + }).compute(password, _salt); + + // Separate key and IV + const iv = WordArray.create(key.words.slice(keySize), ivSize * 4); + key.sigBytes = keySize * 4; + + // Return params + return CipherParams.create({ + key, + iv, + salt: _salt + }); + } +}; + +/** + * A serializable cipher wrapper that derives the key from a password, + * and returns ciphertext as a serializable cipher params object. + */ +export class PasswordBasedCipher extends SerializableCipher { + /** + * Encrypts a message using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher + * .encrypt(CryptoJS.algo.AES, message, 'password'); + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher + * .encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); + */ + static encrypt(cipher, message, password, cfg) { + // Apply config defaults + const _cfg = Object.assign(new Base(), this.cfg, cfg); + + // Derive key and other params + const derivedParams = _cfg.kdf.execute(password, cipher.keySize, cipher.ivSize); + + // Add IV to config + _cfg.iv = derivedParams.iv; + + // Encrypt + const ciphertext = SerializableCipher.encrypt + .call(this, cipher, message, derivedParams.key, _cfg); + + // Mix in derived params + ciphertext.mixIn(derivedParams); + + return ciphertext; + } + + /** + * Decrypts serialized ciphertext using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.PasswordBasedCipher + * .decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', + * { format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.PasswordBasedCipher + * .decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', + * { format: CryptoJS.format.OpenSSL }); + */ + static decrypt(cipher, ciphertext, password, cfg) { + let _ciphertext = ciphertext; + + // Apply config defaults + const _cfg = Object.assign(new Base(), this.cfg, cfg); + + // Convert string to CipherParams + _ciphertext = this._parse(_ciphertext, _cfg.format); + + // Derive key and other params + const derivedParams = _cfg.kdf + .execute(password, cipher.keySize, cipher.ivSize, _ciphertext.salt); + + // Add IV to config + _cfg.iv = derivedParams.iv; + + // Decrypt + const plaintext = SerializableCipher.decrypt + .call(this, cipher, _ciphertext, derivedParams.key, _cfg); + + return plaintext; + } +} +/** + * Configuration options. + * + * @property {KDF} kdf + * The key derivation function to use to generate a key and IV from a password. + * Default: OpenSSL + */ +PasswordBasedCipher.cfg = Object.assign(SerializableCipher.cfg, { + kdf: OpenSSLKdf +}); \ No newline at end of file diff --git a/src/core.js b/src/core.js index fd95ea5..f7c98e9 100644 --- a/src/core.js +++ b/src/core.js @@ -1,742 +1,787 @@ -/** - * CryptoJS core components. - */ -var CryptoJS = CryptoJS || (function (Math, undefined) { - /* - * Local polyfil of Object.create - */ - var create = Object.create || (function () { - function F() {} - - return function (obj) { - var subtype; - - F.prototype = obj; - - subtype = new F(); - - F.prototype = null; - - return subtype; - }; - }()) - - /** - * CryptoJS namespace. - */ - var C = {}; - - /** - * Library namespace. - */ - var C_lib = C.lib = {}; - - /** - * Base object for prototypal inheritance. - */ - var Base = C_lib.Base = (function () { - - - return { - /** - * Creates a new object that inherits from this object. - * - * @param {Object} overrides Properties to copy into the new object. - * - * @return {Object} The new object. - * - * @static - * - * @example - * - * var MyType = CryptoJS.lib.Base.extend({ - * field: 'value', - * - * method: function () { - * } - * }); - */ - extend: function (overrides) { - // Spawn - var subtype = create(this); - - // Augment - if (overrides) { - subtype.mixIn(overrides); - } - - // Create default initializer - if (!subtype.hasOwnProperty('init') || this.init === subtype.init) { - subtype.init = function () { - subtype.$super.init.apply(this, arguments); - }; - } - - // Initializer's prototype is the subtype object - subtype.init.prototype = subtype; - - // Reference supertype - subtype.$super = this; - - return subtype; - }, - - /** - * Extends this object and runs the init method. - * Arguments to create() will be passed to init(). - * - * @return {Object} The new object. - * - * @static - * - * @example - * - * var instance = MyType.create(); - */ - create: function () { - var instance = this.extend(); - instance.init.apply(instance, arguments); - - return instance; - }, - - /** - * Initializes a newly created object. - * Override this method to add some logic when your objects are created. - * - * @example - * - * var MyType = CryptoJS.lib.Base.extend({ - * init: function () { - * // ... - * } - * }); - */ - init: function () { - }, - - /** - * Copies properties into this object. - * - * @param {Object} properties The properties to mix in. - * - * @example - * - * MyType.mixIn({ - * field: 'value' - * }); - */ - mixIn: function (properties) { - for (var propertyName in properties) { - if (properties.hasOwnProperty(propertyName)) { - this[propertyName] = properties[propertyName]; - } - } - - // IE won't copy toString using the loop above - if (properties.hasOwnProperty('toString')) { - this.toString = properties.toString; - } - }, - - /** - * Creates a copy of this object. - * - * @return {Object} The clone. - * - * @example - * - * var clone = instance.clone(); - */ - clone: function () { - return this.init.prototype.extend(this); - } - }; - }()); - - /** - * An array of 32-bit words. - * - * @property {Array} words The array of 32-bit words. - * @property {number} sigBytes The number of significant bytes in this word array. - */ - var WordArray = C_lib.WordArray = Base.extend({ - /** - * Initializes a newly created word array. - * - * @param {Array} words (Optional) An array of 32-bit words. - * @param {number} sigBytes (Optional) The number of significant bytes in the words. - * - * @example - * - * var wordArray = CryptoJS.lib.WordArray.create(); - * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); - * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); - */ - init: function (words, sigBytes) { - words = this.words = words || []; - - if (sigBytes != undefined) { - this.sigBytes = sigBytes; - } else { - this.sigBytes = words.length * 4; - } - }, - - /** - * Converts this word array to a string. - * - * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex - * - * @return {string} The stringified word array. - * - * @example - * - * var string = wordArray + ''; - * var string = wordArray.toString(); - * var string = wordArray.toString(CryptoJS.enc.Utf8); - */ - toString: function (encoder) { - return (encoder || Hex).stringify(this); - }, - - /** - * Concatenates a word array to this word array. - * - * @param {WordArray} wordArray The word array to append. - * - * @return {WordArray} This word array. - * - * @example - * - * wordArray1.concat(wordArray2); - */ - concat: function (wordArray) { - // Shortcuts - var thisWords = this.words; - var thatWords = wordArray.words; - var thisSigBytes = this.sigBytes; - var thatSigBytes = wordArray.sigBytes; - - // Clamp excess bits - this.clamp(); - - // Concat - if (thisSigBytes % 4) { - // Copy one byte at a time - for (var i = 0; i < thatSigBytes; i++) { - var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8); - } - } else { - // Copy one word at a time - for (var i = 0; i < thatSigBytes; i += 4) { - thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2]; - } - } - this.sigBytes += thatSigBytes; - - // Chainable - return this; - }, - - /** - * Removes insignificant bits. - * - * @example - * - * wordArray.clamp(); - */ - clamp: function () { - // Shortcuts - var words = this.words; - var sigBytes = this.sigBytes; - - // Clamp - words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8); - words.length = Math.ceil(sigBytes / 4); - }, - - /** - * Creates a copy of this word array. - * - * @return {WordArray} The clone. - * - * @example - * - * var clone = wordArray.clone(); - */ - clone: function () { - var clone = Base.clone.call(this); - clone.words = this.words.slice(0); - - return clone; - }, - - /** - * Creates a word array filled with random bytes. - * - * @param {number} nBytes The number of random bytes to generate. - * - * @return {WordArray} The random word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.lib.WordArray.random(16); - */ - random: function (nBytes) { - var words = []; - - var r = function (m_w) { - var m_w = m_w; - var m_z = 0x3ade68b1; - var mask = 0xffffffff; - - return function () { - m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask; - m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask; - var result = ((m_z << 0x10) + m_w) & mask; - result /= 0x100000000; - result += 0.5; - return result * (Math.random() > 0.5 ? 1 : -1); - } - }; - - for (var i = 0, rcache; i < nBytes; i += 4) { - var _r = r((rcache || Math.random()) * 0x100000000); - - rcache = _r() * 0x3ade67b7; - words.push((_r() * 0x100000000) | 0); - } - - return new WordArray.init(words, nBytes); - } - }); - - /** - * Encoder namespace. - */ - var C_enc = C.enc = {}; - - /** - * Hex encoding strategy. - */ - var Hex = C_enc.Hex = { - /** - * Converts a word array to a hex string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The hex string. - * - * @static - * - * @example - * - * var hexString = CryptoJS.enc.Hex.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; - - // Convert - var hexChars = []; - for (var i = 0; i < sigBytes; i++) { - var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - hexChars.push((bite >>> 4).toString(16)); - hexChars.push((bite & 0x0f).toString(16)); - } - - return hexChars.join(''); - }, - - /** - * Converts a hex string to a word array. - * - * @param {string} hexStr The hex string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Hex.parse(hexString); - */ - parse: function (hexStr) { - // Shortcut - var hexStrLength = hexStr.length; - - // Convert - var words = []; - for (var i = 0; i < hexStrLength; i += 2) { - words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); - } - - return new WordArray.init(words, hexStrLength / 2); - } - }; - - /** - * Latin1 encoding strategy. - */ - var Latin1 = C_enc.Latin1 = { - /** - * Converts a word array to a Latin1 string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The Latin1 string. - * - * @static - * - * @example - * - * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; - - // Convert - var latin1Chars = []; - for (var i = 0; i < sigBytes; i++) { - var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - latin1Chars.push(String.fromCharCode(bite)); - } - - return latin1Chars.join(''); - }, - - /** - * Converts a Latin1 string to a word array. - * - * @param {string} latin1Str The Latin1 string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Latin1.parse(latin1String); - */ - parse: function (latin1Str) { - // Shortcut - var latin1StrLength = latin1Str.length; - - // Convert - var words = []; - for (var i = 0; i < latin1StrLength; i++) { - words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); - } - - return new WordArray.init(words, latin1StrLength); - } - }; - - /** - * UTF-8 encoding strategy. - */ - var Utf8 = C_enc.Utf8 = { - /** - * Converts a word array to a UTF-8 string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The UTF-8 string. - * - * @static - * - * @example - * - * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); - */ - stringify: function (wordArray) { - try { - return decodeURIComponent(escape(Latin1.stringify(wordArray))); - } catch (e) { - throw new Error('Malformed UTF-8 data'); - } - }, - - /** - * Converts a UTF-8 string to a word array. - * - * @param {string} utf8Str The UTF-8 string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Utf8.parse(utf8String); - */ - parse: function (utf8Str) { - return Latin1.parse(unescape(encodeURIComponent(utf8Str))); - } - }; - - /** - * Abstract buffered block algorithm template. - * - * The property blockSize must be implemented in a concrete subtype. - * - * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0 - */ - var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({ - /** - * Resets this block algorithm's data buffer to its initial state. - * - * @example - * - * bufferedBlockAlgorithm.reset(); - */ - reset: function () { - // Initial values - this._data = new WordArray.init(); - this._nDataBytes = 0; - }, - - /** - * Adds new data to this block algorithm's buffer. - * - * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8. - * - * @example - * - * bufferedBlockAlgorithm._append('data'); - * bufferedBlockAlgorithm._append(wordArray); - */ - _append: function (data) { - // Convert string to WordArray, else assume WordArray already - if (typeof data == 'string') { - data = Utf8.parse(data); - } - - // Append - this._data.concat(data); - this._nDataBytes += data.sigBytes; - }, - - /** - * Processes available data blocks. - * - * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. - * - * @param {boolean} doFlush Whether all blocks and partial blocks should be processed. - * - * @return {WordArray} The processed data. - * - * @example - * - * var processedData = bufferedBlockAlgorithm._process(); - * var processedData = bufferedBlockAlgorithm._process(!!'flush'); - */ - _process: function (doFlush) { - var processedWords; - - // Shortcuts - var data = this._data; - var dataWords = data.words; - var dataSigBytes = data.sigBytes; - var blockSize = this.blockSize; - var blockSizeBytes = blockSize * 4; - - // Count blocks ready - var nBlocksReady = dataSigBytes / blockSizeBytes; - if (doFlush) { - // Round up to include partial blocks - nBlocksReady = Math.ceil(nBlocksReady); - } else { - // Round down to include only full blocks, - // less the number of blocks that must remain in the buffer - nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0); - } - - // Count words ready - var nWordsReady = nBlocksReady * blockSize; - - // Count bytes ready - var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes); - - // Process blocks - if (nWordsReady) { - for (var offset = 0; offset < nWordsReady; offset += blockSize) { - // Perform concrete-algorithm logic - this._doProcessBlock(dataWords, offset); - } - - // Remove processed words - processedWords = dataWords.splice(0, nWordsReady); - data.sigBytes -= nBytesReady; - } - - // Return processed words - return new WordArray.init(processedWords, nBytesReady); - }, - - /** - * Creates a copy of this object. - * - * @return {Object} The clone. - * - * @example - * - * var clone = bufferedBlockAlgorithm.clone(); - */ - clone: function () { - var clone = Base.clone.call(this); - clone._data = this._data.clone(); - - return clone; - }, - - _minBufferSize: 0 - }); - - /** - * Abstract hasher template. - * - * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits) - */ - var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({ - /** - * Configuration options. - */ - cfg: Base.extend(), - - /** - * Initializes a newly created hasher. - * - * @param {Object} cfg (Optional) The configuration options to use for this hash computation. - * - * @example - * - * var hasher = CryptoJS.algo.SHA256.create(); - */ - init: function (cfg) { - // Apply config defaults - this.cfg = this.cfg.extend(cfg); - - // Set initial values - this.reset(); - }, - - /** - * Resets this hasher to its initial state. - * - * @example - * - * hasher.reset(); - */ - reset: function () { - // Reset data buffer - BufferedBlockAlgorithm.reset.call(this); - - // Perform concrete-hasher logic - this._doReset(); - }, - - /** - * Updates this hasher with a message. - * - * @param {WordArray|string} messageUpdate The message to append. - * - * @return {Hasher} This hasher. - * - * @example - * - * hasher.update('message'); - * hasher.update(wordArray); - */ - update: function (messageUpdate) { - // Append - this._append(messageUpdate); - - // Update the hash - this._process(); - - // Chainable - return this; - }, - - /** - * Finalizes the hash computation. - * Note that the finalize operation is effectively a destructive, read-once operation. - * - * @param {WordArray|string} messageUpdate (Optional) A final message update. - * - * @return {WordArray} The hash. - * - * @example - * - * var hash = hasher.finalize(); - * var hash = hasher.finalize('message'); - * var hash = hasher.finalize(wordArray); - */ - finalize: function (messageUpdate) { - // Final message update - if (messageUpdate) { - this._append(messageUpdate); - } - - // Perform concrete-hasher logic - var hash = this._doFinalize(); - - return hash; - }, - - blockSize: 512/32, - - /** - * Creates a shortcut function to a hasher's object interface. - * - * @param {Hasher} hasher The hasher to create a helper for. - * - * @return {Function} The shortcut function. - * - * @static - * - * @example - * - * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); - */ - _createHelper: function (hasher) { - return function (message, cfg) { - return new hasher.init(cfg).finalize(message); - }; - }, - - /** - * Creates a shortcut function to the HMAC's object interface. - * - * @param {Hasher} hasher The hasher to use in this HMAC helper. - * - * @return {Function} The shortcut function. - * - * @static - * - * @example - * - * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); - */ - _createHmacHelper: function (hasher) { - return function (message, key) { - return new C_algo.HMAC.init(hasher, key).finalize(message); - }; - } - }); - - /** - * Algorithm namespace. - */ - var C_algo = C.algo = {}; - - return C; -}(Math)); +/* eslint-disable no-use-before-define */ + +/** + * Base class for inheritance. + */ +export class Base { + /** + * Extends this object and runs the init method. + * Arguments to create() will be passed to init(). + * + * @return {Object} The new object. + * + * @static + * + * @example + * + * var instance = MyType.create(); + */ + static create(...args) { + return new this(...args); + } + + /** + * Copies properties into this object. + * + * @param {Object} properties The properties to mix in. + * + * @example + * + * MyType.mixIn({ + * field: 'value' + * }); + */ + mixIn(properties) { + return Object.assign(this, properties); + } + + /** + * Creates a copy of this object. + * + * @return {Object} The clone. + * + * @example + * + * var clone = instance.clone(); + */ + clone() { + const clone = new this.constructor(); + Object.assign(clone, this); + return clone; + } +} + +/** + * An array of 32-bit words. + * + * @property {Array} words The array of 32-bit words. + * @property {number} sigBytes The number of significant bytes in this word array. + */ +export class WordArray extends Base { + /** + * Initializes a newly created word array. + * + * @param {Array} words (Optional) An array of 32-bit words. + * @param {number} sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * var wordArray = CryptoJS.lib.WordArray.create(); + * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); + * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); + */ + constructor(words = [], sigBytes = words.length * 4) { + super(); + + let typedArray = words; + // Convert buffers to uint8 + if (typedArray instanceof ArrayBuffer) { + typedArray = new Uint8Array(typedArray); + } + + // Convert other array views to uint8 + if ( + typedArray instanceof Int8Array || + typedArray instanceof Uint8ClampedArray || + typedArray instanceof Int16Array || + typedArray instanceof Uint16Array || + typedArray instanceof Int32Array || + typedArray instanceof Uint32Array || + typedArray instanceof Float32Array || + typedArray instanceof Float64Array + ) { + typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); + } + + // Handle Uint8Array + if (typedArray instanceof Uint8Array) { + // Shortcut + const typedArrayByteLength = typedArray.byteLength; + + // Extract bytes + const _words = []; + for (let i = 0; i < typedArrayByteLength; i += 1) { + _words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8); + } + + // Initialize this word array + this.words = _words; + this.sigBytes = typedArrayByteLength; + } else { + // Else call normal init + this.words = words; + this.sigBytes = sigBytes; + } + } + + /** + * Creates a word array filled with random bytes. + * + * @param {number} nBytes The number of random bytes to generate. + * + * @return {WordArray} The random word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.lib.WordArray.random(16); + */ + static random(nBytes) { + const words = []; + + const r = (m_w) => { + let _m_w = m_w; + let _m_z = 0x3ade68b1; + const mask = 0xffffffff; + + return () => { + _m_z = (0x9069 * (_m_z & 0xFFFF) + (_m_z >> 0x10)) & mask; + _m_w = (0x4650 * (_m_w & 0xFFFF) + (_m_w >> 0x10)) & mask; + let result = ((_m_z << 0x10) + _m_w) & mask; + result /= 0x100000000; + result += 0.5; + return result * (Math.random() > 0.5 ? 1 : -1); + }; + }; + + for (let i = 0, rcache; i < nBytes; i += 4) { + const _r = r((rcache || Math.random()) * 0x100000000); + + rcache = _r() * 0x3ade67b7; + words.push((_r() * 0x100000000) | 0); + } + + return new WordArray(words, nBytes); + } + + /** + * Converts this word array to a string. + * + * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex + * + * @return {string} The stringified word array. + * + * @example + * + * var string = wordArray + ''; + * var string = wordArray.toString(); + * var string = wordArray.toString(CryptoJS.enc.Utf8); + */ + toString(encoder = Hex) { + return encoder.stringify(this); + } + + /** + * Concatenates a word array to this word array. + * + * @param {WordArray} wordArray The word array to append. + * + * @return {WordArray} This word array. + * + * @example + * + * wordArray1.concat(wordArray2); + */ + concat(wordArray) { + // Shortcuts + const thisWords = this.words; + const thatWords = wordArray.words; + const thisSigBytes = this.sigBytes; + const thatSigBytes = wordArray.sigBytes; + + // Clamp excess bits + this.clamp(); + + // Concat + if (thisSigBytes % 4) { + // Copy one byte at a time + for (let i = 0; i < thatSigBytes; i += 1) { + const thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8); + } + } else { + // Copy one word at a time + for (let i = 0; i < thatSigBytes; i += 4) { + thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2]; + } + } + this.sigBytes += thatSigBytes; + + // Chainable + return this; + } + + /** + * Removes insignificant bits. + * + * @example + * + * wordArray.clamp(); + */ + clamp() { + // Shortcuts + const { + words, + sigBytes + } = this; + + // Clamp + words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8); + words.length = Math.ceil(sigBytes / 4); + } + + /** + * Creates a copy of this word array. + * + * @return {WordArray} The clone. + * + * @example + * + * var clone = wordArray.clone(); + */ + clone() { + const clone = super.clone.call(this); + clone.words = this.words.slice(0); + + return clone; + } +} + +/** + * Hex encoding strategy. + */ +export const Hex = { + /** + * Converts a word array to a hex string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The hex string. + * + * @static + * + * @example + * + * var hexString = CryptoJS.enc.Hex.stringify(wordArray); + */ + stringify(wordArray) { + // Shortcuts + const { + words, + sigBytes + } = wordArray; + + // Convert + const hexChars = []; + for (let i = 0; i < sigBytes; i += 1) { + const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + hexChars.push((bite >>> 4).toString(16)); + hexChars.push((bite & 0x0f).toString(16)); + } + + return hexChars.join(''); + }, + + /** + * Converts a hex string to a word array. + * + * @param {string} hexStr The hex string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Hex.parse(hexString); + */ + parse(hexStr) { + // Shortcut + const hexStrLength = hexStr.length; + + // Convert + const words = []; + for (let i = 0; i < hexStrLength; i += 2) { + words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); + } + + return new WordArray(words, hexStrLength / 2); + } +}; + +/** + * Latin1 encoding strategy. + */ +export const Latin1 = { + /** + * Converts a word array to a Latin1 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Latin1 string. + * + * @static + * + * @example + * + * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); + */ + stringify(wordArray) { + // Shortcuts + const { + words, + sigBytes + } = wordArray; + + // Convert + const latin1Chars = []; + for (let i = 0; i < sigBytes; i += 1) { + const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + latin1Chars.push(String.fromCharCode(bite)); + } + + return latin1Chars.join(''); + }, + + /** + * Converts a Latin1 string to a word array. + * + * @param {string} latin1Str The Latin1 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Latin1.parse(latin1String); + */ + parse(latin1Str) { + // Shortcut + const latin1StrLength = latin1Str.length; + + // Convert + const words = []; + for (let i = 0; i < latin1StrLength; i += 1) { + words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); + } + + return new WordArray(words, latin1StrLength); + } +}; + +/** + * UTF-8 encoding strategy. + */ +export const Utf8 = { + /** + * Converts a word array to a UTF-8 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-8 string. + * + * @static + * + * @example + * + * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); + */ + stringify(wordArray) { + try { + return decodeURIComponent(escape(Latin1.stringify(wordArray))); + } catch (e) { + throw new Error('Malformed UTF-8 data'); + } + }, + + /** + * Converts a UTF-8 string to a word array. + * + * @param {string} utf8Str The UTF-8 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Utf8.parse(utf8String); + */ + parse(utf8Str) { + return Latin1.parse(unescape(encodeURIComponent(utf8Str))); + } +}; + +/** + * Abstract buffered block algorithm template. + * + * The property blockSize must be implemented in a concrete subtype. + * + * @property {number} _minBufferSize + * + * The number of blocks that should be kept unprocessed in the buffer. Default: 0 + */ +export class BufferedBlockAlgorithm extends Base { + constructor() { + super(); + this._minBufferSize = 0; + } + + /** + * Resets this block algorithm's data buffer to its initial state. + * + * @example + * + * bufferedBlockAlgorithm.reset(); + */ + reset() { + // Initial values + this._data = new WordArray(); + this._nDataBytes = 0; + } + + /** + * Adds new data to this block algorithm's buffer. + * + * @param {WordArray|string} data + * + * The data to append. Strings are converted to a WordArray using UTF-8. + * + * @example + * + * bufferedBlockAlgorithm._append('data'); + * bufferedBlockAlgorithm._append(wordArray); + */ + _append(data) { + let m_data = data; + + // Convert string to WordArray, else assume WordArray already + if (typeof m_data === 'string') { + m_data = Utf8.parse(m_data); + } + + // Append + this._data.concat(m_data); + this._nDataBytes += m_data.sigBytes; + } + + /** + * Processes available data blocks. + * + * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. + * + * @param {boolean} doFlush Whether all blocks and partial blocks should be processed. + * + * @return {WordArray} The processed data. + * + * @example + * + * var processedData = bufferedBlockAlgorithm._process(); + * var processedData = bufferedBlockAlgorithm._process(!!'flush'); + */ + _process(doFlush) { + let processedWords; + + // Shortcuts + const { + _data: data, + blockSize + } = this; + const dataWords = data.words; + const dataSigBytes = data.sigBytes; + const blockSizeBytes = blockSize * 4; + + // Count blocks ready + let nBlocksReady = dataSigBytes / blockSizeBytes; + if (doFlush) { + // Round up to include partial blocks + nBlocksReady = Math.ceil(nBlocksReady); + } else { + // Round down to include only full blocks, + // less the number of blocks that must remain in the buffer + nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0); + } + + // Count words ready + const nWordsReady = nBlocksReady * blockSize; + + // Count bytes ready + const nBytesReady = Math.min(nWordsReady * 4, dataSigBytes); + + // Process blocks + if (nWordsReady) { + for (let offset = 0; offset < nWordsReady; offset += blockSize) { + // Perform concrete-algorithm logic + this._doProcessBlock(dataWords, offset); + } + + // Remove processed words + processedWords = dataWords.splice(0, nWordsReady); + data.sigBytes -= nBytesReady; + } + + // Return processed words + return new WordArray(processedWords, nBytesReady); + } + + /** + * Creates a copy of this object. + * + * @return {Object} The clone. + * + * @example + * + * var clone = bufferedBlockAlgorithm.clone(); + */ + clone() { + const clone = super.clone.call(this); + clone._data = this._data.clone(); + + return clone; + } +} + +/** + * Abstract hasher template. + * + * @property {number} blockSize + * + * The number of 32-bit words this hasher operates on. Default: 16 (512 bits) + */ +export class Hasher extends BufferedBlockAlgorithm { + constructor(cfg) { + super(); + + this.blockSize = 512 / 32; + + /** + * Configuration options. + */ + this.cfg = Object.assign(new Base(), cfg); + + // Set initial values + this.reset(); + } + + /** + * Creates a shortcut function to a hasher's object interface. + * + * @param {Hasher} SubHasher The hasher to create a helper for. + * + * @return {Function} The shortcut function. + * + * @static + * + * @example + * + * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); + */ + static _createHelper(SubHasher) { + return (message, cfg) => new SubHasher(cfg).finalize(message); + } + + /** + * Creates a shortcut function to the HMAC's object interface. + * + * @param {Hasher} SubHasher The hasher to use in this HMAC helper. + * + * @return {Function} The shortcut function. + * + * @static + * + * @example + * + * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); + */ + static _createHmacHelper(SubHasher) { + return (message, key) => new HMAC(SubHasher, key).finalize(message); + } + + /** + * Resets this hasher to its initial state. + * + * @example + * + * hasher.reset(); + */ + reset() { + // Reset data buffer + super.reset.call(this); + + // Perform concrete-hasher logic + this._doReset(); + } + + /** + * Updates this hasher with a message. + * + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {Hasher} This hasher. + * + * @example + * + * hasher.update('message'); + * hasher.update(wordArray); + */ + update(messageUpdate) { + // Append + this._append(messageUpdate); + + // Update the hash + this._process(); + + // Chainable + return this; + } + + /** + * Finalizes the hash computation. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} messageUpdate (Optional) A final message update. + * + * @return {WordArray} The hash. + * + * @example + * + * var hash = hasher.finalize(); + * var hash = hasher.finalize('message'); + * var hash = hasher.finalize(wordArray); + */ + finalize(messageUpdate) { + // Final message update + if (messageUpdate) { + this._append(messageUpdate); + } + + // Perform concrete-hasher logic + const hash = this._doFinalize(); + + return hash; + } +} + +/** + * HMAC algorithm. + */ +export class HMAC extends Base { + /** + * Initializes a newly created HMAC. + * + * @param {Hasher} SubHasher The hash algorithm to use. + * @param {WordArray|string} key The secret key. + * + * @example + * + * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); + */ + constructor(SubHasher, key) { + super(); + + const hasher = new SubHasher(); + this._hasher = hasher; + + // Convert string to WordArray, else assume WordArray already + let _key = key; + if (typeof _key === 'string') { + _key = Utf8.parse(_key); + } + + // Shortcuts + const hasherBlockSize = hasher.blockSize; + const hasherBlockSizeBytes = hasherBlockSize * 4; + + // Allow arbitrary length keys + if (_key.sigBytes > hasherBlockSizeBytes) { + _key = hasher.finalize(key); + } + + // Clamp excess bits + _key.clamp(); + + // Clone key for inner and outer pads + const oKey = _key.clone(); + this._oKey = oKey; + const iKey = _key.clone(); + this._iKey = iKey; + + // Shortcuts + const oKeyWords = oKey.words; + const iKeyWords = iKey.words; + + // XOR keys with pad constants + for (let i = 0; i < hasherBlockSize; i += 1) { + oKeyWords[i] ^= 0x5c5c5c5c; + iKeyWords[i] ^= 0x36363636; + } + oKey.sigBytes = hasherBlockSizeBytes; + iKey.sigBytes = hasherBlockSizeBytes; + + // Set initial values + this.reset(); + } + + /** + * Resets this HMAC to its initial state. + * + * @example + * + * hmacHasher.reset(); + */ + reset() { + // Shortcut + const hasher = this._hasher; + + // Reset + hasher.reset(); + hasher.update(this._iKey); + } + + /** + * Updates this HMAC with a message. + * + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {HMAC} This HMAC instance. + * + * @example + * + * hmacHasher.update('message'); + * hmacHasher.update(wordArray); + */ + update(messageUpdate) { + this._hasher.update(messageUpdate); + + // Chainable + return this; + } + + /** + * Finalizes the HMAC computation. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} messageUpdate (Optional) A final message update. + * + * @return {WordArray} The HMAC. + * + * @example + * + * var hmac = hmacHasher.finalize(); + * var hmac = hmacHasher.finalize('message'); + * var hmac = hmacHasher.finalize(wordArray); + */ + finalize(messageUpdate) { + // Shortcut + const hasher = this._hasher; + + // Compute HMAC + const innerHash = hasher.finalize(messageUpdate); + hasher.reset(); + const hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); + + return hmac; + } +} \ No newline at end of file diff --git a/src/enc-base64.js b/src/enc-base64.js index a32b9a4..822b7a2 100644 --- a/src/enc-base64.js +++ b/src/enc-base64.js @@ -1,116 +1,111 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var C_enc = C.enc; - - /** - * Base64 encoding strategy. - */ - var Base64 = C_enc.Base64 = { - /** - * Converts a word array to a Base64 string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The Base64 string. - * - * @static - * - * @example - * - * var base64String = CryptoJS.enc.Base64.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; - var map = this._map; - - // Clamp excess bits - wordArray.clamp(); - - // Convert - var base64Chars = []; - for (var i = 0; i < sigBytes; i += 3) { - var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; - var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; +import { + WordArray +} from './core.js'; - var triplet = (byte1 << 16) | (byte2 << 8) | byte3; +const parseLoop = (base64Str, base64StrLength, reverseMap) => { + const words = []; + let nBytes = 0; + for (let i = 0; i < base64StrLength; i += 1) { + if (i % 4) { + const bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2); + const bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2); + const bitsCombined = bits1 | bits2; + words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8); + nBytes += 1; + } + } + return WordArray.create(words, nBytes); +}; - for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { - base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); - } - } +/** + * Base64 encoding strategy. + */ +export const Base64 = { + /** + * Converts a word array to a Base64 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Base64 string. + * + * @static + * + * @example + * + * const base64String = CryptoJS.enc.Base64.stringify(wordArray); + */ + stringify(wordArray) { + // Shortcuts + const { words, sigBytes } = wordArray; + const map = this._map; - // Add padding - var paddingChar = map.charAt(64); - if (paddingChar) { - while (base64Chars.length % 4) { - base64Chars.push(paddingChar); - } - } + // Clamp excess bits + wordArray.clamp(); - return base64Chars.join(''); - }, + // Convert + const base64Chars = []; + for (let i = 0; i < sigBytes; i += 3) { + const byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + const byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; + const byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; - /** - * Converts a Base64 string to a word array. - * - * @param {string} base64Str The Base64 string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Base64.parse(base64String); - */ - parse: function (base64Str) { - // Shortcuts - var base64StrLength = base64Str.length; - var map = this._map; - var reverseMap = this._reverseMap; + const triplet = (byte1 << 16) | (byte2 << 8) | byte3; - if (!reverseMap) { - reverseMap = this._reverseMap = []; - for (var j = 0; j < map.length; j++) { - reverseMap[map.charCodeAt(j)] = j; - } - } + for (let j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j += 1) { + base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); + } + } - // Ignore padding - var paddingChar = map.charAt(64); - if (paddingChar) { - var paddingIndex = base64Str.indexOf(paddingChar); - if (paddingIndex !== -1) { - base64StrLength = paddingIndex; - } - } + // Add padding + const paddingChar = map.charAt(64); + if (paddingChar) { + while (base64Chars.length % 4) { + base64Chars.push(paddingChar); + } + } - // Convert - return parseLoop(base64Str, base64StrLength, reverseMap); + return base64Chars.join(''); + }, - }, + /** + * Converts a Base64 string to a word array. + * + * @param {string} base64Str The Base64 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * const wordArray = CryptoJS.enc.Base64.parse(base64String); + */ + parse(base64Str) { + // Shortcuts + let base64StrLength = base64Str.length; + const map = this._map; + let reverseMap = this._reverseMap; - _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' - }; + if (!reverseMap) { + this._reverseMap = []; + reverseMap = this._reverseMap; + for (let j = 0; j < map.length; j += 1) { + reverseMap[map.charCodeAt(j)] = j; + } + } - function parseLoop(base64Str, base64StrLength, reverseMap) { - var words = []; - var nBytes = 0; - for (var i = 0; i < base64StrLength; i++) { - if (i % 4) { - var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2); - var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2); - var bitsCombined = bits1 | bits2; - words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8); - nBytes++; - } + // Ignore padding + const paddingChar = map.charAt(64); + if (paddingChar) { + const paddingIndex = base64Str.indexOf(paddingChar); + if (paddingIndex !== -1) { + base64StrLength = paddingIndex; } - return WordArray.create(words, nBytes); } -}()); + + // Convert + return parseLoop(base64Str, base64StrLength, reverseMap); + }, + + _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' +}; diff --git a/src/enc-utf16.js b/src/enc-utf16.js deleted file mode 100644 index a13cf20..0000000 --- a/src/enc-utf16.js +++ /dev/null @@ -1,129 +0,0 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var C_enc = C.enc; - - /** - * UTF-16 BE encoding strategy. - */ - var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = { - /** - * Converts a word array to a UTF-16 BE string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The UTF-16 BE string. - * - * @static - * - * @example - * - * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; - - // Convert - var utf16Chars = []; - for (var i = 0; i < sigBytes; i += 2) { - var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff; - utf16Chars.push(String.fromCharCode(codePoint)); - } - - return utf16Chars.join(''); - }, - - /** - * Converts a UTF-16 BE string to a word array. - * - * @param {string} utf16Str The UTF-16 BE string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Utf16.parse(utf16String); - */ - parse: function (utf16Str) { - // Shortcut - var utf16StrLength = utf16Str.length; - - // Convert - var words = []; - for (var i = 0; i < utf16StrLength; i++) { - words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16); - } - - return WordArray.create(words, utf16StrLength * 2); - } - }; - - /** - * UTF-16 LE encoding strategy. - */ - C_enc.Utf16LE = { - /** - * Converts a word array to a UTF-16 LE string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The UTF-16 LE string. - * - * @static - * - * @example - * - * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; - - // Convert - var utf16Chars = []; - for (var i = 0; i < sigBytes; i += 2) { - var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff); - utf16Chars.push(String.fromCharCode(codePoint)); - } - - return utf16Chars.join(''); - }, - - /** - * Converts a UTF-16 LE string to a word array. - * - * @param {string} utf16Str The UTF-16 LE string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str); - */ - parse: function (utf16Str) { - // Shortcut - var utf16StrLength = utf16Str.length; - - // Convert - var words = []; - for (var i = 0; i < utf16StrLength; i++) { - words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16)); - } - - return WordArray.create(words, utf16StrLength * 2); - } - }; - - function swapEndian(word) { - return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff); - } -}()); diff --git a/src/evpkdf.js b/src/evpkdf.js index 2bc993e..5f974b2 100644 --- a/src/evpkdf.js +++ b/src/evpkdf.js @@ -1,114 +1,111 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var WordArray = C_lib.WordArray; - var C_algo = C.algo; - var MD5 = C_algo.MD5; - - /** - * This key derivation function is meant to conform with EVP_BytesToKey. - * www.openssl.org/docs/crypto/EVP_BytesToKey.html - */ - var EvpKDF = C_algo.EvpKDF = Base.extend({ - /** - * Configuration options. - * - * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) - * @property {Hasher} hasher The hash algorithm to use. Default: MD5 - * @property {number} iterations The number of iterations to perform. Default: 1 - */ - cfg: Base.extend({ - keySize: 128/32, - hasher: MD5, - iterations: 1 - }), - - /** - * Initializes a newly created key derivation function. - * - * @param {Object} cfg (Optional) The configuration options to use for the derivation. - * - * @example - * - * var kdf = CryptoJS.algo.EvpKDF.create(); - * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); - * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); - */ - init: function (cfg) { - this.cfg = this.cfg.extend(cfg); - }, - - /** - * Derives a key from a password. - * - * @param {WordArray|string} password The password. - * @param {WordArray|string} salt A salt. - * - * @return {WordArray} The derived key. - * - * @example - * - * var key = kdf.compute(password, salt); - */ - compute: function (password, salt) { - var block; - - // Shortcut - var cfg = this.cfg; - - // Init hasher - var hasher = cfg.hasher.create(); - - // Initial values - var derivedKey = WordArray.create(); - - // Shortcuts - var derivedKeyWords = derivedKey.words; - var keySize = cfg.keySize; - var iterations = cfg.iterations; - - // Generate key - while (derivedKeyWords.length < keySize) { - if (block) { - hasher.update(block); - } - block = hasher.update(password).finalize(salt); - hasher.reset(); - - // Iterations - for (var i = 1; i < iterations; i++) { - block = hasher.finalize(block); - hasher.reset(); - } - - derivedKey.concat(block); - } - derivedKey.sigBytes = keySize * 4; - - return derivedKey; - } - }); - - /** - * Derives a key from a password. - * - * @param {WordArray|string} password The password. - * @param {WordArray|string} salt A salt. - * @param {Object} cfg (Optional) The configuration options to use for this computation. - * - * @return {WordArray} The derived key. - * - * @static - * - * @example - * - * var key = CryptoJS.EvpKDF(password, salt); - * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 }); - * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 }); - */ - C.EvpKDF = function (password, salt, cfg) { - return EvpKDF.create(cfg).compute(password, salt); - }; -}()); +import { + Base, + WordArray +} from './core.js'; +import { MD5Algo } from './md5.js'; + +/** + * This key derivation function is meant to conform with EVP_BytesToKey. + * www.openssl.org/docs/crypto/EVP_BytesToKey.html + */ +export class EvpKDFAlgo extends Base { + /** + * Initializes a newly created key derivation function. + * + * @param {Object} cfg (Optional) The configuration options to use for the derivation. + * + * @example + * + * const kdf = CryptoJS.algo.EvpKDF.create(); + * const kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); + * const kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); + */ + constructor(cfg) { + super(); + + /** + * Configuration options. + * + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) + * @property {Hasher} hasher The hash algorithm to use. Default: MD5 + * @property {number} iterations The number of iterations to perform. Default: 1 + */ + this.cfg = Object.assign( + new Base(), + { + keySize: 128 / 32, + hasher: MD5Algo, + iterations: 1 + }, + cfg, + ); + } + + /** + * Derives a key from a password. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * + * @return {WordArray} The derived key. + * + * @example + * + * const key = kdf.compute(password, salt); + */ + compute(password, salt) { + let block; + + // Shortcut + const { cfg } = this; + + // Init hasher + const hasher = cfg.hasher.create(); + + // Initial values + const derivedKey = WordArray.create(); + + // Shortcuts + const derivedKeyWords = derivedKey.words; + const { keySize, iterations } = cfg; + + // Generate key + while (derivedKeyWords.length < keySize) { + if (block) { + hasher.update(block); + } + block = hasher.update(password).finalize(salt); + hasher.reset(); + + // Iterations + for (let i = 1; i < iterations; i += 1) { + block = hasher.finalize(block); + hasher.reset(); + } + + derivedKey.concat(block); + } + derivedKey.sigBytes = keySize * 4; + + return derivedKey; + } +} + +/** + * Derives a key from a password. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * @param {Object} cfg (Optional) The configuration options to use for this computation. + * + * @return {WordArray} The derived key. + * + * @static + * + * @example + * + * var key = CryptoJS.EvpKDF(password, salt); + * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 }); + * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 }); + */ +export const EvpKDF = (password, salt, cfg) => EvpKDFAlgo.create(cfg).compute(password, salt); diff --git a/src/format-hex.js b/src/format-hex.js deleted file mode 100644 index d967034..0000000 --- a/src/format-hex.js +++ /dev/null @@ -1,46 +0,0 @@ -(function (undefined) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var CipherParams = C_lib.CipherParams; - var C_enc = C.enc; - var Hex = C_enc.Hex; - var C_format = C.format; - - var HexFormatter = C_format.Hex = { - /** - * Converts the ciphertext of a cipher params object to a hexadecimally encoded string. - * - * @param {CipherParams} cipherParams The cipher params object. - * - * @return {string} The hexadecimally encoded string. - * - * @static - * - * @example - * - * var hexString = CryptoJS.format.Hex.stringify(cipherParams); - */ - stringify: function (cipherParams) { - return cipherParams.ciphertext.toString(Hex); - }, - - /** - * Converts a hexadecimally encoded ciphertext string to a cipher params object. - * - * @param {string} input The hexadecimally encoded string. - * - * @return {CipherParams} The cipher params object. - * - * @static - * - * @example - * - * var cipherParams = CryptoJS.format.Hex.parse(hexString); - */ - parse: function (input) { - var ciphertext = Hex.parse(input); - return CipherParams.create({ ciphertext: ciphertext }); - } - }; -}()); diff --git a/src/hmac.js b/src/hmac.js index 24762a9..62f853d 100644 --- a/src/hmac.js +++ b/src/hmac.js @@ -1,125 +1,3 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var C_enc = C.enc; - var Utf8 = C_enc.Utf8; - var C_algo = C.algo; - - /** - * HMAC algorithm. - */ - var HMAC = C_algo.HMAC = Base.extend({ - /** - * Initializes a newly created HMAC. - * - * @param {Hasher} hasher The hash algorithm to use. - * @param {WordArray|string} key The secret key. - * - * @example - * - * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); - */ - init: function (hasher, key) { - // Init hasher - hasher = this._hasher = new hasher.init(); - - // Convert string to WordArray, else assume WordArray already - if (typeof key == 'string') { - key = Utf8.parse(key); - } - - // Shortcuts - var hasherBlockSize = hasher.blockSize; - var hasherBlockSizeBytes = hasherBlockSize * 4; - - // Allow arbitrary length keys - if (key.sigBytes > hasherBlockSizeBytes) { - key = hasher.finalize(key); - } - - // Clamp excess bits - key.clamp(); - - // Clone key for inner and outer pads - var oKey = this._oKey = key.clone(); - var iKey = this._iKey = key.clone(); - - // Shortcuts - var oKeyWords = oKey.words; - var iKeyWords = iKey.words; - - // XOR keys with pad constants - for (var i = 0; i < hasherBlockSize; i++) { - oKeyWords[i] ^= 0x5c5c5c5c; - iKeyWords[i] ^= 0x36363636; - } - oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes; - - // Set initial values - this.reset(); - }, - - /** - * Resets this HMAC to its initial state. - * - * @example - * - * hmacHasher.reset(); - */ - reset: function () { - // Shortcut - var hasher = this._hasher; - - // Reset - hasher.reset(); - hasher.update(this._iKey); - }, - - /** - * Updates this HMAC with a message. - * - * @param {WordArray|string} messageUpdate The message to append. - * - * @return {HMAC} This HMAC instance. - * - * @example - * - * hmacHasher.update('message'); - * hmacHasher.update(wordArray); - */ - update: function (messageUpdate) { - this._hasher.update(messageUpdate); - - // Chainable - return this; - }, - - /** - * Finalizes the HMAC computation. - * Note that the finalize operation is effectively a destructive, read-once operation. - * - * @param {WordArray|string} messageUpdate (Optional) A final message update. - * - * @return {WordArray} The HMAC. - * - * @example - * - * var hmac = hmacHasher.finalize(); - * var hmac = hmacHasher.finalize('message'); - * var hmac = hmacHasher.finalize(wordArray); - */ - finalize: function (messageUpdate) { - // Shortcut - var hasher = this._hasher; - - // Compute HMAC - var innerHash = hasher.finalize(messageUpdate); - hasher.reset(); - var hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); - - return hmac; - } - }); -}()); +export { + HMAC +} from './core.js'; diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..0df8cda --- /dev/null +++ b/src/index.js @@ -0,0 +1,80 @@ +import { + Base, + WordArray, + Hex, + Latin1, + Utf8, + BufferedBlockAlgorithm, + Hasher +} from './core.js'; +import { + X64Word, + X64WordArray +} from './x64-core.js'; +import { + Cipher, + StreamCipher, + BlockCipherMode, + CBC, + Pkcs7, + BlockCipher, + CipherParams, + OpenSSLFormatter, + SerializableCipher, + OpenSSLKdf, + PasswordBasedCipher +} from './cipher-core.js'; + +import { MD5Algo, MD5, HmacMD5 } from './md5.js'; +import { HMAC } from './hmac.js'; + +export default { + lib: { + Base, + WordArray, + BufferedBlockAlgorithm, + Hasher, + Cipher, + StreamCipher, + BlockCipherMode, + BlockCipher, + CipherParams, + SerializableCipher, + PasswordBasedCipher + }, + + x64: { + Word: X64Word, + WordArray: X64WordArray + }, + + enc: { + Hex, + Latin1, + Utf8 + }, + + algo: { + HMAC, + MD5: MD5Algo + }, + + mode: { + CBC + }, + + pad: { + Pkcs7 + }, + + format: { + OpenSSL: OpenSSLFormatter + }, + + kdf: { + OpenSSL: OpenSSLKdf + }, + + MD5, + HmacMD5 +}; diff --git a/src/lib-typedarrays.js b/src/lib-typedarrays.js deleted file mode 100644 index 01e4428..0000000 --- a/src/lib-typedarrays.js +++ /dev/null @@ -1,56 +0,0 @@ -(function () { - // Check if typed arrays are supported - if (typeof ArrayBuffer != 'function') { - return; - } - - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - - // Reference original init - var superInit = WordArray.init; - - // Augment WordArray.init to handle typed arrays - var subInit = WordArray.init = function (typedArray) { - // Convert buffers to uint8 - if (typedArray instanceof ArrayBuffer) { - typedArray = new Uint8Array(typedArray); - } - - // Convert other array views to uint8 - if ( - typedArray instanceof Int8Array || - (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) || - typedArray instanceof Int16Array || - typedArray instanceof Uint16Array || - typedArray instanceof Int32Array || - typedArray instanceof Uint32Array || - typedArray instanceof Float32Array || - typedArray instanceof Float64Array - ) { - typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); - } - - // Handle Uint8Array - if (typedArray instanceof Uint8Array) { - // Shortcut - var typedArrayByteLength = typedArray.byteLength; - - // Extract bytes - var words = []; - for (var i = 0; i < typedArrayByteLength; i++) { - words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8); - } - - // Initialize this word array - superInit.call(this, words, typedArrayByteLength); - } else { - // Else call normal init - superInit.apply(this, arguments); - } - }; - - subInit.prototype = WordArray; -}()); diff --git a/src/md5.js b/src/md5.js index 5189321..3e7083f 100644 --- a/src/md5.js +++ b/src/md5.js @@ -1,248 +1,247 @@ -(function (Math) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var Hasher = C_lib.Hasher; - var C_algo = C.algo; - - // Constants table - var T = []; - - // Compute constants - (function () { - for (var i = 0; i < 64; i++) { - T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0; - } - }()); - - /** - * MD5 hash algorithm. - */ - var MD5 = C_algo.MD5 = Hasher.extend({ - _doReset: function () { - this._hash = new WordArray.init([ - 0x67452301, 0xefcdab89, - 0x98badcfe, 0x10325476 - ]); - }, - - _doProcessBlock: function (M, offset) { - // Swap endian - for (var i = 0; i < 16; i++) { - // Shortcuts - var offset_i = offset + i; - var M_offset_i = M[offset_i]; - - M[offset_i] = ( - (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | - (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) - ); - } - - // Shortcuts - var H = this._hash.words; - - var M_offset_0 = M[offset + 0]; - var M_offset_1 = M[offset + 1]; - var M_offset_2 = M[offset + 2]; - var M_offset_3 = M[offset + 3]; - var M_offset_4 = M[offset + 4]; - var M_offset_5 = M[offset + 5]; - var M_offset_6 = M[offset + 6]; - var M_offset_7 = M[offset + 7]; - var M_offset_8 = M[offset + 8]; - var M_offset_9 = M[offset + 9]; - var M_offset_10 = M[offset + 10]; - var M_offset_11 = M[offset + 11]; - var M_offset_12 = M[offset + 12]; - var M_offset_13 = M[offset + 13]; - var M_offset_14 = M[offset + 14]; - var M_offset_15 = M[offset + 15]; - - // Working varialbes - var a = H[0]; - var b = H[1]; - var c = H[2]; - var d = H[3]; - - // Computation - a = FF(a, b, c, d, M_offset_0, 7, T[0]); - d = FF(d, a, b, c, M_offset_1, 12, T[1]); - c = FF(c, d, a, b, M_offset_2, 17, T[2]); - b = FF(b, c, d, a, M_offset_3, 22, T[3]); - a = FF(a, b, c, d, M_offset_4, 7, T[4]); - d = FF(d, a, b, c, M_offset_5, 12, T[5]); - c = FF(c, d, a, b, M_offset_6, 17, T[6]); - b = FF(b, c, d, a, M_offset_7, 22, T[7]); - a = FF(a, b, c, d, M_offset_8, 7, T[8]); - d = FF(d, a, b, c, M_offset_9, 12, T[9]); - c = FF(c, d, a, b, M_offset_10, 17, T[10]); - b = FF(b, c, d, a, M_offset_11, 22, T[11]); - a = FF(a, b, c, d, M_offset_12, 7, T[12]); - d = FF(d, a, b, c, M_offset_13, 12, T[13]); - c = FF(c, d, a, b, M_offset_14, 17, T[14]); - b = FF(b, c, d, a, M_offset_15, 22, T[15]); - - a = GG(a, b, c, d, M_offset_1, 5, T[16]); - d = GG(d, a, b, c, M_offset_6, 9, T[17]); - c = GG(c, d, a, b, M_offset_11, 14, T[18]); - b = GG(b, c, d, a, M_offset_0, 20, T[19]); - a = GG(a, b, c, d, M_offset_5, 5, T[20]); - d = GG(d, a, b, c, M_offset_10, 9, T[21]); - c = GG(c, d, a, b, M_offset_15, 14, T[22]); - b = GG(b, c, d, a, M_offset_4, 20, T[23]); - a = GG(a, b, c, d, M_offset_9, 5, T[24]); - d = GG(d, a, b, c, M_offset_14, 9, T[25]); - c = GG(c, d, a, b, M_offset_3, 14, T[26]); - b = GG(b, c, d, a, M_offset_8, 20, T[27]); - a = GG(a, b, c, d, M_offset_13, 5, T[28]); - d = GG(d, a, b, c, M_offset_2, 9, T[29]); - c = GG(c, d, a, b, M_offset_7, 14, T[30]); - b = GG(b, c, d, a, M_offset_12, 20, T[31]); - - a = HH(a, b, c, d, M_offset_5, 4, T[32]); - d = HH(d, a, b, c, M_offset_8, 11, T[33]); - c = HH(c, d, a, b, M_offset_11, 16, T[34]); - b = HH(b, c, d, a, M_offset_14, 23, T[35]); - a = HH(a, b, c, d, M_offset_1, 4, T[36]); - d = HH(d, a, b, c, M_offset_4, 11, T[37]); - c = HH(c, d, a, b, M_offset_7, 16, T[38]); - b = HH(b, c, d, a, M_offset_10, 23, T[39]); - a = HH(a, b, c, d, M_offset_13, 4, T[40]); - d = HH(d, a, b, c, M_offset_0, 11, T[41]); - c = HH(c, d, a, b, M_offset_3, 16, T[42]); - b = HH(b, c, d, a, M_offset_6, 23, T[43]); - a = HH(a, b, c, d, M_offset_9, 4, T[44]); - d = HH(d, a, b, c, M_offset_12, 11, T[45]); - c = HH(c, d, a, b, M_offset_15, 16, T[46]); - b = HH(b, c, d, a, M_offset_2, 23, T[47]); - - a = II(a, b, c, d, M_offset_0, 6, T[48]); - d = II(d, a, b, c, M_offset_7, 10, T[49]); - c = II(c, d, a, b, M_offset_14, 15, T[50]); - b = II(b, c, d, a, M_offset_5, 21, T[51]); - a = II(a, b, c, d, M_offset_12, 6, T[52]); - d = II(d, a, b, c, M_offset_3, 10, T[53]); - c = II(c, d, a, b, M_offset_10, 15, T[54]); - b = II(b, c, d, a, M_offset_1, 21, T[55]); - a = II(a, b, c, d, M_offset_8, 6, T[56]); - d = II(d, a, b, c, M_offset_15, 10, T[57]); - c = II(c, d, a, b, M_offset_6, 15, T[58]); - b = II(b, c, d, a, M_offset_13, 21, T[59]); - a = II(a, b, c, d, M_offset_4, 6, T[60]); - d = II(d, a, b, c, M_offset_11, 10, T[61]); - c = II(c, d, a, b, M_offset_2, 15, T[62]); - b = II(b, c, d, a, M_offset_9, 21, T[63]); - - // Intermediate hash value - H[0] = (H[0] + a) | 0; - H[1] = (H[1] + b) | 0; - H[2] = (H[2] + c) | 0; - H[3] = (H[3] + d) | 0; - }, - - _doFinalize: function () { - // Shortcuts - var data = this._data; - var dataWords = data.words; - - var nBitsTotal = this._nDataBytes * 8; - var nBitsLeft = data.sigBytes * 8; - - // Add padding - dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); - - var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000); - var nBitsTotalL = nBitsTotal; - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = ( - (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) | - (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00) - ); - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( - (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) | - (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00) - ); - - data.sigBytes = (dataWords.length + 1) * 4; - - // Hash final blocks - this._process(); - - // Shortcuts - var hash = this._hash; - var H = hash.words; - - // Swap endian - for (var i = 0; i < 4; i++) { - // Shortcut - var H_i = H[i]; - - H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) | - (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); - } - - // Return final computed hash - return hash; - }, - - clone: function () { - var clone = Hasher.clone.call(this); - clone._hash = this._hash.clone(); - - return clone; - } - }); - - function FF(a, b, c, d, x, s, t) { - var n = a + ((b & c) | (~b & d)) + x + t; - return ((n << s) | (n >>> (32 - s))) + b; - } - - function GG(a, b, c, d, x, s, t) { - var n = a + ((b & d) | (c & ~d)) + x + t; - return ((n << s) | (n >>> (32 - s))) + b; - } - - function HH(a, b, c, d, x, s, t) { - var n = a + (b ^ c ^ d) + x + t; - return ((n << s) | (n >>> (32 - s))) + b; - } - - function II(a, b, c, d, x, s, t) { - var n = a + (c ^ (b | ~d)) + x + t; - return ((n << s) | (n >>> (32 - s))) + b; - } - - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.MD5('message'); - * var hash = CryptoJS.MD5(wordArray); - */ - C.MD5 = Hasher._createHelper(MD5); - - /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacMD5(message, key); - */ - C.HmacMD5 = Hasher._createHmacHelper(MD5); -}(Math)); +import { + WordArray, + Hasher +} from './core.js'; + +// Constants table +const T = []; + +// Compute constants +for (let i = 0; i < 64; i += 1) { + T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0; +} + +const FF = (a, b, c, d, x, s, t) => { + const n = a + ((b & c) | (~b & d)) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; +}; + +const GG = (a, b, c, d, x, s, t) => { + const n = a + ((b & d) | (c & ~d)) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; +}; + +const HH = (a, b, c, d, x, s, t) => { + const n = a + (b ^ c ^ d) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; +}; + +const II = (a, b, c, d, x, s, t) => { + const n = a + (c ^ (b | ~d)) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; +}; + +/** + * MD5 hash algorithm. + */ +export class MD5Algo extends Hasher { + _doReset() { + this._hash = new WordArray([ + 0x67452301, + 0xefcdab89, + 0x98badcfe, + 0x10325476 + ]); + } + + _doProcessBlock(M, offset) { + const _M = M; + + // Swap endian + for (let i = 0; i < 16; i += 1) { + // Shortcuts + const offset_i = offset + i; + const M_offset_i = M[offset_i]; + + _M[offset_i] = ( + (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) + | (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) + ); + } + + // Shortcuts + const H = this._hash.words; + + const M_offset_0 = _M[offset + 0]; + const M_offset_1 = _M[offset + 1]; + const M_offset_2 = _M[offset + 2]; + const M_offset_3 = _M[offset + 3]; + const M_offset_4 = _M[offset + 4]; + const M_offset_5 = _M[offset + 5]; + const M_offset_6 = _M[offset + 6]; + const M_offset_7 = _M[offset + 7]; + const M_offset_8 = _M[offset + 8]; + const M_offset_9 = _M[offset + 9]; + const M_offset_10 = _M[offset + 10]; + const M_offset_11 = _M[offset + 11]; + const M_offset_12 = _M[offset + 12]; + const M_offset_13 = _M[offset + 13]; + const M_offset_14 = _M[offset + 14]; + const M_offset_15 = _M[offset + 15]; + + // Working varialbes + let a = H[0]; + let b = H[1]; + let c = H[2]; + let d = H[3]; + + // Computation + a = FF(a, b, c, d, M_offset_0, 7, T[0]); + d = FF(d, a, b, c, M_offset_1, 12, T[1]); + c = FF(c, d, a, b, M_offset_2, 17, T[2]); + b = FF(b, c, d, a, M_offset_3, 22, T[3]); + a = FF(a, b, c, d, M_offset_4, 7, T[4]); + d = FF(d, a, b, c, M_offset_5, 12, T[5]); + c = FF(c, d, a, b, M_offset_6, 17, T[6]); + b = FF(b, c, d, a, M_offset_7, 22, T[7]); + a = FF(a, b, c, d, M_offset_8, 7, T[8]); + d = FF(d, a, b, c, M_offset_9, 12, T[9]); + c = FF(c, d, a, b, M_offset_10, 17, T[10]); + b = FF(b, c, d, a, M_offset_11, 22, T[11]); + a = FF(a, b, c, d, M_offset_12, 7, T[12]); + d = FF(d, a, b, c, M_offset_13, 12, T[13]); + c = FF(c, d, a, b, M_offset_14, 17, T[14]); + b = FF(b, c, d, a, M_offset_15, 22, T[15]); + + a = GG(a, b, c, d, M_offset_1, 5, T[16]); + d = GG(d, a, b, c, M_offset_6, 9, T[17]); + c = GG(c, d, a, b, M_offset_11, 14, T[18]); + b = GG(b, c, d, a, M_offset_0, 20, T[19]); + a = GG(a, b, c, d, M_offset_5, 5, T[20]); + d = GG(d, a, b, c, M_offset_10, 9, T[21]); + c = GG(c, d, a, b, M_offset_15, 14, T[22]); + b = GG(b, c, d, a, M_offset_4, 20, T[23]); + a = GG(a, b, c, d, M_offset_9, 5, T[24]); + d = GG(d, a, b, c, M_offset_14, 9, T[25]); + c = GG(c, d, a, b, M_offset_3, 14, T[26]); + b = GG(b, c, d, a, M_offset_8, 20, T[27]); + a = GG(a, b, c, d, M_offset_13, 5, T[28]); + d = GG(d, a, b, c, M_offset_2, 9, T[29]); + c = GG(c, d, a, b, M_offset_7, 14, T[30]); + b = GG(b, c, d, a, M_offset_12, 20, T[31]); + + a = HH(a, b, c, d, M_offset_5, 4, T[32]); + d = HH(d, a, b, c, M_offset_8, 11, T[33]); + c = HH(c, d, a, b, M_offset_11, 16, T[34]); + b = HH(b, c, d, a, M_offset_14, 23, T[35]); + a = HH(a, b, c, d, M_offset_1, 4, T[36]); + d = HH(d, a, b, c, M_offset_4, 11, T[37]); + c = HH(c, d, a, b, M_offset_7, 16, T[38]); + b = HH(b, c, d, a, M_offset_10, 23, T[39]); + a = HH(a, b, c, d, M_offset_13, 4, T[40]); + d = HH(d, a, b, c, M_offset_0, 11, T[41]); + c = HH(c, d, a, b, M_offset_3, 16, T[42]); + b = HH(b, c, d, a, M_offset_6, 23, T[43]); + a = HH(a, b, c, d, M_offset_9, 4, T[44]); + d = HH(d, a, b, c, M_offset_12, 11, T[45]); + c = HH(c, d, a, b, M_offset_15, 16, T[46]); + b = HH(b, c, d, a, M_offset_2, 23, T[47]); + + a = II(a, b, c, d, M_offset_0, 6, T[48]); + d = II(d, a, b, c, M_offset_7, 10, T[49]); + c = II(c, d, a, b, M_offset_14, 15, T[50]); + b = II(b, c, d, a, M_offset_5, 21, T[51]); + a = II(a, b, c, d, M_offset_12, 6, T[52]); + d = II(d, a, b, c, M_offset_3, 10, T[53]); + c = II(c, d, a, b, M_offset_10, 15, T[54]); + b = II(b, c, d, a, M_offset_1, 21, T[55]); + a = II(a, b, c, d, M_offset_8, 6, T[56]); + d = II(d, a, b, c, M_offset_15, 10, T[57]); + c = II(c, d, a, b, M_offset_6, 15, T[58]); + b = II(b, c, d, a, M_offset_13, 21, T[59]); + a = II(a, b, c, d, M_offset_4, 6, T[60]); + d = II(d, a, b, c, M_offset_11, 10, T[61]); + c = II(c, d, a, b, M_offset_2, 15, T[62]); + b = II(b, c, d, a, M_offset_9, 21, T[63]); + + // Intermediate hash value + H[0] = (H[0] + a) | 0; + H[1] = (H[1] + b) | 0; + H[2] = (H[2] + c) | 0; + H[3] = (H[3] + d) | 0; + } + /* eslint-ensable no-param-reassign */ + + _doFinalize() { + // Shortcuts + const data = this._data; + const dataWords = data.words; + + const nBitsTotal = this._nDataBytes * 8; + const nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32)); + + const nBitsTotalH = Math.floor(nBitsTotal / 0x100000000); + const nBitsTotalL = nBitsTotal; + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = ( + (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) + | (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00) + ); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( + (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) + | (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00) + ); + + data.sigBytes = (dataWords.length + 1) * 4; + + // Hash final blocks + this._process(); + + // Shortcuts + const hash = this._hash; + const H = hash.words; + + // Swap endian + for (let i = 0; i < 4; i += 1) { + // Shortcut + const H_i = H[i]; + + H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) + | (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); + } + + // Return final computed hash + return hash; + } + + clone() { + const clone = super.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } +} + +/** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.MD5('message'); + * var hash = CryptoJS.MD5(wordArray); + */ +export const MD5 = Hasher._createHelper(MD5Algo); + +/** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacMD5(message, key); + */ +export const HmacMD5 = Hasher._createHmacHelper(MD5Algo); diff --git a/src/mode-cfb.js b/src/mode-cfb.js deleted file mode 100644 index e750620..0000000 --- a/src/mode-cfb.js +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Cipher Feedback block mode. - */ -CryptoJS.mode.CFB = (function () { - var CFB = CryptoJS.lib.BlockCipherMode.extend(); - - CFB.Encryptor = CFB.extend({ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher; - var blockSize = cipher.blockSize; - - generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher); - - // Remember this block to use with next block - this._prevBlock = words.slice(offset, offset + blockSize); - } - }); - - CFB.Decryptor = CFB.extend({ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher; - var blockSize = cipher.blockSize; - - // Remember this block to use with next block - var thisBlock = words.slice(offset, offset + blockSize); - - generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher); - - // This block becomes the previous block - this._prevBlock = thisBlock; - } - }); - - function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) { - var keystream; - - // Shortcut - var iv = this._iv; - - // Generate keystream - if (iv) { - keystream = iv.slice(0); - - // Remove IV for subsequent blocks - this._iv = undefined; - } else { - keystream = this._prevBlock; - } - cipher.encryptBlock(keystream, 0); - - // Encrypt - for (var i = 0; i < blockSize; i++) { - words[offset + i] ^= keystream[i]; - } - } - - return CFB; -}()); diff --git a/src/mode-ctr-gladman.js b/src/mode-ctr-gladman.js deleted file mode 100644 index 67dd933..0000000 --- a/src/mode-ctr-gladman.js +++ /dev/null @@ -1,96 +0,0 @@ -/** @preserve - * Counter block mode compatible with Dr Brian Gladman fileenc.c - * derived from CryptoJS.mode.CTR - * Jan Hruby jhruby.web@gmail.com - */ -CryptoJS.mode.CTRGladman = (function () { - var CTRGladman = CryptoJS.lib.BlockCipherMode.extend(); - - function incWord(word) - { - if (((word >> 24) & 0xff) === 0xff) { //overflow - var b1 = (word >> 16)&0xff; - var b2 = (word >> 8)&0xff; - var b3 = word & 0xff; - - if (b1 === 0xff) // overflow b1 - { - b1 = 0; - if (b2 === 0xff) - { - b2 = 0; - if (b3 === 0xff) - { - b3 = 0; - } - else - { - ++b3; - } - } - else - { - ++b2; - } - } - else - { - ++b1; - } - - word = 0; - word += (b1 << 16); - word += (b2 << 8); - word += b3; - } - else - { - word += (0x01 << 24); - } - return word; - } - - function incCounter(counter) - { - if ((counter[0] = incWord(counter[0])) === 0) - { - // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8 - counter[1] = incWord(counter[1]); - } - return counter; - } - - var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher - var blockSize = cipher.blockSize; - var iv = this._iv; - var counter = this._counter; - - // Generate keystream - if (iv) { - counter = this._counter = iv.slice(0); - - // Remove IV for subsequent blocks - this._iv = undefined; - } - - incCounter(counter); - - var keystream = counter.slice(0); - cipher.encryptBlock(keystream, 0); - - // Encrypt - for (var i = 0; i < blockSize; i++) { - words[offset + i] ^= keystream[i]; - } - } - }); - - CTRGladman.Decryptor = Encryptor; - - return CTRGladman; -}()); - - diff --git a/src/mode-ctr.js b/src/mode-ctr.js deleted file mode 100644 index 59c8bff..0000000 --- a/src/mode-ctr.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Counter block mode. - */ -CryptoJS.mode.CTR = (function () { - var CTR = CryptoJS.lib.BlockCipherMode.extend(); - - var Encryptor = CTR.Encryptor = CTR.extend({ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher - var blockSize = cipher.blockSize; - var iv = this._iv; - var counter = this._counter; - - // Generate keystream - if (iv) { - counter = this._counter = iv.slice(0); - - // Remove IV for subsequent blocks - this._iv = undefined; - } - var keystream = counter.slice(0); - cipher.encryptBlock(keystream, 0); - - // Increment counter - counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0 - - // Encrypt - for (var i = 0; i < blockSize; i++) { - words[offset + i] ^= keystream[i]; - } - } - }); - - CTR.Decryptor = Encryptor; - - return CTR; -}()); diff --git a/src/mode-ecb.js b/src/mode-ecb.js deleted file mode 100644 index 786ae2e..0000000 --- a/src/mode-ecb.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Electronic Codebook block mode. - */ -CryptoJS.mode.ECB = (function () { - var ECB = CryptoJS.lib.BlockCipherMode.extend(); - - ECB.Encryptor = ECB.extend({ - processBlock: function (words, offset) { - this._cipher.encryptBlock(words, offset); - } - }); - - ECB.Decryptor = ECB.extend({ - processBlock: function (words, offset) { - this._cipher.decryptBlock(words, offset); - } - }); - - return ECB; -}()); diff --git a/src/mode-ofb.js b/src/mode-ofb.js deleted file mode 100644 index 78f0cbe..0000000 --- a/src/mode-ofb.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Output Feedback block mode. - */ -CryptoJS.mode.OFB = (function () { - var OFB = CryptoJS.lib.BlockCipherMode.extend(); - - var Encryptor = OFB.Encryptor = OFB.extend({ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher - var blockSize = cipher.blockSize; - var iv = this._iv; - var keystream = this._keystream; - - // Generate keystream - if (iv) { - keystream = this._keystream = iv.slice(0); - - // Remove IV for subsequent blocks - this._iv = undefined; - } - cipher.encryptBlock(keystream, 0); - - // Encrypt - for (var i = 0; i < blockSize; i++) { - words[offset + i] ^= keystream[i]; - } - } - }); - - OFB.Decryptor = Encryptor; - - return OFB; -}()); diff --git a/src/pad-ansix923.js b/src/pad-ansix923.js deleted file mode 100644 index deb0472..0000000 --- a/src/pad-ansix923.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * ANSI X.923 padding strategy. - */ -CryptoJS.pad.AnsiX923 = { - pad: function (data, blockSize) { - // Shortcuts - var dataSigBytes = data.sigBytes; - var blockSizeBytes = blockSize * 4; - - // Count padding bytes - var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes; - - // Compute last byte position - var lastBytePos = dataSigBytes + nPaddingBytes - 1; - - // Pad - data.clamp(); - data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8); - data.sigBytes += nPaddingBytes; - }, - - unpad: function (data) { - // Get number of padding bytes from last byte - var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; - - // Remove padding - data.sigBytes -= nPaddingBytes; - } -}; diff --git a/src/pad-iso10126.js b/src/pad-iso10126.js deleted file mode 100644 index 7ed9a21..0000000 --- a/src/pad-iso10126.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * ISO 10126 padding strategy. - */ -CryptoJS.pad.Iso10126 = { - pad: function (data, blockSize) { - // Shortcut - var blockSizeBytes = blockSize * 4; - - // Count padding bytes - var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; - - // Pad - data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)). - concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1)); - }, - - unpad: function (data) { - // Get number of padding bytes from last byte - var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; - - // Remove padding - data.sigBytes -= nPaddingBytes; - } -}; diff --git a/src/pad-iso97971.js b/src/pad-iso97971.js deleted file mode 100644 index d42c104..0000000 --- a/src/pad-iso97971.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * ISO/IEC 9797-1 Padding Method 2. - */ -CryptoJS.pad.Iso97971 = { - pad: function (data, blockSize) { - // Add 0x80 byte - data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1)); - - // Zero pad the rest - CryptoJS.pad.ZeroPadding.pad(data, blockSize); - }, - - unpad: function (data) { - // Remove zero padding - CryptoJS.pad.ZeroPadding.unpad(data); - - // Remove one more byte -- the 0x80 byte - data.sigBytes--; - } -}; diff --git a/src/pad-nopadding.js b/src/pad-nopadding.js deleted file mode 100644 index 81fb38b..0000000 --- a/src/pad-nopadding.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * A noop padding strategy. - */ -CryptoJS.pad.NoPadding = { - pad: function () { - }, - - unpad: function () { - } -}; diff --git a/src/pad-zeropadding.js b/src/pad-zeropadding.js deleted file mode 100644 index 2b82b58..0000000 --- a/src/pad-zeropadding.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Zero padding strategy. - */ -CryptoJS.pad.ZeroPadding = { - pad: function (data, blockSize) { - // Shortcut - var blockSizeBytes = blockSize * 4; - - // Pad - data.clamp(); - data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes); - }, - - unpad: function (data) { - // Shortcut - var dataWords = data.words; - - // Unpad - var i = data.sigBytes - 1; - for (var i = data.sigBytes - 1; i >= 0; i--) { - if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) { - data.sigBytes = i + 1; - break; - } - } - } -}; diff --git a/src/pbkdf2.js b/src/pbkdf2.js deleted file mode 100644 index 15a1cfd..0000000 --- a/src/pbkdf2.js +++ /dev/null @@ -1,125 +0,0 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var WordArray = C_lib.WordArray; - var C_algo = C.algo; - var SHA1 = C_algo.SHA1; - var HMAC = C_algo.HMAC; - - /** - * Password-Based Key Derivation Function 2 algorithm. - */ - var PBKDF2 = C_algo.PBKDF2 = Base.extend({ - /** - * Configuration options. - * - * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) - * @property {Hasher} hasher The hasher to use. Default: SHA1 - * @property {number} iterations The number of iterations to perform. Default: 1 - */ - cfg: Base.extend({ - keySize: 128/32, - hasher: SHA1, - iterations: 1 - }), - - /** - * Initializes a newly created key derivation function. - * - * @param {Object} cfg (Optional) The configuration options to use for the derivation. - * - * @example - * - * var kdf = CryptoJS.algo.PBKDF2.create(); - * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 }); - * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 }); - */ - init: function (cfg) { - this.cfg = this.cfg.extend(cfg); - }, - - /** - * Computes the Password-Based Key Derivation Function 2. - * - * @param {WordArray|string} password The password. - * @param {WordArray|string} salt A salt. - * - * @return {WordArray} The derived key. - * - * @example - * - * var key = kdf.compute(password, salt); - */ - compute: function (password, salt) { - // Shortcut - var cfg = this.cfg; - - // Init HMAC - var hmac = HMAC.create(cfg.hasher, password); - - // Initial values - var derivedKey = WordArray.create(); - var blockIndex = WordArray.create([0x00000001]); - - // Shortcuts - var derivedKeyWords = derivedKey.words; - var blockIndexWords = blockIndex.words; - var keySize = cfg.keySize; - var iterations = cfg.iterations; - - // Generate key - while (derivedKeyWords.length < keySize) { - var block = hmac.update(salt).finalize(blockIndex); - hmac.reset(); - - // Shortcuts - var blockWords = block.words; - var blockWordsLength = blockWords.length; - - // Iterations - var intermediate = block; - for (var i = 1; i < iterations; i++) { - intermediate = hmac.finalize(intermediate); - hmac.reset(); - - // Shortcut - var intermediateWords = intermediate.words; - - // XOR intermediate with block - for (var j = 0; j < blockWordsLength; j++) { - blockWords[j] ^= intermediateWords[j]; - } - } - - derivedKey.concat(block); - blockIndexWords[0]++; - } - derivedKey.sigBytes = keySize * 4; - - return derivedKey; - } - }); - - /** - * Computes the Password-Based Key Derivation Function 2. - * - * @param {WordArray|string} password The password. - * @param {WordArray|string} salt A salt. - * @param {Object} cfg (Optional) The configuration options to use for this computation. - * - * @return {WordArray} The derived key. - * - * @static - * - * @example - * - * var key = CryptoJS.PBKDF2(password, salt); - * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 }); - * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 }); - */ - C.PBKDF2 = function (password, salt, cfg) { - return PBKDF2.create(cfg).compute(password, salt); - }; -}()); diff --git a/src/rabbit-legacy.js b/src/rabbit-legacy.js deleted file mode 100644 index ff02aef..0000000 --- a/src/rabbit-legacy.js +++ /dev/null @@ -1,170 +0,0 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var StreamCipher = C_lib.StreamCipher; - var C_algo = C.algo; - - // Reusable objects - var S = []; - var C_ = []; - var G = []; - - /** - * Rabbit stream cipher algorithm. - * - * This is a legacy version that neglected to convert the key to little-endian. - * This error doesn't affect the cipher's security, - * but it does affect its compatibility with other implementations. - */ - var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({ - _doReset: function () { - // Shortcuts - var K = this._key.words; - var iv = this.cfg.iv; - - // Generate initial state values - var X = this._X = [ - K[0], (K[3] << 16) | (K[2] >>> 16), - K[1], (K[0] << 16) | (K[3] >>> 16), - K[2], (K[1] << 16) | (K[0] >>> 16), - K[3], (K[2] << 16) | (K[1] >>> 16) - ]; - - // Generate initial counter values - var C = this._C = [ - (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), - (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), - (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), - (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff) - ]; - - // Carry bit - this._b = 0; - - // Iterate the system four times - for (var i = 0; i < 4; i++) { - nextState.call(this); - } - - // Modify the counters - for (var i = 0; i < 8; i++) { - C[i] ^= X[(i + 4) & 7]; - } - - // IV setup - if (iv) { - // Shortcuts - var IV = iv.words; - var IV_0 = IV[0]; - var IV_1 = IV[1]; - - // Generate four subvectors - var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); - var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); - var i1 = (i0 >>> 16) | (i2 & 0xffff0000); - var i3 = (i2 << 16) | (i0 & 0x0000ffff); - - // Modify counter values - C[0] ^= i0; - C[1] ^= i1; - C[2] ^= i2; - C[3] ^= i3; - C[4] ^= i0; - C[5] ^= i1; - C[6] ^= i2; - C[7] ^= i3; - - // Iterate the system four times - for (var i = 0; i < 4; i++) { - nextState.call(this); - } - } - }, - - _doProcessBlock: function (M, offset) { - // Shortcut - var X = this._X; - - // Iterate the system - nextState.call(this); - - // Generate four keystream words - S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); - S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); - S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); - S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); - - for (var i = 0; i < 4; i++) { - // Swap endian - S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) | - (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00); - - // Encrypt - M[offset + i] ^= S[i]; - } - }, - - blockSize: 128/32, - - ivSize: 64/32 - }); - - function nextState() { - // Shortcuts - var X = this._X; - var C = this._C; - - // Save old counter values - for (var i = 0; i < 8; i++) { - C_[i] = C[i]; - } - - // Calculate new counter values - C[0] = (C[0] + 0x4d34d34d + this._b) | 0; - C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0; - C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0; - C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0; - C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0; - C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0; - C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0; - C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0; - this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0; - - // Calculate the g-values - for (var i = 0; i < 8; i++) { - var gx = X[i] + C[i]; - - // Construct high and low argument for squaring - var ga = gx & 0xffff; - var gb = gx >>> 16; - - // Calculate high and low result of squaring - var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; - var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); - - // High XOR low - G[i] = gh ^ gl; - } - - // Calculate new state values - X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; - X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; - X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; - X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; - X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; - X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; - X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; - X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; - } - - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg); - * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg); - */ - C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy); -}()); diff --git a/src/rabbit.js b/src/rabbit.js deleted file mode 100644 index e12e759..0000000 --- a/src/rabbit.js +++ /dev/null @@ -1,172 +0,0 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var StreamCipher = C_lib.StreamCipher; - var C_algo = C.algo; - - // Reusable objects - var S = []; - var C_ = []; - var G = []; - - /** - * Rabbit stream cipher algorithm - */ - var Rabbit = C_algo.Rabbit = StreamCipher.extend({ - _doReset: function () { - // Shortcuts - var K = this._key.words; - var iv = this.cfg.iv; - - // Swap endian - for (var i = 0; i < 4; i++) { - K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) | - (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00); - } - - // Generate initial state values - var X = this._X = [ - K[0], (K[3] << 16) | (K[2] >>> 16), - K[1], (K[0] << 16) | (K[3] >>> 16), - K[2], (K[1] << 16) | (K[0] >>> 16), - K[3], (K[2] << 16) | (K[1] >>> 16) - ]; - - // Generate initial counter values - var C = this._C = [ - (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), - (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), - (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), - (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff) - ]; - - // Carry bit - this._b = 0; - - // Iterate the system four times - for (var i = 0; i < 4; i++) { - nextState.call(this); - } - - // Modify the counters - for (var i = 0; i < 8; i++) { - C[i] ^= X[(i + 4) & 7]; - } - - // IV setup - if (iv) { - // Shortcuts - var IV = iv.words; - var IV_0 = IV[0]; - var IV_1 = IV[1]; - - // Generate four subvectors - var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); - var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); - var i1 = (i0 >>> 16) | (i2 & 0xffff0000); - var i3 = (i2 << 16) | (i0 & 0x0000ffff); - - // Modify counter values - C[0] ^= i0; - C[1] ^= i1; - C[2] ^= i2; - C[3] ^= i3; - C[4] ^= i0; - C[5] ^= i1; - C[6] ^= i2; - C[7] ^= i3; - - // Iterate the system four times - for (var i = 0; i < 4; i++) { - nextState.call(this); - } - } - }, - - _doProcessBlock: function (M, offset) { - // Shortcut - var X = this._X; - - // Iterate the system - nextState.call(this); - - // Generate four keystream words - S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); - S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); - S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); - S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); - - for (var i = 0; i < 4; i++) { - // Swap endian - S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) | - (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00); - - // Encrypt - M[offset + i] ^= S[i]; - } - }, - - blockSize: 128/32, - - ivSize: 64/32 - }); - - function nextState() { - // Shortcuts - var X = this._X; - var C = this._C; - - // Save old counter values - for (var i = 0; i < 8; i++) { - C_[i] = C[i]; - } - - // Calculate new counter values - C[0] = (C[0] + 0x4d34d34d + this._b) | 0; - C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0; - C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0; - C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0; - C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0; - C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0; - C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0; - C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0; - this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0; - - // Calculate the g-values - for (var i = 0; i < 8; i++) { - var gx = X[i] + C[i]; - - // Construct high and low argument for squaring - var ga = gx & 0xffff; - var gb = gx >>> 16; - - // Calculate high and low result of squaring - var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; - var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); - - // High XOR low - G[i] = gh ^ gl; - } - - // Calculate new state values - X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; - X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; - X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; - X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; - X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; - X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; - X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; - X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; - } - - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg); - * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg); - */ - C.Rabbit = StreamCipher._createHelper(Rabbit); -}()); diff --git a/src/rc4.js b/src/rc4.js deleted file mode 100644 index cc891d2..0000000 --- a/src/rc4.js +++ /dev/null @@ -1,119 +0,0 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var StreamCipher = C_lib.StreamCipher; - var C_algo = C.algo; - - /** - * RC4 stream cipher algorithm. - */ - var RC4 = C_algo.RC4 = StreamCipher.extend({ - _doReset: function () { - // Shortcuts - var key = this._key; - var keyWords = key.words; - var keySigBytes = key.sigBytes; - - // Init sbox - var S = this._S = []; - for (var i = 0; i < 256; i++) { - S[i] = i; - } - - // Key setup - for (var i = 0, j = 0; i < 256; i++) { - var keyByteIndex = i % keySigBytes; - var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff; - - j = (j + S[i] + keyByte) % 256; - - // Swap - var t = S[i]; - S[i] = S[j]; - S[j] = t; - } - - // Counters - this._i = this._j = 0; - }, - - _doProcessBlock: function (M, offset) { - M[offset] ^= generateKeystreamWord.call(this); - }, - - keySize: 256/32, - - ivSize: 0 - }); - - function generateKeystreamWord() { - // Shortcuts - var S = this._S; - var i = this._i; - var j = this._j; - - // Generate keystream word - var keystreamWord = 0; - for (var n = 0; n < 4; n++) { - i = (i + 1) % 256; - j = (j + S[i]) % 256; - - // Swap - var t = S[i]; - S[i] = S[j]; - S[j] = t; - - keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8); - } - - // Update counters - this._i = i; - this._j = j; - - return keystreamWord; - } - - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg); - * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg); - */ - C.RC4 = StreamCipher._createHelper(RC4); - - /** - * Modified RC4 stream cipher algorithm. - */ - var RC4Drop = C_algo.RC4Drop = RC4.extend({ - /** - * Configuration options. - * - * @property {number} drop The number of keystream words to drop. Default 192 - */ - cfg: RC4.cfg.extend({ - drop: 192 - }), - - _doReset: function () { - RC4._doReset.call(this); - - // Drop - for (var i = this.cfg.drop; i > 0; i--) { - generateKeystreamWord.call(this); - } - } - }); - - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg); - * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg); - */ - C.RC4Drop = StreamCipher._createHelper(RC4Drop); -}()); diff --git a/src/ripemd160.js b/src/ripemd160.js deleted file mode 100644 index 3336bc8..0000000 --- a/src/ripemd160.js +++ /dev/null @@ -1,247 +0,0 @@ -/** @preserve -(c) 2012 by Cédric Mesnil. 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. - -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. -*/ - -(function (Math) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var Hasher = C_lib.Hasher; - var C_algo = C.algo; - - // Constants table - var _zl = WordArray.create([ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, - 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, - 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, - 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]); - var _zr = WordArray.create([ - 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, - 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, - 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, - 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, - 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]); - var _sl = WordArray.create([ - 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, - 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, - 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, - 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, - 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]); - var _sr = WordArray.create([ - 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, - 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, - 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, - 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, - 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]); - - var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]); - var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]); - - /** - * RIPEMD160 hash algorithm. - */ - var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({ - _doReset: function () { - this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]); - }, - - _doProcessBlock: function (M, offset) { - - // Swap endian - for (var i = 0; i < 16; i++) { - // Shortcuts - var offset_i = offset + i; - var M_offset_i = M[offset_i]; - - // Swap - M[offset_i] = ( - (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | - (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) - ); - } - // Shortcut - var H = this._hash.words; - var hl = _hl.words; - var hr = _hr.words; - var zl = _zl.words; - var zr = _zr.words; - var sl = _sl.words; - var sr = _sr.words; - - // Working variables - var al, bl, cl, dl, el; - var ar, br, cr, dr, er; - - ar = al = H[0]; - br = bl = H[1]; - cr = cl = H[2]; - dr = dl = H[3]; - er = el = H[4]; - // Computation - var t; - for (var i = 0; i < 80; i += 1) { - t = (al + M[offset+zl[i]])|0; - if (i<16){ - t += f1(bl,cl,dl) + hl[0]; - } else if (i<32) { - t += f2(bl,cl,dl) + hl[1]; - } else if (i<48) { - t += f3(bl,cl,dl) + hl[2]; - } else if (i<64) { - t += f4(bl,cl,dl) + hl[3]; - } else {// if (i<80) { - t += f5(bl,cl,dl) + hl[4]; - } - t = t|0; - t = rotl(t,sl[i]); - t = (t+el)|0; - al = el; - el = dl; - dl = rotl(cl, 10); - cl = bl; - bl = t; - - t = (ar + M[offset+zr[i]])|0; - if (i<16){ - t += f5(br,cr,dr) + hr[0]; - } else if (i<32) { - t += f4(br,cr,dr) + hr[1]; - } else if (i<48) { - t += f3(br,cr,dr) + hr[2]; - } else if (i<64) { - t += f2(br,cr,dr) + hr[3]; - } else {// if (i<80) { - t += f1(br,cr,dr) + hr[4]; - } - t = t|0; - t = rotl(t,sr[i]) ; - t = (t+er)|0; - ar = er; - er = dr; - dr = rotl(cr, 10); - cr = br; - br = t; - } - // Intermediate hash value - t = (H[1] + cl + dr)|0; - H[1] = (H[2] + dl + er)|0; - H[2] = (H[3] + el + ar)|0; - H[3] = (H[4] + al + br)|0; - H[4] = (H[0] + bl + cr)|0; - H[0] = t; - }, - - _doFinalize: function () { - // Shortcuts - var data = this._data; - var dataWords = data.words; - - var nBitsTotal = this._nDataBytes * 8; - var nBitsLeft = data.sigBytes * 8; - - // Add padding - dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( - (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) | - (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00) - ); - data.sigBytes = (dataWords.length + 1) * 4; - - // Hash final blocks - this._process(); - - // Shortcuts - var hash = this._hash; - var H = hash.words; - - // Swap endian - for (var i = 0; i < 5; i++) { - // Shortcut - var H_i = H[i]; - - // Swap - H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) | - (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); - } - - // Return final computed hash - return hash; - }, - - clone: function () { - var clone = Hasher.clone.call(this); - clone._hash = this._hash.clone(); - - return clone; - } - }); - - - function f1(x, y, z) { - return ((x) ^ (y) ^ (z)); - - } - - function f2(x, y, z) { - return (((x)&(y)) | ((~x)&(z))); - } - - function f3(x, y, z) { - return (((x) | (~(y))) ^ (z)); - } - - function f4(x, y, z) { - return (((x) & (z)) | ((y)&(~(z)))); - } - - function f5(x, y, z) { - return ((x) ^ ((y) |(~(z)))); - - } - - function rotl(x,n) { - return (x<>>(32-n)); - } - - - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.RIPEMD160('message'); - * var hash = CryptoJS.RIPEMD160(wordArray); - */ - C.RIPEMD160 = Hasher._createHelper(RIPEMD160); - - /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacRIPEMD160(message, key); - */ - C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160); -}(Math)); diff --git a/src/sha1.js b/src/sha1.js deleted file mode 100644 index d052aeb..0000000 --- a/src/sha1.js +++ /dev/null @@ -1,130 +0,0 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var Hasher = C_lib.Hasher; - var C_algo = C.algo; - - // Reusable object - var W = []; - - /** - * SHA-1 hash algorithm. - */ - var SHA1 = C_algo.SHA1 = Hasher.extend({ - _doReset: function () { - this._hash = new WordArray.init([ - 0x67452301, 0xefcdab89, - 0x98badcfe, 0x10325476, - 0xc3d2e1f0 - ]); - }, - - _doProcessBlock: function (M, offset) { - // Shortcut - var H = this._hash.words; - - // Working variables - var a = H[0]; - var b = H[1]; - var c = H[2]; - var d = H[3]; - var e = H[4]; - - // Computation - for (var i = 0; i < 80; i++) { - if (i < 16) { - W[i] = M[offset + i] | 0; - } else { - var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; - W[i] = (n << 1) | (n >>> 31); - } - - var t = ((a << 5) | (a >>> 27)) + e + W[i]; - if (i < 20) { - t += ((b & c) | (~b & d)) + 0x5a827999; - } else if (i < 40) { - t += (b ^ c ^ d) + 0x6ed9eba1; - } else if (i < 60) { - t += ((b & c) | (b & d) | (c & d)) - 0x70e44324; - } else /* if (i < 80) */ { - t += (b ^ c ^ d) - 0x359d3e2a; - } - - e = d; - d = c; - c = (b << 30) | (b >>> 2); - b = a; - a = t; - } - - // Intermediate hash value - H[0] = (H[0] + a) | 0; - H[1] = (H[1] + b) | 0; - H[2] = (H[2] + c) | 0; - H[3] = (H[3] + d) | 0; - H[4] = (H[4] + e) | 0; - }, - - _doFinalize: function () { - // Shortcuts - var data = this._data; - var dataWords = data.words; - - var nBitsTotal = this._nDataBytes * 8; - var nBitsLeft = data.sigBytes * 8; - - // Add padding - dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; - data.sigBytes = dataWords.length * 4; - - // Hash final blocks - this._process(); - - // Return final computed hash - return this._hash; - }, - - clone: function () { - var clone = Hasher.clone.call(this); - clone._hash = this._hash.clone(); - - return clone; - } - }); - - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.SHA1('message'); - * var hash = CryptoJS.SHA1(wordArray); - */ - C.SHA1 = Hasher._createHelper(SHA1); - - /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacSHA1(message, key); - */ - C.HmacSHA1 = Hasher._createHmacHelper(SHA1); -}()); diff --git a/src/sha224.js b/src/sha224.js deleted file mode 100644 index 6bd2533..0000000 --- a/src/sha224.js +++ /dev/null @@ -1,60 +0,0 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var C_algo = C.algo; - var SHA256 = C_algo.SHA256; - - /** - * SHA-224 hash algorithm. - */ - var SHA224 = C_algo.SHA224 = SHA256.extend({ - _doReset: function () { - this._hash = new WordArray.init([ - 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, - 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 - ]); - }, - - _doFinalize: function () { - var hash = SHA256._doFinalize.call(this); - - hash.sigBytes -= 4; - - return hash; - } - }); - - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.SHA224('message'); - * var hash = CryptoJS.SHA224(wordArray); - */ - C.SHA224 = SHA256._createHelper(SHA224); - - /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacSHA224(message, key); - */ - C.HmacSHA224 = SHA256._createHmacHelper(SHA224); -}()); diff --git a/src/sha256.js b/src/sha256.js deleted file mode 100644 index ce5525d..0000000 --- a/src/sha256.js +++ /dev/null @@ -1,179 +0,0 @@ -(function (Math) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var Hasher = C_lib.Hasher; - var C_algo = C.algo; - - // Initialization and round constants tables - var H = []; - var K = []; - - // Compute constants - (function () { - function isPrime(n) { - var sqrtN = Math.sqrt(n); - for (var factor = 2; factor <= sqrtN; factor++) { - if (!(n % factor)) { - return false; - } - } - - return true; - } - - function getFractionalBits(n) { - return ((n - (n | 0)) * 0x100000000) | 0; - } - - var n = 2; - var nPrime = 0; - while (nPrime < 64) { - if (isPrime(n)) { - if (nPrime < 8) { - H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2)); - } - K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3)); - - nPrime++; - } - - n++; - } - }()); - - // Reusable object - var W = []; - - /** - * SHA-256 hash algorithm. - */ - var SHA256 = C_algo.SHA256 = Hasher.extend({ - _doReset: function () { - this._hash = new WordArray.init(H.slice(0)); - }, - - _doProcessBlock: function (M, offset) { - // Shortcut - var H = this._hash.words; - - // Working variables - var a = H[0]; - var b = H[1]; - var c = H[2]; - var d = H[3]; - var e = H[4]; - var f = H[5]; - var g = H[6]; - var h = H[7]; - - // Computation - for (var i = 0; i < 64; i++) { - if (i < 16) { - W[i] = M[offset + i] | 0; - } else { - var gamma0x = W[i - 15]; - var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^ - ((gamma0x << 14) | (gamma0x >>> 18)) ^ - (gamma0x >>> 3); - - var gamma1x = W[i - 2]; - var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^ - ((gamma1x << 13) | (gamma1x >>> 19)) ^ - (gamma1x >>> 10); - - W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]; - } - - var ch = (e & f) ^ (~e & g); - var maj = (a & b) ^ (a & c) ^ (b & c); - - var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22)); - var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25)); - - var t1 = h + sigma1 + ch + K[i] + W[i]; - var t2 = sigma0 + maj; - - h = g; - g = f; - f = e; - e = (d + t1) | 0; - d = c; - c = b; - b = a; - a = (t1 + t2) | 0; - } - - // Intermediate hash value - H[0] = (H[0] + a) | 0; - H[1] = (H[1] + b) | 0; - H[2] = (H[2] + c) | 0; - H[3] = (H[3] + d) | 0; - H[4] = (H[4] + e) | 0; - H[5] = (H[5] + f) | 0; - H[6] = (H[6] + g) | 0; - H[7] = (H[7] + h) | 0; - }, - - _doFinalize: function () { - // Shortcuts - var data = this._data; - var dataWords = data.words; - - var nBitsTotal = this._nDataBytes * 8; - var nBitsLeft = data.sigBytes * 8; - - // Add padding - dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; - data.sigBytes = dataWords.length * 4; - - // Hash final blocks - this._process(); - - // Return final computed hash - return this._hash; - }, - - clone: function () { - var clone = Hasher.clone.call(this); - clone._hash = this._hash.clone(); - - return clone; - } - }); - - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.SHA256('message'); - * var hash = CryptoJS.SHA256(wordArray); - */ - C.SHA256 = Hasher._createHelper(SHA256); - - /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacSHA256(message, key); - */ - C.HmacSHA256 = Hasher._createHmacHelper(SHA256); -}(Math)); diff --git a/src/sha3.js b/src/sha3.js deleted file mode 100644 index 9545fcd..0000000 --- a/src/sha3.js +++ /dev/null @@ -1,306 +0,0 @@ -(function (Math) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var Hasher = C_lib.Hasher; - var C_x64 = C.x64; - var X64Word = C_x64.Word; - var C_algo = C.algo; - - // Constants tables - var RHO_OFFSETS = []; - var PI_INDEXES = []; - var ROUND_CONSTANTS = []; - - // Compute Constants - (function () { - // Compute rho offset constants - var x = 1, y = 0; - for (var t = 0; t < 24; t++) { - RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64; - - var newX = y % 5; - var newY = (2 * x + 3 * y) % 5; - x = newX; - y = newY; - } - - // Compute pi index constants - for (var x = 0; x < 5; x++) { - for (var y = 0; y < 5; y++) { - PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5; - } - } - - // Compute round constants - var LFSR = 0x01; - for (var i = 0; i < 24; i++) { - var roundConstantMsw = 0; - var roundConstantLsw = 0; - - for (var j = 0; j < 7; j++) { - if (LFSR & 0x01) { - var bitPosition = (1 << j) - 1; - if (bitPosition < 32) { - roundConstantLsw ^= 1 << bitPosition; - } else /* if (bitPosition >= 32) */ { - roundConstantMsw ^= 1 << (bitPosition - 32); - } - } - - // Compute next LFSR - if (LFSR & 0x80) { - // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1 - LFSR = (LFSR << 1) ^ 0x71; - } else { - LFSR <<= 1; - } - } - - ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw); - } - }()); - - // Reusable objects for temporary values - var T = []; - (function () { - for (var i = 0; i < 25; i++) { - T[i] = X64Word.create(); - } - }()); - - /** - * SHA-3 hash algorithm. - */ - var SHA3 = C_algo.SHA3 = Hasher.extend({ - /** - * Configuration options. - * - * @property {number} outputLength - * The desired number of bits in the output hash. - * Only values permitted are: 224, 256, 384, 512. - * Default: 512 - */ - cfg: Hasher.cfg.extend({ - outputLength: 512 - }), - - _doReset: function () { - var state = this._state = [] - for (var i = 0; i < 25; i++) { - state[i] = new X64Word.init(); - } - - this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32; - }, - - _doProcessBlock: function (M, offset) { - // Shortcuts - var state = this._state; - var nBlockSizeLanes = this.blockSize / 2; - - // Absorb - for (var i = 0; i < nBlockSizeLanes; i++) { - // Shortcuts - var M2i = M[offset + 2 * i]; - var M2i1 = M[offset + 2 * i + 1]; - - // Swap endian - M2i = ( - (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) | - (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00) - ); - M2i1 = ( - (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) | - (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00) - ); - - // Absorb message into state - var lane = state[i]; - lane.high ^= M2i1; - lane.low ^= M2i; - } - - // Rounds - for (var round = 0; round < 24; round++) { - // Theta - for (var x = 0; x < 5; x++) { - // Mix column lanes - var tMsw = 0, tLsw = 0; - for (var y = 0; y < 5; y++) { - var lane = state[x + 5 * y]; - tMsw ^= lane.high; - tLsw ^= lane.low; - } - - // Temporary values - var Tx = T[x]; - Tx.high = tMsw; - Tx.low = tLsw; - } - for (var x = 0; x < 5; x++) { - // Shortcuts - var Tx4 = T[(x + 4) % 5]; - var Tx1 = T[(x + 1) % 5]; - var Tx1Msw = Tx1.high; - var Tx1Lsw = Tx1.low; - - // Mix surrounding columns - var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31)); - var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31)); - for (var y = 0; y < 5; y++) { - var lane = state[x + 5 * y]; - lane.high ^= tMsw; - lane.low ^= tLsw; - } - } - - // Rho Pi - for (var laneIndex = 1; laneIndex < 25; laneIndex++) { - var tMsw; - var tLsw; - - // Shortcuts - var lane = state[laneIndex]; - var laneMsw = lane.high; - var laneLsw = lane.low; - var rhoOffset = RHO_OFFSETS[laneIndex]; - - // Rotate lanes - if (rhoOffset < 32) { - tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset)); - tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset)); - } else /* if (rhoOffset >= 32) */ { - tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset)); - tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset)); - } - - // Transpose lanes - var TPiLane = T[PI_INDEXES[laneIndex]]; - TPiLane.high = tMsw; - TPiLane.low = tLsw; - } - - // Rho pi at x = y = 0 - var T0 = T[0]; - var state0 = state[0]; - T0.high = state0.high; - T0.low = state0.low; - - // Chi - for (var x = 0; x < 5; x++) { - for (var y = 0; y < 5; y++) { - // Shortcuts - var laneIndex = x + 5 * y; - var lane = state[laneIndex]; - var TLane = T[laneIndex]; - var Tx1Lane = T[((x + 1) % 5) + 5 * y]; - var Tx2Lane = T[((x + 2) % 5) + 5 * y]; - - // Mix rows - lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high); - lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low); - } - } - - // Iota - var lane = state[0]; - var roundConstant = ROUND_CONSTANTS[round]; - lane.high ^= roundConstant.high; - lane.low ^= roundConstant.low; - } - }, - - _doFinalize: function () { - // Shortcuts - var data = this._data; - var dataWords = data.words; - var nBitsTotal = this._nDataBytes * 8; - var nBitsLeft = data.sigBytes * 8; - var blockSizeBits = this.blockSize * 32; - - // Add padding - dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32); - dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80; - data.sigBytes = dataWords.length * 4; - - // Hash final blocks - this._process(); - - // Shortcuts - var state = this._state; - var outputLengthBytes = this.cfg.outputLength / 8; - var outputLengthLanes = outputLengthBytes / 8; - - // Squeeze - var hashWords = []; - for (var i = 0; i < outputLengthLanes; i++) { - // Shortcuts - var lane = state[i]; - var laneMsw = lane.high; - var laneLsw = lane.low; - - // Swap endian - laneMsw = ( - (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) | - (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00) - ); - laneLsw = ( - (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) | - (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00) - ); - - // Squeeze state to retrieve hash - hashWords.push(laneLsw); - hashWords.push(laneMsw); - } - - // Return final computed hash - return new WordArray.init(hashWords, outputLengthBytes); - }, - - clone: function () { - var clone = Hasher.clone.call(this); - - var state = clone._state = this._state.slice(0); - for (var i = 0; i < 25; i++) { - state[i] = state[i].clone(); - } - - return clone; - } - }); - - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.SHA3('message'); - * var hash = CryptoJS.SHA3(wordArray); - */ - C.SHA3 = Hasher._createHelper(SHA3); - - /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacSHA3(message, key); - */ - C.HmacSHA3 = Hasher._createHmacHelper(SHA3); -}(Math)); diff --git a/src/sha384.js b/src/sha384.js deleted file mode 100644 index b15965b..0000000 --- a/src/sha384.js +++ /dev/null @@ -1,63 +0,0 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_x64 = C.x64; - var X64Word = C_x64.Word; - var X64WordArray = C_x64.WordArray; - var C_algo = C.algo; - var SHA512 = C_algo.SHA512; - - /** - * SHA-384 hash algorithm. - */ - var SHA384 = C_algo.SHA384 = SHA512.extend({ - _doReset: function () { - this._hash = new X64WordArray.init([ - new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507), - new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939), - new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511), - new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4) - ]); - }, - - _doFinalize: function () { - var hash = SHA512._doFinalize.call(this); - - hash.sigBytes -= 16; - - return hash; - } - }); - - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.SHA384('message'); - * var hash = CryptoJS.SHA384(wordArray); - */ - C.SHA384 = SHA512._createHelper(SHA384); - - /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacSHA384(message, key); - */ - C.HmacSHA384 = SHA512._createHmacHelper(SHA384); -}()); diff --git a/src/sha512.js b/src/sha512.js deleted file mode 100644 index 2ca9991..0000000 --- a/src/sha512.js +++ /dev/null @@ -1,306 +0,0 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Hasher = C_lib.Hasher; - var C_x64 = C.x64; - var X64Word = C_x64.Word; - var X64WordArray = C_x64.WordArray; - var C_algo = C.algo; - - function X64Word_create() { - return X64Word.create.apply(X64Word, arguments); - } - - // Constants - var K = [ - X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd), - X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc), - X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019), - X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118), - X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe), - X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2), - X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1), - X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694), - X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3), - X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65), - X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483), - X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5), - X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210), - X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4), - X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725), - X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70), - X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926), - X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df), - X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8), - X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b), - X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001), - X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30), - X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910), - X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8), - X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53), - X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8), - X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb), - X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3), - X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60), - X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec), - X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9), - X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b), - X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207), - X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178), - X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6), - X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b), - X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493), - X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c), - X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a), - X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817) - ]; - - // Reusable objects - var W = []; - (function () { - for (var i = 0; i < 80; i++) { - W[i] = X64Word_create(); - } - }()); - - /** - * SHA-512 hash algorithm. - */ - var SHA512 = C_algo.SHA512 = Hasher.extend({ - _doReset: function () { - this._hash = new X64WordArray.init([ - new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b), - new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1), - new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f), - new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179) - ]); - }, - - _doProcessBlock: function (M, offset) { - // Shortcuts - var H = this._hash.words; - - var H0 = H[0]; - var H1 = H[1]; - var H2 = H[2]; - var H3 = H[3]; - var H4 = H[4]; - var H5 = H[5]; - var H6 = H[6]; - var H7 = H[7]; - - var H0h = H0.high; - var H0l = H0.low; - var H1h = H1.high; - var H1l = H1.low; - var H2h = H2.high; - var H2l = H2.low; - var H3h = H3.high; - var H3l = H3.low; - var H4h = H4.high; - var H4l = H4.low; - var H5h = H5.high; - var H5l = H5.low; - var H6h = H6.high; - var H6l = H6.low; - var H7h = H7.high; - var H7l = H7.low; - - // Working variables - var ah = H0h; - var al = H0l; - var bh = H1h; - var bl = H1l; - var ch = H2h; - var cl = H2l; - var dh = H3h; - var dl = H3l; - var eh = H4h; - var el = H4l; - var fh = H5h; - var fl = H5l; - var gh = H6h; - var gl = H6l; - var hh = H7h; - var hl = H7l; - - // Rounds - for (var i = 0; i < 80; i++) { - var Wil; - var Wih; - - // Shortcut - var Wi = W[i]; - - // Extend message - if (i < 16) { - Wih = Wi.high = M[offset + i * 2] | 0; - Wil = Wi.low = M[offset + i * 2 + 1] | 0; - } else { - // Gamma0 - var gamma0x = W[i - 15]; - var gamma0xh = gamma0x.high; - var gamma0xl = gamma0x.low; - var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7); - var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25)); - - // Gamma1 - var gamma1x = W[i - 2]; - var gamma1xh = gamma1x.high; - var gamma1xl = gamma1x.low; - var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6); - var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26)); - - // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] - var Wi7 = W[i - 7]; - var Wi7h = Wi7.high; - var Wi7l = Wi7.low; - - var Wi16 = W[i - 16]; - var Wi16h = Wi16.high; - var Wi16l = Wi16.low; - - Wil = gamma0l + Wi7l; - Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0); - Wil = Wil + gamma1l; - Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0); - Wil = Wil + Wi16l; - Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0); - - Wi.high = Wih; - Wi.low = Wil; - } - - var chh = (eh & fh) ^ (~eh & gh); - var chl = (el & fl) ^ (~el & gl); - var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch); - var majl = (al & bl) ^ (al & cl) ^ (bl & cl); - - var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7)); - var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7)); - var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9)); - var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9)); - - // t1 = h + sigma1 + ch + K[i] + W[i] - var Ki = K[i]; - var Kih = Ki.high; - var Kil = Ki.low; - - var t1l = hl + sigma1l; - var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0); - var t1l = t1l + chl; - var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0); - var t1l = t1l + Kil; - var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0); - var t1l = t1l + Wil; - var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0); - - // t2 = sigma0 + maj - var t2l = sigma0l + majl; - var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0); - - // Update working variables - hh = gh; - hl = gl; - gh = fh; - gl = fl; - fh = eh; - fl = el; - el = (dl + t1l) | 0; - eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0; - dh = ch; - dl = cl; - ch = bh; - cl = bl; - bh = ah; - bl = al; - al = (t1l + t2l) | 0; - ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0; - } - - // Intermediate hash value - H0l = H0.low = (H0l + al); - H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0)); - H1l = H1.low = (H1l + bl); - H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0)); - H2l = H2.low = (H2l + cl); - H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0)); - H3l = H3.low = (H3l + dl); - H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0)); - H4l = H4.low = (H4l + el); - H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0)); - H5l = H5.low = (H5l + fl); - H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0)); - H6l = H6.low = (H6l + gl); - H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0)); - H7l = H7.low = (H7l + hl); - H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0)); - }, - - _doFinalize: function () { - // Shortcuts - var data = this._data; - var dataWords = data.words; - - var nBitsTotal = this._nDataBytes * 8; - var nBitsLeft = data.sigBytes * 8; - - // Add padding - dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); - dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000); - dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal; - data.sigBytes = dataWords.length * 4; - - // Hash final blocks - this._process(); - - // Convert hash to 32-bit word array before returning - var hash = this._hash.toX32(); - - // Return final computed hash - return hash; - }, - - clone: function () { - var clone = Hasher.clone.call(this); - clone._hash = this._hash.clone(); - - return clone; - }, - - blockSize: 1024/32 - }); - - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.SHA512('message'); - * var hash = CryptoJS.SHA512(wordArray); - */ - C.SHA512 = Hasher._createHelper(SHA512); - - /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacSHA512(message, key); - */ - C.HmacSHA512 = Hasher._createHmacHelper(SHA512); -}()); diff --git a/src/tripledes.js b/src/tripledes.js deleted file mode 100644 index 8771943..0000000 --- a/src/tripledes.js +++ /dev/null @@ -1,750 +0,0 @@ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var BlockCipher = C_lib.BlockCipher; - var C_algo = C.algo; - - // Permuted Choice 1 constants - var PC1 = [ - 57, 49, 41, 33, 25, 17, 9, 1, - 58, 50, 42, 34, 26, 18, 10, 2, - 59, 51, 43, 35, 27, 19, 11, 3, - 60, 52, 44, 36, 63, 55, 47, 39, - 31, 23, 15, 7, 62, 54, 46, 38, - 30, 22, 14, 6, 61, 53, 45, 37, - 29, 21, 13, 5, 28, 20, 12, 4 - ]; - - // Permuted Choice 2 constants - var PC2 = [ - 14, 17, 11, 24, 1, 5, - 3, 28, 15, 6, 21, 10, - 23, 19, 12, 4, 26, 8, - 16, 7, 27, 20, 13, 2, - 41, 52, 31, 37, 47, 55, - 30, 40, 51, 45, 33, 48, - 44, 49, 39, 56, 34, 53, - 46, 42, 50, 36, 29, 32 - ]; - - // Cumulative bit shift constants - var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28]; - - // SBOXes and round permutation constants - var SBOX_P = [ - { - 0x0: 0x808200, - 0x10000000: 0x8000, - 0x20000000: 0x808002, - 0x30000000: 0x2, - 0x40000000: 0x200, - 0x50000000: 0x808202, - 0x60000000: 0x800202, - 0x70000000: 0x800000, - 0x80000000: 0x202, - 0x90000000: 0x800200, - 0xa0000000: 0x8200, - 0xb0000000: 0x808000, - 0xc0000000: 0x8002, - 0xd0000000: 0x800002, - 0xe0000000: 0x0, - 0xf0000000: 0x8202, - 0x8000000: 0x0, - 0x18000000: 0x808202, - 0x28000000: 0x8202, - 0x38000000: 0x8000, - 0x48000000: 0x808200, - 0x58000000: 0x200, - 0x68000000: 0x808002, - 0x78000000: 0x2, - 0x88000000: 0x800200, - 0x98000000: 0x8200, - 0xa8000000: 0x808000, - 0xb8000000: 0x800202, - 0xc8000000: 0x800002, - 0xd8000000: 0x8002, - 0xe8000000: 0x202, - 0xf8000000: 0x800000, - 0x1: 0x8000, - 0x10000001: 0x2, - 0x20000001: 0x808200, - 0x30000001: 0x800000, - 0x40000001: 0x808002, - 0x50000001: 0x8200, - 0x60000001: 0x200, - 0x70000001: 0x800202, - 0x80000001: 0x808202, - 0x90000001: 0x808000, - 0xa0000001: 0x800002, - 0xb0000001: 0x8202, - 0xc0000001: 0x202, - 0xd0000001: 0x800200, - 0xe0000001: 0x8002, - 0xf0000001: 0x0, - 0x8000001: 0x808202, - 0x18000001: 0x808000, - 0x28000001: 0x800000, - 0x38000001: 0x200, - 0x48000001: 0x8000, - 0x58000001: 0x800002, - 0x68000001: 0x2, - 0x78000001: 0x8202, - 0x88000001: 0x8002, - 0x98000001: 0x800202, - 0xa8000001: 0x202, - 0xb8000001: 0x808200, - 0xc8000001: 0x800200, - 0xd8000001: 0x0, - 0xe8000001: 0x8200, - 0xf8000001: 0x808002 - }, - { - 0x0: 0x40084010, - 0x1000000: 0x4000, - 0x2000000: 0x80000, - 0x3000000: 0x40080010, - 0x4000000: 0x40000010, - 0x5000000: 0x40084000, - 0x6000000: 0x40004000, - 0x7000000: 0x10, - 0x8000000: 0x84000, - 0x9000000: 0x40004010, - 0xa000000: 0x40000000, - 0xb000000: 0x84010, - 0xc000000: 0x80010, - 0xd000000: 0x0, - 0xe000000: 0x4010, - 0xf000000: 0x40080000, - 0x800000: 0x40004000, - 0x1800000: 0x84010, - 0x2800000: 0x10, - 0x3800000: 0x40004010, - 0x4800000: 0x40084010, - 0x5800000: 0x40000000, - 0x6800000: 0x80000, - 0x7800000: 0x40080010, - 0x8800000: 0x80010, - 0x9800000: 0x0, - 0xa800000: 0x4000, - 0xb800000: 0x40080000, - 0xc800000: 0x40000010, - 0xd800000: 0x84000, - 0xe800000: 0x40084000, - 0xf800000: 0x4010, - 0x10000000: 0x0, - 0x11000000: 0x40080010, - 0x12000000: 0x40004010, - 0x13000000: 0x40084000, - 0x14000000: 0x40080000, - 0x15000000: 0x10, - 0x16000000: 0x84010, - 0x17000000: 0x4000, - 0x18000000: 0x4010, - 0x19000000: 0x80000, - 0x1a000000: 0x80010, - 0x1b000000: 0x40000010, - 0x1c000000: 0x84000, - 0x1d000000: 0x40004000, - 0x1e000000: 0x40000000, - 0x1f000000: 0x40084010, - 0x10800000: 0x84010, - 0x11800000: 0x80000, - 0x12800000: 0x40080000, - 0x13800000: 0x4000, - 0x14800000: 0x40004000, - 0x15800000: 0x40084010, - 0x16800000: 0x10, - 0x17800000: 0x40000000, - 0x18800000: 0x40084000, - 0x19800000: 0x40000010, - 0x1a800000: 0x40004010, - 0x1b800000: 0x80010, - 0x1c800000: 0x0, - 0x1d800000: 0x4010, - 0x1e800000: 0x40080010, - 0x1f800000: 0x84000 - }, - { - 0x0: 0x104, - 0x100000: 0x0, - 0x200000: 0x4000100, - 0x300000: 0x10104, - 0x400000: 0x10004, - 0x500000: 0x4000004, - 0x600000: 0x4010104, - 0x700000: 0x4010000, - 0x800000: 0x4000000, - 0x900000: 0x4010100, - 0xa00000: 0x10100, - 0xb00000: 0x4010004, - 0xc00000: 0x4000104, - 0xd00000: 0x10000, - 0xe00000: 0x4, - 0xf00000: 0x100, - 0x80000: 0x4010100, - 0x180000: 0x4010004, - 0x280000: 0x0, - 0x380000: 0x4000100, - 0x480000: 0x4000004, - 0x580000: 0x10000, - 0x680000: 0x10004, - 0x780000: 0x104, - 0x880000: 0x4, - 0x980000: 0x100, - 0xa80000: 0x4010000, - 0xb80000: 0x10104, - 0xc80000: 0x10100, - 0xd80000: 0x4000104, - 0xe80000: 0x4010104, - 0xf80000: 0x4000000, - 0x1000000: 0x4010100, - 0x1100000: 0x10004, - 0x1200000: 0x10000, - 0x1300000: 0x4000100, - 0x1400000: 0x100, - 0x1500000: 0x4010104, - 0x1600000: 0x4000004, - 0x1700000: 0x0, - 0x1800000: 0x4000104, - 0x1900000: 0x4000000, - 0x1a00000: 0x4, - 0x1b00000: 0x10100, - 0x1c00000: 0x4010000, - 0x1d00000: 0x104, - 0x1e00000: 0x10104, - 0x1f00000: 0x4010004, - 0x1080000: 0x4000000, - 0x1180000: 0x104, - 0x1280000: 0x4010100, - 0x1380000: 0x0, - 0x1480000: 0x10004, - 0x1580000: 0x4000100, - 0x1680000: 0x100, - 0x1780000: 0x4010004, - 0x1880000: 0x10000, - 0x1980000: 0x4010104, - 0x1a80000: 0x10104, - 0x1b80000: 0x4000004, - 0x1c80000: 0x4000104, - 0x1d80000: 0x4010000, - 0x1e80000: 0x4, - 0x1f80000: 0x10100 - }, - { - 0x0: 0x80401000, - 0x10000: 0x80001040, - 0x20000: 0x401040, - 0x30000: 0x80400000, - 0x40000: 0x0, - 0x50000: 0x401000, - 0x60000: 0x80000040, - 0x70000: 0x400040, - 0x80000: 0x80000000, - 0x90000: 0x400000, - 0xa0000: 0x40, - 0xb0000: 0x80001000, - 0xc0000: 0x80400040, - 0xd0000: 0x1040, - 0xe0000: 0x1000, - 0xf0000: 0x80401040, - 0x8000: 0x80001040, - 0x18000: 0x40, - 0x28000: 0x80400040, - 0x38000: 0x80001000, - 0x48000: 0x401000, - 0x58000: 0x80401040, - 0x68000: 0x0, - 0x78000: 0x80400000, - 0x88000: 0x1000, - 0x98000: 0x80401000, - 0xa8000: 0x400000, - 0xb8000: 0x1040, - 0xc8000: 0x80000000, - 0xd8000: 0x400040, - 0xe8000: 0x401040, - 0xf8000: 0x80000040, - 0x100000: 0x400040, - 0x110000: 0x401000, - 0x120000: 0x80000040, - 0x130000: 0x0, - 0x140000: 0x1040, - 0x150000: 0x80400040, - 0x160000: 0x80401000, - 0x170000: 0x80001040, - 0x180000: 0x80401040, - 0x190000: 0x80000000, - 0x1a0000: 0x80400000, - 0x1b0000: 0x401040, - 0x1c0000: 0x80001000, - 0x1d0000: 0x400000, - 0x1e0000: 0x40, - 0x1f0000: 0x1000, - 0x108000: 0x80400000, - 0x118000: 0x80401040, - 0x128000: 0x0, - 0x138000: 0x401000, - 0x148000: 0x400040, - 0x158000: 0x80000000, - 0x168000: 0x80001040, - 0x178000: 0x40, - 0x188000: 0x80000040, - 0x198000: 0x1000, - 0x1a8000: 0x80001000, - 0x1b8000: 0x80400040, - 0x1c8000: 0x1040, - 0x1d8000: 0x80401000, - 0x1e8000: 0x400000, - 0x1f8000: 0x401040 - }, - { - 0x0: 0x80, - 0x1000: 0x1040000, - 0x2000: 0x40000, - 0x3000: 0x20000000, - 0x4000: 0x20040080, - 0x5000: 0x1000080, - 0x6000: 0x21000080, - 0x7000: 0x40080, - 0x8000: 0x1000000, - 0x9000: 0x20040000, - 0xa000: 0x20000080, - 0xb000: 0x21040080, - 0xc000: 0x21040000, - 0xd000: 0x0, - 0xe000: 0x1040080, - 0xf000: 0x21000000, - 0x800: 0x1040080, - 0x1800: 0x21000080, - 0x2800: 0x80, - 0x3800: 0x1040000, - 0x4800: 0x40000, - 0x5800: 0x20040080, - 0x6800: 0x21040000, - 0x7800: 0x20000000, - 0x8800: 0x20040000, - 0x9800: 0x0, - 0xa800: 0x21040080, - 0xb800: 0x1000080, - 0xc800: 0x20000080, - 0xd800: 0x21000000, - 0xe800: 0x1000000, - 0xf800: 0x40080, - 0x10000: 0x40000, - 0x11000: 0x80, - 0x12000: 0x20000000, - 0x13000: 0x21000080, - 0x14000: 0x1000080, - 0x15000: 0x21040000, - 0x16000: 0x20040080, - 0x17000: 0x1000000, - 0x18000: 0x21040080, - 0x19000: 0x21000000, - 0x1a000: 0x1040000, - 0x1b000: 0x20040000, - 0x1c000: 0x40080, - 0x1d000: 0x20000080, - 0x1e000: 0x0, - 0x1f000: 0x1040080, - 0x10800: 0x21000080, - 0x11800: 0x1000000, - 0x12800: 0x1040000, - 0x13800: 0x20040080, - 0x14800: 0x20000000, - 0x15800: 0x1040080, - 0x16800: 0x80, - 0x17800: 0x21040000, - 0x18800: 0x40080, - 0x19800: 0x21040080, - 0x1a800: 0x0, - 0x1b800: 0x21000000, - 0x1c800: 0x1000080, - 0x1d800: 0x40000, - 0x1e800: 0x20040000, - 0x1f800: 0x20000080 - }, - { - 0x0: 0x10000008, - 0x100: 0x2000, - 0x200: 0x10200000, - 0x300: 0x10202008, - 0x400: 0x10002000, - 0x500: 0x200000, - 0x600: 0x200008, - 0x700: 0x10000000, - 0x800: 0x0, - 0x900: 0x10002008, - 0xa00: 0x202000, - 0xb00: 0x8, - 0xc00: 0x10200008, - 0xd00: 0x202008, - 0xe00: 0x2008, - 0xf00: 0x10202000, - 0x80: 0x10200000, - 0x180: 0x10202008, - 0x280: 0x8, - 0x380: 0x200000, - 0x480: 0x202008, - 0x580: 0x10000008, - 0x680: 0x10002000, - 0x780: 0x2008, - 0x880: 0x200008, - 0x980: 0x2000, - 0xa80: 0x10002008, - 0xb80: 0x10200008, - 0xc80: 0x0, - 0xd80: 0x10202000, - 0xe80: 0x202000, - 0xf80: 0x10000000, - 0x1000: 0x10002000, - 0x1100: 0x10200008, - 0x1200: 0x10202008, - 0x1300: 0x2008, - 0x1400: 0x200000, - 0x1500: 0x10000000, - 0x1600: 0x10000008, - 0x1700: 0x202000, - 0x1800: 0x202008, - 0x1900: 0x0, - 0x1a00: 0x8, - 0x1b00: 0x10200000, - 0x1c00: 0x2000, - 0x1d00: 0x10002008, - 0x1e00: 0x10202000, - 0x1f00: 0x200008, - 0x1080: 0x8, - 0x1180: 0x202000, - 0x1280: 0x200000, - 0x1380: 0x10000008, - 0x1480: 0x10002000, - 0x1580: 0x2008, - 0x1680: 0x10202008, - 0x1780: 0x10200000, - 0x1880: 0x10202000, - 0x1980: 0x10200008, - 0x1a80: 0x2000, - 0x1b80: 0x202008, - 0x1c80: 0x200008, - 0x1d80: 0x0, - 0x1e80: 0x10000000, - 0x1f80: 0x10002008 - }, - { - 0x0: 0x100000, - 0x10: 0x2000401, - 0x20: 0x400, - 0x30: 0x100401, - 0x40: 0x2100401, - 0x50: 0x0, - 0x60: 0x1, - 0x70: 0x2100001, - 0x80: 0x2000400, - 0x90: 0x100001, - 0xa0: 0x2000001, - 0xb0: 0x2100400, - 0xc0: 0x2100000, - 0xd0: 0x401, - 0xe0: 0x100400, - 0xf0: 0x2000000, - 0x8: 0x2100001, - 0x18: 0x0, - 0x28: 0x2000401, - 0x38: 0x2100400, - 0x48: 0x100000, - 0x58: 0x2000001, - 0x68: 0x2000000, - 0x78: 0x401, - 0x88: 0x100401, - 0x98: 0x2000400, - 0xa8: 0x2100000, - 0xb8: 0x100001, - 0xc8: 0x400, - 0xd8: 0x2100401, - 0xe8: 0x1, - 0xf8: 0x100400, - 0x100: 0x2000000, - 0x110: 0x100000, - 0x120: 0x2000401, - 0x130: 0x2100001, - 0x140: 0x100001, - 0x150: 0x2000400, - 0x160: 0x2100400, - 0x170: 0x100401, - 0x180: 0x401, - 0x190: 0x2100401, - 0x1a0: 0x100400, - 0x1b0: 0x1, - 0x1c0: 0x0, - 0x1d0: 0x2100000, - 0x1e0: 0x2000001, - 0x1f0: 0x400, - 0x108: 0x100400, - 0x118: 0x2000401, - 0x128: 0x2100001, - 0x138: 0x1, - 0x148: 0x2000000, - 0x158: 0x100000, - 0x168: 0x401, - 0x178: 0x2100400, - 0x188: 0x2000001, - 0x198: 0x2100000, - 0x1a8: 0x0, - 0x1b8: 0x2100401, - 0x1c8: 0x100401, - 0x1d8: 0x400, - 0x1e8: 0x2000400, - 0x1f8: 0x100001 - }, - { - 0x0: 0x8000820, - 0x1: 0x20000, - 0x2: 0x8000000, - 0x3: 0x20, - 0x4: 0x20020, - 0x5: 0x8020820, - 0x6: 0x8020800, - 0x7: 0x800, - 0x8: 0x8020000, - 0x9: 0x8000800, - 0xa: 0x20800, - 0xb: 0x8020020, - 0xc: 0x820, - 0xd: 0x0, - 0xe: 0x8000020, - 0xf: 0x20820, - 0x80000000: 0x800, - 0x80000001: 0x8020820, - 0x80000002: 0x8000820, - 0x80000003: 0x8000000, - 0x80000004: 0x8020000, - 0x80000005: 0x20800, - 0x80000006: 0x20820, - 0x80000007: 0x20, - 0x80000008: 0x8000020, - 0x80000009: 0x820, - 0x8000000a: 0x20020, - 0x8000000b: 0x8020800, - 0x8000000c: 0x0, - 0x8000000d: 0x8020020, - 0x8000000e: 0x8000800, - 0x8000000f: 0x20000, - 0x10: 0x20820, - 0x11: 0x8020800, - 0x12: 0x20, - 0x13: 0x800, - 0x14: 0x8000800, - 0x15: 0x8000020, - 0x16: 0x8020020, - 0x17: 0x20000, - 0x18: 0x0, - 0x19: 0x20020, - 0x1a: 0x8020000, - 0x1b: 0x8000820, - 0x1c: 0x8020820, - 0x1d: 0x20800, - 0x1e: 0x820, - 0x1f: 0x8000000, - 0x80000010: 0x20000, - 0x80000011: 0x800, - 0x80000012: 0x8020020, - 0x80000013: 0x20820, - 0x80000014: 0x20, - 0x80000015: 0x8020000, - 0x80000016: 0x8000000, - 0x80000017: 0x8000820, - 0x80000018: 0x8020820, - 0x80000019: 0x8000020, - 0x8000001a: 0x8000800, - 0x8000001b: 0x0, - 0x8000001c: 0x20800, - 0x8000001d: 0x820, - 0x8000001e: 0x20020, - 0x8000001f: 0x8020800 - } - ]; - - // Masks that select the SBOX input - var SBOX_MASK = [ - 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000, - 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f - ]; - - /** - * DES block cipher algorithm. - */ - var DES = C_algo.DES = BlockCipher.extend({ - _doReset: function () { - // Shortcuts - var key = this._key; - var keyWords = key.words; - - // Select 56 bits according to PC1 - var keyBits = []; - for (var i = 0; i < 56; i++) { - var keyBitPos = PC1[i] - 1; - keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1; - } - - // Assemble 16 subkeys - var subKeys = this._subKeys = []; - for (var nSubKey = 0; nSubKey < 16; nSubKey++) { - // Create subkey - var subKey = subKeys[nSubKey] = []; - - // Shortcut - var bitShift = BIT_SHIFTS[nSubKey]; - - // Select 48 bits according to PC2 - for (var i = 0; i < 24; i++) { - // Select from the left 28 key bits - subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6); - - // Select from the right 28 key bits - subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6); - } - - // Since each subkey is applied to an expanded 32-bit input, - // the subkey can be broken into 8 values scaled to 32-bits, - // which allows the key to be used without expansion - subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31); - for (var i = 1; i < 7; i++) { - subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3); - } - subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27); - } - - // Compute inverse subkeys - var invSubKeys = this._invSubKeys = []; - for (var i = 0; i < 16; i++) { - invSubKeys[i] = subKeys[15 - i]; - } - }, - - encryptBlock: function (M, offset) { - this._doCryptBlock(M, offset, this._subKeys); - }, - - decryptBlock: function (M, offset) { - this._doCryptBlock(M, offset, this._invSubKeys); - }, - - _doCryptBlock: function (M, offset, subKeys) { - // Get input - this._lBlock = M[offset]; - this._rBlock = M[offset + 1]; - - // Initial permutation - exchangeLR.call(this, 4, 0x0f0f0f0f); - exchangeLR.call(this, 16, 0x0000ffff); - exchangeRL.call(this, 2, 0x33333333); - exchangeRL.call(this, 8, 0x00ff00ff); - exchangeLR.call(this, 1, 0x55555555); - - // Rounds - for (var round = 0; round < 16; round++) { - // Shortcuts - var subKey = subKeys[round]; - var lBlock = this._lBlock; - var rBlock = this._rBlock; - - // Feistel function - var f = 0; - for (var i = 0; i < 8; i++) { - f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0]; - } - this._lBlock = rBlock; - this._rBlock = lBlock ^ f; - } - - // Undo swap from last round - var t = this._lBlock; - this._lBlock = this._rBlock; - this._rBlock = t; - - // Final permutation - exchangeLR.call(this, 1, 0x55555555); - exchangeRL.call(this, 8, 0x00ff00ff); - exchangeRL.call(this, 2, 0x33333333); - exchangeLR.call(this, 16, 0x0000ffff); - exchangeLR.call(this, 4, 0x0f0f0f0f); - - // Set output - M[offset] = this._lBlock; - M[offset + 1] = this._rBlock; - }, - - keySize: 64/32, - - ivSize: 64/32, - - blockSize: 64/32 - }); - - // Swap bits across the left and right words - function exchangeLR(offset, mask) { - var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask; - this._rBlock ^= t; - this._lBlock ^= t << offset; - } - - function exchangeRL(offset, mask) { - var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask; - this._lBlock ^= t; - this._rBlock ^= t << offset; - } - - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg); - * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg); - */ - C.DES = BlockCipher._createHelper(DES); - - /** - * Triple-DES block cipher algorithm. - */ - var TripleDES = C_algo.TripleDES = BlockCipher.extend({ - _doReset: function () { - // Shortcuts - var key = this._key; - var keyWords = key.words; - - // Create DES instances - this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2))); - this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4))); - this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6))); - }, - - encryptBlock: function (M, offset) { - this._des1.encryptBlock(M, offset); - this._des2.decryptBlock(M, offset); - this._des3.encryptBlock(M, offset); - }, - - decryptBlock: function (M, offset) { - this._des3.decryptBlock(M, offset); - this._des2.encryptBlock(M, offset); - this._des1.decryptBlock(M, offset); - }, - - keySize: 192/32, - - ivSize: 64/32, - - blockSize: 64/32 - }); - - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg); - * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg); - */ - C.TripleDES = BlockCipher._createHelper(TripleDES); -}()); diff --git a/src/x64-core.js b/src/x64-core.js index fabcf0e..1592ba2 100644 --- a/src/x64-core.js +++ b/src/x64-core.js @@ -1,284 +1,113 @@ -(function (undefined) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var X32WordArray = C_lib.WordArray; - - /** - * x64 namespace. - */ - var C_x64 = C.x64 = {}; - - /** - * A 64-bit word. - */ - var X64Word = C_x64.Word = Base.extend({ - /** - * Initializes a newly created 64-bit word. - * - * @param {number} high The high 32 bits. - * @param {number} low The low 32 bits. - * - * @example - * - * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); - */ - init: function (high, low) { - this.high = high; - this.low = low; - } - - /** - * Bitwise NOTs this word. - * - * @return {X64Word} A new x64-Word object after negating. - * - * @example - * - * var negated = x64Word.not(); - */ - // not: function () { - // var high = ~this.high; - // var low = ~this.low; - - // return X64Word.create(high, low); - // }, - - /** - * Bitwise ANDs this word with the passed word. - * - * @param {X64Word} word The x64-Word to AND with this word. - * - * @return {X64Word} A new x64-Word object after ANDing. - * - * @example - * - * var anded = x64Word.and(anotherX64Word); - */ - // and: function (word) { - // var high = this.high & word.high; - // var low = this.low & word.low; - - // return X64Word.create(high, low); - // }, - - /** - * Bitwise ORs this word with the passed word. - * - * @param {X64Word} word The x64-Word to OR with this word. - * - * @return {X64Word} A new x64-Word object after ORing. - * - * @example - * - * var ored = x64Word.or(anotherX64Word); - */ - // or: function (word) { - // var high = this.high | word.high; - // var low = this.low | word.low; - - // return X64Word.create(high, low); - // }, - - /** - * Bitwise XORs this word with the passed word. - * - * @param {X64Word} word The x64-Word to XOR with this word. - * - * @return {X64Word} A new x64-Word object after XORing. - * - * @example - * - * var xored = x64Word.xor(anotherX64Word); - */ - // xor: function (word) { - // var high = this.high ^ word.high; - // var low = this.low ^ word.low; - - // return X64Word.create(high, low); - // }, - - /** - * Shifts this word n bits to the left. - * - * @param {number} n The number of bits to shift. - * - * @return {X64Word} A new x64-Word object after shifting. - * - * @example - * - * var shifted = x64Word.shiftL(25); - */ - // shiftL: function (n) { - // if (n < 32) { - // var high = (this.high << n) | (this.low >>> (32 - n)); - // var low = this.low << n; - // } else { - // var high = this.low << (n - 32); - // var low = 0; - // } - - // return X64Word.create(high, low); - // }, - - /** - * Shifts this word n bits to the right. - * - * @param {number} n The number of bits to shift. - * - * @return {X64Word} A new x64-Word object after shifting. - * - * @example - * - * var shifted = x64Word.shiftR(7); - */ - // shiftR: function (n) { - // if (n < 32) { - // var low = (this.low >>> n) | (this.high << (32 - n)); - // var high = this.high >>> n; - // } else { - // var low = this.high >>> (n - 32); - // var high = 0; - // } - - // return X64Word.create(high, low); - // }, - - /** - * Rotates this word n bits to the left. - * - * @param {number} n The number of bits to rotate. - * - * @return {X64Word} A new x64-Word object after rotating. - * - * @example - * - * var rotated = x64Word.rotL(25); - */ - // rotL: function (n) { - // return this.shiftL(n).or(this.shiftR(64 - n)); - // }, - - /** - * Rotates this word n bits to the right. - * - * @param {number} n The number of bits to rotate. - * - * @return {X64Word} A new x64-Word object after rotating. - * - * @example - * - * var rotated = x64Word.rotR(7); - */ - // rotR: function (n) { - // return this.shiftR(n).or(this.shiftL(64 - n)); - // }, - - /** - * Adds this word with the passed word. - * - * @param {X64Word} word The x64-Word to add with this word. - * - * @return {X64Word} A new x64-Word object after adding. - * - * @example - * - * var added = x64Word.add(anotherX64Word); - */ - // add: function (word) { - // var low = (this.low + word.low) | 0; - // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0; - // var high = (this.high + word.high + carry) | 0; - - // return X64Word.create(high, low); - // } - }); - - /** - * An array of 64-bit words. - * - * @property {Array} words The array of CryptoJS.x64.Word objects. - * @property {number} sigBytes The number of significant bytes in this word array. - */ - var X64WordArray = C_x64.WordArray = Base.extend({ - /** - * Initializes a newly created word array. - * - * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects. - * @param {number} sigBytes (Optional) The number of significant bytes in the words. - * - * @example - * - * var wordArray = CryptoJS.x64.WordArray.create(); - * - * var wordArray = CryptoJS.x64.WordArray.create([ - * CryptoJS.x64.Word.create(0x00010203, 0x04050607), - * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) - * ]); - * - * var wordArray = CryptoJS.x64.WordArray.create([ - * CryptoJS.x64.Word.create(0x00010203, 0x04050607), - * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) - * ], 10); - */ - init: function (words, sigBytes) { - words = this.words = words || []; - - if (sigBytes != undefined) { - this.sigBytes = sigBytes; - } else { - this.sigBytes = words.length * 8; - } - }, - - /** - * Converts this 64-bit word array to a 32-bit word array. - * - * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array. - * - * @example - * - * var x32WordArray = x64WordArray.toX32(); - */ - toX32: function () { - // Shortcuts - var x64Words = this.words; - var x64WordsLength = x64Words.length; - - // Convert - var x32Words = []; - for (var i = 0; i < x64WordsLength; i++) { - var x64Word = x64Words[i]; - x32Words.push(x64Word.high); - x32Words.push(x64Word.low); - } - - return X32WordArray.create(x32Words, this.sigBytes); - }, - - /** - * Creates a copy of this word array. - * - * @return {X64WordArray} The clone. - * - * @example - * - * var clone = x64WordArray.clone(); - */ - clone: function () { - var clone = Base.clone.call(this); - - // Clone "words" array - var words = clone.words = this.words.slice(0); - - // Clone each X64Word object - var wordsLength = words.length; - for (var i = 0; i < wordsLength; i++) { - words[i] = words[i].clone(); - } - - return clone; - } - }); -}()); +import { + Base, + WordArray +} from './core.js'; + +const X32WordArray = WordArray; + +/** + * A 64-bit word. + */ +export class X64Word extends Base { + /** + * Initializes a newly created 64-bit word. + * + * @param {number} high The high 32 bits. + * @param {number} low The low 32 bits. + * + * @example + * + * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); + */ + constructor(high, low) { + super(); + + this.high = high; + this.low = low; + } +} + +/** + * An array of 64-bit words. + * + * @property {Array} words The array of CryptoJS.x64.Word objects. + * @property {number} sigBytes The number of significant bytes in this word array. + */ +export class X64WordArray extends Base { + /** + * Initializes a newly created word array. + * + * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects. + * @param {number} sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * var wordArray = CryptoJS.x64.WordArray.create(); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ]); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ], 10); + */ + constructor(words = [], sigBytes = words.length * 8) { + super(); + + this.words = words; + this.sigBytes = sigBytes; + } + + /** + * Converts this 64-bit word array to a 32-bit word array. + * + * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array. + * + * @example + * + * var x32WordArray = x64WordArray.toX32(); + */ + toX32() { + // Shortcuts + const x64Words = this.words; + const x64WordsLength = x64Words.length; + + // Convert + const x32Words = []; + for (let i = 0; i < x64WordsLength; i += 1) { + const x64Word = x64Words[i]; + x32Words.push(x64Word.high); + x32Words.push(x64Word.low); + } + + return X32WordArray.create(x32Words, this.sigBytes); + } + + /** + * Creates a copy of this word array. + * + * @return {X64WordArray} The clone. + * + * @example + * + * var clone = x64WordArray.clone(); + */ + clone() { + const clone = super.clone.call(this); + + // Clone "words" array + clone.words = this.words.slice(0); + const { words } = clone; + + // Clone each X64Word object + const wordsLength = words.length; + for (let i = 0; i < wordsLength; i += 1) { + words[i] = words[i].clone(); + } + + return clone; + } +} diff --git a/test/aes-profile.js b/test/aes-profile.js deleted file mode 100644 index b13d2a9..0000000 --- a/test/aes-profile.js +++ /dev/null @@ -1,31 +0,0 @@ -YUI.add('algo-aes-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'AES', - - setUp: function () { - this.data = { - key: C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'), - iv: C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f') - }; - }, - - profileSinglePartMessage: function () { - var singlePartMessage = ''; - for (var i = 0; i < 500; i++) { - singlePartMessage += '12345678901234567890123456789012345678901234567890'; - } - - C.algo.AES.createEncryptor(this.data.key, { iv: this.data.iv }).finalize(singlePartMessage) + ''; - }, - - profileMultiPartMessage: function () { - var aes = C.algo.AES.createEncryptor(this.data.key, { iv: this.data.iv }); - for (var i = 0; i < 500; i++) { - aes.process('12345678901234567890123456789012345678901234567890') + ''; - } - aes.finalize() + ''; - } - }); -}, '$Rev$'); diff --git a/test/aes-test.js b/test/aes-test.js deleted file mode 100644 index ca589dd..0000000 --- a/test/aes-test.js +++ /dev/null @@ -1,80 +0,0 @@ -YUI.add('algo-aes-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'AES', - - testEncryptKeySize128: function () { - Y.Assert.areEqual('69c4e0d86a7b0430d8cdb78070b4c55a', C.AES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testEncryptKeySize192: function () { - Y.Assert.areEqual('dda97ca4864cdfe06eaf70a0ec0d7191', C.AES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testEncryptKeySize256: function () { - Y.Assert.areEqual('8ea2b7ca516745bfeafc49904b496089', C.AES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testDecryptKeySize128: function () { - Y.Assert.areEqual('00112233445566778899aabbccddeeff', C.AES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('69c4e0d86a7b0430d8cdb78070b4c55a') }), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testDecryptKeySize192: function () { - Y.Assert.areEqual('00112233445566778899aabbccddeeff', C.AES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('dda97ca4864cdfe06eaf70a0ec0d7191') }), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testDecryptKeySize256: function () { - Y.Assert.areEqual('00112233445566778899aabbccddeeff', C.AES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('8ea2b7ca516745bfeafc49904b496089') }), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testMultiPart: function () { - var aes = C.algo.AES.createEncryptor(C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }); - var ciphertext1 = aes.process(C.enc.Hex.parse('001122334455')); - var ciphertext2 = aes.process(C.enc.Hex.parse('66778899aa')); - var ciphertext3 = aes.process(C.enc.Hex.parse('bbccddeeff')); - var ciphertext4 = aes.finalize(); - - Y.Assert.areEqual('69c4e0d86a7b0430d8cdb78070b4c55a', ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString()); - }, - - testInputIntegrity: function () { - var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff'); - var key = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'); - var iv = C.enc.Hex.parse('101112131415161718191a1b1c1d1e1f'); - - var expectedMessage = message.toString(); - var expectedKey = key.toString(); - var expectedIv = iv.toString(); - - C.AES.encrypt(message, key, { iv: iv }); - - Y.Assert.areEqual(expectedMessage, message.toString()); - Y.Assert.areEqual(expectedKey, key.toString()); - Y.Assert.areEqual(expectedIv, iv.toString()); - }, - - testHelper: function () { - // Save original random method - var random = C.lib.WordArray.random; - - // Replace random method with one that returns a predictable value - C.lib.WordArray.random = function (nBytes) { - var words = []; - for (var i = 0; i < nBytes; i += 4) { - words.push([0x11223344]); - } - - return C.lib.WordArray.create(words, nBytes); - }; - - // Test - Y.Assert.areEqual(C.algo.AES.createEncryptor(C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).finalize('Hi There').toString(), C.AES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.AES, 'Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.AES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.AES, 'Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.AES.encrypt('Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - - // Restore random method - C.lib.WordArray.random = random; - } - })); -}, '$Rev$'); diff --git a/test/cipher-test.js b/test/cipher-test.js deleted file mode 100644 index 2529eff..0000000 --- a/test/cipher-test.js +++ /dev/null @@ -1,522 +0,0 @@ -function extendWithCMAC(C) { - function createExt(C) { - /* - * The MIT License (MIT) - * - * Copyright (c) 2015 artjomb - */ - // put on ext property in CryptoJS - var ext; - if (!C.hasOwnProperty("ext")) { - ext = C.ext = {}; - } else { - ext = C.ext; - } - - // Shortcuts - var Base = C.lib.Base; - var WordArray = C.lib.WordArray; - - // Constants - ext.const_Zero = new WordArray.init([0x00000000, 0x00000000, 0x00000000, 0x00000000]); - ext.const_One = new WordArray.init([0x00000000, 0x00000000, 0x00000000, 0x00000001]); - ext.const_Rb = new WordArray.init([0x00000000, 0x00000000, 0x00000000, 0x00000087]); // 00..0010000111 - ext.const_Rb_Shifted = new WordArray.init([0x80000000, 0x00000000, 0x00000000, 0x00000043]); // 100..001000011 - ext.const_nonMSB = new WordArray.init([0xFFFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF]); // 1^64 || 0^1 || 1^31 || 0^1 || 1^31 - - /** - * Looks into the object to see if it is a WordArray. - * - * @param obj Some object - * - * @returns {boolean} - */ - ext.isWordArray = function(obj) { - return obj && typeof obj.clamp === "function" && typeof obj.concat === "function" && typeof obj.words === "array"; - } - - /** - * This padding is a 1 bit followed by as many 0 bits as needed to fill - * up the block. This implementation doesn't work on bits directly, - * but on bytes. Therefore the granularity is much bigger. - */ - C.pad.OneZeroPadding = { - pad: function (data, blocksize) { - // Shortcut - var blockSizeBytes = blocksize * 4; - - // Count padding bytes - var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; - - // Create padding - var paddingWords = []; - for (var i = 0; i < nPaddingBytes; i += 4) { - var paddingWord = 0x00000000; - if (i === 0) { - paddingWord = 0x80000000; - } - paddingWords.push(paddingWord); - } - var padding = new WordArray.init(paddingWords, nPaddingBytes); - - // Add padding - data.concat(padding); - }, - unpad: function () { - // TODO: implement - } - }; - - /** - * No padding is applied. This is necessary for streaming cipher modes - * like CTR. - */ - C.pad.NoPadding = { - pad: function () {}, - unpad: function () {} - }; - - /** - * Returns the n leftmost bytes of the WordArray. - * - * @param {WordArray} wordArray WordArray to work on - * @param {int} n Bytes to retrieve - * - * @returns new WordArray - */ - ext.leftmostBytes = function(wordArray, n){ - var lmArray = wordArray.clone(); - lmArray.sigBytes = n; - lmArray.clamp(); - return lmArray; - }; - - /** - * Returns the n rightmost bytes of the WordArray. - * - * @param {WordArray} wordArray WordArray to work on - * @param {int} n Bytes to retrieve (must be positive) - * - * @returns new WordArray - */ - ext.rightmostBytes = function(wordArray, n){ - wordArray.clamp(); - var wordSize = 32; - var rmArray = wordArray.clone(); - var bitsToShift = (rmArray.sigBytes - n) * 8; - if (bitsToShift >= wordSize) { - var popCount = Math.floor(bitsToShift/wordSize); - bitsToShift -= popCount * wordSize; - rmArray.words.splice(0, popCount); - rmArray.sigBytes -= popCount * wordSize / 8; - } - if (bitsToShift > 0) { - ext.bitshift(rmArray, bitsToShift); - rmArray.sigBytes -= bitsToShift / 8; - } - return rmArray; - }; - - /** - * Returns the n rightmost words of the WordArray. It assumes - * that the current WordArray has at least n words. - * - * @param {WordArray} wordArray WordArray to work on - * @param {int} n Words to retrieve (must be positive) - * - * @returns popped words as new WordArray - */ - ext.popWords = function(wordArray, n){ - var left = wordArray.words.splice(0, n); - wordArray.sigBytes -= n * 4; - return new WordArray.init(left); - }; - - /** - * Shifts the array to the left and returns the shifted dropped elements - * as WordArray. The initial WordArray must contain at least n bytes and - * they have to be significant. - * - * @param {WordArray} wordArray WordArray to work on (is modified) - * @param {int} n Bytes to shift (must be positive, default 16) - * - * @returns new WordArray - */ - ext.shiftBytes = function(wordArray, n){ - n = n || 16; - var r = n % 4; - n -= r; - - var shiftedArray = new WordArray.init(); - for(var i = 0; i < n; i += 4) { - shiftedArray.words.push(wordArray.words.shift()); - wordArray.sigBytes -= 4; - shiftedArray.sigBytes += 4; - } - if (r > 0) { - shiftedArray.words.push(wordArray.words[0]); - shiftedArray.sigBytes += r; - - ext.bitshift(wordArray, r * 8); - wordArray.sigBytes -= r; - } - return shiftedArray; - }; - - /** - * XORs arr2 to the end of arr1 array. This doesn't modify the current - * array aside from clamping. - * - * @param {WordArray} arr1 Bigger array - * @param {WordArray} arr2 Smaller array to be XORed to the end - * - * @returns new WordArray - */ - ext.xorendBytes = function(arr1, arr2){ - // TODO: more efficient - return ext.leftmostBytes(arr1, arr1.sigBytes-arr2.sigBytes) - .concat(ext.xor(ext.rightmostBytes(arr1, arr2.sigBytes), arr2)); - }; - - /** - * Doubling operation on a 128-bit value. This operation modifies the - * passed array. - * - * @param {WordArray} wordArray WordArray to work on - * - * @returns passed WordArray - */ - ext.dbl = function(wordArray){ - var carry = ext.msb(wordArray); - ext.bitshift(wordArray, 1); - ext.xor(wordArray, carry === 1 ? ext.const_Rb : ext.const_Zero); - return wordArray; - }; - - /** - * Inverse operation on a 128-bit value. This operation modifies the - * passed array. - * - * @param {WordArray} wordArray WordArray to work on - * - * @returns passed WordArray - */ - ext.inv = function(wordArray){ - var carry = wordArray.words[4] & 1; - ext.bitshift(wordArray, -1); - ext.xor(wordArray, carry === 1 ? ext.const_Rb_Shifted : ext.const_Zero); - return wordArray; - }; - - /** - * Check whether the word arrays are equal. - * - * @param {WordArray} arr1 Array 1 - * @param {WordArray} arr2 Array 2 - * - * @returns boolean - */ - ext.equals = function(arr1, arr2){ - if (!arr2 || !arr2.words || arr1.sigBytes !== arr2.sigBytes) { - return false; - } - arr1.clamp(); - arr2.clamp(); - var equal = 0; - for(var i = 0; i < arr1.words.length; i++) { - equal |= arr1.words[i] ^ arr2.words[i]; - } - return equal === 0; - }; - - /** - * Retrieves the most significant bit of the WordArray as an Integer. - * - * @param {WordArray} arr - * - * @returns Integer - */ - ext.msb = function(arr) { - return arr.words[0] >>> 31; - } - } - - function createExtBit(C) { - /* - * The MIT License (MIT) - * - * Copyright (c) 2015 artjomb - */ - // put on ext property in CryptoJS - var ext; - if (!C.hasOwnProperty("ext")) { - ext = C.ext = {}; - } else { - ext = C.ext; - } - - /** - * Shifts the array by n bits to the left. Zero bits are added as the - * least significant bits. This operation modifies the current array. - * - * @param {WordArray} wordArray WordArray to work on - * @param {int} n Bits to shift by - * - * @returns the WordArray that was passed in - */ - ext.bitshift = function(wordArray, n){ - var carry = 0, - words = wordArray.words, - wres, - skipped = 0, - carryMask; - if (n > 0) { - while(n > 31) { - // delete first element: - words.splice(0, 1); - - // add `0` word to the back - words.push(0); - - n -= 32; - skipped++; - } - if (n == 0) { - // 1. nothing to shift if the shift amount is on a word boundary - // 2. This has to be done, because the following algorithm computes - // wrong values only for n==0 - return carry; - } - for(var i = words.length - skipped - 1; i >= 0; i--) { - wres = words[i]; - words[i] <<= n; - words[i] |= carry; - carry = wres >>> (32 - n); - } - } else if (n < 0) { - while(n < -31) { - // insert `0` word to the front: - words.splice(0, 0, 0); - - // remove last element: - words.length--; - - n += 32; - skipped++; - } - if (n == 0) { - // nothing to shift if the shift amount is on a word boundary - return carry; - } - n = -n; - carryMask = (1 << n) - 1; - for(var i = skipped; i < words.length; i++) { - wres = words[i] & carryMask; - words[i] >>>= n; - words[i] |= carry; - carry = wres << (32 - n); - } - } - return carry; - }; - - /** - * Negates all bits in the WordArray. This manipulates the given array. - * - * @param {WordArray} wordArray WordArray to work on - * - * @returns the WordArray that was passed in - */ - ext.neg = function(wordArray){ - var words = wordArray.words; - for(var i = 0; i < words.length; i++) { - words[i] = ~words[i]; - } - return wordArray; - }; - - /** - * Applies XOR on both given word arrays and returns a third resulting - * WordArray. The initial word arrays must have the same length - * (significant bytes). - * - * @param {WordArray} wordArray1 WordArray - * @param {WordArray} wordArray2 WordArray - * - * @returns first passed WordArray (modified) - */ - ext.xor = function(wordArray1, wordArray2){ - for(var i = 0; i < wordArray1.words.length; i++) { - wordArray1.words[i] ^= wordArray2.words[i]; - } - return wordArray1; - }; - - /** - * Logical AND between the two passed arrays. Both arrays must have the - * same length. - * - * @param {WordArray} arr1 Array 1 - * @param {WordArray} arr2 Array 2 - * - * @returns new WordArray - */ - ext.bitand = function(arr1, arr2){ - var newArr = arr1.clone(), - tw = newArr.words, - ow = arr2.words; - for(var i = 0; i < tw.length; i++) { - tw[i] &= ow[i]; - } - return newArr; - }; - } - - function createCMAC(C) { - /* - * The MIT License (MIT) - * - * Copyright (c) 2015 artjomb - */ - // Shortcuts - var Base = C.lib.Base; - var WordArray = C.lib.WordArray; - var AES = C.algo.AES; - var ext = C.ext; - var OneZeroPadding = C.pad.OneZeroPadding; - - var CMAC = C.algo.CMAC = Base.extend({ - /** - * Initializes a newly created CMAC - * - * @param {WordArray} key The secret key - * - * @example - * - * var cmacer = CryptoJS.algo.CMAC.create(key); - */ - init: function(key){ - // generate sub keys... - this._aes = AES.createEncryptor(key, { iv: new WordArray.init(), padding: C.pad.NoPadding }); - - // Step 1 - var L = this._aes.finalize(ext.const_Zero); - - // Step 2 - var K1 = L.clone(); - ext.dbl(K1); - - // Step 3 - if (!this._isTwo) { - var K2 = K1.clone(); - ext.dbl(K2); - } else { - var K2 = L.clone(); - ext.inv(K2); - } - - this._K1 = K1; - this._K2 = K2; - - this._const_Bsize = 16; - - this.reset(); - }, - - reset: function () { - this._x = ext.const_Zero.clone(); - this._counter = 0; - this._buffer = new WordArray.init(); - }, - - update: function (messageUpdate) { - if (!messageUpdate) { - return this; - } - - // Shortcuts - var buffer = this._buffer; - var bsize = this._const_Bsize; - - if (typeof messageUpdate === "string") { - messageUpdate = C.enc.Utf8.parse(messageUpdate); - } - - buffer.concat(messageUpdate); - - while(buffer.sigBytes > bsize){ - var M_i = ext.shiftBytes(buffer, bsize); - ext.xor(this._x, M_i); - this._x.clamp(); - this._aes.reset(); - this._x = this._aes.finalize(this._x); - this._counter++; - } - - // Chainable - return this; - }, - - finalize: function (messageUpdate) { - this.update(messageUpdate); - - // Shortcuts - var buffer = this._buffer; - var bsize = this._const_Bsize; - - var M_last = buffer.clone(); - if (buffer.sigBytes === bsize) { - ext.xor(M_last, this._K1); - } else { - OneZeroPadding.pad(M_last, bsize/4); - ext.xor(M_last, this._K2); - } - - ext.xor(M_last, this._x); - - this.reset(); // Can be used immediately afterwards - - this._aes.reset(); - return this._aes.finalize(M_last); - }, - - _isTwo: false - }); - - /** - * Directly invokes the CMAC and returns the calculated MAC. - * - * @param {WordArray} key The key to be used for CMAC - * @param {WordArray|string} message The data to be MAC'ed (either WordArray or UTF-8 encoded string) - * - * @returns {WordArray} MAC - */ - C.CMAC = function(key, message){ - return CMAC.create(key).finalize(message); - }; - - C.algo.OMAC1 = CMAC; - C.algo.OMAC2 = CMAC.extend({ - _isTwo: true - }); - } - - createExt(C); - createExtBit(C); - createCMAC(C); -} - -YUI.add('cipher-core-test', function (Y) { - var C = CryptoJS; - - // Extend with CMAC to test `cipher-core.js` L:457-462 - extendWithCMAC(C); - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'Cipher', - - testCMAC: function () { - Y.Assert.areEqual('35e1872b95ce5d99bb5dbbbbd79b9b9b', C.CMAC('69c4e0d86a7b0430d8cdb78070b4c55a', 'Test message').toString()); - } - })); -}, '$Rev$'); diff --git a/test/des-profile.js b/test/des-profile.js deleted file mode 100644 index 37a27e8..0000000 --- a/test/des-profile.js +++ /dev/null @@ -1,31 +0,0 @@ -YUI.add('algo-des-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'DES', - - setUp: function () { - this.data = { - key: C.enc.Hex.parse('0001020304050607'), - iv: C.enc.Hex.parse('08090a0b0c0d0e0f') - }; - }, - - profileSinglePartMessage: function () { - var singlePartMessage = ''; - for (var i = 0; i < 100; i++) { - singlePartMessage += '12345678901234567890123456789012345678901234567890'; - } - - C.algo.DES.createEncryptor(this.data.key, { iv: this.data.iv }).finalize(singlePartMessage) + ''; - }, - - profileMultiPartMessage: function () { - var des = C.algo.DES.createEncryptor(this.data.key, { iv: this.data.iv }); - for (var i = 0; i < 100; i++) { - des.process('12345678901234567890123456789012345678901234567890') + ''; - } - des.finalize() + ''; - } - }); -}, '$Rev$'); diff --git a/test/des-test.js b/test/des-test.js deleted file mode 100644 index 6580a3e..0000000 --- a/test/des-test.js +++ /dev/null @@ -1,104 +0,0 @@ -YUI.add('algo-des-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'DES', - - testEncrypt1: function () { - Y.Assert.areEqual('95a8d72813daa94d', C.DES.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('8000000000000000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testEncrypt2: function () { - Y.Assert.areEqual('1de5279dae3bed6f', C.DES.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('0000000000002000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testEncrypt3: function () { - Y.Assert.areEqual('1d1ca853ae7c0c5f', C.DES.encrypt(C.enc.Hex.parse('0000000000002000'), C.enc.Hex.parse('0000000000000000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testEncrypt4: function () { - Y.Assert.areEqual('ac978c247863388f', C.DES.encrypt(C.enc.Hex.parse('3232323232323232'), C.enc.Hex.parse('3232323232323232'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testEncrypt5: function () { - Y.Assert.areEqual('3af1703d76442789', C.DES.encrypt(C.enc.Hex.parse('6464646464646464'), C.enc.Hex.parse('6464646464646464'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testEncrypt6: function () { - Y.Assert.areEqual('a020003c5554f34c', C.DES.encrypt(C.enc.Hex.parse('9696969696969696'), C.enc.Hex.parse('9696969696969696'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testDecrypt1: function () { - Y.Assert.areEqual('0000000000000000', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('95a8d72813daa94d') }), C.enc.Hex.parse('8000000000000000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testDecrypt2: function () { - Y.Assert.areEqual('0000000000000000', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('1de5279dae3bed6f') }), C.enc.Hex.parse('0000000000002000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testDecrypt3: function () { - Y.Assert.areEqual('0000000000002000', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('1d1ca853ae7c0c5f') }), C.enc.Hex.parse('0000000000000000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testDecrypt4: function () { - Y.Assert.areEqual('3232323232323232', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('ac978c247863388f') }), C.enc.Hex.parse('3232323232323232'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testDecrypt5: function () { - Y.Assert.areEqual('6464646464646464', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('3af1703d76442789') }), C.enc.Hex.parse('6464646464646464'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testDecrypt6: function () { - Y.Assert.areEqual('9696969696969696', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('a020003c5554f34c') }), C.enc.Hex.parse('9696969696969696'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testMultiPart: function () { - var des = C.algo.DES.createEncryptor(C.enc.Hex.parse('0123456789abcdef'), { mode: C.mode.ECB, padding: C.pad.NoPadding }); - var ciphertext1 = des.process(C.enc.Hex.parse('001122334455')); - var ciphertext2 = des.process(C.enc.Hex.parse('66778899aa')); - var ciphertext3 = des.process(C.enc.Hex.parse('bbccddeeff')); - var ciphertext4 = des.finalize(); - - Y.Assert.areEqual(C.DES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('0123456789abcdef'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString(), ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString()); - }, - - testInputIntegrity: function () { - var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff'); - var key = C.enc.Hex.parse('0001020304050607'); - var iv = C.enc.Hex.parse('08090a0b0c0d0e0f'); - - var expectedMessage = message.toString(); - var expectedKey = key.toString(); - var expectedIv = iv.toString(); - - C.DES.encrypt(message, key, { iv: iv }); - - Y.Assert.areEqual(expectedMessage, message.toString()); - Y.Assert.areEqual(expectedKey, key.toString()); - Y.Assert.areEqual(expectedIv, iv.toString()); - }, - - testHelper: function () { - // Save original random method - var random = C.lib.WordArray.random; - - // Replace random method with one that returns a predictable value - C.lib.WordArray.random = function (nBytes) { - var words = []; - for (var i = 0; i < nBytes; i += 4) { - words.push([0x11223344]); - } - - return C.lib.WordArray.create(words, nBytes); - }; - - // Test - Y.Assert.areEqual(C.algo.DES.createEncryptor(C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).finalize('Hi There').toString(), C.DES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.DES, 'Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.DES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.DES, 'Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.DES.encrypt('Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - - // Restore random method - C.lib.WordArray.random = random; - } - })); -}, '$Rev$'); diff --git a/test/enc-base64-test.js b/test/enc-base64-test.js deleted file mode 100644 index a40da35..0000000 --- a/test/enc-base64-test.js +++ /dev/null @@ -1,71 +0,0 @@ -YUI.add('enc-base64-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'Base64', - - testStringify0: function () { - Y.Assert.areEqual('', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 0))); - }, - - testStringify1: function () { - Y.Assert.areEqual('Zg==', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 1))); - }, - - testStringify2: function () { - Y.Assert.areEqual('Zm8=', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 2))); - }, - - testStringify3: function () { - Y.Assert.areEqual('Zm9v', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 3))); - }, - - testStringify4: function () { - Y.Assert.areEqual('Zm9vYg==', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 4))); - }, - - testStringify5: function () { - Y.Assert.areEqual('Zm9vYmE=', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 5))); - }, - - testStringify6: function () { - Y.Assert.areEqual('Zm9vYmFy', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 6))); - }, - - testStringify15: function () { - Y.Assert.areEqual('Pj4+Pz8/Pj4+Pz8/PS8r', C.enc.Base64.stringify(C.lib.WordArray.create([0x3e3e3e3f, 0x3f3f3e3e, 0x3e3f3f3f, 0x3d2f2b00], 15))); - }, - - testParse0: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 0).toString(), C.enc.Base64.parse('').toString()); - }, - - testParse1: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 1).toString(), C.enc.Base64.parse('Zg==').toString()); - }, - - testParse2: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 2).toString(), C.enc.Base64.parse('Zm8=').toString()); - }, - - testParse3: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 3).toString(), C.enc.Base64.parse('Zm9v').toString()); - }, - - testParse4: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 4).toString(), C.enc.Base64.parse('Zm9vYg==').toString()); - }, - - testParse5: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 5).toString(), C.enc.Base64.parse('Zm9vYmE=').toString()); - }, - - testParse6: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 6).toString(), C.enc.Base64.parse('Zm9vYmFy').toString()); - }, - - testParse15: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x3e3e3e3f, 0x3f3f3e3e, 0x3e3f3f3f, 0x3d2f2b00], 15).toString(), C.enc.Base64.parse('Pj4+Pz8/Pj4+Pz8/PS8r').toString()); - } - })); -}, '$Rev$'); diff --git a/test/enc-hex-test.js b/test/enc-hex-test.js deleted file mode 100644 index 8ef9167..0000000 --- a/test/enc-hex-test.js +++ /dev/null @@ -1,15 +0,0 @@ -YUI.add('enc-hex-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'Hex', - - testStringify: function () { - Y.Assert.areEqual('12345678', C.enc.Hex.stringify(C.lib.WordArray.create([0x12345678]))); - }, - - testParse: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x12345678]).toString(), C.enc.Hex.parse('12345678').toString()); - } - })); -}, '$Rev$'); diff --git a/test/enc-latin1-test.js b/test/enc-latin1-test.js deleted file mode 100644 index fc2c274..0000000 --- a/test/enc-latin1-test.js +++ /dev/null @@ -1,15 +0,0 @@ -YUI.add('enc-latin1-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'Latin1', - - testStringify: function () { - Y.Assert.areEqual('\x12\x34\x56\x78', C.enc.Latin1.stringify(C.lib.WordArray.create([0x12345678]))); - }, - - testParse: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x12345678]).toString(), C.enc.Latin1.parse('\x12\x34\x56\x78').toString()); - } - })); -}, '$Rev$'); diff --git a/test/enc-utf16-test.js b/test/enc-utf16-test.js deleted file mode 100644 index 073763a..0000000 --- a/test/enc-utf16-test.js +++ /dev/null @@ -1,55 +0,0 @@ -YUI.add('enc-utf16-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'Utf16', - - testStringify1: function () { - Y.Assert.areEqual('z', C.enc.Utf16.stringify(C.lib.WordArray.create([0x007a0000], 2))); - }, - - testStringify2: function () { - Y.Assert.areEqual('水', C.enc.Utf16.stringify(C.lib.WordArray.create([0x6c340000], 2))); - }, - - testStringify3: function () { - Y.Assert.areEqual('𐀀', C.enc.Utf16.stringify(C.lib.WordArray.create([0xd800dc00], 4))); - }, - - testStringify4: function () { - Y.Assert.areEqual('𝄞', C.enc.Utf16.stringify(C.lib.WordArray.create([0xd834dd1e], 4))); - }, - - testStringify5: function () { - Y.Assert.areEqual('􏿽', C.enc.Utf16.stringify(C.lib.WordArray.create([0xdbffdffd], 4))); - }, - - testStringifyLE: function () { - Y.Assert.areEqual('􏿽', C.enc.Utf16LE.stringify(C.lib.WordArray.create([0xffdbfddf], 4))); - }, - - testParse1: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x007a0000], 2).toString(), C.enc.Utf16.parse('z').toString()); - }, - - testParse2: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x6c340000], 2).toString(), C.enc.Utf16.parse('水').toString()); - }, - - testParse3: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0xd800dc00], 4).toString(), C.enc.Utf16.parse('𐀀').toString()); - }, - - testParse4: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0xd834dd1e], 4).toString(), C.enc.Utf16.parse('𝄞').toString()); - }, - - testParse5: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0xdbffdffd], 4).toString(), C.enc.Utf16.parse('􏿽').toString()); - }, - - testParseLE: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0xffdbfddf], 4).toString(), C.enc.Utf16LE.parse('􏿽').toString()); - } - })); -}, '$Rev$'); diff --git a/test/enc-utf8-test.js b/test/enc-utf8-test.js deleted file mode 100644 index 7786c96..0000000 --- a/test/enc-utf8-test.js +++ /dev/null @@ -1,39 +0,0 @@ -YUI.add('enc-utf8-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'Utf8', - - testStringify1: function () { - Y.Assert.areEqual('$', C.enc.Utf8.stringify(C.lib.WordArray.create([0x24000000], 1))); - }, - - testStringify2: function () { - Y.Assert.areEqual('¢', C.enc.Utf8.stringify(C.lib.WordArray.create([0xc2a20000], 2))); - }, - - testStringify3: function () { - Y.Assert.areEqual('€', C.enc.Utf8.stringify(C.lib.WordArray.create([0xe282ac00], 3))); - }, - - testStringify4: function () { - Y.Assert.areEqual('𤭢', C.enc.Utf8.stringify(C.lib.WordArray.create([0xf0a4ada2], 4))); - }, - - testParse1: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0x24000000], 1).toString(), C.enc.Utf8.parse('$').toString()); - }, - - testParse2: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0xc2a20000], 2).toString(), C.enc.Utf8.parse('¢').toString()); - }, - - testParse3: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0xe282ac00], 3).toString(), C.enc.Utf8.parse('€').toString()); - }, - - testParse4: function () { - Y.Assert.areEqual(C.lib.WordArray.create([0xf0a4ada2], 4).toString(), C.enc.Utf8.parse('𤭢').toString()); - } - })); -}, '$Rev$'); diff --git a/test/evpkdf-profile.js b/test/evpkdf-profile.js deleted file mode 100644 index 68a709b..0000000 --- a/test/evpkdf-profile.js +++ /dev/null @@ -1,11 +0,0 @@ -YUI.add('algo-evpkdf-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'EvpKDF', - - profileKeySize256Iterations20: function () { - C.algo.EvpKDF.create({ keySize: 256/32, iterations: 20 }).compute('password', 'ATHENA.MIT.EDUraeburn'); - } - }); -}, '$Rev$'); diff --git a/test/evpkdf-test.js b/test/evpkdf-test.js deleted file mode 100644 index 492551a..0000000 --- a/test/evpkdf-test.js +++ /dev/null @@ -1,32 +0,0 @@ -YUI.add('algo-evpkdf-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'EvpKDF', - - testVector: function () { - Y.Assert.areEqual('fdbdf3419fff98bdb0241390f62a9db35f4aba29d77566377997314ebfc709f20b5ca7b1081f94b1ac12e3c8ba87d05a', C.EvpKDF('password', 'saltsalt', { keySize: (256+128)/32 }).toString()); - }, - - // There are no official test vectors that I could find, and the EVP implementation is short on comments. - // Need to use the C code to generate more test vectors. - // The iteration count in particular needs to be tested. - - testInputIntegrity: function () { - var password = C.lib.WordArray.create([0x12345678]); - var salt = C.lib.WordArray.create([0x12345678]); - - var expectedPassword = password.toString(); - var expectedSalt = salt.toString(); - - C.EvpKDF(password, salt); - - Y.Assert.areEqual(expectedPassword, password.toString()); - Y.Assert.areEqual(expectedSalt, salt.toString()); - }, - - testHelper: function () { - Y.Assert.areEqual(C.algo.EvpKDF.create({ keySize: (256+128)/32 }).compute('password', 'saltsalt').toString(), C.EvpKDF('password', 'saltsalt', { keySize: (256+128)/32 }).toString()); - } - })); -}, '$Rev$'); diff --git a/test/format-openssl-test.js b/test/format-openssl-test.js deleted file mode 100644 index b6a6153..0000000 --- a/test/format-openssl-test.js +++ /dev/null @@ -1,37 +0,0 @@ -YUI.add('format-openssl-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'OpenSSLFormatter', - - setUp: function () { - this.data = {}; - - this.data.ciphertext = C.lib.WordArray.create([0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f]); - this.data.salt = C.lib.WordArray.create([0x01234567, 0x89abcdef]); - }, - - testSaltedToString: function () { - Y.Assert.areEqual(C.enc.Latin1.parse('Salted__').concat(this.data.salt).concat(this.data.ciphertext).toString(C.enc.Base64), C.format.OpenSSL.stringify(C.lib.CipherParams.create({ ciphertext: this.data.ciphertext, salt: this.data.salt }))); - }, - - testUnsaltedToString: function () { - Y.Assert.areEqual(this.data.ciphertext.toString(C.enc.Base64), C.format.OpenSSL.stringify(C.lib.CipherParams.create({ ciphertext: this.data.ciphertext }))); - }, - - testSaltedFromString: function () { - var openSSLStr = C.format.OpenSSL.stringify(C.lib.CipherParams.create({ ciphertext: this.data.ciphertext, salt: this.data.salt })); - var cipherParams = C.format.OpenSSL.parse(openSSLStr); - - Y.Assert.areEqual(this.data.ciphertext.toString(), cipherParams.ciphertext.toString()); - Y.Assert.areEqual(this.data.salt.toString(), cipherParams.salt.toString()); - }, - - testUnsaltedFromString: function () { - var openSSLStr = C.format.OpenSSL.stringify(C.lib.CipherParams.create({ ciphertext: this.data.ciphertext })); - var cipherParams = C.format.OpenSSL.parse(openSSLStr); - - Y.Assert.areEqual(this.data.ciphertext.toString(), cipherParams.ciphertext.toString()); - } - })); -}, '$Rev$'); diff --git a/test/hmac-md5-profile.js b/test/hmac-md5-profile.js deleted file mode 100644 index b628240..0000000 --- a/test/hmac-md5-profile.js +++ /dev/null @@ -1,30 +0,0 @@ -YUI.add('algo-hmac-md5-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'HMAC MD5', - - setUp: function () { - this.data = { - key: C.lib.WordArray.random(128/8) - }; - }, - - profileSinglePartMessage: function () { - var singlePartMessage = ''; - for (var i = 0; i < 500; i++) { - singlePartMessage += '12345678901234567890123456789012345678901234567890'; - } - - C.algo.HMAC.create(C.algo.MD5, this.data.key).finalize(singlePartMessage) + ''; - }, - - profileMultiPartMessage: function () { - var hmac = C.algo.HMAC.create(C.algo.MD5, this.data.key); - for (var i = 0; i < 500; i++) { - hmac.update('12345678901234567890123456789012345678901234567890'); - } - hmac.finalize() + ''; - } - }); -}, '$Rev$'); diff --git a/test/hmac-md5-test.js b/test/hmac-md5-test.js deleted file mode 100644 index b87aaf9..0000000 --- a/test/hmac-md5-test.js +++ /dev/null @@ -1,59 +0,0 @@ -YUI.add('algo-hmac-md5-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'HMAC MD5', - - testVector1: function () { - Y.Assert.areEqual('9294727a3638bb1c13f48ef8158bfc9d', C.HmacMD5('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('750c783e6ab0b503eaa86e310a5db738', C.HmacMD5('what do ya want for nothing?', 'Jefe').toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('56be34521d144c88dbb8c733f0e8b3f6', C.HmacMD5(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()); - }, - - testVector4: function () { - Y.Assert.areEqual('7ee2a3cc979ab19865704644ce13355c', C.HmacMD5('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString()); - }, - - testVector5: function () { - Y.Assert.areEqual('0e1bd89c43e3e6e3b3f8cf1d5ba4f77a', C.HmacMD5('abcdefghijklmnopqrstuvwxyz', 'A').toString()); - }, - - testUpdate: function () { - var hmac = C.algo.HMAC.create(C.algo.MD5, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); - - Y.Assert.areEqual(C.HmacMD5(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString()); - }, - - testInputIntegrity: function () { - var message = C.lib.WordArray.create([0x12345678]); - var key = C.lib.WordArray.create([0x12345678]); - - var expectedMessage = message.toString(); - var expectedKey = key.toString(); - - C.HmacMD5(message, key); - - Y.Assert.areEqual(expectedMessage, message.toString()); - Y.Assert.areEqual(expectedKey, key.toString()); - }, - - testRespectKeySigBytes: function () { - var key = C.lib.WordArray.random(8); - key.sigBytes = 4; - - var keyClamped = key.clone(); - keyClamped.clamp(); - - Y.Assert.areEqual(CryptoJS.HmacSHA256("Message", keyClamped).toString(), CryptoJS.HmacSHA256("Message", key).toString()); - } - })); -}, '$Rev$'); diff --git a/test/hmac-sha224-test.js b/test/hmac-sha224-test.js deleted file mode 100644 index 4895137..0000000 --- a/test/hmac-sha224-test.js +++ /dev/null @@ -1,59 +0,0 @@ -YUI.add('algo-hmac-sha224-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'HMAC SHA224', - - testVector1: function () { - Y.Assert.areEqual('4e841ce7a4ae83fbcf71e3cd64bfbf277f73a14680aae8c518ac7861', C.HmacSHA224('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44', C.HmacSHA224('what do ya want for nothing?', 'Jefe').toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('cbff7c2716bbaa7c77bed4f491d3e8456cb6c574e92f672b291acf5b', C.HmacSHA224(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()); - }, - - testVector4: function () { - Y.Assert.areEqual('61bf669da4fdcd8e5c3bd09ebbb4a986d3d1b298d3ca05c511f7aeff', C.HmacSHA224('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString()); - }, - - testVector5: function () { - Y.Assert.areEqual('16fc69ada3c3edc1fe9144d6b98d93393833ae442bedf681110a1176', C.HmacSHA224('abcdefghijklmnopqrstuvwxyz', 'A').toString()); - }, - - testUpdate: function () { - var hmac = C.algo.HMAC.create(C.algo.SHA224, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); - - Y.Assert.areEqual(C.HmacSHA224(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString()); - }, - - testInputIntegrity: function () { - var message = C.lib.WordArray.create([0x12345678]); - var key = C.lib.WordArray.create([0x12345678]); - - var expectedMessage = message.toString(); - var expectedKey = key.toString(); - - C.HmacSHA224(message, key); - - Y.Assert.areEqual(expectedMessage, message.toString()); - Y.Assert.areEqual(expectedKey, key.toString()); - }, - - testRespectKeySigBytes: function () { - var key = C.lib.WordArray.random(8); - key.sigBytes = 4; - - var keyClamped = key.clone(); - keyClamped.clamp(); - - Y.Assert.areEqual(CryptoJS.HmacSHA224("Message", keyClamped).toString(), CryptoJS.HmacSHA224("Message", key).toString()); - } - })); -}, '$Rev$'); diff --git a/test/hmac-sha256-test.js b/test/hmac-sha256-test.js deleted file mode 100644 index f10d89e..0000000 --- a/test/hmac-sha256-test.js +++ /dev/null @@ -1,59 +0,0 @@ -YUI.add('algo-hmac-sha256-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'HMAC SHA256', - - testVector1: function () { - Y.Assert.areEqual('492ce020fe2534a5789dc3848806c78f4f6711397f08e7e7a12ca5a4483c8aa6', C.HmacSHA256('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843', C.HmacSHA256('what do ya want for nothing?', 'Jefe').toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('7dda3cc169743a6484649f94f0eda0f9f2ff496a9733fb796ed5adb40a44c3c1', C.HmacSHA256(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()); - }, - - testVector4: function () { - Y.Assert.areEqual('a89dc8178c1184a62df87adaa77bf86e93064863d93c5131140b0ae98b866687', C.HmacSHA256('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString()); - }, - - testVector5: function () { - Y.Assert.areEqual('d8cb78419c02fe20b90f8b77427dd9f81817a751d74c2e484e0ac5fc4e6ca986', C.HmacSHA256('abcdefghijklmnopqrstuvwxyz', 'A').toString()); - }, - - testUpdate: function () { - var hmac = C.algo.HMAC.create(C.algo.SHA256, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); - - Y.Assert.areEqual(C.HmacSHA256(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString()); - }, - - testInputIntegrity: function () { - var message = C.lib.WordArray.create([0x12345678]); - var key = C.lib.WordArray.create([0x12345678]); - - var expectedMessage = message.toString(); - var expectedKey = key.toString(); - - C.HmacSHA256(message, key); - - Y.Assert.areEqual(expectedMessage, message.toString()); - Y.Assert.areEqual(expectedKey, key.toString()); - }, - - testRespectKeySigBytes: function () { - var key = C.lib.WordArray.random(8); - key.sigBytes = 4; - - var keyClamped = key.clone(); - keyClamped.clamp(); - - Y.Assert.areEqual(CryptoJS.HmacSHA256("Message", keyClamped).toString(), CryptoJS.HmacSHA256("Message", key).toString()); - } - })); -}, '$Rev$'); diff --git a/test/hmac-sha384-test.js b/test/hmac-sha384-test.js deleted file mode 100644 index ebea5e1..0000000 --- a/test/hmac-sha384-test.js +++ /dev/null @@ -1,59 +0,0 @@ -YUI.add('algo-hmac-sha384-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'HMAC SHA384', - - testVector1: function () { - Y.Assert.areEqual('7afaa633e20d379b02395915fbc385ff8dc27dcd3885e1068ab942eeab52ec1f20ad382a92370d8b2e0ac8b83c4d53bf', C.HmacSHA384('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649', C.HmacSHA384('what do ya want for nothing?', 'Jefe').toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('1383e82e28286b91f4cc7afbd13d5b5c6f887c05e7c4542484043a37a5fe45802a9470fb663bd7b6570fe2f503fc92f5', C.HmacSHA384(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()); - }, - - testVector4: function () { - Y.Assert.areEqual('365dfb271adb8e30fe6c74220b75df1b38c2d19b9d37f2e5a0ec2f3f22bd0406bf5b786e98d81b82c36d3d8a1be6cd07', C.HmacSHA384('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString()); - }, - - testVector5: function () { - Y.Assert.areEqual('a8357d5e84da64140e41545562ae0782e2a58e39c6cd98939fad8d9080e774c84b7eaca4ba07f6dbf0f12eab912c5285', C.HmacSHA384('abcdefghijklmnopqrstuvwxyz', 'A').toString()); - }, - - testUpdate: function () { - var hmac = C.algo.HMAC.create(C.algo.SHA384, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); - - Y.Assert.areEqual(C.HmacSHA384(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString()); - }, - - testInputIntegrity: function () { - var message = C.lib.WordArray.create([0x12345678]); - var key = C.lib.WordArray.create([0x12345678]); - - var expectedMessage = message.toString(); - var expectedKey = key.toString(); - - C.HmacSHA384(message, key); - - Y.Assert.areEqual(expectedMessage, message.toString()); - Y.Assert.areEqual(expectedKey, key.toString()); - }, - - testRespectKeySigBytes: function () { - var key = C.lib.WordArray.random(8); - key.sigBytes = 4; - - var keyClamped = key.clone(); - keyClamped.clamp(); - - Y.Assert.areEqual(CryptoJS.HmacSHA384("Message", keyClamped).toString(), CryptoJS.HmacSHA384("Message", key).toString()); - } - })); -}, '$Rev$'); diff --git a/test/hmac-sha512-test.js b/test/hmac-sha512-test.js deleted file mode 100644 index 1e5d820..0000000 --- a/test/hmac-sha512-test.js +++ /dev/null @@ -1,59 +0,0 @@ -YUI.add('algo-hmac-sha512-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'HMAC SHA512', - - testVector1: function () { - Y.Assert.areEqual('7641c48a3b4aa8f887c07b3e83f96affb89c978fed8c96fcbbf4ad596eebfe496f9f16da6cd080ba393c6f365ad72b50d15c71bfb1d6b81f66a911786c6ce932', C.HmacSHA512('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737', C.HmacSHA512('what do ya want for nothing?', 'Jefe').toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('ad9b5c7de72693737cd5e9d9f41170d18841fec1201c1c1b02e05cae116718009f771cad9946ddbf7e3cde3e818d9ae85d91b2badae94172d096a44a79c91e86', C.HmacSHA512(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()); - }, - - testVector4: function () { - Y.Assert.areEqual('a303979f7c94bb39a8ab6ce05cdbe28f0255da8bb305263e3478ef7e855f0242729bf1d2be55398f14da8e63f0302465a8a3f76c297bd584ad028d18ed7f0195', C.HmacSHA512('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString()); - }, - - testVector5: function () { - Y.Assert.areEqual('8c2d56f7628325e62124c0a870ad98d101327fc42696899a06ce0d7121454022fae597e42c25ac3a4c380fd514f553702a5b0afaa9b5a22050902f024368e9d9', C.HmacSHA512('abcdefghijklmnopqrstuvwxyz', 'A').toString()); - }, - - testUpdate: function () { - var hmac = C.algo.HMAC.create(C.algo.SHA512, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); - hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); - - Y.Assert.areEqual(C.HmacSHA512(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString()); - }, - - testInputIntegrity: function () { - var message = C.lib.WordArray.create([0x12345678]); - var key = C.lib.WordArray.create([0x12345678]); - - var expectedMessage = message.toString(); - var expectedKey = key.toString(); - - C.HmacSHA512(message, key); - - Y.Assert.areEqual(expectedMessage, message.toString()); - Y.Assert.areEqual(expectedKey, key.toString()); - }, - - testRespectKeySigBytes: function () { - var key = C.lib.WordArray.random(8); - key.sigBytes = 4; - - var keyClamped = key.clone(); - keyClamped.clamp(); - - Y.Assert.areEqual(CryptoJS.HmacSHA512("Message", keyClamped).toString(), CryptoJS.HmacSHA512("Message", key).toString()); - } - })); -}, '$Rev$'); diff --git a/test/kdf-openssl-test.js b/test/kdf-openssl-test.js deleted file mode 100644 index 92a8d9e..0000000 --- a/test/kdf-openssl-test.js +++ /dev/null @@ -1,15 +0,0 @@ -YUI.add('kdf-openssl-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'OpenSSLKdf', - - testVector: function () { - var derivedParams = C.kdf.OpenSSL.execute('password', 256/32, 128/32, C.enc.Hex.parse('0a9d8620cf7219f1')); - - Y.Assert.areEqual('50f32e0ec9408e02ff42364a52aac95c3694fc027256c6f488bf84b8e60effcd', derivedParams.key.toString()); - Y.Assert.areEqual('81381e39b94fd692dff7e2239a298cb6', derivedParams.iv.toString()); - Y.Assert.areEqual('0a9d8620cf7219f1', derivedParams.salt.toString()); - } - })); -}, '$Rev$'); diff --git a/test/lib-base-test.js b/test/lib-base-test.js deleted file mode 100644 index ed8e642..0000000 --- a/test/lib-base-test.js +++ /dev/null @@ -1,92 +0,0 @@ -YUI.add('lib-base-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'Base', - - setUp: function () { - this.data = {}; - - this.data.overrides = { - init: function (arg) { - this.initFired = true; - this.initArg = arg; - }, - - toString: function () { - } - }; - - this.data.mixins = { - mixinMethod: function () { - } - }; - - this.data.Obj = C.lib.Base.extend(this.data.overrides); - - this.data.Obj.mixIn(this.data.mixins); - - this.data.obj = this.data.Obj.create('argValue'); - - this.data.objClone = this.data.obj.clone(); - }, - - testExtendInheritance: function () { - Y.Assert.areEqual(C.lib.Base.extend, this.data.Obj.extend); - Y.Assert.isFalse(this.data.Obj.hasOwnProperty('extend')); - }, - - testExtendSuper: function () { - Y.Assert.areEqual(C.lib.Base, this.data.Obj.$super); - }, - - testExtendOverrideInit: function () { - Y.Assert.areEqual(this.data.overrides.init, this.data.Obj.init); - Y.Assert.isTrue(this.data.Obj.hasOwnProperty('init')); - }, - - testExtendOverrideToString: function () { - Y.Assert.areEqual(this.data.overrides.toString, this.data.Obj.toString); - Y.Assert.isTrue(this.data.Obj.hasOwnProperty('toString')); - }, - - testCreateInheritanceFromBase: function () { - Y.Assert.areEqual(C.lib.Base.extend, this.data.obj.extend); - Y.Assert.isFalse(this.data.obj.hasOwnProperty('extend')); - }, - - testCreateSuper: function () { - Y.Assert.areEqual(this.data.Obj, this.data.obj.$super); - }, - - testCreateInit: function () { - Y.Assert.isTrue(this.data.obj.initFired); - Y.Assert.areEqual('argValue', this.data.obj.initArg); - }, - - testMixIn: function () { - Y.Assert.areEqual(this.data.mixins.mixinMethod, this.data.Obj.mixinMethod); - Y.Assert.isTrue(this.data.Obj.hasOwnProperty('mixinMethod')); - }, - - testCloneDistinct: function () { - Y.Assert.areNotEqual(this.data.obj, this.data.objClone); - }, - - testCloneCopy: function () { - Y.Assert.areEqual(this.data.obj.initArg, this.data.objClone.initArg); - }, - - testCloneIndependent: function () { - this.data.obj.initArg = 'newValue'; - - Y.Assert.areNotEqual(this.data.obj.initArg, this.data.objClone.initArg); - }, - - testCloneLeavesOriginalInitPrototypeUnchanged: function() { - Y.Assert.areEqual(this.data.obj, this.data.obj.init.prototype); - Y.Assert.areEqual(this.data.objClone, this.data.objClone.init.prototype); - Y.Assert.areNotEqual(this.data.obj.init.prototype, this.data.objClone.init.prototype); - } - })); -}, '$Rev$'); diff --git a/test/lib-cipherparams-test.js b/test/lib-cipherparams-test.js deleted file mode 100644 index a99d25d..0000000 --- a/test/lib-cipherparams-test.js +++ /dev/null @@ -1,59 +0,0 @@ -YUI.add('lib-cipherparams-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'CipherParams', - - setUp: function () { - this.data = {}; - - this.data.ciphertext = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'); - this.data.key = C.enc.Hex.parse('101112131415161718191a1b1c1d1e1f'); - this.data.iv = C.enc.Hex.parse('202122232425262728292a2b2c2d2e2f'); - this.data.salt = C.enc.Hex.parse('0123456789abcdef'); - this.data.algorithm = C.algo.AES; - this.data.mode = C.mode.CBC; - this.data.padding = C.pad.PKCS7; - this.data.blockSize = this.data.algorithm.blockSize; - this.data.formatter = C.format.OpenSSL; - - this.data.cipherParams = C.lib.CipherParams.create({ - ciphertext: this.data.ciphertext, - key: this.data.key, - iv: this.data.iv, - salt: this.data.salt, - algorithm: this.data.algorithm, - mode: this.data.mode, - padding: this.data.padding, - blockSize: this.data.blockSize, - formatter: this.data.formatter - }); - }, - - testInit: function () { - Y.Assert.areEqual(this.data.ciphertext, this.data.cipherParams.ciphertext); - Y.Assert.areEqual(this.data.key, this.data.cipherParams.key); - Y.Assert.areEqual(this.data.iv, this.data.cipherParams.iv); - Y.Assert.areEqual(this.data.salt, this.data.cipherParams.salt); - Y.Assert.areEqual(this.data.algorithm, this.data.cipherParams.algorithm); - Y.Assert.areEqual(this.data.mode, this.data.cipherParams.mode); - Y.Assert.areEqual(this.data.padding, this.data.cipherParams.padding); - Y.Assert.areEqual(this.data.blockSize, this.data.cipherParams.blockSize); - Y.Assert.areEqual(this.data.formatter, this.data.cipherParams.formatter); - }, - - testToString0: function () { - Y.Assert.areEqual(C.format.OpenSSL.stringify(this.data.cipherParams), this.data.cipherParams.toString()); - }, - - testToString1: function () { - var JsonFormatter = { - stringify: function (cipherParams) { - return '{ ct: ' + cipherParams.ciphertext + ', iv: ' + cipherParams.iv + ' }'; - } - }; - - Y.Assert.areEqual(JsonFormatter.stringify(this.data.cipherParams), this.data.cipherParams.toString(JsonFormatter)); - } - })); -}, '$Rev$'); diff --git a/test/lib-passwordbasedcipher-test.js b/test/lib-passwordbasedcipher-test.js deleted file mode 100644 index 04f63a1..0000000 --- a/test/lib-passwordbasedcipher-test.js +++ /dev/null @@ -1,25 +0,0 @@ -YUI.add('lib-passwordbasedcipher-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'PasswordBasedCipher', - - testEncrypt: function () { - // Compute actual - var actual = C.lib.PasswordBasedCipher.encrypt(C.algo.AES, 'Hello, World!', 'password'); - - // Compute expected - var aes = C.algo.AES.createEncryptor(actual.key, { iv: actual.iv }); - var expected = aes.finalize('Hello, World!'); - - Y.Assert.areEqual(expected.toString(), actual.ciphertext.toString()); - }, - - testDecrypt: function () { - var ciphertext = C.lib.PasswordBasedCipher.encrypt(C.algo.AES, 'Hello, World!', 'password'); - var plaintext = C.lib.PasswordBasedCipher.decrypt(C.algo.AES, ciphertext, 'password'); - - Y.Assert.areEqual('Hello, World!', plaintext.toString(C.enc.Utf8)); - } - })); -}, '$Rev$'); diff --git a/test/lib-serializablecipher-test.js b/test/lib-serializablecipher-test.js deleted file mode 100644 index 60a13da..0000000 --- a/test/lib-serializablecipher-test.js +++ /dev/null @@ -1,51 +0,0 @@ -YUI.add('lib-serializablecipher-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'SerializableCipher', - - setUp: function () { - this.data = {}; - - this.data.message = C.lib.WordArray.create([0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f]); - this.data.key = C.lib.WordArray.create([0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f]); - this.data.iv = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); - }, - - testEncrypt: function () { - // Compute expected - var aes = C.algo.AES.createEncryptor(this.data.key, { iv: this.data.iv }); - var ciphertext = aes.finalize(this.data.message); - var expected = C.lib.CipherParams.create({ - ciphertext: ciphertext, - key: this.data.key, - iv: this.data.iv, - algorithm: C.algo.AES, - mode: aes.cfg.mode, - padding: aes.cfg.padding, - blockSize: aes.blockSize, - formatter: C.format.OpenSSL - }); - - // Compute actual - var actual = C.lib.SerializableCipher.encrypt(C.algo.AES, this.data.message, this.data.key, { iv: this.data.iv }); - - // Test - Y.Assert.areEqual(expected.toString(), actual.toString()); - Y.Assert.areEqual(expected.ciphertext.toString(), actual.ciphertext.toString()); - Y.Assert.areEqual(expected.key.toString(), actual.key.toString()); - Y.Assert.areEqual(expected.iv.toString(), actual.iv.toString()); - Y.Assert.areEqual(expected.algorithm, actual.algorithm); - Y.Assert.areEqual(expected.mode, actual.mode); - Y.Assert.areEqual(expected.padding, actual.padding); - Y.Assert.areEqual(expected.blockSize, actual.blockSize); - }, - - testDecrypt: function () { - var encrypted = C.lib.SerializableCipher.encrypt(C.algo.AES, this.data.message, this.data.key, { iv: this.data.iv }) + ''; - var decrypted = C.lib.SerializableCipher.decrypt(C.algo.AES, encrypted, this.data.key, { iv: this.data.iv }); - - Y.Assert.areEqual(this.data.message.toString(), decrypted.toString()); - } - })); -}, '$Rev$'); diff --git a/test/lib-typedarrays-test.js b/test/lib-typedarrays-test.js deleted file mode 100644 index 4763a56..0000000 --- a/test/lib-typedarrays-test.js +++ /dev/null @@ -1,57 +0,0 @@ -YUI.add('lib-wordarray-test', function (Y) { - var C = CryptoJS; - - if (typeof ArrayBuffer != 'undefined') { - Y.Test.Runner.add(new Y.Test.Case({ - name: 'TypedArrays', - - setUp: function () { - this.data = {}; - - this.data.buffer = new ArrayBuffer(8); - - var uint8View = new Uint8Array(this.data.buffer); - uint8View[0] = 0x01; - uint8View[1] = 0x23; - uint8View[2] = 0x45; - uint8View[3] = 0x67; - uint8View[4] = 0x89; - uint8View[5] = 0xab; - uint8View[6] = 0xcd; - uint8View[7] = 0xef; - }, - - testInt8Array: function () { - Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Int8Array(this.data.buffer)).toString()); - }, - - testUint8Array: function () { - Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint8Array(this.data.buffer)).toString()); - }, - - testUint8ClampedArray: function () { - Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint8ClampedArray(this.data.buffer)).toString()); - }, - - testInt16Array: function () { - Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Int16Array(this.data.buffer)).toString()); - }, - - testUint16Array: function () { - Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint16Array(this.data.buffer)).toString()); - }, - - testInt32Array: function () { - Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Int32Array(this.data.buffer)).toString()); - }, - - testUint32Array: function () { - Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint32Array(this.data.buffer)).toString()); - }, - - testPartialView: function () { - Y.Assert.areEqual('456789ab', C.lib.WordArray.create(new Int16Array(this.data.buffer, 2, 2)).toString()); - } - })); - } -}, '$Rev$'); diff --git a/test/lib-wordarray-test.js b/test/lib-wordarray-test.js deleted file mode 100644 index ab2aead..0000000 --- a/test/lib-wordarray-test.js +++ /dev/null @@ -1,85 +0,0 @@ -YUI.add('lib-wordarray-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'WordArray', - - testInit0: function () { - Y.Assert.areEqual('', C.lib.WordArray.create().toString()); - }, - - testInit1: function () { - Y.Assert.areEqual('12345678', C.lib.WordArray.create([0x12345678]).toString()); - }, - - testInit2: function () { - Y.Assert.areEqual('1234', C.lib.WordArray.create([0x12345678], 2).toString()); - }, - - testToStringPassedEncoder: function () { - Y.Assert.areEqual('\x12\x34\x56\x78', C.lib.WordArray.create([0x12345678]).toString(C.enc.Latin1)); - }, - - testToStringDefaultEncoder: function () { - Y.Assert.areEqual('12345678', C.lib.WordArray.create([0x12345678]).toString()); - }, - - testConcat3: function () { - var wordArray1 = C.lib.WordArray.create([0x12345678], 3); - var wordArray2 = C.lib.WordArray.create([0x12345678], 3); - - Y.Assert.areEqual('123456123456', wordArray1.concat(wordArray2).toString()); - Y.Assert.areEqual('123456123456', wordArray1.toString()); - }, - - testConcat4: function () { - var wordArray1 = C.lib.WordArray.create([0x12345678], 4); - var wordArray2 = C.lib.WordArray.create([0x12345678], 3); - - Y.Assert.areEqual('12345678123456', wordArray1.concat(wordArray2).toString()); - Y.Assert.areEqual('12345678123456', wordArray1.toString()); - }, - - testConcat5: function () { - var wordArray1 = C.lib.WordArray.create([0x12345678], 5); - var wordArray2 = C.lib.WordArray.create([0x12345678], 3); - - Y.Assert.areEqual('1234567800123456', wordArray1.concat(wordArray2).toString()); - Y.Assert.areEqual('1234567800123456', wordArray1.toString()); - }, - - testConcatLong: function () { - var wordArray1 = C.lib.WordArray.create(); - - var wordArray2 = C.lib.WordArray.create(); - var wordArray3 = C.lib.WordArray.create(); - for (var i = 0; i < 500000; i++) { - wordArray2.words[i] = i; - wordArray3.words[i] = i; - } - wordArray2.sigBytes = wordArray3.sigBytes = 500000; - - Y.Assert.areEqual(wordArray2.toString() + wordArray3.toString(), wordArray1.concat(wordArray2.concat(wordArray3)).toString()); - }, - - testClamp: function () { - var wordArray = C.lib.WordArray.create([0x12345678, 0x12345678], 3); - wordArray.clamp(); - - Y.Assert.areEqual([0x12345600].toString(), wordArray.words.toString()); - }, - - testClone: function () { - var wordArray = C.lib.WordArray.create([0x12345678]); - var clone = wordArray.clone(); - clone.words[0] = 0; - - Y.Assert.areNotEqual(wordArray.toString(), clone.toString()); - }, - - testRandom: function () { - Y.Assert.areNotEqual(C.lib.WordArray.random(8).toString(), C.lib.WordArray.random(8).toString()); - Y.Assert.areEqual(8, C.lib.WordArray.random(8).sigBytes); - } - })); -}, '$Rev$'); diff --git a/test/md5-profile.js b/test/md5-profile.js deleted file mode 100644 index 2747b26..0000000 --- a/test/md5-profile.js +++ /dev/null @@ -1,24 +0,0 @@ -YUI.add('algo-md5-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'MD5', - - profileSinglePartMessage: function () { - var singlePartMessage = ''; - for (var i = 0; i < 500; i++) { - singlePartMessage += '12345678901234567890123456789012345678901234567890'; - } - - C.algo.MD5.create().finalize(singlePartMessage) + ''; - }, - - profileMultiPartMessage: function () { - var md5 = C.algo.MD5.create(); - for (var i = 0; i < 500; i++) { - md5.update('12345678901234567890123456789012345678901234567890'); - } - md5.finalize() + ''; - } - }); -}, '$Rev$'); diff --git a/test/md5-test.js b/test/md5-test.js deleted file mode 100644 index e27674f..0000000 --- a/test/md5-test.js +++ /dev/null @@ -1,70 +0,0 @@ -YUI.add('algo-md5-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'MD5', - - testVector1: function () { - Y.Assert.areEqual('d41d8cd98f00b204e9800998ecf8427e', C.MD5('').toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('0cc175b9c0f1b6a831c399e269772661', C.MD5('a').toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('900150983cd24fb0d6963f7d28e17f72', C.MD5('abc').toString()); - }, - - testVector4: function () { - Y.Assert.areEqual('f96b697d7cb7938d525a2f31aaf161d0', C.MD5('message digest').toString()); - }, - - testVector5: function () { - Y.Assert.areEqual('c3fcd3d76192e4007dfb496cca67e13b', C.MD5('abcdefghijklmnopqrstuvwxyz').toString()); - }, - - testVector6: function () { - Y.Assert.areEqual('d174ab98d277d9f5a5611c2c9f419d9f', C.MD5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789').toString()); - }, - - testVector7: function () { - Y.Assert.areEqual('57edf4a22be3c955ac49da2e2107b67a', C.MD5('12345678901234567890123456789012345678901234567890123456789012345678901234567890').toString()); - }, - - testUpdateAndLongMessage: function () { - var md5 = C.algo.MD5.create(); - for (var i = 0; i < 100; i++) { - md5.update('12345678901234567890123456789012345678901234567890'); - } - - Y.Assert.areEqual('7d017545e0268a6a12f2b507871d0429', md5.finalize().toString()); - }, - - testClone: function () { - var md5 = C.algo.MD5.create(); - - Y.Assert.areEqual(C.MD5('a').toString(), md5.update('a').clone().finalize().toString()); - Y.Assert.areEqual(C.MD5('ab').toString(), md5.update('b').clone().finalize().toString()); - Y.Assert.areEqual(C.MD5('abc').toString(), md5.update('c').clone().finalize().toString()); - }, - - testInputIntegrity: function () { - var message = C.lib.WordArray.create([0x12345678]); - - var expected = message.toString(); - - C.MD5(message); - - Y.Assert.areEqual(expected, message.toString()); - }, - - testHelper: function () { - Y.Assert.areEqual(C.algo.MD5.create().finalize('').toString(), C.MD5('').toString()); - }, - - testHmacHelper: function () { - Y.Assert.areEqual(C.algo.HMAC.create(C.algo.MD5, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacMD5('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()); - } - })); -}, '$Rev$'); diff --git a/test/md5.profile.test.js b/test/md5.profile.test.js new file mode 100644 index 0000000..02345fa --- /dev/null +++ b/test/md5.profile.test.js @@ -0,0 +1,27 @@ +import C from '../src/index'; + +const WORD_ARRAY_TEST = { + 'sigBytes': 16, + 'words': [1410418970, 1874077036, 1337395728, -598079323] +}; +describe('algo-md5-profile', () => { + test('profileSinglePartMessage', () => { + let singlePartMessage = ''; + let i = 0; + while (i < 500) { + singlePartMessage += '12345678901234567890123456789012345678901234567890'; + i++; + } + expect(C.algo.MD5.create().finalize(singlePartMessage)).toMatchObject(WORD_ARRAY_TEST); + }); + + test('profileMultiPartMessage', () => { + let i = 0; + const md5 = C.algo.MD5.create(); + while (i < 500) { + md5.update('12345678901234567890123456789012345678901234567890'); + i++; + } + expect(md5.finalize()).toMatchObject(WORD_ARRAY_TEST); + }); +}); \ No newline at end of file diff --git a/test/md5.test.js b/test/md5.test.js new file mode 100644 index 0000000..dbe1371 --- /dev/null +++ b/test/md5.test.js @@ -0,0 +1,63 @@ +import C from '../lib/index.js'; + +const VECTOR_TEST_CONFIG = [ + [1, '', 'd41d8cd98f00b204e9800998ecf8427e'], + [2, 'a', '0cc175b9c0f1b6a831c399e269772661'], + [3, 'abc', '900150983cd24fb0d6963f7d28e17f72'], + [4, 'message digest', 'f96b697d7cb7938d525a2f31aaf161d0'], + [5, 'abcdefghijklmnopqrstuvwxyz', 'c3fcd3d76192e4007dfb496cca67e13b'], + [6, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'd174ab98d277d9f5a5611c2c9f419d9f'], + [7, '12345678901234567890123456789012345678901234567890123456789012345678901234567890', '57edf4a22be3c955ac49da2e2107b67a'] +]; + +const CLONE_TEST_CONFIG = [ + ['a', 'a'], + ['b', 'ab'], + ['c', 'abc'] +]; + +describe('algo-md5-test', () => { + describe.each(VECTOR_TEST_CONFIG)( + 'testVector%i', + (a, b, expected) => { + test(`return ${expected}`, () => { + expect(C.MD5(b).toString()).toBe(expected); + }); + } + ); + + describe('testClone', () => { + const md5 = C.algo.MD5.create(); + test.each(CLONE_TEST_CONFIG)( + 'return %s, %s', + (a, expected) => { + expect(md5.update(a).clone().finalize().toString()).toBe(C.MD5(expected).toString()); + } + ); + }); + + test('testUpdateAndLongMessage', () => { + let i = 0; + const md5 = C.algo.MD5.create(); + while (i < 100) { + md5.update('12345678901234567890123456789012345678901234567890'); + i++; + } + expect(md5.finalize().toString()).toBe('7d017545e0268a6a12f2b507871d0429'); + }); + + test('testInputIntegrity', () => { + const message = C.lib.WordArray.create([0x12345678]); + const expected = message.toString(); + C.MD5(message); + expect(message.toString()).toBe(expected); + }); + + test('testHelper', () => { + expect(C.MD5('').toString()).toBe(C.algo.MD5.create().finalize('').toString()); + }); + + test('testHmacHelper', () => { + expect(C.HmacMD5('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()).toBe(C.algo.HMAC.create(C.algo.MD5, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString()); + }); +}); \ No newline at end of file diff --git a/test/mode-cbc-test.js b/test/mode-cbc-test.js deleted file mode 100644 index a3e7101..0000000 --- a/test/mode-cbc-test.js +++ /dev/null @@ -1,49 +0,0 @@ -YUI.add('mode-cbc-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'CBC', - - setUp: function () { - this.data = {}; - - this.data.message = C.lib.WordArray.create([ - 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, - 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f - ]); - this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); - this.data.iv = C.lib.WordArray.create([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); - }, - - testEncryptor: function () { - // Compute expected - var expected = this.data.message.clone(); - var aes = C.algo.AES.createEncryptor(this.data.key); - - // First block XORed with IV, then encrypted - for (var i = 0; i < 4; i++) { - expected.words[i] ^= this.data.iv.words[i]; - } - aes.encryptBlock(expected.words, 0); - - // Subsequent blocks XORed with previous crypted block, then encrypted - for (var i = 4; i < 8; i++) { - expected.words[i] ^= expected.words[i - 4]; - } - aes.encryptBlock(expected.words, 4); - - // Compute actual - var actual = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CBC, padding: C.pad.NoPadding }).ciphertext; - - // Test - Y.Assert.areEqual(expected.toString(), actual.toString()); - }, - - testDecryptor: function () { - var encrypted = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CBC, padding: C.pad.NoPadding }); - var decrypted = C.AES.decrypt(encrypted, this.data.key, { iv: this.data.iv, mode: C.mode.CBC, padding: C.pad.NoPadding }); - - Y.Assert.areEqual(this.data.message.toString(), decrypted.toString()); - } - })); -}, '$Rev$'); diff --git a/test/mode-cfb-test.js b/test/mode-cfb-test.js deleted file mode 100644 index 68a7205..0000000 --- a/test/mode-cfb-test.js +++ /dev/null @@ -1,51 +0,0 @@ -YUI.add('mode-cfb-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'CFB', - - setUp: function () { - this.data = {}; - - this.data.message = C.lib.WordArray.create([ - 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, - 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f - ]); - this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); - this.data.iv = C.lib.WordArray.create([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); - }, - - testEncryptor: function () { - // Compute expected - var expected = this.data.message.clone(); - var aes = C.algo.AES.createEncryptor(this.data.key); - - // First block XORed with encrypted IV - var keystream = this.data.iv.words.slice(0); - aes.encryptBlock(keystream, 0); - for (var i = 0; i < 4; i++) { - expected.words[i] ^= keystream[i]; - } - - // Subsequent blocks XORed with encrypted previous crypted block - var keystream = expected.words.slice(0, 4); - aes.encryptBlock(keystream, 0); - for (var i = 4; i < 8; i++) { - expected.words[i] ^= keystream[i % 4]; - } - - // Compute actual - var actual = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CFB, padding: C.pad.NoPadding }).ciphertext; - - // Test - Y.Assert.areEqual(expected.toString(), actual.toString()); - }, - - testDecryptor: function () { - var encrypted = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CFB, padding: C.pad.NoPadding }); - var decrypted = C.AES.decrypt(encrypted, this.data.key, { iv: this.data.iv, mode: C.mode.CFB, padding: C.pad.NoPadding }); - - Y.Assert.areEqual(this.data.message.toString(), decrypted.toString()); - } - })); -}, '$Rev$'); diff --git a/test/mode-ctr-test.js b/test/mode-ctr-test.js deleted file mode 100644 index 4d78385..0000000 --- a/test/mode-ctr-test.js +++ /dev/null @@ -1,55 +0,0 @@ -YUI.add('mode-ctr-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'CTR', - - setUp: function () { - this.data = {}; - - this.data.message = C.lib.WordArray.create([ - 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, - 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f - ]); - this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); - this.data.iv = C.lib.WordArray.create([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); - }, - - testEncryptor: function () { - // Compute expected - var expected = this.data.message.clone(); - var aes = C.algo.AES.createEncryptor(this.data.key); - - // Counter initialized with IV - var counter = this.data.iv.words.slice(0); - - // First block XORed with encrypted counter - var keystream = counter.slice(0); - aes.encryptBlock(keystream, 0); - for (var i = 0; i < 4; i++) { - expected.words[i] ^= keystream[i]; - } - - // Subsequent blocks XORed with encrypted incremented counter - counter[3]++; - var keystream = counter.slice(0); - aes.encryptBlock(keystream, 0); - for (var i = 4; i < 8; i++) { - expected.words[i] ^= keystream[i % 4]; - } - - // Compute actual - var actual = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CTR, padding: C.pad.NoPadding }).ciphertext; - - // Test - Y.Assert.areEqual(expected.toString(), actual.toString()); - }, - - testDecryptor: function () { - var encrypted = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CTR, padding: C.pad.NoPadding }); - var decrypted = C.AES.decrypt(encrypted, this.data.key, { iv: this.data.iv, mode: C.mode.CTR, padding: C.pad.NoPadding }); - - Y.Assert.areEqual(this.data.message.toString(), decrypted.toString()); - } - })); -}, '$Rev$'); diff --git a/test/mode-ecb-test.js b/test/mode-ecb-test.js deleted file mode 100644 index 26156a3..0000000 --- a/test/mode-ecb-test.js +++ /dev/null @@ -1,38 +0,0 @@ -YUI.add('mode-ecb-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'ECB', - - setUp: function () { - this.data = {}; - - this.data.message = C.lib.WordArray.create([ - 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, - 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f - ]); - this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); - }, - - testEncryptor: function () { - // Compute expected - var expected = this.data.message.clone(); - var aes = C.algo.AES.createEncryptor(this.data.key); - aes.encryptBlock(expected.words, 0); - aes.encryptBlock(expected.words, 4); - - // Compute actual - var actual = C.AES.encrypt(this.data.message, this.data.key, { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext; - - // Test - Y.Assert.areEqual(expected.toString(), actual.toString()); - }, - - testDecryptor: function () { - var encrypted = C.AES.encrypt(this.data.message, this.data.key, { mode: C.mode.ECB, padding: C.pad.NoPadding }); - var decrypted = C.AES.decrypt(encrypted, this.data.key, { mode: C.mode.ECB, padding: C.pad.NoPadding }); - - Y.Assert.areEqual(this.data.message.toString(), decrypted.toString()); - } - })); -}, '$Rev$'); diff --git a/test/mode-ofb-test.js b/test/mode-ofb-test.js deleted file mode 100644 index f3ad22b..0000000 --- a/test/mode-ofb-test.js +++ /dev/null @@ -1,50 +0,0 @@ -YUI.add('mode-ofb-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'OFB', - - setUp: function () { - this.data = {}; - - this.data.message = C.lib.WordArray.create([ - 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, - 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f - ]); - this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); - this.data.iv = C.lib.WordArray.create([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); - }, - - testEncryptor: function () { - // Compute expected - var expected = this.data.message.clone(); - var aes = C.algo.AES.createEncryptor(this.data.key); - - // First block XORed with encrypted IV - var keystream = this.data.iv.words.slice(0); - aes.encryptBlock(keystream, 0); - for (var i = 0; i < 4; i++) { - expected.words[i] ^= keystream[i]; - } - - // Subsequent blocks XORed with encrypted previous keystream - aes.encryptBlock(keystream, 0); - for (var i = 4; i < 8; i++) { - expected.words[i] ^= keystream[i % 4]; - } - - // Compute actual - var actual = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.OFB, padding: C.pad.NoPadding }).ciphertext; - - // Test - Y.Assert.areEqual(expected.toString(), actual.toString()); - }, - - testDecryptor: function () { - var encrypted = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.OFB, padding: C.pad.NoPadding }); - var decrypted = C.AES.decrypt(encrypted, this.data.key, { iv: this.data.iv, mode: C.mode.OFB, padding: C.pad.NoPadding }); - - Y.Assert.areEqual(this.data.message.toString(), decrypted.toString()); - } - })); -}, '$Rev$'); diff --git a/test/pad-ansix923-test.js b/test/pad-ansix923-test.js deleted file mode 100644 index 158fa3c..0000000 --- a/test/pad-ansix923-test.js +++ /dev/null @@ -1,28 +0,0 @@ -YUI.add('pad-ansix923-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'AnsiX923', - - testPad: function () { - var data = C.lib.WordArray.create([0xdddddd00], 3); - C.pad.AnsiX923.pad(data, 2); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00, 0x00000005]).toString(), data.toString()); - }, - - testPadClamp: function () { - var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3); - C.pad.AnsiX923.pad(data, 2); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00, 0x00000005]).toString(), data.toString()); - }, - - testUnpad: function () { - var data = C.lib.WordArray.create([0xdddddd00, 0x00000005]); - C.pad.AnsiX923.unpad(data); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString()); - } - })); -}, '$Rev$'); diff --git a/test/pad-iso10126-test.js b/test/pad-iso10126-test.js deleted file mode 100644 index d51211e..0000000 --- a/test/pad-iso10126-test.js +++ /dev/null @@ -1,50 +0,0 @@ -YUI.add('pad-iso10126-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'Iso10126', - - setUp: function () { - this.data = {}; - - // Save original random method - this.data.random = C.lib.WordArray.random; - - // Replace random method with one that returns a predictable value - C.lib.WordArray.random = function (nBytes) { - var words = []; - for (var i = 0; i < nBytes; i += 4) { - words.push([0x11223344]); - } - - return C.lib.WordArray.create(words, nBytes); - }; - }, - - tearDown: function () { - // Restore random method - C.lib.WordArray.random = this.data.random; - }, - - testPad: function () { - var data = C.lib.WordArray.create([0xdddddd00], 3); - C.pad.Iso10126.pad(data, 2); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd11, 0x22334405]).toString(), data.toString()); - }, - - testPadClamp: function () { - var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3); - C.pad.Iso10126.pad(data, 2); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd11, 0x22334405]).toString(), data.toString()); - }, - - testUnpad: function () { - var data = C.lib.WordArray.create([0xdddddd11, 0x22334405]); - C.pad.Iso10126.unpad(data); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString()); - } - })); -}, '$Rev$'); diff --git a/test/pad-iso97971-test.js b/test/pad-iso97971-test.js deleted file mode 100644 index 1541eac..0000000 --- a/test/pad-iso97971-test.js +++ /dev/null @@ -1,35 +0,0 @@ -YUI.add('pad-iso97971-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'Iso97971', - - testPad1: function () { - var data = C.lib.WordArray.create([0xdddddd00], 3); - C.pad.Iso97971.pad(data, 1); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd80]).toString(), data.toString()); - }, - - testPad2: function () { - var data = C.lib.WordArray.create([0xdddddd00], 3); - C.pad.Iso97971.pad(data, 2); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd80, 0x00000000]).toString(), data.toString()); - }, - - testPadClamp: function () { - var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3); - C.pad.Iso97971.pad(data, 2); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd80, 0x00000000]).toString(), data.toString()); - }, - - testUnpad: function () { - var data = C.lib.WordArray.create([0xdddddd80, 0x00000000]); - C.pad.Iso97971.unpad(data); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString()); - } - })); -}, '$Rev$'); diff --git a/test/pad-pkcs7-test.js b/test/pad-pkcs7-test.js deleted file mode 100644 index 6d59947..0000000 --- a/test/pad-pkcs7-test.js +++ /dev/null @@ -1,28 +0,0 @@ -YUI.add('pad-pkcs7-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'Pkcs7', - - testPad: function () { - var data = C.lib.WordArray.create([0xdddddd00], 3); - C.pad.Pkcs7.pad(data, 2); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd05, 0x05050505]).toString(), data.toString()); - }, - - testPadClamp: function () { - var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3); - C.pad.Pkcs7.pad(data, 2); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd05, 0x05050505]).toString(), data.toString()); - }, - - testUnpad: function () { - var data = C.lib.WordArray.create([0xdddddd05, 0x05050505]); - C.pad.Pkcs7.unpad(data); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString()); - } - })); -}, '$Rev$'); diff --git a/test/pad-zeropadding-test.js b/test/pad-zeropadding-test.js deleted file mode 100644 index 6432185..0000000 --- a/test/pad-zeropadding-test.js +++ /dev/null @@ -1,28 +0,0 @@ -YUI.add('pad-zeropadding-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'ZeroPadding', - - testPad: function () { - var data = C.lib.WordArray.create([0xdddddd00], 3); - C.pad.ZeroPadding.pad(data, 2); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00, 0x00000000]).toString(), data.toString()); - }, - - testPadClamp: function () { - var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3); - C.pad.ZeroPadding.pad(data, 2); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00, 0x00000000]).toString(), data.toString()); - }, - - testUnpad: function () { - var data = C.lib.WordArray.create([0xdddddd00, 0x00000000]); - C.pad.ZeroPadding.unpad(data); - - Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString()); - } - })); -}, '$Rev$'); diff --git a/test/pbkdf2-profile.js b/test/pbkdf2-profile.js deleted file mode 100644 index d69e2f1..0000000 --- a/test/pbkdf2-profile.js +++ /dev/null @@ -1,11 +0,0 @@ -YUI.add('algo-pbkdf2-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'PBKDF2', - - profileKeySize256Iterations20: function () { - C.algo.PBKDF2.create({ keySize: 256/32, iterations: 20 }).compute('password', 'ATHENA.MIT.EDUraeburn'); - } - }); -}, '$Rev$'); diff --git a/test/pbkdf2-test.js b/test/pbkdf2-test.js deleted file mode 100644 index e187008..0000000 --- a/test/pbkdf2-test.js +++ /dev/null @@ -1,80 +0,0 @@ -YUI.add('algo-pbkdf2-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'PBKDF2', - - testKeySize128: function () { - Y.Assert.areEqual('cdedb5281bb2f801565a1122b2563515', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128/32 }).toString()); - }, - - testKeySize256: function () { - Y.Assert.areEqual('cdedb5281bb2f801565a1122b25635150ad1f7a04bb9f3a333ecc0e2e1f70837', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 256/32 }).toString()); - }, - - testKeySize128Iterations2: function () { - Y.Assert.areEqual('01dbee7f4a9e243e988b62c73cda935d', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128/32, iterations: 2 }).toString()); - }, - - testKeySize256Iterations2: function () { - Y.Assert.areEqual('01dbee7f4a9e243e988b62c73cda935da05378b93244ec8f48a99e61ad799d86', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 256/32, iterations: 2 }).toString()); - }, - - testKeySize128Iterations1200: function () { - Y.Assert.areEqual('5c08eb61fdf71e4e4ec3cf6ba1f5512b', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128/32, iterations: 1200 }).toString()); - }, - - testKeySize256Iterations1200: function () { - Y.Assert.areEqual('5c08eb61fdf71e4e4ec3cf6ba1f5512ba7e52ddbc5e5142f708a31e2e62b1e13', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 256/32, iterations: 1200 }).toString()); - }, - - testKeySize128Iterations5: function () { - Y.Assert.areEqual('d1daa78615f287e6a1c8b120d7062a49', C.PBKDF2('password', C.enc.Hex.parse('1234567878563412'), { keySize: 128/32, iterations: 5 }).toString()); - }, - - testKeySize256Iterations5: function () { - Y.Assert.areEqual('d1daa78615f287e6a1c8b120d7062a493f98d203e6be49a6adf4fa574b6e64ee', C.PBKDF2('password', C.enc.Hex.parse('1234567878563412'), { keySize: 256/32, iterations: 5 }).toString()); - }, - - testKeySize128Iterations1200PassPhraseEqualsBlockSize: function () { - Y.Assert.areEqual('139c30c0966bc32ba55fdbf212530ac9', C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase equals block size', { keySize: 128/32, iterations: 1200 }).toString()); - }, - - testKeySize256Iterations1200PassPhraseEqualsBlockSize: function () { - Y.Assert.areEqual('139c30c0966bc32ba55fdbf212530ac9c5ec59f1a452f5cc9ad940fea0598ed1', C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase equals block size', { keySize: 256/32, iterations: 1200 }).toString()); - }, - - testKeySize128Iterations1200PassPhraseExceedsBlockSize: function () { - Y.Assert.areEqual('9ccad6d468770cd51b10e6a68721be61', C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase exceeds block size', { keySize: 128/32, iterations: 1200 }).toString()); - }, - - testKeySize256Iterations1200PassPhraseExceedsBlockSize: function () { - Y.Assert.areEqual('9ccad6d468770cd51b10e6a68721be611a8b4d282601db3b36be9246915ec82a', C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase exceeds block size', { keySize: 256/32, iterations: 1200 }).toString()); - }, - - testKeySize128Iterations50: function () { - Y.Assert.areEqual('6b9cf26d45455a43a5b8bb276a403b39', C.PBKDF2(C.enc.Hex.parse('f09d849e'), 'EXAMPLE.COMpianist', { keySize: 128/32, iterations: 50 }).toString()); - }, - - testKeySize256Iterations50: function () { - Y.Assert.areEqual('6b9cf26d45455a43a5b8bb276a403b39e7fe37a0c41e02c281ff3069e1e94f52', C.PBKDF2(C.enc.Hex.parse('f09d849e'), 'EXAMPLE.COMpianist', { keySize: 256/32, iterations: 50 }).toString()); - }, - - testInputIntegrity: function () { - var password = C.lib.WordArray.create([0x12345678]); - var salt = C.lib.WordArray.create([0x12345678]); - - var expectedPassword = password.toString(); - var expectedSalt = salt.toString(); - - C.PBKDF2(password, salt); - - Y.Assert.areEqual(expectedPassword, password.toString()); - Y.Assert.areEqual(expectedSalt, salt.toString()); - }, - - testHelper: function () { - Y.Assert.areEqual(C.algo.PBKDF2.create({ keySize: 128/32 }).compute('password', 'ATHENA.MIT.EDUraeburn').toString(), C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128/32 }).toString()); - } - })); -}, '$Rev$'); diff --git a/test/profile.html b/test/profile.html deleted file mode 100644 index 65d9fb5..0000000 --- a/test/profile.html +++ /dev/null @@ -1,281 +0,0 @@ - - - - - CryptoJS Profile - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/rabbit-legacy-test.js b/test/rabbit-legacy-test.js deleted file mode 100644 index c0f349a..0000000 --- a/test/rabbit-legacy-test.js +++ /dev/null @@ -1,80 +0,0 @@ -YUI.add('algo-rabbit-legacy-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'RabbitLegacy', - - testVector1: function () { - Y.Assert.areEqual('02f74a1c26456bf5ecd6a536f05457b1', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000')).ciphertext.toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('9c51e28784c37fe9a127f63ec8f32d3d', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('dc51c3ac3bfc62f12e3d36fe91281329')).ciphertext.toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('9b60d002fd5ceb32accd41a0cd0db10c', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('c09b0043e9e9ab0187e0c73383957415')).ciphertext.toString()); - }, - - testVector4: function () { - Y.Assert.areEqual('edb70567375dcd7cd89554f85e27a7c6', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000'), { iv: C.enc.Hex.parse('0000000000000000') }).ciphertext.toString()); - }, - - testVector5: function () { - Y.Assert.areEqual('6d7d012292ccdce0e2120058b94ecd1f', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000'), { iv: C.enc.Hex.parse('597e26c175f573c3') }).ciphertext.toString()); - }, - - testVector6: function () { - Y.Assert.areEqual('4d1051a123afb670bf8d8505c8d85a44', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000'), { iv: C.enc.Hex.parse('2717f4d21a56eba6') }).ciphertext.toString()); - }, - - testMultiPart: function () { - var rabbit = C.algo.RabbitLegacy.createEncryptor(C.enc.Hex.parse('00000000000000000000000000000000')); - var ciphertext1 = rabbit.process(C.enc.Hex.parse('000000000000')); - var ciphertext2 = rabbit.process(C.enc.Hex.parse('0000000000')); - var ciphertext3 = rabbit.process(C.enc.Hex.parse('0000000000')); - var ciphertext4 = rabbit.finalize(); - - Y.Assert.areEqual('02f74a1c26456bf5ecd6a536f05457b1', ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString()); - }, - - testInputIntegrity: function () { - var message = C.enc.Hex.parse('00000000000000000000000000000000'); - var key = C.enc.Hex.parse('00000000000000000000000000000000'); - var iv = C.enc.Hex.parse('0000000000000000'); - - var expectedMessage = message.toString(); - var expectedKey = key.toString(); - var expectedIv = iv.toString(); - - C.RabbitLegacy.encrypt(message, key, { iv: iv }); - - Y.Assert.areEqual(expectedMessage, message.toString()); - Y.Assert.areEqual(expectedKey, key.toString()); - Y.Assert.areEqual(expectedIv, iv.toString()); - }, - - testHelper: function () { - // Save original random method - var random = C.lib.WordArray.random; - - // Replace random method with one that returns a predictable value - C.lib.WordArray.random = function (nBytes) { - var words = []; - for (var i = 0; i < nBytes; i += 4) { - words.push([0x11223344]); - } - - return C.lib.WordArray.create(words, nBytes); - }; - - // Test - Y.Assert.areEqual(C.algo.RabbitLegacy.createEncryptor(C.MD5('Jefe')).finalize('Hi There').toString(), C.RabbitLegacy.encrypt('Hi There', C.MD5('Jefe')).ciphertext.toString()); - Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.RabbitLegacy, 'Hi There', C.MD5('Jefe')).toString(), C.RabbitLegacy.encrypt('Hi There', C.MD5('Jefe')).toString()); - Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.RabbitLegacy, 'Hi There', 'Jefe').toString(), C.RabbitLegacy.encrypt('Hi There', 'Jefe').toString()); - - // Restore random method - C.lib.WordArray.random = random; - } - })); -}, '$Rev$'); diff --git a/test/rabbit-profile.js b/test/rabbit-profile.js deleted file mode 100644 index 2b2dfe2..0000000 --- a/test/rabbit-profile.js +++ /dev/null @@ -1,30 +0,0 @@ -YUI.add('algo-rabbit-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'Rabbit', - - setUp: function () { - this.data = { - key: C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f') - }; - }, - - profileSinglePartMessage: function () { - var singlePartMessage = ''; - for (var i = 0; i < 500; i++) { - singlePartMessage += '12345678901234567890123456789012345678901234567890'; - } - - C.algo.Rabbit.createEncryptor(this.data.key).finalize(singlePartMessage) + ''; - }, - - profileMultiPartMessage: function () { - var rabbit = C.algo.Rabbit.createEncryptor(this.data.key); - for (var i = 0; i < 500; i++) { - rabbit.process('12345678901234567890123456789012345678901234567890') + ''; - } - rabbit.finalize() + ''; - } - }); -}, '$Rev$'); diff --git a/test/rabbit-test.js b/test/rabbit-test.js deleted file mode 100644 index 2fea36e..0000000 --- a/test/rabbit-test.js +++ /dev/null @@ -1,84 +0,0 @@ -YUI.add('algo-rabbit-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'Rabbit', - - testVector1: function () { - Y.Assert.areEqual('02f74a1c26456bf5ecd6a536f05457b1', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000')).ciphertext.toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('3d02e0c730559112b473b790dee018df', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('c21fcf3881cd5ee8628accb0a9890df8')).ciphertext.toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('a3a97abb80393820b7e50c4abb53823d', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('1d272c6a2d8e3dfcac14056b78d633a0')).ciphertext.toString()); - }, - - testVector4: function () { - Y.Assert.areEqual('75d186d6bc6905c64f1b2dfdd51f7bfc', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0053a6f94c9ff24598eb3e91e4378add'), { iv: C.enc.Hex.parse('0d74db42a91077de') }).ciphertext.toString()); - }, - - testVector5: function () { - Y.Assert.areEqual('476e2750c73856c93563b5f546f56a6a', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0558abfe51a4f74a9df04396e93c8fe2'), { iv: C.enc.Hex.parse('167de44bb21980e7') }).ciphertext.toString()); - }, - - testVector6: function () { - Y.Assert.areEqual('921fcf4983891365a7dc901924b5e24b', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0a5db00356a9fc4fa2f5489bee4194e7'), { iv: C.enc.Hex.parse('1f86ed54bb2289f0') }).ciphertext.toString()); - }, - - testVector7: function () { - Y.Assert.areEqual('613cb0ba96aff6cacf2a459a102a7f78', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0f62b5085bae0154a7fa4da0f34699ec'), { iv: C.enc.Hex.parse('288ff65dc42b92f9') }).ciphertext.toString()); - }, - - testMultiPart: function () { - var rabbit = C.algo.Rabbit.createEncryptor(C.enc.Hex.parse('00000000000000000000000000000000')); - var ciphertext1 = rabbit.process(C.enc.Hex.parse('000000000000')); - var ciphertext2 = rabbit.process(C.enc.Hex.parse('0000000000')); - var ciphertext3 = rabbit.process(C.enc.Hex.parse('0000000000')); - var ciphertext4 = rabbit.finalize(); - - Y.Assert.areEqual('02f74a1c26456bf5ecd6a536f05457b1', ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString()); - }, - - testInputIntegrity: function () { - var message = C.enc.Hex.parse('00000000000000000000000000000000'); - var key = C.enc.Hex.parse('00000000000000000000000000000000'); - var iv = C.enc.Hex.parse('0000000000000000'); - - var expectedMessage = message.toString(); - var expectedKey = key.toString(); - var expectedIv = iv.toString(); - - C.Rabbit.encrypt(message, key, { iv: iv }); - - Y.Assert.areEqual(expectedMessage, message.toString()); - Y.Assert.areEqual(expectedKey, key.toString()); - Y.Assert.areEqual(expectedIv, iv.toString()); - }, - - testHelper: function () { - // Save original random method - var random = C.lib.WordArray.random; - - // Replace random method with one that returns a predictable value - C.lib.WordArray.random = function (nBytes) { - var words = []; - for (var i = 0; i < nBytes; i += 4) { - words.push([0x11223344]); - } - - return C.lib.WordArray.create(words, nBytes); - }; - - // Test - Y.Assert.areEqual(C.algo.Rabbit.createEncryptor(C.MD5('Jefe')).finalize('Hi There').toString(), C.Rabbit.encrypt('Hi There', C.MD5('Jefe')).ciphertext.toString()); - Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.Rabbit, 'Hi There', C.MD5('Jefe')).toString(), C.Rabbit.encrypt('Hi There', C.MD5('Jefe')).toString()); - Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.Rabbit, 'Hi There', 'Jefe').toString(), C.Rabbit.encrypt('Hi There', 'Jefe').toString()); - - // Restore random method - C.lib.WordArray.random = random; - } - })); -}, '$Rev$'); diff --git a/test/rc4-profile.js b/test/rc4-profile.js deleted file mode 100644 index 8590d1a..0000000 --- a/test/rc4-profile.js +++ /dev/null @@ -1,30 +0,0 @@ -YUI.add('algo-rc4-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'RC4', - - setUp: function () { - this.data = { - key: C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f') - }; - }, - - profileSinglePartMessage: function () { - var singlePartMessage = ''; - for (var i = 0; i < 500; i++) { - singlePartMessage += '12345678901234567890123456789012345678901234567890'; - } - - C.algo.RC4.createEncryptor(this.data.key).finalize(singlePartMessage) + ''; - }, - - profileMultiPartMessage: function () { - var rc4 = C.algo.RC4.createEncryptor(this.data.key); - for (var i = 0; i < 500; i++) { - rc4.process('12345678901234567890123456789012345678901234567890') + ''; - } - rc4.finalize() + ''; - } - }); -}, '$Rev$'); diff --git a/test/rc4-test.js b/test/rc4-test.js deleted file mode 100644 index 721b676..0000000 --- a/test/rc4-test.js +++ /dev/null @@ -1,68 +0,0 @@ -YUI.add('algo-rc4-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'RC4', - - testVector1: function () { - Y.Assert.areEqual('7494c2e7104b0879', C.RC4.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('0123456789abcdef')).ciphertext.toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('f13829c9de', C.RC4.encrypt(C.enc.Hex.parse('dcee4cf92c'), C.enc.Hex.parse('618a63d2fb')).ciphertext.toString()); - }, - - testDrop: function () { - Y.Assert.areEqual( - C.RC4.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0123456789abcdef')).ciphertext.toString().substr(16), - C.RC4Drop.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('0123456789abcdef'), { drop: 2 }).ciphertext.toString() - ); - }, - - testMultiPart: function () { - var rc4 = C.algo.RC4.createEncryptor(C.enc.Hex.parse('0123456789abcdef')); - var ciphertext1 = rc4.process(C.enc.Hex.parse('00000000')); - var ciphertext2 = rc4.process(C.enc.Hex.parse('0000')); - var ciphertext3 = rc4.process(C.enc.Hex.parse('0000')); - var ciphertext4 = rc4.finalize(); - - Y.Assert.areEqual('7494c2e7104b0879', ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString()); - }, - - testInputIntegrity: function () { - var message = C.enc.Hex.parse('0000000000000000'); - var key = C.enc.Hex.parse('0123456789abcdef'); - - var expectedMessage = message.toString(); - var expectedKey = key.toString(); - - C.RC4.encrypt(message, key); - - Y.Assert.areEqual(expectedMessage, message.toString()); - Y.Assert.areEqual(expectedKey, key.toString()); - }, - - testHelper: function () { - // Save original random method - var random = C.lib.WordArray.random; - - // Replace random method with one that returns a predictable value - C.lib.WordArray.random = function (nBytes) { - var words = []; - for (var i = 0; i < nBytes; i += 4) { - words.push([0x11223344]); - } - - return C.lib.WordArray.create(words, nBytes); - }; - - // Test - Y.Assert.areEqual(C.algo.RC4.createEncryptor(C.SHA256('Jefe')).finalize('Hi There').toString(), C.RC4.encrypt('Hi There', C.SHA256('Jefe')).ciphertext.toString()); - Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.RC4, 'Hi There', C.SHA256('Jefe')).toString(), C.RC4.encrypt('Hi There', C.SHA256('Jefe')).toString()); - Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.RC4, 'Hi There', 'Jefe').toString(), C.RC4.encrypt('Hi There', 'Jefe').toString()); - - // Restore random method - C.lib.WordArray.random = random; - } - })); -}, '$Rev$'); diff --git a/test/ripemd160-test.js b/test/ripemd160-test.js deleted file mode 100644 index 0b4e1f4..0000000 --- a/test/ripemd160-test.js +++ /dev/null @@ -1,19 +0,0 @@ -YUI.add('algo-ripemd160-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'RIPEMD160', - - testVector1: function () { - Y.Assert.areEqual('37f332f68db77bd9d7edd4969571ad671cf9dd3b', C.RIPEMD160('The quick brown fox jumps over the lazy dog').toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('132072df690933835eb8b6ad0b77e7b6f14acad7', C.RIPEMD160('The quick brown fox jumps over the lazy cog').toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('9c1185a5c5e9fc54612808977ee8f548b2258d31', C.RIPEMD160('').toString()); - } - })); -}, '$Rev$'); diff --git a/test/sha1-profile.js b/test/sha1-profile.js deleted file mode 100644 index 55ce702..0000000 --- a/test/sha1-profile.js +++ /dev/null @@ -1,24 +0,0 @@ -YUI.add('algo-sha1-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'SHA1', - - profileSinglePartMessage: function () { - var singlePartMessage = ''; - for (var i = 0; i < 500; i++) { - singlePartMessage += '12345678901234567890123456789012345678901234567890'; - } - - C.algo.SHA1.create().finalize(singlePartMessage) + ''; - }, - - profileMultiPartMessage: function () { - var sha1 = C.algo.SHA1.create(); - for (var i = 0; i < 500; i++) { - sha1.update('12345678901234567890123456789012345678901234567890'); - } - sha1.finalize() + ''; - } - }); -}, '$Rev$'); diff --git a/test/sha1-test.js b/test/sha1-test.js deleted file mode 100644 index c1dd472..0000000 --- a/test/sha1-test.js +++ /dev/null @@ -1,70 +0,0 @@ -YUI.add('algo-sha1-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'SHA1', - - testVector1: function () { - Y.Assert.areEqual('da39a3ee5e6b4b0d3255bfef95601890afd80709', C.SHA1('').toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', C.SHA1('a').toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('a9993e364706816aba3e25717850c26c9cd0d89d', C.SHA1('abc').toString()); - }, - - testVector4: function () { - Y.Assert.areEqual('c12252ceda8be8994d5fa0290a47231c1d16aae3', C.SHA1('message digest').toString()); - }, - - testVector5: function () { - Y.Assert.areEqual('32d10c7b8cf96570ca04ce37f2a19d84240d3a89', C.SHA1('abcdefghijklmnopqrstuvwxyz').toString()); - }, - - testVector6: function () { - Y.Assert.areEqual('761c457bf73b14d27e9e9265c46f4b4dda11f940', C.SHA1('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789').toString()); - }, - - testVector7: function () { - Y.Assert.areEqual('50abf5706a150990a08b2c5ea40fa0e585554732', C.SHA1('12345678901234567890123456789012345678901234567890123456789012345678901234567890').toString()); - }, - - testUpdateAndLongMessage: function () { - var sha1 = C.algo.SHA1.create(); - for (var i = 0; i < 100; i++) { - sha1.update('12345678901234567890123456789012345678901234567890'); - } - - Y.Assert.areEqual('85e4c4b3933d5553ebf82090409a9d90226d845c', sha1.finalize().toString()); - }, - - testClone: function () { - var sha1 = C.algo.SHA1.create(); - - Y.Assert.areEqual(C.SHA1('a').toString(), sha1.update('a').clone().finalize().toString()); - Y.Assert.areEqual(C.SHA1('ab').toString(), sha1.update('b').clone().finalize().toString()); - Y.Assert.areEqual(C.SHA1('abc').toString(), sha1.update('c').clone().finalize().toString()); - }, - - testInputIntegrity: function () { - var message = C.lib.WordArray.create([0x12345678]); - - var expected = message.toString(); - - C.SHA1(message); - - Y.Assert.areEqual(expected, message.toString()); - }, - - testHelper: function () { - Y.Assert.areEqual(C.algo.SHA1.create().finalize('').toString(), C.SHA1('').toString()); - }, - - testHmacHelper: function () { - Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA1, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA1('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()); - } - })); -}, '$Rev$'); diff --git a/test/sha224-test.js b/test/sha224-test.js deleted file mode 100644 index e426555..0000000 --- a/test/sha224-test.js +++ /dev/null @@ -1,19 +0,0 @@ -YUI.add('algo-sha224-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'SHA224', - - testVector1: function () { - Y.Assert.areEqual('d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f', C.SHA224('').toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525', C.SHA224('The quick brown fox jumps over the lazy dog').toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('619cba8e8e05826e9b8c519c0a5c68f4fb653e8a3d8aa04bb2c8cd4c', C.SHA224('The quick brown fox jumps over the lazy dog.').toString()); - } - })); -}, '$Rev$'); diff --git a/test/sha256-profile.js b/test/sha256-profile.js deleted file mode 100644 index c935dee..0000000 --- a/test/sha256-profile.js +++ /dev/null @@ -1,24 +0,0 @@ -YUI.add('algo-sha256-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'SHA256', - - profileSinglePartMessage: function () { - var singlePartMessage = ''; - for (var i = 0; i < 500; i++) { - singlePartMessage += '12345678901234567890123456789012345678901234567890'; - } - - C.algo.SHA256.create().finalize(singlePartMessage) + ''; - }, - - profileMultiPartMessage: function () { - var sha256 = C.algo.SHA256.create(); - for (var i = 0; i < 500; i++) { - sha256.update('12345678901234567890123456789012345678901234567890'); - } - sha256.finalize() + ''; - } - }); -}, '$Rev$'); diff --git a/test/sha256-test.js b/test/sha256-test.js deleted file mode 100644 index e98bfaf..0000000 --- a/test/sha256-test.js +++ /dev/null @@ -1,70 +0,0 @@ -YUI.add('algo-sha256-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'SHA256', - - testVector1: function () { - Y.Assert.areEqual('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', C.SHA256('').toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb', C.SHA256('a').toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad', C.SHA256('abc').toString()); - }, - - testVector4: function () { - Y.Assert.areEqual('f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650', C.SHA256('message digest').toString()); - }, - - testVector5: function () { - Y.Assert.areEqual('71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73', C.SHA256('abcdefghijklmnopqrstuvwxyz').toString()); - }, - - testVector6: function () { - Y.Assert.areEqual('db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0', C.SHA256('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789').toString()); - }, - - testVector7: function () { - Y.Assert.areEqual('f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e', C.SHA256('12345678901234567890123456789012345678901234567890123456789012345678901234567890').toString()); - }, - - testUpdateAndLongMessage: function () { - var sha256 = C.algo.SHA256.create(); - for (var i = 0; i < 100; i++) { - sha256.update('12345678901234567890123456789012345678901234567890'); - } - - Y.Assert.areEqual('f8146961d9b73d8da49ccd526fca65439cdd5b402f76971556d5f52fd129843e', sha256.finalize().toString()); - }, - - testClone: function () { - var sha256 = C.algo.SHA256.create(); - - Y.Assert.areEqual(C.SHA256('a').toString(), sha256.update('a').clone().finalize().toString()); - Y.Assert.areEqual(C.SHA256('ab').toString(), sha256.update('b').clone().finalize().toString()); - Y.Assert.areEqual(C.SHA256('abc').toString(), sha256.update('c').clone().finalize().toString()); - }, - - testInputIntegrity: function () { - var message = C.lib.WordArray.create([0x12345678]); - - var expected = message.toString(); - - C.SHA256(message); - - Y.Assert.areEqual(expected, message.toString()); - }, - - testHelper: function () { - Y.Assert.areEqual(C.algo.SHA256.create().finalize('').toString(), C.SHA256('').toString()); - }, - - testHmacHelper: function () { - Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA256, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA256('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()); - } - })); -}, '$Rev$'); diff --git a/test/sha3-profile.js b/test/sha3-profile.js deleted file mode 100644 index 85f13da..0000000 --- a/test/sha3-profile.js +++ /dev/null @@ -1,24 +0,0 @@ -YUI.add('algo-sha3-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'SHA3', - - profileSinglePartMessage: function () { - var singlePartMessage = ''; - for (var i = 0; i < 500; i++) { - singlePartMessage += '12345678901234567890123456789012345678901234567890'; - } - - C.algo.SHA3.create().finalize(singlePartMessage) + ''; - }, - - profileMultiPartMessage: function () { - var sha3 = C.algo.SHA3.create(); - for (var i = 0; i < 500; i++) { - sha3.update('12345678901234567890123456789012345678901234567890'); - } - sha3.finalize() + ''; - } - }); -}, '$Rev$'); diff --git a/test/sha3-test.js b/test/sha3-test.js deleted file mode 100644 index e274900..0000000 --- a/test/sha3-test.js +++ /dev/null @@ -1,69 +0,0 @@ -YUI.add('algo-sha3-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'SHA3', - - testVector1: function () { - Y.Assert.areEqual('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e', C.SHA3('', { outputLength: 512 }).toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('81950e7096d31d4f22e3db71cac725bf59e81af54c7ca9e6aeee71c010fc5467466312a01aa5c137cfb140646941556796f612c9351268737c7e9a2b9631d1fa', C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { outputLength: 512 }).toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff', C.SHA3('', { outputLength: 384 }).toString()); - }, - - testVector4: function () { - Y.Assert.areEqual('6bff1c8405a3fe594e360e3bccea1ebcd509310dc79b9e45c263783d7a5dd662c6789b18bd567dbdda1554f5bee6a860', C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { outputLength: 384 }).toString()); - }, - - testVector5: function () { - Y.Assert.areEqual('c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470', C.SHA3('', { outputLength: 256 }).toString()); - }, - - testVector6: function () { - Y.Assert.areEqual('348fb774adc970a16b1105669442625e6adaa8257a89effdb5a802f161b862ea', C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { outputLength: 256 }).toString()); - }, - - testVector7: function () { - Y.Assert.areEqual('f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd', C.SHA3('', { outputLength: 224 }).toString()); - }, - - testVector8: function () { - Y.Assert.areEqual('5af56987ea9cf11fcd0eac5ebc14b037365e9b1123e31cb2dfc7929a', C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { outputLength: 224 }).toString()); - }, - - testDefaultOutputLength: function () { - Y.Assert.areEqual('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e', C.SHA3('').toString()); - }, - - testClone: function () { - var sha3 = C.algo.SHA3.create(); - - Y.Assert.areEqual(C.SHA3('a').toString(), sha3.update('a').clone().finalize().toString()); - Y.Assert.areEqual(C.SHA3('ab').toString(), sha3.update('b').clone().finalize().toString()); - Y.Assert.areEqual(C.SHA3('abc').toString(), sha3.update('c').clone().finalize().toString()); - }, - - testInputIntegrity: function () { - var message = C.lib.WordArray.create([0x12345678]); - - var expected = message.toString(); - - C.SHA3(message); - - Y.Assert.areEqual(expected, message.toString()); - }, - - testHelper: function () { - Y.Assert.areEqual(C.algo.SHA3.create({ outputLength: 256 }).finalize('').toString(), C.SHA3('', { outputLength: 256 }).toString()); - }, - - testHmacHelper: function () { - Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA3, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA3('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()); - } - })); -}, '$Rev$'); diff --git a/test/sha384-test.js b/test/sha384-test.js deleted file mode 100644 index b7bdfdc..0000000 --- a/test/sha384-test.js +++ /dev/null @@ -1,54 +0,0 @@ -YUI.add('algo-sha384-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'SHA384', - - testVector1: function () { - Y.Assert.areEqual('38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b', C.SHA384('').toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1', C.SHA384('The quick brown fox jumps over the lazy dog').toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('ed892481d8272ca6df370bf706e4d7bc1b5739fa2177aae6c50e946678718fc67a7af2819a021c2fc34e91bdb63409d7', C.SHA384('The quick brown fox jumps over the lazy dog.').toString()); - }, - - testUpdateAndLongMessage: function () { - var sha384 = C.algo.SHA384.create(); - for (var i = 0; i < 100; i++) { - sha384.update('12345678901234567890123456789012345678901234567890'); - } - - Y.Assert.areEqual('297a519246d6f639a4020119e1f03fc8d77171647b2ff75ea4125b7150fed0cdcc93f8dca1c3c6a624d5e88d780d82cd', sha384.finalize().toString()); - }, - - testClone: function () { - var sha384 = C.algo.SHA384.create(); - - Y.Assert.areEqual(C.SHA384('a').toString(), sha384.update('a').clone().finalize().toString()); - Y.Assert.areEqual(C.SHA384('ab').toString(), sha384.update('b').clone().finalize().toString()); - Y.Assert.areEqual(C.SHA384('abc').toString(), sha384.update('c').clone().finalize().toString()); - }, - - testInputIntegrity: function () { - var message = C.lib.WordArray.create([0x12345678]); - - var expected = message.toString(); - - C.SHA384(message); - - Y.Assert.areEqual(expected, message.toString()); - }, - - testHelper: function () { - Y.Assert.areEqual(C.algo.SHA384.create().finalize('').toString(), C.SHA384('').toString()); - }, - - testHmacHelper: function () { - Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA384, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA384('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()); - } - })); -}, '$Rev$'); diff --git a/test/sha512-profile.js b/test/sha512-profile.js deleted file mode 100644 index c26da6e..0000000 --- a/test/sha512-profile.js +++ /dev/null @@ -1,24 +0,0 @@ -YUI.add('algo-sha512-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'SHA512', - - profileSinglePartMessage: function () { - var singlePartMessage = ''; - for (var i = 0; i < 500; i++) { - singlePartMessage += '12345678901234567890123456789012345678901234567890'; - } - - C.algo.SHA512.create().finalize(singlePartMessage) + ''; - }, - - profileMultiPartMessage: function () { - var sha512 = C.algo.SHA512.create(); - for (var i = 0; i < 500; i++) { - sha512.update('12345678901234567890123456789012345678901234567890'); - } - sha512.finalize() + ''; - } - }); -}, '$Rev$'); diff --git a/test/sha512-test.js b/test/sha512-test.js deleted file mode 100644 index 6761202..0000000 --- a/test/sha512-test.js +++ /dev/null @@ -1,54 +0,0 @@ -YUI.add('algo-sha512-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'SHA512', - - testVector1: function () { - Y.Assert.areEqual('cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', C.SHA512('').toString()); - }, - - testVector2: function () { - Y.Assert.areEqual('07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6', C.SHA512('The quick brown fox jumps over the lazy dog').toString()); - }, - - testVector3: function () { - Y.Assert.areEqual('91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bbc6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed', C.SHA512('The quick brown fox jumps over the lazy dog.').toString()); - }, - - testUpdateAndLongMessage: function () { - var sha512 = C.algo.SHA512.create(); - for (var i = 0; i < 100; i++) { - sha512.update('12345678901234567890123456789012345678901234567890'); - } - - Y.Assert.areEqual('9bc64f37c54606dff234b6607e06683c7ba248558d0ec74a11525d9f59e0be566489cc9413c00ca5e9db705fc52ba71214bcf118f65072fe284af8f8cf9500af', sha512.finalize().toString()); - }, - - testClone: function () { - var sha512 = C.algo.SHA512.create(); - - Y.Assert.areEqual(C.SHA512('a').toString(), sha512.update('a').clone().finalize().toString()); - Y.Assert.areEqual(C.SHA512('ab').toString(), sha512.update('b').clone().finalize().toString()); - Y.Assert.areEqual(C.SHA512('abc').toString(), sha512.update('c').clone().finalize().toString()); - }, - - testInputIntegrity: function () { - var message = C.lib.WordArray.create([0x12345678]); - - var expected = message.toString(); - - C.SHA512(message); - - Y.Assert.areEqual(expected, message.toString()); - }, - - testHelper: function () { - Y.Assert.areEqual(C.algo.SHA512.create().finalize('').toString(), C.SHA512('').toString()); - }, - - testHmacHelper: function () { - Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA512, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA512('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()); - } - })); -}, '$Rev$'); diff --git a/test/test.html b/test/test.html deleted file mode 100644 index d469486..0000000 --- a/test/test.html +++ /dev/null @@ -1,135 +0,0 @@ - - - - - CryptoJS Test Suite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/tripledes-profile.js b/test/tripledes-profile.js deleted file mode 100644 index 9ae1828..0000000 --- a/test/tripledes-profile.js +++ /dev/null @@ -1,31 +0,0 @@ -YUI.add('algo-tripledes-profile', function (Y) { - var C = CryptoJS; - - Y.Profiler.add({ - name: 'TripleDES', - - setUp: function () { - this.data = { - key: C.enc.Hex.parse('0001020304050607'), - iv: C.enc.Hex.parse('08090a0b0c0d0e0f') - }; - }, - - profileSinglePartMessage: function () { - var singlePartMessage = ''; - for (var i = 0; i < 100; i++) { - singlePartMessage += '12345678901234567890123456789012345678901234567890'; - } - - C.algo.TripleDES.createEncryptor(this.data.key, { iv: this.data.iv }).finalize(singlePartMessage) + ''; - }, - - profileMultiPartMessage: function () { - var des = C.algo.TripleDES.createEncryptor(this.data.key, { iv: this.data.iv }); - for (var i = 0; i < 100; i++) { - des.process('12345678901234567890123456789012345678901234567890') + ''; - } - des.finalize() + ''; - } - }); -}, '$Rev$'); diff --git a/test/tripledes-test.js b/test/tripledes-test.js deleted file mode 100644 index b531bc8..0000000 --- a/test/tripledes-test.js +++ /dev/null @@ -1,88 +0,0 @@ -YUI.add('algo-tripledes-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'TripleDES', - - testEncrypt1: function () { - Y.Assert.areEqual('95a8d72813daa94d', C.TripleDES.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('800101010101010180010101010101018001010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testEncrypt2: function () { - Y.Assert.areEqual('869efd7f9f265a09', C.TripleDES.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('010101010101010201010101010101020101010101010102'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testEncrypt3: function () { - Y.Assert.areEqual('95f8a5e5dd31d900', C.TripleDES.encrypt(C.enc.Hex.parse('8000000000000000'), C.enc.Hex.parse('010101010101010101010101010101010101010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testEncrypt4: function () { - Y.Assert.areEqual('166b40b44aba4bd6', C.TripleDES.encrypt(C.enc.Hex.parse('0000000000000001'), C.enc.Hex.parse('010101010101010101010101010101010101010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - }, - - testDecrypt1: function () { - Y.Assert.areEqual('0000000000000000', C.TripleDES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('95a8d72813daa94d') }), C.enc.Hex.parse('800101010101010180010101010101018001010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testDecrypt2: function () { - Y.Assert.areEqual('0000000000000000', C.TripleDES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('869efd7f9f265a09') }), C.enc.Hex.parse('010101010101010201010101010101020101010101010102'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testDecrypt3: function () { - Y.Assert.areEqual('8000000000000000', C.TripleDES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('95f8a5e5dd31d900') }), C.enc.Hex.parse('010101010101010101010101010101010101010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testDecrypt4: function () { - Y.Assert.areEqual('0000000000000001', C.TripleDES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('166b40b44aba4bd6') }), C.enc.Hex.parse('010101010101010101010101010101010101010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - }, - - testMultiPart: function () { - var des = C.algo.TripleDES.createEncryptor(C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { mode: C.mode.ECB, padding: C.pad.NoPadding }); - var ciphertext1 = des.process(C.enc.Hex.parse('001122334455')); - var ciphertext2 = des.process(C.enc.Hex.parse('66778899aa')); - var ciphertext3 = des.process(C.enc.Hex.parse('bbccddeeff')); - var ciphertext4 = des.finalize(); - - Y.Assert.areEqual(C.TripleDES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString(), ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString()); - }, - - testInputIntegrity: function () { - var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff'); - var key = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'); - var iv = C.enc.Hex.parse('08090a0b0c0d0e0f'); - - var expectedMessage = message.toString(); - var expectedKey = key.toString(); - var expectedIv = iv.toString(); - - C.TripleDES.encrypt(message, key, { iv: iv }); - - Y.Assert.areEqual(expectedMessage, message.toString()); - Y.Assert.areEqual(expectedKey, key.toString()); - Y.Assert.areEqual(expectedIv, iv.toString()); - }, - - testHelper: function () { - // Save original random method - var random = C.lib.WordArray.random; - - // Replace random method with one that returns a predictable value - C.lib.WordArray.random = function (nBytes) { - var words = []; - for (var i = 0; i < nBytes; i += 4) { - words.push([0x11223344]); - } - - return C.lib.WordArray.create(words, nBytes); - }; - - // Test - Y.Assert.areEqual(C.algo.TripleDES.createEncryptor(C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).finalize('Hi There').toString(), C.TripleDES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString()); - Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.TripleDES, 'Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.TripleDES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.TripleDES, 'Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.TripleDES.encrypt('Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString()); - - // Restore random method - C.lib.WordArray.random = random; - } - })); -}, '$Rev$'); diff --git a/test/x64-word-test.js b/test/x64-word-test.js deleted file mode 100644 index 296cf69..0000000 --- a/test/x64-word-test.js +++ /dev/null @@ -1,99 +0,0 @@ -YUI.add('x64-word-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'X64Word', - - testInit: function () { - var word = C.x64.Word.create(0x00010203, 0x04050607); - - Y.Assert.areEqual(0x00010203, word.high, 'word.high'); - Y.Assert.areEqual(0x04050607, word.low, 'word.low'); - } - - // testNot: function () { - // var word = C.x64.Word.create(0x00010203, 0x04050607).not(); - - // Y.Assert.areEqual(~0x00010203, word.high, 'word.high'); - // Y.Assert.areEqual(~0x04050607, word.low, 'word.low'); - // }, - - // testAnd: function () { - // var word1 = C.x64.Word.create(0x00010203, 0x04050607); - // var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f); - // var anded = word1.and(word2); - - // Y.Assert.areEqual(0x00010203 & 0x18191a1b, anded.high, 'word.high'); - // Y.Assert.areEqual(0x04050607 & 0x1c1d1e1f, anded.low, 'word.low'); - // }, - - // testOr: function () { - // var word1 = C.x64.Word.create(0x00010203, 0x04050607); - // var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f); - // var ored = word1.or(word2); - - // Y.Assert.areEqual(0x00010203 | 0x18191a1b, ored.high, 'word.high'); - // Y.Assert.areEqual(0x04050607 | 0x1c1d1e1f, ored.low, 'word.low'); - // }, - - // testXor: function () { - // var word1 = C.x64.Word.create(0x00010203, 0x04050607); - // var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f); - // var xored = word1.xor(word2); - - // Y.Assert.areEqual(0x00010203 ^ 0x18191a1b, xored.high, 'word.high'); - // Y.Assert.areEqual(0x04050607 ^ 0x1c1d1e1f, xored.low, 'word.low'); - // }, - - // testShiftL25: function () { - // var word = C.x64.Word.create(0x00010203, 0x04050607).shiftL(25); - - // Y.Assert.areEqual(0x06080a0c, word.high, 'word.high'); - // Y.Assert.areEqual(0x0e000000, word.low, 'word.low'); - // }, - - // testShiftL32: function () { - // var word = C.x64.Word.create(0x00010203, 0x04050607).shiftL(32); - - // Y.Assert.areEqual(0x04050607, word.high, 'word.high'); - // Y.Assert.areEqual(0x00000000, word.low, 'word.low'); - // }, - - // testShiftR7: function () { - // var word = C.x64.Word.create(0x00010203, 0x04050607).shiftR(7); - - // Y.Assert.areEqual(0x00000204, word.high, 'word.high'); - // Y.Assert.areEqual(0x06080A0C, word.low, 'word.low'); - // }, - - // testShiftR32: function () { - // var word = C.x64.Word.create(0x00010203, 0x04050607).shiftR(32); - - // Y.Assert.areEqual(0x00000000, word.high, 'word.high'); - // Y.Assert.areEqual(0x00010203, word.low, 'word.low'); - // }, - - // testRotL: function () { - // var word = C.x64.Word.create(0x00010203, 0x04050607).rotL(25); - - // Y.Assert.areEqual(0x06080a0c, word.high, 'word.high'); - // Y.Assert.areEqual(0x0e000204, word.low, 'word.low'); - // }, - - // testRotR: function () { - // var word = C.x64.Word.create(0x00010203, 0x04050607).rotR(7); - - // Y.Assert.areEqual(0x0e000204, word.high, 'word.high'); - // Y.Assert.areEqual(0x06080a0c, word.low, 'word.low'); - // }, - - // testAdd: function () { - // var word1 = C.x64.Word.create(0x00010203, 0x04050607); - // var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f); - // var added = word1.add(word2); - - // Y.Assert.areEqual(0x181a1c1e, added.high, 'word.high'); - // Y.Assert.areEqual(0x20222426, added.low, 'word.low'); - // } - })); -}, '$Rev$'); diff --git a/test/x64-wordarray-test.js b/test/x64-wordarray-test.js deleted file mode 100644 index 638b5e8..0000000 --- a/test/x64-wordarray-test.js +++ /dev/null @@ -1,38 +0,0 @@ -YUI.add('x64-wordarray-test', function (Y) { - var C = CryptoJS; - - Y.Test.Runner.add(new Y.Test.Case({ - name: 'X64WordArray', - - testInit0: function () { - Y.Assert.areEqual('', C.x64.WordArray.create().toX32().toString()); - }, - - testInit1: function () { - var wordArray = C.x64.WordArray.create([ - C.x64.Word.create(0x00010203, 0x04050607), - C.x64.Word.create(0x18191a1b, 0x1c1d1e1f) - ]); - - Y.Assert.areEqual('000102030405060718191a1b1c1d1e1f', wordArray.toX32().toString()); - }, - - testInit2: function () { - var wordArray = C.x64.WordArray.create([ - C.x64.Word.create(0x00010203, 0x04050607), - C.x64.Word.create(0x18191a1b, 0x1c1d1e1f) - ], 10); - - Y.Assert.areEqual('00010203040506071819', wordArray.toX32().toString()); - }, - - testToX32: function () { - var wordArray = C.x64.WordArray.create([ - C.x64.Word.create(0x00010203, 0x04050607), - C.x64.Word.create(0x18191a1b, 0x1c1d1e1f) - ], 10); - - Y.Assert.areEqual('00010203040506071819', wordArray.toX32().toString()); - } - })); -}, '$Rev$'); From ba01f984ba0b4f4d29fbb854c595b96259db4768 Mon Sep 17 00:00:00 2001 From: Alanscut Date: Thu, 10 Oct 2019 10:54:31 +0800 Subject: [PATCH 2/5] build --- .gitignore | 1 - build/build.js | 81 ++++++++++++++++++++++++++++++++++++++++++ build/config.js | 9 +++++ build/rollup.config.js | 29 +++++++++++++++ 4 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 build/build.js create mode 100644 build/config.js create mode 100644 build/rollup.config.js diff --git a/.gitignore b/.gitignore index a9a3f50..53cd959 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ node_modules -/build /lib .svn coverage \ No newline at end of file diff --git a/build/build.js b/build/build.js new file mode 100644 index 0000000..74f8993 --- /dev/null +++ b/build/build.js @@ -0,0 +1,81 @@ +const chalk = require('chalk'); +const ora = require('ora'); +const path = require('path'); +const fs = require('fs'); +const rollup = require('rollup'); +const zlib = require('zlib'); +const terser = require('terser'); +const config = require('./config'); +const rollupConfig = require('./rollup.config'); + +const spinner = ora('building for crypto-js...\n'); +spinner.start() + +if (!fs.existsSync(config.build.assetsRootPath)) { + fs.mkdirSync(config.build.assetsRootPath); +} + +build(rollupConfig); + +function build(config) { + buildEntry(config).then(() => { + console.log(chalk.cyan('Build Complete.\n')); + spinner.stop(); + process.exit(0); + }).catch((err) => { + console.log(chalk.yellow('build failed with errors.\n')); + spinner.stop(); + process.exit(1); + }) +} + +function buildEntry(config) { + const output = config.output; + const file = output.file; + const isProd = /(min)\.js$/.test(file); + return rollup.rollup(config) + .then((bundle) => { + return bundle.generate(output); + }) + .then(({ + output: [{ + code + }] + }) => { + if (isProd) { + const options = { + toplevel: 'true', + } + const miniCode = terser.minify(code, options).code; + return writeFile(file, miniCode, isProd); + } else { + return writeFile(file, code); + } + }) +} + +function writeFile(dest, code, isMin) { + return new Promise((resolve, reject) => { + function exportInfo(info = '') { + console.log(`${chalk.cyan(path.relative(process.cwd(), dest))} ${getFileSize(code)}${info}`); + resolve(); + } + fs.writeFile(dest, code, (err) => { + if (err) throw err; + if (isMin) { + zlib.gzip(code, (err, zipped) => { + if (err) { + return reject(err); + }; + exportInfo(` (gzipped ${getFileSize(zipped)})`); + }) + } else { + exportInfo(); + } + }) + }) +} + +function getFileSize(code) { + return `${(code.length / 1024).toFixed(2)}kb`; +} \ No newline at end of file diff --git a/build/config.js b/build/config.js new file mode 100644 index 0000000..590eb48 --- /dev/null +++ b/build/config.js @@ -0,0 +1,9 @@ +const path = require('path'); + +module.exports = { + build: { + index: path.resolve(__dirname, '../lib/index.js'), + assetsRootPath: path.resolve(__dirname, '../lib'), + assetsPublicPath: './' + } +} \ No newline at end of file diff --git a/build/rollup.config.js b/build/rollup.config.js new file mode 100644 index 0000000..1fa6b21 --- /dev/null +++ b/build/rollup.config.js @@ -0,0 +1,29 @@ +const path = require('path'); +const pkg = require('../package.json'); +const resolve = require('rollup-plugin-node-resolve'); +// const commonjs = require('rollup-plugin-commonjs'); +// const babel = require('rollup-plugin-babel'); +// const json = require('rollup-plugin-json'); + +const banner = `/* + @license + crypto-js v${pkg.version} + (c) 2009-2013 Jeff Most + (c) 2013-${new Date().getFullYear()} ${pkg.author.name} + ${pkg.repository.url} + Released under the MIT License. +*/`; + +const uniqResolve = (p) => { + return path.resolve(__dirname, './', p); +} + +module.exports = { + input: uniqResolve('../src/index.js'), + output: { + file: uniqResolve('../lib/index.js'), + format: 'umd', + name: 'crypto', + banner + } +} \ No newline at end of file From a6b5280792442c5317e81fad7d9c0450ebe31968 Mon Sep 17 00:00:00 2001 From: Alanscut Date: Sat, 12 Oct 2019 11:50:51 +0800 Subject: [PATCH 3/5] add README --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d09a3d3 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# crypto-js [![Build Status](https://travis-ci.org/brix/crypto-js.svg?branch=develop)](https://travis-ci.org/brix/crypto-js) + +JavaScript library of crypto standards. + +## Node.js (Install) + +Requirements: + +- Node.js +- npm (Node.js package manager) + +```bash +npm install crypto-js +``` + +### Usage + +Including all libraries, for access to extra methods: + +```javascript +import CryptoJS from 'crypto-js'; +const rst = CryptoJS.MD5("Message").toString(); +``` + From fe6c3a9dbf05254c547149234e94efd3fce00a16 Mon Sep 17 00:00:00 2001 From: Alanscut Date: Fri, 18 Oct 2019 10:59:56 +0800 Subject: [PATCH 4/5] rewrite Base.create() --- package-lock.json | 49 ---------------------------- src/cipher-core.js | 64 ++++++++++++++++++------------------- src/core.js | 69 ++++++++++++++++------------------------ src/enc-base64.js | 2 +- src/evpkdf.js | 18 +++++------ src/md5.js | 6 ++-- src/x64-core.js | 22 ++++++------- test/md5.profile.test.js | 4 +-- test/md5.test.js | 12 +++---- 9 files changed, 91 insertions(+), 155 deletions(-) diff --git a/package-lock.json b/package-lock.json index c2710b1..2d61b84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1110,15 +1110,6 @@ "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", "dev": true }, - "@types/resolve": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", - "integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/stack-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz", @@ -1570,12 +1561,6 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, - "builtin-modules": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", - "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", - "dev": true - }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -2415,12 +2400,6 @@ "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, - "estree-walker": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", - "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", - "dev": true - }, "esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -3935,12 +3914,6 @@ "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", "dev": true }, - "is-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", - "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", - "dev": true - }, "is-number": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", @@ -6306,28 +6279,6 @@ "acorn": "^7.1.0" } }, - "rollup-plugin-node-resolve": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz", - "integrity": "sha512-jUlyaDXts7TW2CqQ4GaO5VJ4PwwaV8VUGA7+km3n6k6xtOEacf61u0VXwN80phY/evMcaS+9eIeJ9MOyDxt5Zw==", - "dev": true, - "requires": { - "@types/resolve": "0.0.8", - "builtin-modules": "^3.1.0", - "is-module": "^1.0.0", - "resolve": "^1.11.1", - "rollup-pluginutils": "^2.8.1" - } - }, - "rollup-pluginutils": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", - "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", - "dev": true, - "requires": { - "estree-walker": "^0.6.1" - } - }, "rsvp": { "version": "4.8.5", "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", diff --git a/src/cipher-core.js b/src/cipher-core.js index 85e910a..6b74f0e 100644 --- a/src/cipher-core.js +++ b/src/cipher-core.js @@ -30,7 +30,7 @@ export class Cipher extends BufferedBlockAlgorithm { * * @example * - * const cipher = CryptoJS.algo.AES.create( + * const cipher = new Cipher( * CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray } * ); */ @@ -70,7 +70,7 @@ export class Cipher extends BufferedBlockAlgorithm { * const cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); */ static createEncryptor(key, cfg) { - return this.create(this._ENC_XFORM_MODE, key, cfg); + return new this(this._ENC_XFORM_MODE, key, cfg); } /** @@ -88,7 +88,7 @@ export class Cipher extends BufferedBlockAlgorithm { * const cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); */ static createDecryptor(key, cfg) { - return this.create(this._DEC_XFORM_MODE, key, cfg); + return new this(this._DEC_XFORM_MODE, key, cfg); } /** @@ -221,7 +221,7 @@ export class BlockCipherMode extends Base { * * @example * - * const mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); + * const mode = new BlockCipherMode(cipher, iv.words); */ constructor(cipher, iv) { super(); @@ -243,7 +243,7 @@ export class BlockCipherMode extends Base { * const mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); */ static createEncryptor(cipher, iv) { - return this.Encryptor.create(cipher, iv); + return new this.Encryptor(cipher, iv); } /** @@ -259,7 +259,7 @@ export class BlockCipherMode extends Base { * const mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); */ static createDecryptor(cipher, iv) { - return this.Decryptor.create(cipher, iv); + return new this.Decryptor(cipher, iv); } } @@ -390,7 +390,7 @@ export const Pkcs7 = { for (let i = 0; i < nPaddingBytes; i += 4) { paddingWords.push(paddingWord); } - const padding = WordArray.create(paddingWords, nPaddingBytes); + const padding =new WordArray(paddingWords, nPaddingBytes); // Add padding data.concat(padding); @@ -524,7 +524,7 @@ export class CipherParams extends Base { * * @example * - * var cipherParams = CryptoJS.lib.CipherParams.create({ + * let cipherParams =new CipherParams({ * ciphertext: ciphertextWordArray, * key: keyWordArray, * iv: ivWordArray, @@ -553,9 +553,9 @@ export class CipherParams extends Base { * * @example * - * var string = cipherParams + ''; - * var string = cipherParams.toString(); - * var string = cipherParams.toString(CryptoJS.format.OpenSSL); + * let string = cipherParams + ''; + * let string = cipherParams.toString(); + * let string = cipherParams.toString(CryptoJS.format.OpenSSL); */ toString(formatter) { return (formatter || this.formatter).stringify(this); @@ -577,7 +577,7 @@ export const OpenSSLFormatter = { * * @example * - * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); + * let openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); */ stringify(cipherParams) { let wordArray; @@ -590,7 +590,7 @@ export const OpenSSLFormatter = { // Format if (salt) { - wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); + wordArray =new WordArray([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); } else { wordArray = ciphertext; } @@ -609,7 +609,7 @@ export const OpenSSLFormatter = { * * @example * - * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); + * let cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); */ parse(openSSLStr) { let salt; @@ -623,14 +623,14 @@ export const OpenSSLFormatter = { // Test for salt if (ciphertextWords[0] === 0x53616c74 && ciphertextWords[1] === 0x65645f5f) { // Extract salt - salt = WordArray.create(ciphertextWords.slice(2, 4)); + salt =new WordArray(ciphertextWords.slice(2, 4)); // Remove salt from ciphertext ciphertextWords.splice(0, 4); ciphertext.sigBytes -= 16; } - return CipherParams.create({ + return new CipherParams({ ciphertext, salt }); @@ -655,11 +655,11 @@ export class SerializableCipher extends Base { * * @example * - * var ciphertextParams = CryptoJS.lib.SerializableCipher + * let ciphertextParams = CryptoJS.lib.SerializableCipher * .encrypt(CryptoJS.algo.AES, message, key); - * var ciphertextParams = CryptoJS.lib.SerializableCipher + * let ciphertextParams = CryptoJS.lib.SerializableCipher * .encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); - * var ciphertextParams = CryptoJS.lib.SerializableCipher + * let ciphertextParams = CryptoJS.lib.SerializableCipher * .encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); */ static encrypt(cipher, message, key, cfg) { @@ -674,7 +674,7 @@ export class SerializableCipher extends Base { const cipherCfg = encryptor.cfg; // Create and return serializable cipher params - return CipherParams.create({ + return new CipherParams({ ciphertext, key, iv: cipherCfg.iv, @@ -700,10 +700,10 @@ export class SerializableCipher extends Base { * * @example * - * var plaintext = CryptoJS.lib.SerializableCipher + * let plaintext = CryptoJS.lib.SerializableCipher * .decrypt(CryptoJS.algo.AES, formattedCiphertext, key, * { iv: iv, format: CryptoJS.format.OpenSSL }); - * var plaintext = CryptoJS.lib.SerializableCipher + * let plaintext = CryptoJS.lib.SerializableCipher * .decrypt(CryptoJS.algo.AES, ciphertextParams, key, * { iv: iv, format: CryptoJS.format.OpenSSL }); */ @@ -735,7 +735,7 @@ export class SerializableCipher extends Base { * * @example * - * var ciphertextParams = CryptoJS.lib.SerializableCipher + * let ciphertextParams = CryptoJS.lib.SerializableCipher * ._parse(ciphertextStringOrParams, format); */ static _parse(ciphertext, format) { @@ -778,8 +778,8 @@ export const OpenSSLKdf = { * * @example * - * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); - * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); + * let derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); + * let derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); */ execute(password, keySize, ivSize, salt) { let _salt = salt; @@ -790,16 +790,16 @@ export const OpenSSLKdf = { } // Derive key and IV - const key = EvpKDFAlgo.create({ + const key =new EvpKDFAlgo({ keySize: keySize + ivSize }).compute(password, _salt); // Separate key and IV - const iv = WordArray.create(key.words.slice(keySize), ivSize * 4); + const iv =new WordArray(key.words.slice(keySize), ivSize * 4); key.sigBytes = keySize * 4; // Return params - return CipherParams.create({ + return new CipherParams({ key, iv, salt: _salt @@ -826,9 +826,9 @@ export class PasswordBasedCipher extends SerializableCipher { * * @example * - * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher + * let ciphertextParams = CryptoJS.lib.PasswordBasedCipher * .encrypt(CryptoJS.algo.AES, message, 'password'); - * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher + * let ciphertextParams = CryptoJS.lib.PasswordBasedCipher * .encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); */ static encrypt(cipher, message, password, cfg) { @@ -865,10 +865,10 @@ export class PasswordBasedCipher extends SerializableCipher { * * @example * - * var plaintext = CryptoJS.lib.PasswordBasedCipher + * let plaintext = CryptoJS.lib.PasswordBasedCipher * .decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', * { format: CryptoJS.format.OpenSSL }); - * var plaintext = CryptoJS.lib.PasswordBasedCipher + * let plaintext = CryptoJS.lib.PasswordBasedCipher * .decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', * { format: CryptoJS.format.OpenSSL }); */ diff --git a/src/core.js b/src/core.js index f7c98e9..aa35d00 100644 --- a/src/core.js +++ b/src/core.js @@ -4,21 +4,6 @@ * Base class for inheritance. */ export class Base { - /** - * Extends this object and runs the init method. - * Arguments to create() will be passed to init(). - * - * @return {Object} The new object. - * - * @static - * - * @example - * - * var instance = MyType.create(); - */ - static create(...args) { - return new this(...args); - } /** * Copies properties into this object. @@ -42,7 +27,7 @@ export class Base { * * @example * - * var clone = instance.clone(); + * let clone = instance.clone(); */ clone() { const clone = new this.constructor(); @@ -66,9 +51,9 @@ export class WordArray extends Base { * * @example * - * var wordArray = CryptoJS.lib.WordArray.create(); - * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); - * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); + * let wordArray = new WordArray(); + * let wordArray = new WordArray([0x00010203, 0x04050607]); + * let wordArray = new WordArray([0x00010203, 0x04050607], 6); */ constructor(words = [], sigBytes = words.length * 4) { super(); @@ -125,7 +110,7 @@ export class WordArray extends Base { * * @example * - * var wordArray = CryptoJS.lib.WordArray.random(16); + * let wordArray = CryptoJS.lib.WordArray.random(16); */ static random(nBytes) { const words = []; @@ -164,9 +149,9 @@ export class WordArray extends Base { * * @example * - * var string = wordArray + ''; - * var string = wordArray.toString(); - * var string = wordArray.toString(CryptoJS.enc.Utf8); + * let string = wordArray + ''; + * let string = wordArray.toString(); + * let string = wordArray.toString(CryptoJS.enc.Utf8); */ toString(encoder = Hex) { return encoder.stringify(this); @@ -238,7 +223,7 @@ export class WordArray extends Base { * * @example * - * var clone = wordArray.clone(); + * let clone = wordArray.clone(); */ clone() { const clone = super.clone.call(this); @@ -263,7 +248,7 @@ export const Hex = { * * @example * - * var hexString = CryptoJS.enc.Hex.stringify(wordArray); + * let hexString = CryptoJS.enc.Hex.stringify(wordArray); */ stringify(wordArray) { // Shortcuts @@ -294,7 +279,7 @@ export const Hex = { * * @example * - * var wordArray = CryptoJS.enc.Hex.parse(hexString); + * let wordArray = CryptoJS.enc.Hex.parse(hexString); */ parse(hexStr) { // Shortcut @@ -325,7 +310,7 @@ export const Latin1 = { * * @example * - * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); + * let latin1String = CryptoJS.enc.Latin1.stringify(wordArray); */ stringify(wordArray) { // Shortcuts @@ -355,7 +340,7 @@ export const Latin1 = { * * @example * - * var wordArray = CryptoJS.enc.Latin1.parse(latin1String); + * let wordArray = CryptoJS.enc.Latin1.parse(latin1String); */ parse(latin1Str) { // Shortcut @@ -386,7 +371,7 @@ export const Utf8 = { * * @example * - * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); + * let utf8String = CryptoJS.enc.Utf8.stringify(wordArray); */ stringify(wordArray) { try { @@ -407,7 +392,7 @@ export const Utf8 = { * * @example * - * var wordArray = CryptoJS.enc.Utf8.parse(utf8String); + * let wordArray = CryptoJS.enc.Utf8.parse(utf8String); */ parse(utf8Str) { return Latin1.parse(unescape(encodeURIComponent(utf8Str))); @@ -478,8 +463,8 @@ export class BufferedBlockAlgorithm extends Base { * * @example * - * var processedData = bufferedBlockAlgorithm._process(); - * var processedData = bufferedBlockAlgorithm._process(!!'flush'); + * let processedData = bufferedBlockAlgorithm._process(); + * let processedData = bufferedBlockAlgorithm._process(!!'flush'); */ _process(doFlush) { let processedWords; @@ -533,7 +518,7 @@ export class BufferedBlockAlgorithm extends Base { * * @example * - * var clone = bufferedBlockAlgorithm.clone(); + * let clone = bufferedBlockAlgorithm.clone(); */ clone() { const clone = super.clone.call(this); @@ -576,7 +561,7 @@ export class Hasher extends BufferedBlockAlgorithm { * * @example * - * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); + * let SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); */ static _createHelper(SubHasher) { return (message, cfg) => new SubHasher(cfg).finalize(message); @@ -593,7 +578,7 @@ export class Hasher extends BufferedBlockAlgorithm { * * @example * - * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); + * let HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); */ static _createHmacHelper(SubHasher) { return (message, key) => new HMAC(SubHasher, key).finalize(message); @@ -647,9 +632,9 @@ export class Hasher extends BufferedBlockAlgorithm { * * @example * - * var hash = hasher.finalize(); - * var hash = hasher.finalize('message'); - * var hash = hasher.finalize(wordArray); + * let hash = hasher.finalize(); + * let hash = hasher.finalize('message'); + * let hash = hasher.finalize(wordArray); */ finalize(messageUpdate) { // Final message update @@ -676,7 +661,7 @@ export class HMAC extends Base { * * @example * - * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); + * let hmacHasher =new HMAC(CryptoJS.algo.SHA256, key); */ constructor(SubHasher, key) { super(); @@ -769,9 +754,9 @@ export class HMAC extends Base { * * @example * - * var hmac = hmacHasher.finalize(); - * var hmac = hmacHasher.finalize('message'); - * var hmac = hmacHasher.finalize(wordArray); + * let hmac = hmacHasher.finalize(); + * let hmac = hmacHasher.finalize('message'); + * let hmac = hmacHasher.finalize(wordArray); */ finalize(messageUpdate) { // Shortcut diff --git a/src/enc-base64.js b/src/enc-base64.js index 822b7a2..da41ad3 100644 --- a/src/enc-base64.js +++ b/src/enc-base64.js @@ -14,7 +14,7 @@ const parseLoop = (base64Str, base64StrLength, reverseMap) => { nBytes += 1; } } - return WordArray.create(words, nBytes); + return new WordArray(words, nBytes); }; /** diff --git a/src/evpkdf.js b/src/evpkdf.js index 5f974b2..72304fe 100644 --- a/src/evpkdf.js +++ b/src/evpkdf.js @@ -16,9 +16,9 @@ export class EvpKDFAlgo extends Base { * * @example * - * const kdf = CryptoJS.algo.EvpKDF.create(); - * const kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); - * const kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); + * const kdf = new EvpKDF(); + * const kdf = new EvpKDF({ keySize: 8 }); + * const kdf = new EvpKDF({ keySize: 8, iterations: 1000 }); */ constructor(cfg) { super(); @@ -60,10 +60,10 @@ export class EvpKDFAlgo extends Base { const { cfg } = this; // Init hasher - const hasher = cfg.hasher.create(); + const hasher =new cfg.hasher(); // Initial values - const derivedKey = WordArray.create(); + const derivedKey =new WordArray(); // Shortcuts const derivedKeyWords = derivedKey.words; @@ -104,8 +104,8 @@ export class EvpKDFAlgo extends Base { * * @example * - * var key = CryptoJS.EvpKDF(password, salt); - * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 }); - * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 }); + * let key = CryptoJS.EvpKDF(password, salt); + * let key = CryptoJS.EvpKDF(password, salt, { keySize: 8 }); + * let key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 }); */ -export const EvpKDF = (password, salt, cfg) => EvpKDFAlgo.create(cfg).compute(password, salt); +export const EvpKDF = (password, salt, cfg) => new EvpKDFAlgo(cfg).compute(password, salt); diff --git a/src/md5.js b/src/md5.js index 3e7083f..ba013a1 100644 --- a/src/md5.js +++ b/src/md5.js @@ -225,8 +225,8 @@ export class MD5Algo extends Hasher { * * @example * - * var hash = CryptoJS.MD5('message'); - * var hash = CryptoJS.MD5(wordArray); + * let hash = CryptoJS.MD5('message'); + * let hash = CryptoJS.MD5(wordArray); */ export const MD5 = Hasher._createHelper(MD5Algo); @@ -242,6 +242,6 @@ export const MD5 = Hasher._createHelper(MD5Algo); * * @example * - * var hmac = CryptoJS.HmacMD5(message, key); + * let hmac = CryptoJS.HmacMD5(message, key); */ export const HmacMD5 = Hasher._createHmacHelper(MD5Algo); diff --git a/src/x64-core.js b/src/x64-core.js index 1592ba2..8fbcf22 100644 --- a/src/x64-core.js +++ b/src/x64-core.js @@ -17,7 +17,7 @@ export class X64Word extends Base { * * @example * - * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); + * let x64Word = new X64Word(0x00010203, 0x04050607); */ constructor(high, low) { super(); @@ -42,16 +42,16 @@ export class X64WordArray extends Base { * * @example * - * var wordArray = CryptoJS.x64.WordArray.create(); + * let wordArray =new X64WordArray(); * - * var wordArray = CryptoJS.x64.WordArray.create([ - * CryptoJS.x64.Word.create(0x00010203, 0x04050607), - * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * let wordArray =new X64WordArray([ + * new x64Word(0x00010203, 0x04050607), + * new x64Word(0x18191a1b, 0x1c1d1e1f) * ]); * - * var wordArray = CryptoJS.x64.WordArray.create([ - * CryptoJS.x64.Word.create(0x00010203, 0x04050607), - * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * let wordArray =new X64WordArray([ + * new x64Word(0x00010203, 0x04050607), + * new x64Word(0x18191a1b, 0x1c1d1e1f) * ], 10); */ constructor(words = [], sigBytes = words.length * 8) { @@ -68,7 +68,7 @@ export class X64WordArray extends Base { * * @example * - * var x32WordArray = x64WordArray.toX32(); + * let x32WordArray = x64WordArray.toX32(); */ toX32() { // Shortcuts @@ -83,7 +83,7 @@ export class X64WordArray extends Base { x32Words.push(x64Word.low); } - return X32WordArray.create(x32Words, this.sigBytes); + return new X32WordArray(x32Words, this.sigBytes); } /** @@ -93,7 +93,7 @@ export class X64WordArray extends Base { * * @example * - * var clone = x64WordArray.clone(); + * let clone = x64WordArray.clone(); */ clone() { const clone = super.clone.call(this); diff --git a/test/md5.profile.test.js b/test/md5.profile.test.js index 02345fa..a198fbf 100644 --- a/test/md5.profile.test.js +++ b/test/md5.profile.test.js @@ -12,12 +12,12 @@ describe('algo-md5-profile', () => { singlePartMessage += '12345678901234567890123456789012345678901234567890'; i++; } - expect(C.algo.MD5.create().finalize(singlePartMessage)).toMatchObject(WORD_ARRAY_TEST); + expect(new C.algo.MD5().finalize(singlePartMessage)).toMatchObject(WORD_ARRAY_TEST); }); test('profileMultiPartMessage', () => { let i = 0; - const md5 = C.algo.MD5.create(); + const md5 =new C.algo.MD5(); while (i < 500) { md5.update('12345678901234567890123456789012345678901234567890'); i++; diff --git a/test/md5.test.js b/test/md5.test.js index dbe1371..fbb219b 100644 --- a/test/md5.test.js +++ b/test/md5.test.js @@ -1,4 +1,4 @@ -import C from '../lib/index.js'; +import C from '../src/index.js'; const VECTOR_TEST_CONFIG = [ [1, '', 'd41d8cd98f00b204e9800998ecf8427e'], @@ -27,7 +27,7 @@ describe('algo-md5-test', () => { ); describe('testClone', () => { - const md5 = C.algo.MD5.create(); + const md5 =new C.algo.MD5(); test.each(CLONE_TEST_CONFIG)( 'return %s, %s', (a, expected) => { @@ -38,7 +38,7 @@ describe('algo-md5-test', () => { test('testUpdateAndLongMessage', () => { let i = 0; - const md5 = C.algo.MD5.create(); + const md5 =new C.algo.MD5(); while (i < 100) { md5.update('12345678901234567890123456789012345678901234567890'); i++; @@ -47,17 +47,17 @@ describe('algo-md5-test', () => { }); test('testInputIntegrity', () => { - const message = C.lib.WordArray.create([0x12345678]); + const message =new C.lib.WordArray([0x12345678]); const expected = message.toString(); C.MD5(message); expect(message.toString()).toBe(expected); }); test('testHelper', () => { - expect(C.MD5('').toString()).toBe(C.algo.MD5.create().finalize('').toString()); + expect(C.MD5('').toString()).toBe(new C.algo.MD5().finalize('').toString()); }); test('testHmacHelper', () => { - expect(C.HmacMD5('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()).toBe(C.algo.HMAC.create(C.algo.MD5, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString()); + expect(C.HmacMD5('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()).toBe(new C.algo.HMAC(C.algo.MD5, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString()); }); }); \ No newline at end of file From d9770e4f7ac1b9062a994355f82f69c5d4d83182 Mon Sep 17 00:00:00 2001 From: wangpeng Date: Tue, 22 Oct 2019 11:13:30 +0800 Subject: [PATCH 5/5] rewrite all the other files and update unit test code --- build/rollup.config.js | 7 +- src/{ => algo/hash}/md5.js | 20 +- src/algo/hash/ripemd160.js | 243 +++++++++ src/algo/hash/sha1.js | 129 +++++ src/algo/hash/sha224.js | 60 +++ src/algo/hash/sha256.js | 171 ++++++ src/algo/hash/sha3.js | 295 ++++++++++ src/algo/hash/sha384.js | 63 +++ src/algo/hash/sha512.js | 369 +++++++++++++ src/algo/hmac/hmac.js | 129 +++++ src/algo/pbkdf2/pbkdf2.js | 123 +++++ src/core.js | 772 --------------------------- src/{ => core}/cipher-core.js | 95 +--- src/core/core.js | 373 +++++++++++++ src/core/hasher.js | 128 +++++ src/{ => core}/x64-core.js | 12 +- src/{ => encoding}/enc-base64.js | 17 +- src/encoding/enc-hax.js | 65 +++ src/encoding/enc-latin1.js | 64 +++ src/encoding/enc-utf16.js | 122 +++++ src/encoding/enc-utf8.js | 47 ++ src/encryption/aes.js | 283 ++++++++++ src/{ => encryption}/evpkdf.js | 12 +- src/encryption/rabbit-legacy.js | 175 ++++++ src/encryption/rabbit.js | 177 ++++++ src/encryption/rc4.js | 124 +++++ src/encryption/tripledes.js | 759 ++++++++++++++++++++++++++ src/format/format-hex.js | 43 ++ src/hmac.js | 3 - src/index.js | 129 ++++- src/mode/mode-cfb.js | 63 +++ src/mode/mode-ctr-gladman.js | 87 +++ src/mode/mode-ctr.js | 40 ++ src/mode/mode-ecb.js | 19 + src/mode/mode-ofb.js | 36 ++ src/pad/pad-ansix923.js | 33 ++ src/pad/pad-iso10126.js | 30 ++ src/pad/pad-iso97971.js | 29 + src/pad/pad-nopadding.js | 10 + src/pad/pad-pkcs7.js | 63 +++ src/pad/pad-zeropadding.js | 30 ++ src/utils.js | 61 +++ test/aes.profile.test.js | 30 ++ test/aes.test.js | 101 ++++ test/algo.pbkdf2.profile.test.js | 10 + test/algo.pbkdf2.test.js | 119 +++++ test/algo.rabbit.legacy.test.js | 115 ++++ test/algo.rabbit.profile.test.js | 26 + test/algo.rabbit.test.js | 120 +++++ test/algo.rc4.profile.test.js | 24 + test/algo.rc4.test.js | 89 +++ test/algo.ripemd160.test.js | 16 + test/algo.sha1.profile.test.js | 20 + test/algo.sha1.test.js | 56 ++ test/algo.sha224.test.js | 16 + test/algo.sha256.profile.test.js | 19 + test/algo.sha256.test.js | 50 ++ test/algo.sha3.profile.test.js | 20 + test/algo.sha3.test.js | 96 ++++ test/algo.sha384.test.js | 53 ++ test/algo.sha512.profile.test.js | 19 + test/algo.sha512.test.js | 53 ++ test/algo.tripledes.profile.test.js | 30 ++ test/algo.tripledes.test.js | 111 ++++ test/cipher.test.js | 516 ++++++++++++++++++ test/des.profile.test.js | 29 + test/des.test.js | 114 ++++ test/enc.base64.test.js | 45 ++ test/enc.hex.test.js | 11 + test/enc.latain1.test.js | 11 + test/enc.utf16.test.js | 41 ++ test/enc.utf8.test.js | 31 ++ test/evpkdf.profile.test.js | 7 + test/evpkdf.test.js | 27 + test/format.openssl.test.js | 40 ++ test/hmac.md5.profile.test.js | 24 + test/hmac.md5.test.js | 53 ++ test/hmac.sha224.test.js | 54 ++ test/hmac.sha256.test.js | 53 ++ test/hmac.sha384.test.js | 48 ++ test/hmac.sha512.test.js | 48 ++ test/kdf.openssl.test.js | 10 + test/lib.base.test.js | 57 ++ test/lib.cipherparams.test.js | 52 ++ test/lib.passwordbasedcipher.test.js | 21 + test/lib.serializablecipher.test.js | 51 ++ test/lib.typedarrays.test.js | 50 ++ test/lib.wordarray.test.js | 76 +++ test/md5.profile.test.js | 2 +- test/md5.test.js | 16 +- test/mode.cbc.test.js | 53 ++ test/mode.cfb.test.js | 56 ++ test/mode.ctr.test.js | 59 ++ test/mode.ecb.test.js | 40 ++ test/mode.ofb.test.js | 55 ++ test/pad.ansix923.test.js | 21 + test/pad.iso10126.test.js | 42 ++ test/pad.iso97971.test.js | 27 + test/pad.pkcs7.test.js | 21 + test/pad.zeropadding.test.js | 21 + test/x64.word.test.js | 9 + test/x64.wordarray.test.js | 24 + 102 files changed, 7705 insertions(+), 913 deletions(-) rename src/{ => algo/hash}/md5.js (94%) create mode 100644 src/algo/hash/ripemd160.js create mode 100644 src/algo/hash/sha1.js create mode 100644 src/algo/hash/sha224.js create mode 100644 src/algo/hash/sha256.js create mode 100644 src/algo/hash/sha3.js create mode 100644 src/algo/hash/sha384.js create mode 100644 src/algo/hash/sha512.js create mode 100644 src/algo/hmac/hmac.js create mode 100644 src/algo/pbkdf2/pbkdf2.js delete mode 100644 src/core.js rename src/{ => core}/cipher-core.js (91%) create mode 100644 src/core/core.js create mode 100644 src/core/hasher.js rename src/{ => core}/x64-core.js (90%) rename src/{ => encoding}/enc-base64.js (90%) create mode 100644 src/encoding/enc-hax.js create mode 100644 src/encoding/enc-latin1.js create mode 100644 src/encoding/enc-utf16.js create mode 100644 src/encoding/enc-utf8.js create mode 100644 src/encryption/aes.js rename src/{ => encryption}/evpkdf.js (92%) create mode 100644 src/encryption/rabbit-legacy.js create mode 100644 src/encryption/rabbit.js create mode 100644 src/encryption/rc4.js create mode 100644 src/encryption/tripledes.js create mode 100644 src/format/format-hex.js delete mode 100644 src/hmac.js create mode 100644 src/mode/mode-cfb.js create mode 100644 src/mode/mode-ctr-gladman.js create mode 100644 src/mode/mode-ctr.js create mode 100644 src/mode/mode-ecb.js create mode 100644 src/mode/mode-ofb.js create mode 100644 src/pad/pad-ansix923.js create mode 100644 src/pad/pad-iso10126.js create mode 100644 src/pad/pad-iso97971.js create mode 100644 src/pad/pad-nopadding.js create mode 100644 src/pad/pad-pkcs7.js create mode 100644 src/pad/pad-zeropadding.js create mode 100644 src/utils.js create mode 100644 test/aes.profile.test.js create mode 100644 test/aes.test.js create mode 100644 test/algo.pbkdf2.profile.test.js create mode 100644 test/algo.pbkdf2.test.js create mode 100644 test/algo.rabbit.legacy.test.js create mode 100644 test/algo.rabbit.profile.test.js create mode 100644 test/algo.rabbit.test.js create mode 100644 test/algo.rc4.profile.test.js create mode 100644 test/algo.rc4.test.js create mode 100644 test/algo.ripemd160.test.js create mode 100644 test/algo.sha1.profile.test.js create mode 100644 test/algo.sha1.test.js create mode 100644 test/algo.sha224.test.js create mode 100644 test/algo.sha256.profile.test.js create mode 100644 test/algo.sha256.test.js create mode 100644 test/algo.sha3.profile.test.js create mode 100644 test/algo.sha3.test.js create mode 100644 test/algo.sha384.test.js create mode 100644 test/algo.sha512.profile.test.js create mode 100644 test/algo.sha512.test.js create mode 100644 test/algo.tripledes.profile.test.js create mode 100644 test/algo.tripledes.test.js create mode 100644 test/cipher.test.js create mode 100644 test/des.profile.test.js create mode 100644 test/des.test.js create mode 100644 test/enc.base64.test.js create mode 100644 test/enc.hex.test.js create mode 100644 test/enc.latain1.test.js create mode 100644 test/enc.utf16.test.js create mode 100644 test/enc.utf8.test.js create mode 100644 test/evpkdf.profile.test.js create mode 100644 test/evpkdf.test.js create mode 100644 test/format.openssl.test.js create mode 100644 test/hmac.md5.profile.test.js create mode 100644 test/hmac.md5.test.js create mode 100644 test/hmac.sha224.test.js create mode 100644 test/hmac.sha256.test.js create mode 100644 test/hmac.sha384.test.js create mode 100644 test/hmac.sha512.test.js create mode 100644 test/kdf.openssl.test.js create mode 100644 test/lib.base.test.js create mode 100644 test/lib.cipherparams.test.js create mode 100644 test/lib.passwordbasedcipher.test.js create mode 100644 test/lib.serializablecipher.test.js create mode 100644 test/lib.typedarrays.test.js create mode 100644 test/lib.wordarray.test.js create mode 100644 test/mode.cbc.test.js create mode 100644 test/mode.cfb.test.js create mode 100644 test/mode.ctr.test.js create mode 100644 test/mode.ecb.test.js create mode 100644 test/mode.ofb.test.js create mode 100644 test/pad.ansix923.test.js create mode 100644 test/pad.iso10126.test.js create mode 100644 test/pad.iso97971.test.js create mode 100644 test/pad.pkcs7.test.js create mode 100644 test/pad.zeropadding.test.js create mode 100644 test/x64.word.test.js create mode 100644 test/x64.wordarray.test.js diff --git a/build/rollup.config.js b/build/rollup.config.js index 1fa6b21..4387422 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -1,9 +1,6 @@ const path = require('path'); const pkg = require('../package.json'); -const resolve = require('rollup-plugin-node-resolve'); -// const commonjs = require('rollup-plugin-commonjs'); -// const babel = require('rollup-plugin-babel'); -// const json = require('rollup-plugin-json'); + const banner = `/* @license @@ -23,7 +20,7 @@ module.exports = { output: { file: uniqResolve('../lib/index.js'), format: 'umd', - name: 'crypto', + name: 'CryptoJS', banner } } \ No newline at end of file diff --git a/src/md5.js b/src/algo/hash/md5.js similarity index 94% rename from src/md5.js rename to src/algo/hash/md5.js index ba013a1..f5c9480 100644 --- a/src/md5.js +++ b/src/algo/hash/md5.js @@ -1,13 +1,13 @@ import { - WordArray, - Hasher -} from './core.js'; + WordArray +} from '../../core/core.js'; +import { Hasher } from '../../core/hasher'; // Constants table const T = []; // Compute constants -for (let i = 0; i < 64; i += 1) { +for (let i = 0; i < 64; i++) { T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0; } @@ -48,14 +48,14 @@ export class MD5Algo extends Hasher { const _M = M; // Swap endian - for (let i = 0; i < 16; i += 1) { + for (let i = 0; i < 16; i++) { // Shortcuts const offset_i = offset + i; const M_offset_i = M[offset_i]; _M[offset_i] = ( (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) - | (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) + | (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) ); } @@ -79,7 +79,7 @@ export class MD5Algo extends Hasher { const M_offset_14 = _M[offset + 14]; const M_offset_15 = _M[offset + 15]; - // Working varialbes + // Working variables let a = H[0]; let b = H[1]; let c = H[2]; @@ -177,11 +177,11 @@ export class MD5Algo extends Hasher { const nBitsTotalL = nBitsTotal; dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = ( (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) - | (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00) + | (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00) ); dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) - | (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00) + | (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00) ); data.sigBytes = (dataWords.length + 1) * 4; @@ -194,7 +194,7 @@ export class MD5Algo extends Hasher { const H = hash.words; // Swap endian - for (let i = 0; i < 4; i += 1) { + for (let i = 0; i < 4; i++) { // Shortcut const H_i = H[i]; diff --git a/src/algo/hash/ripemd160.js b/src/algo/hash/ripemd160.js new file mode 100644 index 0000000..4129905 --- /dev/null +++ b/src/algo/hash/ripemd160.js @@ -0,0 +1,243 @@ +/** @preserve +(c) 2012 by Cédric Mesnil. 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. + +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. +*/ + +import { + WordArray +} from '../../core/core.js'; + +import { Hasher } from '../../core/hasher'; + +// Constants table +const _zl = new WordArray([ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]); +const _zr = new WordArray([ + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]); +const _sl = new WordArray([ + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]); +const _sr = new WordArray([ + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]); + +const _hl = new WordArray([0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]); +const _hr = new WordArray([0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]); + +const f1 = (x, y, z) => (x) ^ (y) ^ (z); + +const f2 = (x, y, z) => ((x) & (y)) | ((~x) & (z)); + +const f3 = (x, y, z) => ((x) | (~(y))) ^ (z); + +const f4 = (x, y, z) => ((x) & (z)) | ((y) & (~(z))); + +const f5 = (x, y, z) => (x) ^ ((y) | (~(z))); + +const rotl = (x, n) => (x << n) | (x >>> (32 - n)); + +/** + * RIPEMD160 hash algorithm. + */ +export class RIPEMD160Algo extends Hasher { + _doReset() { + this._hash = new WordArray([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]); + } + + _doProcessBlock(M, offset) { + const _M = M; + + // Swap endian + for (let i = 0; i < 16; i++) { + // Shortcuts + const offset_i = offset + i; + const M_offset_i = _M[offset_i]; + + // Swap + _M[offset_i] = ( + (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) + | (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) + ); + } + // Shortcut + const H = this._hash.words; + const hl = _hl.words; + const hr = _hr.words; + const zl = _zl.words; + const zr = _zr.words; + const sl = _sl.words; + const sr = _sr.words; + + // Working variables + let al = H[0]; + let bl = H[1]; + let cl = H[2]; + let dl = H[3]; + let el = H[4]; + let ar = H[0]; + let br = H[1]; + let cr = H[2]; + let dr = H[3]; + let er = H[4]; + + // Computation + let t; + for (let i = 0; i < 80; i++) { + t = (al + _M[offset + zl[i]]) | 0; + if (i < 16) { + t += f1(bl, cl, dl) + hl[0]; + } else if (i < 32) { + t += f2(bl, cl, dl) + hl[1]; + } else if (i < 48) { + t += f3(bl, cl, dl) + hl[2]; + } else if (i < 64) { + t += f4(bl, cl, dl) + hl[3]; + } else { // if (i<80) { + t += f5(bl, cl, dl) + hl[4]; + } + t = t | 0; + t = rotl(t, sl[i]); + t = (t + el) | 0; + al = el; + el = dl; + dl = rotl(cl, 10); + cl = bl; + bl = t; + + t = (ar + _M[offset + zr[i]]) | 0; + if (i < 16) { + t += f5(br, cr, dr) + hr[0]; + } else if (i < 32) { + t += f4(br, cr, dr) + hr[1]; + } else if (i < 48) { + t += f3(br, cr, dr) + hr[2]; + } else if (i < 64) { + t += f2(br, cr, dr) + hr[3]; + } else { // if (i<80) { + t += f1(br, cr, dr) + hr[4]; + } + t |= 0; + t = rotl(t, sr[i]); + t = (t + er) | 0; + ar = er; + er = dr; + dr = rotl(cr, 10); + cr = br; + br = t; + } + // Intermediate hash value + t = (H[1] + cl + dr) | 0; + H[1] = (H[2] + dl + er) | 0; + H[2] = (H[3] + el + ar) | 0; + H[3] = (H[4] + al + br) | 0; + H[4] = (H[0] + bl + cr) | 0; + H[0] = t; + } + + _doFinalize() { + // Shortcuts + const data = this._data; + const dataWords = data.words; + + const nBitsTotal = this._nDataBytes * 8; + const nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32)); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( + (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) + | (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00) + ); + data.sigBytes = (dataWords.length + 1) * 4; + + // Hash final blocks + this._process(); + + // Shortcuts + const hash = this._hash; + const H = hash.words; + + // Swap endian + for (let i = 0; i < 5; i++) { + // Shortcut + const H_i = H[i]; + + // Swap + H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) + | (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); + } + + // Return final computed hash + return hash; + } + + clone() { + const clone = super.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } +} + +/** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.RIPEMD160('message'); + * var hash = CryptoJS.RIPEMD160(wordArray); + */ +export const RIPEMD160 = Hasher._createHelper(RIPEMD160Algo); + +/** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacRIPEMD160(message, key); + */ +export const HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160Algo); diff --git a/src/algo/hash/sha1.js b/src/algo/hash/sha1.js new file mode 100644 index 0000000..741c718 --- /dev/null +++ b/src/algo/hash/sha1.js @@ -0,0 +1,129 @@ +import { + WordArray +} from '../../core/core.js'; + +import { Hasher } from '../../core/hasher'; + +// Reusable object +const W = []; + +/** + * SHA-1 hash algorithm. + */ +export class SHA1Algo extends Hasher { + _doReset() { + this._hash = new WordArray([ + 0x67452301, + 0xefcdab89, + 0x98badcfe, + 0x10325476, + 0xc3d2e1f0 + ]); + } + + _doProcessBlock(M, offset) { + // Shortcut + const H = this._hash.words; + + // Working variables + let a = H[0]; + let b = H[1]; + let c = H[2]; + let d = H[3]; + let e = H[4]; + + // Computation + for (let i = 0; i < 80; i++) { + if (i < 16) { + W[i] = M[offset + i] | 0; + } else { + const n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; + W[i] = (n << 1) | (n >>> 31); + } + + let t = ((a << 5) | (a >>> 27)) + e + W[i]; + if (i < 20) { + t += ((b & c) | (~b & d)) + 0x5a827999; + } else if (i < 40) { + t += (b ^ c ^ d) + 0x6ed9eba1; + } else if (i < 60) { + t += ((b & c) | (b & d) | (c & d)) - 0x70e44324; + } else /* if (i < 80) */ { + t += (b ^ c ^ d) - 0x359d3e2a; + } + + e = d; + d = c; + c = (b << 30) | (b >>> 2); + b = a; + a = t; + } + + // Intermediate hash value + H[0] = (H[0] + a) | 0; + H[1] = (H[1] + b) | 0; + H[2] = (H[2] + c) | 0; + H[3] = (H[3] + d) | 0; + H[4] = (H[4] + e) | 0; + } + + _doFinalize() { + // Shortcuts + const data = this._data; + const dataWords = data.words; + + const nBitsTotal = this._nDataBytes * 8; + const nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32)); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; + data.sigBytes = dataWords.length * 4; + + // Hash final blocks + this._process(); + + // Return final computed hash + return this._hash; + } + + clone() { + const clone = super.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } +} + +/** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA1('message'); + * var hash = CryptoJS.SHA1(wordArray); + */ +export const SHA1 = Hasher._createHelper(SHA1Algo); + +/** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA1(message, key); + */ +export const HmacSHA1 = Hasher._createHmacHelper(SHA1Algo); diff --git a/src/algo/hash/sha224.js b/src/algo/hash/sha224.js new file mode 100644 index 0000000..be0d2ba --- /dev/null +++ b/src/algo/hash/sha224.js @@ -0,0 +1,60 @@ +import { WordArray } from '../../core/core.js'; +import { SHA256Algo } from './sha256.js'; + +/** + * SHA-224 hash algorithm. + */ +export class SHA224Algo extends SHA256Algo { + _doReset() { + this._hash = new WordArray([ + 0xc1059ed8, + 0x367cd507, + 0x3070dd17, + 0xf70e5939, + 0xffc00b31, + 0x68581511, + 0x64f98fa7, + 0xbefa4fa4 + ]); + } + + _doFinalize() { + const hash = super._doFinalize.call(this); + + hash.sigBytes -= 4; + + return hash; + } +} + +/** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA224('message'); + * var hash = CryptoJS.SHA224(wordArray); + */ +export const SHA224 = SHA256Algo._createHelper(SHA224Algo); + +/** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA224(message, key); + */ +export const HmacSHA224 = SHA256Algo._createHmacHelper(SHA224Algo); diff --git a/src/algo/hash/sha256.js b/src/algo/hash/sha256.js new file mode 100644 index 0000000..f649d2c --- /dev/null +++ b/src/algo/hash/sha256.js @@ -0,0 +1,171 @@ +import { + WordArray +} from '../../core/core.js'; +import { Hasher } from '../../core/hasher'; + +// Initialization and round constants tables +const H = []; +const K = []; + +// Compute constants +const isPrime = (n) => { + const sqrtN = Math.sqrt(n); + for (let factor = 2; factor <= sqrtN; factor++) { + if (!(n % factor)) { + return false; + } + } + + return true; +}; + +const getFractionalBits = n => ((n - (n | 0)) * 0x100000000) | 0; + +let n = 2; +let nPrime = 0; +while (nPrime < 64) { + if (isPrime(n)) { + if (nPrime < 8) { + H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2)); + } + K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3)); + + nPrime++; + } + + n++; +} + +// Reusable object +const W = []; + +/** + * SHA-256 hash algorithm. + */ +export class SHA256Algo extends Hasher { + _doReset() { + this._hash = new WordArray(H.slice(0)); + } + + _doProcessBlock(M, offset) { + // Shortcut + const H = this._hash.words; + + // Working variables + let a = H[0]; + let b = H[1]; + let c = H[2]; + let d = H[3]; + let e = H[4]; + let f = H[5]; + let g = H[6]; + let h = H[7]; + + // Computation + for (let i = 0; i < 64; i++) { + if (i < 16) { + W[i] = M[offset + i] | 0; + } else { + const gamma0x = W[i - 15]; + const gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) + ^ ((gamma0x << 14) | (gamma0x >>> 18)) + ^ (gamma0x >>> 3); + + const gamma1x = W[i - 2]; + const gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) + ^ ((gamma1x << 13) | (gamma1x >>> 19)) + ^ (gamma1x >>> 10); + + W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]; + } + + const ch = (e & f) ^ (~e & g); + const maj = (a & b) ^ (a & c) ^ (b & c); + + const sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22)); + const sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25)); + + const t1 = h + sigma1 + ch + K[i] + W[i]; + const t2 = sigma0 + maj; + + h = g; + g = f; + f = e; + e = (d + t1) | 0; + d = c; + c = b; + b = a; + a = (t1 + t2) | 0; + } + + // Intermediate hash value + H[0] = (H[0] + a) | 0; + H[1] = (H[1] + b) | 0; + H[2] = (H[2] + c) | 0; + H[3] = (H[3] + d) | 0; + H[4] = (H[4] + e) | 0; + H[5] = (H[5] + f) | 0; + H[6] = (H[6] + g) | 0; + H[7] = (H[7] + h) | 0; + } + + _doFinalize() { + // Shortcuts + const data = this._data; + const dataWords = data.words; + + const nBitsTotal = this._nDataBytes * 8; + const nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32)); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; + data.sigBytes = dataWords.length * 4; + + // Hash final blocks + this._process(); + + // Return final computed hash + return this._hash; + } + + clone() { + const clone = super.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } +} + +/** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA256('message'); + * var hash = CryptoJS.SHA256(wordArray); + */ +export const SHA256 = Hasher._createHelper(SHA256Algo); + +/** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA256(message, key); + */ +export const HmacSHA256 = Hasher._createHmacHelper(SHA256Algo); diff --git a/src/algo/hash/sha3.js b/src/algo/hash/sha3.js new file mode 100644 index 0000000..25eacaf --- /dev/null +++ b/src/algo/hash/sha3.js @@ -0,0 +1,295 @@ +import { + WordArray +} from '../../core/core.js'; +import { X64Word } from '../../core/x64-core.js'; +import { Hasher } from '../../core/hasher'; + +// Constants tables +const RHO_OFFSETS = []; +const PI_INDEXES = []; +const ROUND_CONSTANTS = []; + +// Compute Constants +// Compute rho offset constants +let _x = 1; +let _y = 0; +for (let t = 0; t < 24; t++) { + RHO_OFFSETS[_x + 5 * _y] = ((t + 1) * (t + 2) / 2) % 64; + + const newX = _y % 5; + const newY = (2 * _x + 3 * _y) % 5; + _x = newX; + _y = newY; +} + +// Compute pi index constants +for (let x = 0; x < 5; x++) { + for (let y = 0; y < 5; y++) { + PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5; + } +} + +// Compute round constants +let LFSR = 0x01; +for (let i = 0; i < 24; i++) { + let roundConstantMsw = 0; + let roundConstantLsw = 0; + + for (let j = 0; j < 7; j++) { + if (LFSR & 0x01) { + const bitPosition = (1 << j) - 1; + if (bitPosition < 32) { + roundConstantLsw ^= 1 << bitPosition; + } else /* if (bitPosition >= 32) */ { + roundConstantMsw ^= 1 << (bitPosition - 32); + } + } + + // Compute next LFSR + if (LFSR & 0x80) { + // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1 + LFSR = (LFSR << 1) ^ 0x71; + } else { + LFSR <<= 1; + } + } + + ROUND_CONSTANTS[i] = new X64Word(roundConstantMsw, roundConstantLsw); +} + +// Reusable objects for temporary values +const T = []; +for (let i = 0; i < 25; i++) { + T[i] = new X64Word(); +} + +/** + * SHA-3 hash algorithm. + */ +export class SHA3Algo extends Hasher { + constructor(cfg) { + /** + * Configuration options. + * + * @property {number} outputLength + * The desired number of bits in the output hash. + * Only values permitted are: 224, 256, 384, 512. + * Default: 512 + */ + super(Object.assign( + { outputLength: 512 }, + cfg + )); + } + + _doReset() { + this._state = []; + const state = this._state; + for (let i = 0; i < 25; i++) { + state[i] = new X64Word(); + } + + this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32; + } + + _doProcessBlock(M, offset) { + // Shortcuts + const state = this._state; + const nBlockSizeLanes = this.blockSize / 2; + + // Absorb + for (let i = 0; i < nBlockSizeLanes; i++) { + // Shortcuts + let M2i = M[offset + 2 * i]; + let M2i1 = M[offset + 2 * i + 1]; + + // Swap endian + M2i = (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) + | (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00); + M2i1 = (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) + | (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00); + + // Absorb message into state + const lane = state[i]; + lane.high ^= M2i1; + lane.low ^= M2i; + } + + // Rounds + for (let round = 0; round < 24; round++) { + // Theta + for (let x = 0; x < 5; x++) { + // Mix column lanes + let tMsw = 0; + let tLsw = 0; + for (let y = 0; y < 5; y++) { + const lane = state[x + 5 * y]; + tMsw ^= lane.high; + tLsw ^= lane.low; + } + + // Temporary values + const Tx = T[x]; + Tx.high = tMsw; + Tx.low = tLsw; + } + for (let x = 0; x < 5; x++) { + // Shortcuts + const Tx4 = T[(x + 4) % 5]; + const Tx1 = T[(x + 1) % 5]; + const Tx1Msw = Tx1.high; + const Tx1Lsw = Tx1.low; + + // Mix surrounding columns + const tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31)); + const tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31)); + for (let y = 0; y < 5; y++) { + const lane = state[x + 5 * y]; + lane.high ^= tMsw; + lane.low ^= tLsw; + } + } + + // Rho Pi + for (let laneIndex = 1; laneIndex < 25; laneIndex++) { + let tMsw; + let tLsw; + + // Shortcuts + const lane = state[laneIndex]; + const laneMsw = lane.high; + const laneLsw = lane.low; + const rhoOffset = RHO_OFFSETS[laneIndex]; + + // Rotate lanes + if (rhoOffset < 32) { + tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset)); + tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset)); + } else /* if (rhoOffset >= 32) */ { + tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset)); + tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset)); + } + + // Transpose lanes + const TPiLane = T[PI_INDEXES[laneIndex]]; + TPiLane.high = tMsw; + TPiLane.low = tLsw; + } + + // Rho pi at x = y = 0 + const T0 = T[0]; + const state0 = state[0]; + T0.high = state0.high; + T0.low = state0.low; + + // Chi + for (let x = 0; x < 5; x++) { + for (let y = 0; y < 5; y++) { + // Shortcuts + const laneIndex = x + 5 * y; + const lane = state[laneIndex]; + const TLane = T[laneIndex]; + const Tx1Lane = T[((x + 1) % 5) + 5 * y]; + const Tx2Lane = T[((x + 2) % 5) + 5 * y]; + + // Mix rows + lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high); + lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low); + } + } + + // Iota + const lane = state[0]; + const roundConstant = ROUND_CONSTANTS[round]; + lane.high ^= roundConstant.high; + lane.low ^= roundConstant.low; + } + } + + _doFinalize() { + // Shortcuts + const data = this._data; + const dataWords = data.words; + const nBitsLeft = data.sigBytes * 8; + const blockSizeBits = this.blockSize * 32; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32); + dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80; + data.sigBytes = dataWords.length * 4; + + // Hash final blocks + this._process(); + + // Shortcuts + const state = this._state; + const outputLengthBytes = this.cfg.outputLength / 8; + const outputLengthLanes = outputLengthBytes / 8; + + // Squeeze + const hashWords = []; + for (let i = 0; i < outputLengthLanes; i++) { + // Shortcuts + const lane = state[i]; + let laneMsw = lane.high; + let laneLsw = lane.low; + + // Swap endian + laneMsw = (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) + | (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00); + laneLsw = (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) + | (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00); + + // Squeeze state to retrieve hash + hashWords.push(laneLsw); + hashWords.push(laneMsw); + } + + // Return final computed hash + return new WordArray(hashWords, outputLengthBytes); + } + + clone() { + const clone = super.clone.call(this); + + clone._state = this._state.slice(0); + const state = clone._state; + for (let i = 0; i < 25; i++) { + state[i] = state[i].clone(); + } + + return clone; + } +} + +/** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA3('message'); + * var hash = CryptoJS.SHA3(wordArray); + */ +export const SHA3 = Hasher._createHelper(SHA3Algo); + +/** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA3(message, key); + */ +export const HmacSHA3 = Hasher._createHmacHelper(SHA3Algo); diff --git a/src/algo/hash/sha384.js b/src/algo/hash/sha384.js new file mode 100644 index 0000000..c4e04bb --- /dev/null +++ b/src/algo/hash/sha384.js @@ -0,0 +1,63 @@ +import { + X64Word, + X64WordArray +} from '../../core/x64-core.js'; +import { SHA512Algo } from './sha512.js'; + +/** + * SHA-384 hash algorithm. + */ +export class SHA384Algo extends SHA512Algo { + _doReset() { + this._hash = new X64WordArray([ + new X64Word(0xcbbb9d5d, 0xc1059ed8), + new X64Word(0x629a292a, 0x367cd507), + new X64Word(0x9159015a, 0x3070dd17), + new X64Word(0x152fecd8, 0xf70e5939), + new X64Word(0x67332667, 0xffc00b31), + new X64Word(0x8eb44a87, 0x68581511), + new X64Word(0xdb0c2e0d, 0x64f98fa7), + new X64Word(0x47b5481d, 0xbefa4fa4) + ]); + } + + _doFinalize() { + const hash = super._doFinalize.call(this); + + hash.sigBytes -= 16; + + return hash; + } +} + +/** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA384('message'); + * var hash = CryptoJS.SHA384(wordArray); + */ +export const SHA384 = SHA512Algo._createHelper(SHA384Algo); + +/** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA384(message, key); + */ +export const HmacSHA384 = SHA512Algo._createHmacHelper(SHA384Algo); diff --git a/src/algo/hash/sha512.js b/src/algo/hash/sha512.js new file mode 100644 index 0000000..bffae19 --- /dev/null +++ b/src/algo/hash/sha512.js @@ -0,0 +1,369 @@ +import { Hasher } from '../../core/hasher'; +import { + X64Word, + X64WordArray +} from '../../core/x64-core.js'; + +// Constants +const K = [ + new X64Word(0x428a2f98, 0xd728ae22), + new X64Word(0x71374491, 0x23ef65cd), + new X64Word(0xb5c0fbcf, 0xec4d3b2f), + new X64Word(0xe9b5dba5, 0x8189dbbc), + new X64Word(0x3956c25b, 0xf348b538), + new X64Word(0x59f111f1, 0xb605d019), + new X64Word(0x923f82a4, 0xaf194f9b), + new X64Word(0xab1c5ed5, 0xda6d8118), + new X64Word(0xd807aa98, 0xa3030242), + new X64Word(0x12835b01, 0x45706fbe), + new X64Word(0x243185be, 0x4ee4b28c), + new X64Word(0x550c7dc3, 0xd5ffb4e2), + new X64Word(0x72be5d74, 0xf27b896f), + new X64Word(0x80deb1fe, 0x3b1696b1), + new X64Word(0x9bdc06a7, 0x25c71235), + new X64Word(0xc19bf174, 0xcf692694), + new X64Word(0xe49b69c1, 0x9ef14ad2), + new X64Word(0xefbe4786, 0x384f25e3), + new X64Word(0x0fc19dc6, 0x8b8cd5b5), + new X64Word(0x240ca1cc, 0x77ac9c65), + new X64Word(0x2de92c6f, 0x592b0275), + new X64Word(0x4a7484aa, 0x6ea6e483), + new X64Word(0x5cb0a9dc, 0xbd41fbd4), + new X64Word(0x76f988da, 0x831153b5), + new X64Word(0x983e5152, 0xee66dfab), + new X64Word(0xa831c66d, 0x2db43210), + new X64Word(0xb00327c8, 0x98fb213f), + new X64Word(0xbf597fc7, 0xbeef0ee4), + new X64Word(0xc6e00bf3, 0x3da88fc2), + new X64Word(0xd5a79147, 0x930aa725), + new X64Word(0x06ca6351, 0xe003826f), + new X64Word(0x14292967, 0x0a0e6e70), + new X64Word(0x27b70a85, 0x46d22ffc), + new X64Word(0x2e1b2138, 0x5c26c926), + new X64Word(0x4d2c6dfc, 0x5ac42aed), + new X64Word(0x53380d13, 0x9d95b3df), + new X64Word(0x650a7354, 0x8baf63de), + new X64Word(0x766a0abb, 0x3c77b2a8), + new X64Word(0x81c2c92e, 0x47edaee6), + new X64Word(0x92722c85, 0x1482353b), + new X64Word(0xa2bfe8a1, 0x4cf10364), + new X64Word(0xa81a664b, 0xbc423001), + new X64Word(0xc24b8b70, 0xd0f89791), + new X64Word(0xc76c51a3, 0x0654be30), + new X64Word(0xd192e819, 0xd6ef5218), + new X64Word(0xd6990624, 0x5565a910), + new X64Word(0xf40e3585, 0x5771202a), + new X64Word(0x106aa070, 0x32bbd1b8), + new X64Word(0x19a4c116, 0xb8d2d0c8), + new X64Word(0x1e376c08, 0x5141ab53), + new X64Word(0x2748774c, 0xdf8eeb99), + new X64Word(0x34b0bcb5, 0xe19b48a8), + new X64Word(0x391c0cb3, 0xc5c95a63), + new X64Word(0x4ed8aa4a, 0xe3418acb), + new X64Word(0x5b9cca4f, 0x7763e373), + new X64Word(0x682e6ff3, 0xd6b2b8a3), + new X64Word(0x748f82ee, 0x5defb2fc), + new X64Word(0x78a5636f, 0x43172f60), + new X64Word(0x84c87814, 0xa1f0ab72), + new X64Word(0x8cc70208, 0x1a6439ec), + new X64Word(0x90befffa, 0x23631e28), + new X64Word(0xa4506ceb, 0xde82bde9), + new X64Word(0xbef9a3f7, 0xb2c67915), + new X64Word(0xc67178f2, 0xe372532b), + new X64Word(0xca273ece, 0xea26619c), + new X64Word(0xd186b8c7, 0x21c0c207), + new X64Word(0xeada7dd6, 0xcde0eb1e), + new X64Word(0xf57d4f7f, 0xee6ed178), + new X64Word(0x06f067aa, 0x72176fba), + new X64Word(0x0a637dc5, 0xa2c898a6), + new X64Word(0x113f9804, 0xbef90dae), + new X64Word(0x1b710b35, 0x131c471b), + new X64Word(0x28db77f5, 0x23047d84), + new X64Word(0x32caab7b, 0x40c72493), + new X64Word(0x3c9ebe0a, 0x15c9bebc), + new X64Word(0x431d67c4, 0x9c100d4c), + new X64Word(0x4cc5d4be, 0xcb3e42b6), + new X64Word(0x597f299c, 0xfc657e2a), + new X64Word(0x5fcb6fab, 0x3ad6faec), + new X64Word(0x6c44198c, 0x4a475817) +]; + +// Reusable objects +const W = []; +for (let i = 0; i < 80; i++) { + W[i] = new X64Word(); +} + +/** + * SHA-512 hash algorithm. + */ +export class SHA512Algo extends Hasher { + constructor() { + super(); + + this.blockSize = 1024 / 32; + } + + _doReset() { + this._hash = new X64WordArray([ + new X64Word(0x6a09e667, 0xf3bcc908), + new X64Word(0xbb67ae85, 0x84caa73b), + new X64Word(0x3c6ef372, 0xfe94f82b), + new X64Word(0xa54ff53a, 0x5f1d36f1), + new X64Word(0x510e527f, 0xade682d1), + new X64Word(0x9b05688c, 0x2b3e6c1f), + new X64Word(0x1f83d9ab, 0xfb41bd6b), + new X64Word(0x5be0cd19, 0x137e2179) + ]); + } + + _doProcessBlock(M, offset) { + // Shortcuts + const H = this._hash.words; + + const H0 = H[0]; + const H1 = H[1]; + const H2 = H[2]; + const H3 = H[3]; + const H4 = H[4]; + const H5 = H[5]; + const H6 = H[6]; + const H7 = H[7]; + + const H0h = H0.high; + let H0l = H0.low; + const H1h = H1.high; + let H1l = H1.low; + const H2h = H2.high; + let H2l = H2.low; + const H3h = H3.high; + let H3l = H3.low; + const H4h = H4.high; + let H4l = H4.low; + const H5h = H5.high; + let H5l = H5.low; + const H6h = H6.high; + let H6l = H6.low; + const H7h = H7.high; + let H7l = H7.low; + + // Working variables + let ah = H0h; + let al = H0l; + let bh = H1h; + let bl = H1l; + let ch = H2h; + let cl = H2l; + let dh = H3h; + let dl = H3l; + let eh = H4h; + let el = H4l; + let fh = H5h; + let fl = H5l; + let gh = H6h; + let gl = H6l; + let hh = H7h; + let hl = H7l; + + // Rounds + for (let i = 0; i < 80; i++) { + let Wil; + let Wih; + + // Shortcut + const Wi = W[i]; + + // Extend message + if (i < 16) { + Wi.high = M[offset + i * 2] | 0; + Wih = Wi.high; + Wi.low = M[offset + i * 2 + 1] | 0; + Wil = Wi.low; + } else { + // Gamma0 + const gamma0x = W[i - 15]; + const gamma0xh = gamma0x.high; + const gamma0xl = gamma0x.low; + const gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) + ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) + ^ (gamma0xh >>> 7); + const gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) + ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) + ^ ((gamma0xl >>> 7) | (gamma0xh << 25)); + + // Gamma1 + const gamma1x = W[i - 2]; + const gamma1xh = gamma1x.high; + const gamma1xl = gamma1x.low; + const gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) + ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) + ^ (gamma1xh >>> 6); + const gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) + ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) + ^ ((gamma1xl >>> 6) | (gamma1xh << 26)); + + // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] + const Wi7 = W[i - 7]; + const Wi7h = Wi7.high; + const Wi7l = Wi7.low; + + const Wi16 = W[i - 16]; + const Wi16h = Wi16.high; + const Wi16l = Wi16.low; + + Wil = gamma0l + Wi7l; + Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0); + Wil = Wil + gamma1l; + Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0); + Wil = Wil + Wi16l; + Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0); + + Wi.high = Wih; + Wi.low = Wil; + } + + const chh = (eh & fh) ^ (~eh & gh); + const chl = (el & fl) ^ (~el & gl); + const majh = (ah & bh) ^ (ah & ch) ^ (bh & ch); + const majl = (al & bl) ^ (al & cl) ^ (bl & cl); + + const sigma0h = ((ah >>> 28) | (al << 4)) + ^ ((ah << 30) | (al >>> 2)) + ^ ((ah << 25) | (al >>> 7)); + const sigma0l = ((al >>> 28) | (ah << 4)) + ^ ((al << 30) | (ah >>> 2)) + ^ ((al << 25) | (ah >>> 7)); + const sigma1h = ((eh >>> 14) | (el << 18)) + ^ ((eh >>> 18) | (el << 14)) + ^ ((eh << 23) | (el >>> 9)); + const sigma1l = ((el >>> 14) | (eh << 18)) + ^ ((el >>> 18) | (eh << 14)) + ^ ((el << 23) | (eh >>> 9)); + + // t1 = h + sigma1 + ch + K[i] + W[i] + const Ki = K[i]; + const Kih = Ki.high; + const Kil = Ki.low; + + let t1l = hl + sigma1l; + let t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0); + t1l = t1l + chl; + t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0); + t1l = t1l + Kil; + t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0); + t1l = t1l + Wil; + t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0); + + // t2 = sigma0 + maj + const t2l = sigma0l + majl; + const t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0); + + // Update working variables + hh = gh; + hl = gl; + gh = fh; + gl = fl; + fh = eh; + fl = el; + el = (dl + t1l) | 0; + eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0; + dh = ch; + dl = cl; + ch = bh; + cl = bl; + bh = ah; + bl = al; + al = (t1l + t2l) | 0; + ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0; + } + + // Intermediate hash value + H0.low = (H0l + al); + H0l = H0.low; + H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0)); + H1.low = (H1l + bl); + H1l = H1.low; + H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0)); + H2.low = (H2l + cl); + H2l = H2.low; + H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0)); + H3.low = (H3l + dl); + H3l = H3.low; + H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0)); + H4.low = (H4l + el); + H4l = H4.low; + H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0)); + H5.low = (H5l + fl); + H5l = H5.low; + H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0)); + H6.low = (H6l + gl); + H6l = H6.low; + H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0)); + H7.low = (H7l + hl); + H7l = H7.low; + H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0)); + } + + _doFinalize() { + // Shortcuts + const data = this._data; + const dataWords = data.words; + + const nBitsTotal = this._nDataBytes * 8; + const nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - (nBitsLeft % 32)); + dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000); + dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal; + data.sigBytes = dataWords.length * 4; + + // Hash final blocks + this._process(); + + // Convert hash to 32-bit word array before returning + const hash = this._hash.toX32(); + + // Return final computed hash + return hash; + } + + clone() { + const clone = super.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } +} + +/** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA512('message'); + * var hash = CryptoJS.SHA512(wordArray); + */ +export const SHA512 = Hasher._createHelper(SHA512Algo); + +/** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA512(message, key); + */ +export const HmacSHA512 = Hasher._createHmacHelper(SHA512Algo); diff --git a/src/algo/hmac/hmac.js b/src/algo/hmac/hmac.js new file mode 100644 index 0000000..18dcdcd --- /dev/null +++ b/src/algo/hmac/hmac.js @@ -0,0 +1,129 @@ +import { + Base, WordArray +} from '../../core/core.js'; +import { Utf8 } from '../../encoding/enc-utf8'; +import { isString } from '../../utils'; + + +/** + * HMAC algorithm. + */ +export class HMAC extends Base { + /** + * Initializes a newly created HMAC. + * + * @param {Hasher} SubHasher The hash algorithm to use. + * @param {WordArray|string} key The secret key. + * + * @example + * + * let hmacHasher = new HMAC(CryptoJS.algo.SHA256, key); + */ + constructor(SubHasher, key) { + super(); + + const hasher = new SubHasher(); + this._hasher = hasher; + + // Convert string to WordArray, else assume WordArray already + let _key = key; + if (isString(_key)) { + _key = Utf8.parse(_key); + } + + // Shortcuts + const hasherBlockSize = hasher.blockSize; + const hasherBlockSizeBytes = hasherBlockSize * 4; + + // Allow arbitrary length keys + if (_key.sigBytes > hasherBlockSizeBytes) { + _key = hasher.finalize(key); + } + + // Clamp excess bits + _key.clamp(); + + // Clone key for inner and outer pads + const oKey = _key.clone(); + this._oKey = oKey; + const iKey = _key.clone(); + this._iKey = iKey; + + // Shortcuts + const oKeyWords = oKey.words; + const iKeyWords = iKey.words; + + // XOR keys with pad constants + for (let i = 0; i < hasherBlockSize; i++) { + oKeyWords[i] ^= 0x5c5c5c5c; + iKeyWords[i] ^= 0x36363636; + } + oKey.sigBytes = hasherBlockSizeBytes; + iKey.sigBytes = hasherBlockSizeBytes; + + // Set initial values + this.reset(); + } + + /** + * Resets this HMAC to its initial state. + * + * @example + * + * hmacHasher.reset(); + */ + reset() { + // Shortcut + const hasher = this._hasher; + + // Reset + hasher.reset(); + hasher.update(this._iKey); + } + + /** + * Updates this HMAC with a message. + * + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {HMAC} This HMAC instance. + * + * @example + * + * hmacHasher.update('message'); + * hmacHasher.update(wordArray); + */ + update(messageUpdate) { + this._hasher.update(messageUpdate); + + // Chainable + return this; + } + + /** + * Finalizes the HMAC computation. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} messageUpdate (Optional) A final message update. + * + * @return {WordArray} The HMAC. + * + * @example + * + * let hmac = hmacHasher.finalize(); + * let hmac = hmacHasher.finalize('message'); + * let hmac = hmacHasher.finalize(wordArray); + */ + finalize(messageUpdate) { + // Shortcut + const hasher = this._hasher; + + // Compute HMAC + const innerHash = hasher.finalize(messageUpdate); + hasher.reset(); + const hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); + + return hmac; + } +} + diff --git a/src/algo/pbkdf2/pbkdf2.js b/src/algo/pbkdf2/pbkdf2.js new file mode 100644 index 0000000..e0b4d20 --- /dev/null +++ b/src/algo/pbkdf2/pbkdf2.js @@ -0,0 +1,123 @@ +import { + Base, + WordArray +} from '../../core/core.js'; +import { SHA1Algo } from '../hash/sha1.js'; +import { HMAC } from '../hmac/hmac.js'; + + +/** + * Password-Based Key Derivation Function 2 algorithm. + */ +export class PBKDF2Algo extends Base { + /** + * Initializes a newly created key derivation function. + * + * @param {Object} cfg (Optional) The configuration options to use for the derivation. + * + * @example + * + * const kdf = new CryptoJS.algo.PBKDF2(); + * const kdf = new CryptoJS.algo.PBKDF2({ keySize: 8 }); + * const kdf = new CryptoJS.algo.PBKDF2({ keySize: 8, iterations: 1000 }); + */ + constructor(cfg) { + super(); + + /** + * Configuration options. + * + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) + * @property {Hasher} hasher The hasher to use. Default: SHA1 + * @property {number} iterations The number of iterations to perform. Default: 1 + */ + this.cfg = Object.assign( + new Base(), + { + keySize: 128 / 32, + hasher: SHA1Algo, + iterations: 1 + }, + cfg + ); + } + + /** + * Computes the Password-Based Key Derivation Function 2. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * + * @return {WordArray} The derived key. + * + * @example + * + * const key = kdf.compute(password, salt); + */ + compute(password, salt) { + // Shortcut + const { cfg } = this; + + // Init HMAC + const hmac = new HMAC(cfg.hasher, password); + + // Initial values + const derivedKey = new WordArray(); + const blockIndex = new WordArray([0x00000001]); + + // Shortcuts + const derivedKeyWords = derivedKey.words; + const blockIndexWords = blockIndex.words; + const { keySize, iterations } = cfg; + + // Generate key + while (derivedKeyWords.length < keySize) { + const block = hmac.update(salt).finalize(blockIndex); + hmac.reset(); + + // Shortcuts + const blockWords = block.words; + const blockWordsLength = blockWords.length; + + // Iterations + let intermediate = block; + for (let i = 1; i < iterations; i++) { + intermediate = hmac.finalize(intermediate); + hmac.reset(); + + // Shortcut + const intermediateWords = intermediate.words; + + // XOR intermediate with block + for (let j = 0; j < blockWordsLength; j++) { + blockWords[j] ^= intermediateWords[j]; + } + } + + derivedKey.concat(block); + blockIndexWords[0]++; + } + derivedKey.sigBytes = keySize * 4; + + return derivedKey; + } +} + +/** + * Computes the Password-Based Key Derivation Function 2. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * @param {Object} cfg (Optional) The configuration options to use for this computation. + * + * @return {WordArray} The derived key. + * + * @static + * + * @example + * + * var key = CryptoJS.PBKDF2(password, salt); + * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 }); + * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 }); + */ +export const PBKDF2 = (password, salt, cfg) =>new PBKDF2Algo(cfg).compute(password, salt); diff --git a/src/core.js b/src/core.js deleted file mode 100644 index aa35d00..0000000 --- a/src/core.js +++ /dev/null @@ -1,772 +0,0 @@ -/* eslint-disable no-use-before-define */ - -/** - * Base class for inheritance. - */ -export class Base { - - /** - * Copies properties into this object. - * - * @param {Object} properties The properties to mix in. - * - * @example - * - * MyType.mixIn({ - * field: 'value' - * }); - */ - mixIn(properties) { - return Object.assign(this, properties); - } - - /** - * Creates a copy of this object. - * - * @return {Object} The clone. - * - * @example - * - * let clone = instance.clone(); - */ - clone() { - const clone = new this.constructor(); - Object.assign(clone, this); - return clone; - } -} - -/** - * An array of 32-bit words. - * - * @property {Array} words The array of 32-bit words. - * @property {number} sigBytes The number of significant bytes in this word array. - */ -export class WordArray extends Base { - /** - * Initializes a newly created word array. - * - * @param {Array} words (Optional) An array of 32-bit words. - * @param {number} sigBytes (Optional) The number of significant bytes in the words. - * - * @example - * - * let wordArray = new WordArray(); - * let wordArray = new WordArray([0x00010203, 0x04050607]); - * let wordArray = new WordArray([0x00010203, 0x04050607], 6); - */ - constructor(words = [], sigBytes = words.length * 4) { - super(); - - let typedArray = words; - // Convert buffers to uint8 - if (typedArray instanceof ArrayBuffer) { - typedArray = new Uint8Array(typedArray); - } - - // Convert other array views to uint8 - if ( - typedArray instanceof Int8Array || - typedArray instanceof Uint8ClampedArray || - typedArray instanceof Int16Array || - typedArray instanceof Uint16Array || - typedArray instanceof Int32Array || - typedArray instanceof Uint32Array || - typedArray instanceof Float32Array || - typedArray instanceof Float64Array - ) { - typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); - } - - // Handle Uint8Array - if (typedArray instanceof Uint8Array) { - // Shortcut - const typedArrayByteLength = typedArray.byteLength; - - // Extract bytes - const _words = []; - for (let i = 0; i < typedArrayByteLength; i += 1) { - _words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8); - } - - // Initialize this word array - this.words = _words; - this.sigBytes = typedArrayByteLength; - } else { - // Else call normal init - this.words = words; - this.sigBytes = sigBytes; - } - } - - /** - * Creates a word array filled with random bytes. - * - * @param {number} nBytes The number of random bytes to generate. - * - * @return {WordArray} The random word array. - * - * @static - * - * @example - * - * let wordArray = CryptoJS.lib.WordArray.random(16); - */ - static random(nBytes) { - const words = []; - - const r = (m_w) => { - let _m_w = m_w; - let _m_z = 0x3ade68b1; - const mask = 0xffffffff; - - return () => { - _m_z = (0x9069 * (_m_z & 0xFFFF) + (_m_z >> 0x10)) & mask; - _m_w = (0x4650 * (_m_w & 0xFFFF) + (_m_w >> 0x10)) & mask; - let result = ((_m_z << 0x10) + _m_w) & mask; - result /= 0x100000000; - result += 0.5; - return result * (Math.random() > 0.5 ? 1 : -1); - }; - }; - - for (let i = 0, rcache; i < nBytes; i += 4) { - const _r = r((rcache || Math.random()) * 0x100000000); - - rcache = _r() * 0x3ade67b7; - words.push((_r() * 0x100000000) | 0); - } - - return new WordArray(words, nBytes); - } - - /** - * Converts this word array to a string. - * - * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex - * - * @return {string} The stringified word array. - * - * @example - * - * let string = wordArray + ''; - * let string = wordArray.toString(); - * let string = wordArray.toString(CryptoJS.enc.Utf8); - */ - toString(encoder = Hex) { - return encoder.stringify(this); - } - - /** - * Concatenates a word array to this word array. - * - * @param {WordArray} wordArray The word array to append. - * - * @return {WordArray} This word array. - * - * @example - * - * wordArray1.concat(wordArray2); - */ - concat(wordArray) { - // Shortcuts - const thisWords = this.words; - const thatWords = wordArray.words; - const thisSigBytes = this.sigBytes; - const thatSigBytes = wordArray.sigBytes; - - // Clamp excess bits - this.clamp(); - - // Concat - if (thisSigBytes % 4) { - // Copy one byte at a time - for (let i = 0; i < thatSigBytes; i += 1) { - const thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8); - } - } else { - // Copy one word at a time - for (let i = 0; i < thatSigBytes; i += 4) { - thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2]; - } - } - this.sigBytes += thatSigBytes; - - // Chainable - return this; - } - - /** - * Removes insignificant bits. - * - * @example - * - * wordArray.clamp(); - */ - clamp() { - // Shortcuts - const { - words, - sigBytes - } = this; - - // Clamp - words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8); - words.length = Math.ceil(sigBytes / 4); - } - - /** - * Creates a copy of this word array. - * - * @return {WordArray} The clone. - * - * @example - * - * let clone = wordArray.clone(); - */ - clone() { - const clone = super.clone.call(this); - clone.words = this.words.slice(0); - - return clone; - } -} - -/** - * Hex encoding strategy. - */ -export const Hex = { - /** - * Converts a word array to a hex string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The hex string. - * - * @static - * - * @example - * - * let hexString = CryptoJS.enc.Hex.stringify(wordArray); - */ - stringify(wordArray) { - // Shortcuts - const { - words, - sigBytes - } = wordArray; - - // Convert - const hexChars = []; - for (let i = 0; i < sigBytes; i += 1) { - const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - hexChars.push((bite >>> 4).toString(16)); - hexChars.push((bite & 0x0f).toString(16)); - } - - return hexChars.join(''); - }, - - /** - * Converts a hex string to a word array. - * - * @param {string} hexStr The hex string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * let wordArray = CryptoJS.enc.Hex.parse(hexString); - */ - parse(hexStr) { - // Shortcut - const hexStrLength = hexStr.length; - - // Convert - const words = []; - for (let i = 0; i < hexStrLength; i += 2) { - words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); - } - - return new WordArray(words, hexStrLength / 2); - } -}; - -/** - * Latin1 encoding strategy. - */ -export const Latin1 = { - /** - * Converts a word array to a Latin1 string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The Latin1 string. - * - * @static - * - * @example - * - * let latin1String = CryptoJS.enc.Latin1.stringify(wordArray); - */ - stringify(wordArray) { - // Shortcuts - const { - words, - sigBytes - } = wordArray; - - // Convert - const latin1Chars = []; - for (let i = 0; i < sigBytes; i += 1) { - const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - latin1Chars.push(String.fromCharCode(bite)); - } - - return latin1Chars.join(''); - }, - - /** - * Converts a Latin1 string to a word array. - * - * @param {string} latin1Str The Latin1 string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * let wordArray = CryptoJS.enc.Latin1.parse(latin1String); - */ - parse(latin1Str) { - // Shortcut - const latin1StrLength = latin1Str.length; - - // Convert - const words = []; - for (let i = 0; i < latin1StrLength; i += 1) { - words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); - } - - return new WordArray(words, latin1StrLength); - } -}; - -/** - * UTF-8 encoding strategy. - */ -export const Utf8 = { - /** - * Converts a word array to a UTF-8 string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The UTF-8 string. - * - * @static - * - * @example - * - * let utf8String = CryptoJS.enc.Utf8.stringify(wordArray); - */ - stringify(wordArray) { - try { - return decodeURIComponent(escape(Latin1.stringify(wordArray))); - } catch (e) { - throw new Error('Malformed UTF-8 data'); - } - }, - - /** - * Converts a UTF-8 string to a word array. - * - * @param {string} utf8Str The UTF-8 string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * let wordArray = CryptoJS.enc.Utf8.parse(utf8String); - */ - parse(utf8Str) { - return Latin1.parse(unescape(encodeURIComponent(utf8Str))); - } -}; - -/** - * Abstract buffered block algorithm template. - * - * The property blockSize must be implemented in a concrete subtype. - * - * @property {number} _minBufferSize - * - * The number of blocks that should be kept unprocessed in the buffer. Default: 0 - */ -export class BufferedBlockAlgorithm extends Base { - constructor() { - super(); - this._minBufferSize = 0; - } - - /** - * Resets this block algorithm's data buffer to its initial state. - * - * @example - * - * bufferedBlockAlgorithm.reset(); - */ - reset() { - // Initial values - this._data = new WordArray(); - this._nDataBytes = 0; - } - - /** - * Adds new data to this block algorithm's buffer. - * - * @param {WordArray|string} data - * - * The data to append. Strings are converted to a WordArray using UTF-8. - * - * @example - * - * bufferedBlockAlgorithm._append('data'); - * bufferedBlockAlgorithm._append(wordArray); - */ - _append(data) { - let m_data = data; - - // Convert string to WordArray, else assume WordArray already - if (typeof m_data === 'string') { - m_data = Utf8.parse(m_data); - } - - // Append - this._data.concat(m_data); - this._nDataBytes += m_data.sigBytes; - } - - /** - * Processes available data blocks. - * - * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. - * - * @param {boolean} doFlush Whether all blocks and partial blocks should be processed. - * - * @return {WordArray} The processed data. - * - * @example - * - * let processedData = bufferedBlockAlgorithm._process(); - * let processedData = bufferedBlockAlgorithm._process(!!'flush'); - */ - _process(doFlush) { - let processedWords; - - // Shortcuts - const { - _data: data, - blockSize - } = this; - const dataWords = data.words; - const dataSigBytes = data.sigBytes; - const blockSizeBytes = blockSize * 4; - - // Count blocks ready - let nBlocksReady = dataSigBytes / blockSizeBytes; - if (doFlush) { - // Round up to include partial blocks - nBlocksReady = Math.ceil(nBlocksReady); - } else { - // Round down to include only full blocks, - // less the number of blocks that must remain in the buffer - nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0); - } - - // Count words ready - const nWordsReady = nBlocksReady * blockSize; - - // Count bytes ready - const nBytesReady = Math.min(nWordsReady * 4, dataSigBytes); - - // Process blocks - if (nWordsReady) { - for (let offset = 0; offset < nWordsReady; offset += blockSize) { - // Perform concrete-algorithm logic - this._doProcessBlock(dataWords, offset); - } - - // Remove processed words - processedWords = dataWords.splice(0, nWordsReady); - data.sigBytes -= nBytesReady; - } - - // Return processed words - return new WordArray(processedWords, nBytesReady); - } - - /** - * Creates a copy of this object. - * - * @return {Object} The clone. - * - * @example - * - * let clone = bufferedBlockAlgorithm.clone(); - */ - clone() { - const clone = super.clone.call(this); - clone._data = this._data.clone(); - - return clone; - } -} - -/** - * Abstract hasher template. - * - * @property {number} blockSize - * - * The number of 32-bit words this hasher operates on. Default: 16 (512 bits) - */ -export class Hasher extends BufferedBlockAlgorithm { - constructor(cfg) { - super(); - - this.blockSize = 512 / 32; - - /** - * Configuration options. - */ - this.cfg = Object.assign(new Base(), cfg); - - // Set initial values - this.reset(); - } - - /** - * Creates a shortcut function to a hasher's object interface. - * - * @param {Hasher} SubHasher The hasher to create a helper for. - * - * @return {Function} The shortcut function. - * - * @static - * - * @example - * - * let SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); - */ - static _createHelper(SubHasher) { - return (message, cfg) => new SubHasher(cfg).finalize(message); - } - - /** - * Creates a shortcut function to the HMAC's object interface. - * - * @param {Hasher} SubHasher The hasher to use in this HMAC helper. - * - * @return {Function} The shortcut function. - * - * @static - * - * @example - * - * let HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); - */ - static _createHmacHelper(SubHasher) { - return (message, key) => new HMAC(SubHasher, key).finalize(message); - } - - /** - * Resets this hasher to its initial state. - * - * @example - * - * hasher.reset(); - */ - reset() { - // Reset data buffer - super.reset.call(this); - - // Perform concrete-hasher logic - this._doReset(); - } - - /** - * Updates this hasher with a message. - * - * @param {WordArray|string} messageUpdate The message to append. - * - * @return {Hasher} This hasher. - * - * @example - * - * hasher.update('message'); - * hasher.update(wordArray); - */ - update(messageUpdate) { - // Append - this._append(messageUpdate); - - // Update the hash - this._process(); - - // Chainable - return this; - } - - /** - * Finalizes the hash computation. - * Note that the finalize operation is effectively a destructive, read-once operation. - * - * @param {WordArray|string} messageUpdate (Optional) A final message update. - * - * @return {WordArray} The hash. - * - * @example - * - * let hash = hasher.finalize(); - * let hash = hasher.finalize('message'); - * let hash = hasher.finalize(wordArray); - */ - finalize(messageUpdate) { - // Final message update - if (messageUpdate) { - this._append(messageUpdate); - } - - // Perform concrete-hasher logic - const hash = this._doFinalize(); - - return hash; - } -} - -/** - * HMAC algorithm. - */ -export class HMAC extends Base { - /** - * Initializes a newly created HMAC. - * - * @param {Hasher} SubHasher The hash algorithm to use. - * @param {WordArray|string} key The secret key. - * - * @example - * - * let hmacHasher =new HMAC(CryptoJS.algo.SHA256, key); - */ - constructor(SubHasher, key) { - super(); - - const hasher = new SubHasher(); - this._hasher = hasher; - - // Convert string to WordArray, else assume WordArray already - let _key = key; - if (typeof _key === 'string') { - _key = Utf8.parse(_key); - } - - // Shortcuts - const hasherBlockSize = hasher.blockSize; - const hasherBlockSizeBytes = hasherBlockSize * 4; - - // Allow arbitrary length keys - if (_key.sigBytes > hasherBlockSizeBytes) { - _key = hasher.finalize(key); - } - - // Clamp excess bits - _key.clamp(); - - // Clone key for inner and outer pads - const oKey = _key.clone(); - this._oKey = oKey; - const iKey = _key.clone(); - this._iKey = iKey; - - // Shortcuts - const oKeyWords = oKey.words; - const iKeyWords = iKey.words; - - // XOR keys with pad constants - for (let i = 0; i < hasherBlockSize; i += 1) { - oKeyWords[i] ^= 0x5c5c5c5c; - iKeyWords[i] ^= 0x36363636; - } - oKey.sigBytes = hasherBlockSizeBytes; - iKey.sigBytes = hasherBlockSizeBytes; - - // Set initial values - this.reset(); - } - - /** - * Resets this HMAC to its initial state. - * - * @example - * - * hmacHasher.reset(); - */ - reset() { - // Shortcut - const hasher = this._hasher; - - // Reset - hasher.reset(); - hasher.update(this._iKey); - } - - /** - * Updates this HMAC with a message. - * - * @param {WordArray|string} messageUpdate The message to append. - * - * @return {HMAC} This HMAC instance. - * - * @example - * - * hmacHasher.update('message'); - * hmacHasher.update(wordArray); - */ - update(messageUpdate) { - this._hasher.update(messageUpdate); - - // Chainable - return this; - } - - /** - * Finalizes the HMAC computation. - * Note that the finalize operation is effectively a destructive, read-once operation. - * - * @param {WordArray|string} messageUpdate (Optional) A final message update. - * - * @return {WordArray} The HMAC. - * - * @example - * - * let hmac = hmacHasher.finalize(); - * let hmac = hmacHasher.finalize('message'); - * let hmac = hmacHasher.finalize(wordArray); - */ - finalize(messageUpdate) { - // Shortcut - const hasher = this._hasher; - - // Compute HMAC - const innerHash = hasher.finalize(messageUpdate); - hasher.reset(); - const hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); - - return hmac; - } -} \ No newline at end of file diff --git a/src/cipher-core.js b/src/core/cipher-core.js similarity index 91% rename from src/cipher-core.js rename to src/core/cipher-core.js index 6b74f0e..77d4f1f 100644 --- a/src/cipher-core.js +++ b/src/core/cipher-core.js @@ -4,13 +4,16 @@ import { Base, WordArray, BufferedBlockAlgorithm -} from './core.js'; +} from '../core/core.js'; import { Base64 -} from './enc-base64.js'; +} from '../encoding/enc-base64.js'; import { EvpKDFAlgo -} from './evpkdf.js'; +} from '../encryption/evpkdf.js'; +import { isString } from '../utils'; +import { Pkcs7 } from '../pad/pad-pkcs7'; + /** * Abstract base cipher template. @@ -106,7 +109,7 @@ export class Cipher extends BufferedBlockAlgorithm { */ static _createHelper(SubCipher) { const selectCipherStrategy = (key) => { - if (typeof key === 'string') { + if (isString(key)) { return PasswordBasedCipher; } return SerializableCipher; @@ -281,7 +284,7 @@ function xorBlock(words, offset, blockSize) { } // XOR blocks - for (let i = 0; i < blockSize; i += 1) { + for (let i = 0; i < blockSize; i++) { _words[offset + i] ^= block[i]; } } @@ -293,7 +296,7 @@ function xorBlock(words, offset, blockSize) { /** * Abstract base CBC mode. */ -export class CBC extends BlockCipherMode {} +export class CBC extends BlockCipherMode { } /** * CBC encryptor. */ @@ -356,68 +359,6 @@ CBC.Decryptor = class extends CBC { } }; -/** - * PKCS #5/7 padding strategy. - */ -export const Pkcs7 = { - /** - * Pads data using the algorithm defined in PKCS #5/7. - * - * @param {WordArray} data The data to pad. - * @param {number} blockSize The multiple that the data should be padded to. - * - * @static - * - * @example - * - * CryptoJS.pad.Pkcs7.pad(wordArray, 4); - */ - pad(data, blockSize) { - // Shortcut - const blockSizeBytes = blockSize * 4; - - // Count padding bytes - const nPaddingBytes = blockSizeBytes - (data.sigBytes % blockSizeBytes); - - // Create padding word - const paddingWord = (nPaddingBytes << 24) | - (nPaddingBytes << 16) | - (nPaddingBytes << 8) | - nPaddingBytes; - - // Create padding - const paddingWords = []; - for (let i = 0; i < nPaddingBytes; i += 4) { - paddingWords.push(paddingWord); - } - const padding =new WordArray(paddingWords, nPaddingBytes); - - // Add padding - data.concat(padding); - }, - - /** - * Unpads data that had been padded using the algorithm defined in PKCS #5/7. - * - * @param {WordArray} data The data to unpad. - * - * @static - * - * @example - * - * CryptoJS.pad.Pkcs7.unpad(wordArray); - */ - unpad(data) { - const _data = data; - - // Get number of padding bytes from last byte - const nPaddingBytes = _data.words[(_data.sigBytes - 1) >>> 2] & 0xff; - - // Remove padding - _data.sigBytes -= nPaddingBytes; - } -}; - /** * Abstract base block cipher template. * @@ -437,7 +378,7 @@ export class BlockCipher extends Cipher { mode: CBC, padding: Pkcs7 }, - cfg, + cfg, )); this.blockSize = 128 / 32; @@ -524,7 +465,7 @@ export class CipherParams extends Base { * * @example * - * let cipherParams =new CipherParams({ + * let cipherParams = new CipherParams({ * ciphertext: ciphertextWordArray, * key: keyWordArray, * iv: ivWordArray, @@ -590,7 +531,7 @@ export const OpenSSLFormatter = { // Format if (salt) { - wordArray =new WordArray([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); + wordArray = new WordArray([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); } else { wordArray = ciphertext; } @@ -623,7 +564,7 @@ export const OpenSSLFormatter = { // Test for salt if (ciphertextWords[0] === 0x53616c74 && ciphertextWords[1] === 0x65645f5f) { // Extract salt - salt =new WordArray(ciphertextWords.slice(2, 4)); + salt = new WordArray(ciphertextWords.slice(2, 4)); // Remove salt from ciphertext ciphertextWords.splice(0, 4); @@ -739,7 +680,7 @@ export class SerializableCipher extends Base { * ._parse(ciphertextStringOrParams, format); */ static _parse(ciphertext, format) { - if (typeof ciphertext === 'string') { + if (isString(ciphertext)) { return format.parse(ciphertext, this); } return ciphertext; @@ -755,8 +696,8 @@ export class SerializableCipher extends Base { */ SerializableCipher.cfg = Object.assign( new Base(), { - format: OpenSSLFormatter - }, + format: OpenSSLFormatter +}, ); /** @@ -790,12 +731,12 @@ export const OpenSSLKdf = { } // Derive key and IV - const key =new EvpKDFAlgo({ + const key = new EvpKDFAlgo({ keySize: keySize + ivSize }).compute(password, _salt); // Separate key and IV - const iv =new WordArray(key.words.slice(keySize), ivSize * 4); + const iv = new WordArray(key.words.slice(keySize), ivSize * 4); key.sigBytes = keySize * 4; // Return params diff --git a/src/core/core.js b/src/core/core.js new file mode 100644 index 0000000..e11ffb1 --- /dev/null +++ b/src/core/core.js @@ -0,0 +1,373 @@ +/* eslint-disable no-use-before-define */ + +/** + * Base class for inheritance. + */ +import { Utf8 } from '../encoding/enc-utf8'; +import { Hex } from '../encoding/enc-hax'; +import { isString } from '../utils'; + +export class Base { + + /** + * Copies properties into this object. + * + * @param {Object} properties The properties to mix in. + * + * @example + * + * MyType.mixIn({ + * field: 'value' + * }); + */ + mixIn(properties) { + return Object.assign(this, properties); + } + + /** + * Creates a copy of this object. + * + * @return {Object} The clone. + * + * @example + * + * let clone = instance.clone(); + */ + clone() { + const clone = new this.constructor(); + Object.assign(clone, this); + return clone; + } +} + +/** + * An array of 32-bit words. + * + * @property {Array} words The array of 32-bit words. + * @property {number} sigBytes The number of significant bytes in this word array. + */ +export class WordArray extends Base { + /** + * Initializes a newly created word array. + * + * @param {Array} words (Optional) An array of 32-bit words. + * @param {number} sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * let wordArray = new WordArray(); + * let wordArray = new WordArray([0x00010203, 0x04050607]); + * let wordArray = new WordArray([0x00010203, 0x04050607], 6); + */ + constructor(words = [], sigBytes = words.length * 4) { + super(); + + let typedArray = words; + // Convert buffers to uint8 + if (typedArray instanceof ArrayBuffer) { + typedArray = new Uint8Array(typedArray); + } + + // Convert other array views to uint8 + if ( + typedArray instanceof Int8Array + || typedArray instanceof Uint8ClampedArray + || typedArray instanceof Int16Array + || typedArray instanceof Uint16Array + || typedArray instanceof Int32Array + || typedArray instanceof Uint32Array + || typedArray instanceof Float32Array + || typedArray instanceof Float64Array + ) { + typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); + } + + // Handle Uint8Array + if (typedArray instanceof Uint8Array) { + // Shortcut + const typedArrayByteLength = typedArray.byteLength; + + // Extract bytes + const _words = []; + for (let i = 0; i < typedArrayByteLength; i++) { + _words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8); + } + + // Initialize this word array + this.words = _words; + this.sigBytes = typedArrayByteLength; + } else { + // Else call normal init + this.words = words; + this.sigBytes = sigBytes; + } + } + + /** + * Creates a word array filled with random bytes. + * + * @param {number} nBytes The number of random bytes to generate. + * + * @return {WordArray} The random word array. + * + * @static + * + * @example + * + * let wordArray = CryptoJS.lib.WordArray.random(16); + */ + static random(nBytes) { + const words = []; + + const r = (m_w) => { + let _m_w = m_w; + let _m_z = 0x3ade68b1; + const mask = 0xffffffff; + + return () => { + _m_z = (0x9069 * (_m_z & 0xFFFF) + (_m_z >> 0x10)) & mask; + _m_w = (0x4650 * (_m_w & 0xFFFF) + (_m_w >> 0x10)) & mask; + let result = ((_m_z << 0x10) + _m_w) & mask; + result /= 0x100000000; + result += 0.5; + return result * (Math.random() > 0.5 ? 1 : -1); + }; + }; + + for (let i = 0, rcache; i < nBytes; i += 4) { + const _r = r((rcache || Math.random()) * 0x100000000); + + rcache = _r() * 0x3ade67b7; + words.push((_r() * 0x100000000) | 0); + } + + return new WordArray(words, nBytes); + } + + /** + * Converts this word array to a string. + * + * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex + * + * @return {string} The stringified word array. + * + * @example + * + * let string = wordArray + ''; + * let string = wordArray.toString(); + * let string = wordArray.toString(CryptoJS.enc.Utf8); + */ + toString(encoder = Hex) { + return encoder.stringify(this); + } + + /** + * Concatenates a word array to this word array. + * + * @param {WordArray} wordArray The word array to append. + * + * @return {WordArray} This word array. + * + * @example + * + * wordArray1.concat(wordArray2); + */ + concat(wordArray) { + // Shortcuts + const thisWords = this.words; + const thatWords = wordArray.words; + const thisSigBytes = this.sigBytes; + const thatSigBytes = wordArray.sigBytes; + + // Clamp excess bits + this.clamp(); + + // Concat + if (thisSigBytes % 4) { + // Copy one byte at a time + for (let i = 0; i < thatSigBytes; i++) { + const thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8); + } + } else { + // Copy one word at a time + for (let i = 0; i < thatSigBytes; i += 4) { + thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2]; + } + } + this.sigBytes += thatSigBytes; + + // Chainable + return this; + } + + /** + * Removes insignificant bits. + * + * @example + * + * wordArray.clamp(); + */ + clamp() { + // Shortcuts + const { + words, + sigBytes + } = this; + + // Clamp + words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8); + words.length = Math.ceil(sigBytes / 4); + } + + /** + * Creates a copy of this word array. + * + * @return {WordArray} The clone. + * + * @example + * + * let clone = wordArray.clone(); + */ + clone() { + const clone = super.clone.call(this); + clone.words = this.words.slice(0); + + return clone; + } +} + + +/** + * Abstract buffered block algorithm template. + * + * The property blockSize must be implemented in a concrete subtype. + * + * @property {number} _minBufferSize + * + * The number of blocks that should be kept unprocessed in the buffer. Default: 0 + */ +export class BufferedBlockAlgorithm extends Base { + constructor() { + super(); + this._minBufferSize = 0; + } + + /** + * Resets this block algorithm's data buffer to its initial state. + * + * @example + * + * bufferedBlockAlgorithm.reset(); + */ + reset() { + // Initial values + this._data = new WordArray(); + this._nDataBytes = 0; + } + + /** + * Adds new data to this block algorithm's buffer. + * + * @param {WordArray|string} data + * + * The data to append. Strings are converted to a WordArray using UTF-8. + * + * @example + * + * bufferedBlockAlgorithm._append('data'); + * bufferedBlockAlgorithm._append(wordArray); + */ + _append(data) { + let m_data = data; + + // Convert string to WordArray, else assume WordArray already + if (isString(m_data)) { + m_data = Utf8.parse(m_data); + } + + // Append + this._data.concat(m_data); + this._nDataBytes += m_data.sigBytes; + } + + /** + * Processes available data blocks. + * + * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. + * + * @param {boolean} doFlush Whether all blocks and partial blocks should be processed. + * + * @return {WordArray} The processed data. + * + * @example + * + * let processedData = bufferedBlockAlgorithm._process(); + * let processedData = bufferedBlockAlgorithm._process(!!'flush'); + */ + _process(doFlush) { + let processedWords; + + // Shortcuts + const { + _data: data, + blockSize + } = this; + const dataWords = data.words; + const dataSigBytes = data.sigBytes; + const blockSizeBytes = blockSize * 4; + + // Count blocks ready + let nBlocksReady = dataSigBytes / blockSizeBytes; + if (doFlush) { + // Round up to include partial blocks + nBlocksReady = Math.ceil(nBlocksReady); + } else { + // Round down to include only full blocks, + // less the number of blocks that must remain in the buffer + nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0); + } + + // Count words ready + const nWordsReady = nBlocksReady * blockSize; + + // Count bytes ready + const nBytesReady = Math.min(nWordsReady * 4, dataSigBytes); + + // Process blocks + if (nWordsReady) { + for (let offset = 0; offset < nWordsReady; offset += blockSize) { + // Perform concrete-algorithm logic + this._doProcessBlock(dataWords, offset); + } + + // Remove processed words + processedWords = dataWords.splice(0, nWordsReady); + data.sigBytes -= nBytesReady; + } + + // Return processed words + return new WordArray(processedWords, nBytesReady); + } + + /** + * Creates a copy of this object. + * + * @return {Object} The clone. + * + * @example + * + * let clone = bufferedBlockAlgorithm.clone(); + */ + clone() { + const clone = super.clone.call(this); + clone._data = this._data.clone(); + + return clone; + } +} + + + + + diff --git a/src/core/hasher.js b/src/core/hasher.js new file mode 100644 index 0000000..44134f9 --- /dev/null +++ b/src/core/hasher.js @@ -0,0 +1,128 @@ +import {BufferedBlockAlgorithm, Base} from './core'; +import {HMAC} from '../algo/hmac/hmac'; + + +/** + * Abstract hasher template. + * + * @property {number} blockSize + * + * The number of 32-bit words this hasher operates on. Default: 16 (512 bits) + */ + +export class Hasher extends BufferedBlockAlgorithm { + + + + constructor(cfg) { + super(); + + this.blockSize = 512 / 32; + + /** + * Configuration options. + */ + this.cfg = Object.assign(new Base(), cfg); + + // Set initial values + this.reset(); + } + + /** + * Creates a shortcut function to a hasher's object interface. + * + * @param {Hasher} SubHasher The hasher to create a helper for. + * + * @return {Function} The shortcut function. + * + * @static + * + * @example + * + * let SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); + */ + static _createHelper(SubHasher) { + return (message, cfg) => new SubHasher(cfg).finalize(message); + } + + /** + * Creates a shortcut function to the HMAC's object interface. + * + * @param {Hasher} SubHasher The hasher to use in this HMAC helper. + * + * @return {Function} The shortcut function. + * + * @static + * + * @example + * + * let HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); + */ + static _createHmacHelper(SubHasher) { + return (message, key) => new HMAC(SubHasher, key).finalize(message); + } + + /** + * Resets this hasher to its initial state. + * + * @example + * + * hasher.reset(); + */ + reset() { + // Reset data buffer + super.reset.call(this); + + // Perform concrete-hasher logic + this._doReset(); + } + + /** + * Updates this hasher with a message. + * + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {Hasher} This hasher. + * + * @example + * + * hasher.update('message'); + * hasher.update(wordArray); + */ + update(messageUpdate) { + // Append + this._append(messageUpdate); + + // Update the hash + this._process(); + + // Chainable + return this; + } + + /** + * Finalizes the hash computation. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} messageUpdate (Optional) A final message update. + * + * @return {WordArray} The hash. + * + * @example + * + * let hash = hasher.finalize(); + * let hash = hasher.finalize('message'); + * let hash = hasher.finalize(wordArray); + */ + finalize(messageUpdate) { + // Final message update + if (messageUpdate) { + this._append(messageUpdate); + } + + // Perform concrete-hasher logic + const hash = this._doFinalize(); + + return hash; + } + } \ No newline at end of file diff --git a/src/x64-core.js b/src/core/x64-core.js similarity index 90% rename from src/x64-core.js rename to src/core/x64-core.js index 8fbcf22..22d601b 100644 --- a/src/x64-core.js +++ b/src/core/x64-core.js @@ -1,7 +1,7 @@ import { Base, WordArray -} from './core.js'; +} from '../core/core.js'; const X32WordArray = WordArray; @@ -42,14 +42,14 @@ export class X64WordArray extends Base { * * @example * - * let wordArray =new X64WordArray(); + * let wordArray = new X64WordArray(); * - * let wordArray =new X64WordArray([ + * let wordArray = new X64WordArray([ * new x64Word(0x00010203, 0x04050607), * new x64Word(0x18191a1b, 0x1c1d1e1f) * ]); * - * let wordArray =new X64WordArray([ + * let wordArray = new X64WordArray([ * new x64Word(0x00010203, 0x04050607), * new x64Word(0x18191a1b, 0x1c1d1e1f) * ], 10); @@ -77,7 +77,7 @@ export class X64WordArray extends Base { // Convert const x32Words = []; - for (let i = 0; i < x64WordsLength; i += 1) { + for (let i = 0; i < x64WordsLength; i++) { const x64Word = x64Words[i]; x32Words.push(x64Word.high); x32Words.push(x64Word.low); @@ -104,7 +104,7 @@ export class X64WordArray extends Base { // Clone each X64Word object const wordsLength = words.length; - for (let i = 0; i < wordsLength; i += 1) { + for (let i = 0; i < wordsLength; i++) { words[i] = words[i].clone(); } diff --git a/src/enc-base64.js b/src/encoding/enc-base64.js similarity index 90% rename from src/enc-base64.js rename to src/encoding/enc-base64.js index da41ad3..b22aee7 100644 --- a/src/enc-base64.js +++ b/src/encoding/enc-base64.js @@ -1,17 +1,17 @@ import { WordArray -} from './core.js'; +} from '../core/core.js'; const parseLoop = (base64Str, base64StrLength, reverseMap) => { const words = []; let nBytes = 0; - for (let i = 0; i < base64StrLength; i += 1) { + for (let i = 0; i < base64StrLength; i++) { if (i % 4) { const bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2); const bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2); const bitsCombined = bits1 | bits2; words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8); - nBytes += 1; + nBytes++; } } return new WordArray(words, nBytes); @@ -36,7 +36,10 @@ export const Base64 = { */ stringify(wordArray) { // Shortcuts - const { words, sigBytes } = wordArray; + const { + words, + sigBytes + } = wordArray; const map = this._map; // Clamp excess bits @@ -51,7 +54,7 @@ export const Base64 = { const triplet = (byte1 << 16) | (byte2 << 8) | byte3; - for (let j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j += 1) { + for (let j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); } } @@ -89,7 +92,7 @@ export const Base64 = { if (!reverseMap) { this._reverseMap = []; reverseMap = this._reverseMap; - for (let j = 0; j < map.length; j += 1) { + for (let j = 0; j < map.length; j++) { reverseMap[map.charCodeAt(j)] = j; } } @@ -108,4 +111,4 @@ export const Base64 = { }, _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' -}; +}; \ No newline at end of file diff --git a/src/encoding/enc-hax.js b/src/encoding/enc-hax.js new file mode 100644 index 0000000..ad333f4 --- /dev/null +++ b/src/encoding/enc-hax.js @@ -0,0 +1,65 @@ +import { + WordArray + } from '../core/core.js'; + + /** + * Hex encoding strategy. + */ +export const Hex = { + /** + * Converts a word array to a hex string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The hex string. + * + * @static + * + * @example + * + * let hexString = CryptoJS.enc.Hex.stringify(wordArray); + */ + stringify(wordArray) { + // Shortcuts + const { + words, + sigBytes + } = wordArray; + + // Convert + const hexChars = []; + for (let i = 0; i < sigBytes; i++) { + const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + hexChars.push((bite >>> 4).toString(16)); + hexChars.push((bite & 0x0f).toString(16)); + } + + return hexChars.join(''); + }, + + /** + * Converts a hex string to a word array. + * + * @param {string} hexStr The hex string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * let wordArray = CryptoJS.enc.Hex.parse(hexString); + */ + parse(hexStr) { + // Shortcut + const hexStrLength = hexStr.length; + + // Convert + const words = []; + for (let i = 0; i < hexStrLength; i += 2) { + words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); + } + + return new WordArray(words, hexStrLength / 2); + } + }; \ No newline at end of file diff --git a/src/encoding/enc-latin1.js b/src/encoding/enc-latin1.js new file mode 100644 index 0000000..ba05f20 --- /dev/null +++ b/src/encoding/enc-latin1.js @@ -0,0 +1,64 @@ +import { + WordArray + } from '../core/core.js'; + +/** + * Latin1 encoding strategy. + */ + export const Latin1 = { + /** + * Converts a word array to a Latin1 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Latin1 string. + * + * @static + * + * @example + * + * let latin1String = CryptoJS.enc.Latin1.stringify(wordArray); + */ + stringify(wordArray) { + // Shortcuts + const { + words, + sigBytes + } = wordArray; + + // Convert + const latin1Chars = []; + for (let i = 0; i < sigBytes; i++) { + const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + latin1Chars.push(String.fromCharCode(bite)); + } + + return latin1Chars.join(''); + }, + + /** + * Converts a Latin1 string to a word array. + * + * @param {string} latin1Str The Latin1 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * let wordArray = CryptoJS.enc.Latin1.parse(latin1String); + */ + parse(latin1Str) { + // Shortcut + const latin1StrLength = latin1Str.length; + + // Convert + const words = []; + for (let i = 0; i < latin1StrLength; i++) { + words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); + } + + return new WordArray(words, latin1StrLength); + } + }; \ No newline at end of file diff --git a/src/encoding/enc-utf16.js b/src/encoding/enc-utf16.js new file mode 100644 index 0000000..4ac5190 --- /dev/null +++ b/src/encoding/enc-utf16.js @@ -0,0 +1,122 @@ +import { + WordArray +} from '../core/core'; + +const swapEndian = word => ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff); + +/** + * UTF-16 BE encoding strategy. + */ +export const Utf16BE = { + /** + * Converts a word array to a UTF-16 BE string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-16 BE string. + * + * @static + * + * @example + * + * const utf16String = CryptoJS.enc.Utf16.stringify(wordArray); + */ + stringify(wordArray) { + // Shortcuts + const { words, sigBytes } = wordArray; + + // Convert + const utf16Chars = []; + for (let i = 0; i < sigBytes; i += 2) { + const codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff; + utf16Chars.push(String.fromCharCode(codePoint)); + } + + return utf16Chars.join(''); + }, + + /** + * Converts a UTF-16 BE string to a word array. + * + * @param {string} utf16Str The UTF-16 BE string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * const wordArray = CryptoJS.enc.Utf16.parse(utf16String); + */ + parse(utf16Str) { + // Shortcut + const utf16StrLength = utf16Str.length; + + // Convert + const words = []; + for (let i = 0; i < utf16StrLength; i++) { + words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16); + } + + return new WordArray(words, utf16StrLength * 2); + } +}; +export const Utf16 = Utf16BE; + +/** + * UTF-16 LE encoding strategy. + */ +export const Utf16LE = { + /** + * Converts a word array to a UTF-16 LE string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-16 LE string. + * + * @static + * + * @example + * + * const utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray); + */ + stringify(wordArray) { + // Shortcuts + const { words, sigBytes } = wordArray; + + // Convert + const utf16Chars = []; + for (let i = 0; i < sigBytes; i += 2) { + const codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff); + utf16Chars.push(String.fromCharCode(codePoint)); + } + + return utf16Chars.join(''); + }, + + /** + * Converts a UTF-16 LE string to a word array. + * + * @param {string} utf16Str The UTF-16 LE string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * const wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str); + */ + parse(utf16Str) { + // Shortcut + const utf16StrLength = utf16Str.length; + + // Convert + const words = []; + for (let i = 0; i < utf16StrLength; i++) { + words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16)); + } + + return new WordArray(words, utf16StrLength * 2); + } +}; diff --git a/src/encoding/enc-utf8.js b/src/encoding/enc-utf8.js new file mode 100644 index 0000000..e3a181e --- /dev/null +++ b/src/encoding/enc-utf8.js @@ -0,0 +1,47 @@ +import { + WordArray +} from '../core/core.js'; +import { Latin1 } from './enc-latin1.js'; + +/** +* UTF-8 encoding strategy. +*/ +export const Utf8 = { + /** + * Converts a word array to a UTF-8 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-8 string. + * + * @static + * + * @example + * + * let utf8String = CryptoJS.enc.Utf8.stringify(wordArray); + */ + stringify(wordArray) { + try { + return decodeURIComponent(escape(Latin1.stringify(wordArray))); + } catch (e) { + throw new Error('Malformed UTF-8 data'); + } + }, + + /** + * Converts a UTF-8 string to a word array. + * + * @param {string} utf8Str The UTF-8 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * let wordArray = CryptoJS.enc.Utf8.parse(utf8String); + */ + parse(utf8Str) { + return Latin1.parse(unescape(encodeURIComponent(utf8Str))); + } +}; \ No newline at end of file diff --git a/src/encryption/aes.js b/src/encryption/aes.js new file mode 100644 index 0000000..eee520d --- /dev/null +++ b/src/encryption/aes.js @@ -0,0 +1,283 @@ +import { + BlockCipher +} from '../core/cipher-core.js'; + +// Lookup tables +const _SBOX = []; +const INV_SBOX = []; +const _SUB_MIX_0 = []; +const _SUB_MIX_1 = []; +const _SUB_MIX_2 = []; +const _SUB_MIX_3 = []; +const INV_SUB_MIX_0 = []; +const INV_SUB_MIX_1 = []; +const INV_SUB_MIX_2 = []; +const INV_SUB_MIX_3 = []; + +// Compute lookup tables + +// Compute double table +const d = []; +for (let i = 0; i < 256; i++) { + if (i < 128) { + d[i] = i << 1; + } else { + d[i] = (i << 1) ^ 0x11b; + } +} + +// Walk GF(2^8) +let x = 0; +let xi = 0; +for (let i = 0; i < 256; i++) { + // Compute sbox + let sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4); + sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63; + _SBOX[x] = sx; + INV_SBOX[sx] = x; + + // Compute multiplication + const x2 = d[x]; + const x4 = d[x2]; + const x8 = d[x4]; + + // Compute sub bytes, mix columns tables + let t = (d[sx] * 0x101) ^ (sx * 0x1010100); + _SUB_MIX_0[x] = (t << 24) | (t >>> 8); + _SUB_MIX_1[x] = (t << 16) | (t >>> 16); + _SUB_MIX_2[x] = (t << 8) | (t >>> 24); + _SUB_MIX_3[x] = t; + + // Compute inv sub bytes, inv mix columns tables + t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100); + INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8); + INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16); + INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24); + INV_SUB_MIX_3[sx] = t; + + // Compute next counter + if (!x) { + xi = 1; + x = xi; + } else { + x = x2 ^ d[d[d[x8 ^ x2]]]; + xi ^= d[d[xi]]; + } +} + +// Precomputed Rcon lookup +const RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]; + +/** + * AES block cipher algorithm. + */ +export class AESAlgo extends BlockCipher { + constructor(...args) { + super(...args); + + this.keySize = 256 / 32; + } + + _doReset() { + let t; + + // Skip reset of nRounds has been set before and key did not change + if (this._nRounds && this._keyPriorReset === this._key) { + return; + } + + // Shortcuts + this._keyPriorReset = this._key; + const key = this._keyPriorReset; + const keyWords = key.words; + const keySize = key.sigBytes / 4; + + // Compute number of rounds + this._nRounds = keySize + 6; + const nRounds = this._nRounds; + + // Compute number of key schedule rows + const ksRows = (nRounds + 1) * 4; + + // Compute key schedule + this._keySchedule = []; + const keySchedule = this._keySchedule; + for (let ksRow = 0; ksRow < ksRows; ksRow++) { + if (ksRow < keySize) { + keySchedule[ksRow] = keyWords[ksRow]; + } else { + t = keySchedule[ksRow - 1]; + + if (!(ksRow % keySize)) { + // Rot word + t = (t << 8) | (t >>> 24); + + // Sub word + t = (_SBOX[t >>> 24] << 24) + | (_SBOX[(t >>> 16) & 0xff] << 16) + | (_SBOX[(t >>> 8) & 0xff] << 8) + | _SBOX[t & 0xff]; + + // Mix Rcon + t ^= RCON[(ksRow / keySize) | 0] << 24; + } else if (keySize > 6 && ksRow % keySize === 4) { + // Sub word + t = (_SBOX[t >>> 24] << 24) + | (_SBOX[(t >>> 16) & 0xff] << 16) + | (_SBOX[(t >>> 8) & 0xff] << 8) + | _SBOX[t & 0xff]; + } + + keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; + } + } + + // Compute inv key schedule + this._invKeySchedule = []; + const invKeySchedule = this._invKeySchedule; + for (let invKsRow = 0; invKsRow < ksRows; invKsRow++) { + const ksRow = ksRows - invKsRow; + + if (invKsRow % 4) { + t = keySchedule[ksRow]; + } else { + t = keySchedule[ksRow - 4]; + } + + if (invKsRow < 4 || ksRow <= 4) { + invKeySchedule[invKsRow] = t; + } else { + invKeySchedule[invKsRow] = INV_SUB_MIX_0[_SBOX[t >>> 24]] + ^ INV_SUB_MIX_1[_SBOX[(t >>> 16) & 0xff]] + ^ INV_SUB_MIX_2[_SBOX[(t >>> 8) & 0xff]] + ^ INV_SUB_MIX_3[_SBOX[t & 0xff]]; + } + } + } + + encryptBlock(M, offset) { + this._doCryptBlock( + M, offset, this._keySchedule, _SUB_MIX_0, _SUB_MIX_1, _SUB_MIX_2, _SUB_MIX_3, _SBOX, + ); + } + + decryptBlock(M, offset) { + const _M = M; + + // Swap 2nd and 4th rows + let t = _M[offset + 1]; + _M[offset + 1] = _M[offset + 3]; + _M[offset + 3] = t; + + this._doCryptBlock( + _M, + offset, + this._invKeySchedule, + INV_SUB_MIX_0, + INV_SUB_MIX_1, + INV_SUB_MIX_2, + INV_SUB_MIX_3, + INV_SBOX, + ); + + // Inv swap 2nd and 4th rows + t = _M[offset + 1]; + _M[offset + 1] = _M[offset + 3]; + _M[offset + 3] = t; + } + + _doCryptBlock(M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) { + const _M = M; + + // Shortcut + const nRounds = this._nRounds; + + // Get input, add round key + let s0 = _M[offset] ^ keySchedule[0]; + let s1 = _M[offset + 1] ^ keySchedule[1]; + let s2 = _M[offset + 2] ^ keySchedule[2]; + let s3 = _M[offset + 3] ^ keySchedule[3]; + + // Key schedule row counter + let ksRow = 4; + + // Rounds + for (let round = 1; round < nRounds; round++) { + // Shift rows, sub bytes, mix columns, add round key + const t0 = SUB_MIX_0[s0 >>> 24] + ^ SUB_MIX_1[(s1 >>> 16) & 0xff] + ^ SUB_MIX_2[(s2 >>> 8) & 0xff] + ^ SUB_MIX_3[s3 & 0xff] + ^ keySchedule[ksRow]; + ksRow++; + const t1 = SUB_MIX_0[s1 >>> 24] + ^ SUB_MIX_1[(s2 >>> 16) & 0xff] + ^ SUB_MIX_2[(s3 >>> 8) & 0xff] + ^ SUB_MIX_3[s0 & 0xff] + ^ keySchedule[ksRow]; + ksRow++; + const t2 = SUB_MIX_0[s2 >>> 24] + ^ SUB_MIX_1[(s3 >>> 16) & 0xff] + ^ SUB_MIX_2[(s0 >>> 8) & 0xff] + ^ SUB_MIX_3[s1 & 0xff] + ^ keySchedule[ksRow]; + ksRow++; + const t3 = SUB_MIX_0[s3 >>> 24] + ^ SUB_MIX_1[(s0 >>> 16) & 0xff] + ^ SUB_MIX_2[(s1 >>> 8) & 0xff] + ^ SUB_MIX_3[s2 & 0xff] + ^ keySchedule[ksRow]; + ksRow++; + + // Update state + s0 = t0; + s1 = t1; + s2 = t2; + s3 = t3; + } + + // Shift rows, sub bytes, add round key + const t0 = ( + (SBOX[s0 >>> 24] << 24) + | (SBOX[(s1 >>> 16) & 0xff] << 16) + | (SBOX[(s2 >>> 8) & 0xff] << 8) + | SBOX[s3 & 0xff] + ) ^ keySchedule[ksRow]; + ksRow++; + const t1 = ( + (SBOX[s1 >>> 24] << 24) + | (SBOX[(s2 >>> 16) & 0xff] << 16) + | (SBOX[(s3 >>> 8) & 0xff] << 8) + | SBOX[s0 & 0xff] + ) ^ keySchedule[ksRow]; + ksRow++; + const t2 = ( + (SBOX[s2 >>> 24] << 24) + | (SBOX[(s3 >>> 16) & 0xff] << 16) + | (SBOX[(s0 >>> 8) & 0xff] << 8) + | SBOX[s1 & 0xff] + ) ^ keySchedule[ksRow]; + ksRow++; + const t3 = ( + (SBOX[s3 >>> 24] << 24) + | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff] + ) ^ keySchedule[ksRow]; + ksRow++; + + // Set output + _M[offset] = t0; + _M[offset + 1] = t1; + _M[offset + 2] = t2; + _M[offset + 3] = t3; + } +} + +/** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg); + */ +export const AES = BlockCipher._createHelper(AESAlgo); diff --git a/src/evpkdf.js b/src/encryption/evpkdf.js similarity index 92% rename from src/evpkdf.js rename to src/encryption/evpkdf.js index 72304fe..3f06b01 100644 --- a/src/evpkdf.js +++ b/src/encryption/evpkdf.js @@ -1,8 +1,8 @@ import { Base, WordArray -} from './core.js'; -import { MD5Algo } from './md5.js'; +} from '../core/core.js'; +import { MD5Algo } from '../algo/hash/md5.js'; /** * This key derivation function is meant to conform with EVP_BytesToKey. @@ -37,7 +37,7 @@ export class EvpKDFAlgo extends Base { hasher: MD5Algo, iterations: 1 }, - cfg, + cfg ); } @@ -60,10 +60,10 @@ export class EvpKDFAlgo extends Base { const { cfg } = this; // Init hasher - const hasher =new cfg.hasher(); + const hasher = new cfg.hasher(); // Initial values - const derivedKey =new WordArray(); + const derivedKey = new WordArray(); // Shortcuts const derivedKeyWords = derivedKey.words; @@ -78,7 +78,7 @@ export class EvpKDFAlgo extends Base { hasher.reset(); // Iterations - for (let i = 1; i < iterations; i += 1) { + for (let i = 1; i < iterations; i++) { block = hasher.finalize(block); hasher.reset(); } diff --git a/src/encryption/rabbit-legacy.js b/src/encryption/rabbit-legacy.js new file mode 100644 index 0000000..8d1c02c --- /dev/null +++ b/src/encryption/rabbit-legacy.js @@ -0,0 +1,175 @@ +import { + StreamCipher +} from '../core/cipher-core.js'; + +// Reusable objects +const S = []; +const C_ = []; +const G = []; + +function nextState() { + // Shortcuts + const X = this._X; + const C = this._C; + + // Save old counter values + for (let i = 0; i < 8; i++) { + C_[i] = C[i]; + } + + // Calculate new counter values + C[0] = (C[0] + 0x4d34d34d + this._b) | 0; + C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0; + C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0; + C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0; + C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0; + C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0; + C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0; + C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0; + this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0; + + // Calculate the g-values + for (let i = 0; i < 8; i++) { + const gx = X[i] + C[i]; + + // Construct high and low argument for squaring + const ga = gx & 0xffff; + const gb = gx >>> 16; + + // Calculate high and low result of squaring + const gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; + const gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); + + // High XOR low + G[i] = gh ^ gl; + } + + // Calculate new state values + X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; + X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; + X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; + X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; + X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; + X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; + X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; + X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; +} + +/** + * Rabbit stream cipher algorithm. + * + * This is a legacy version that neglected to convert the key to little-endian. + * This error doesn't affect the cipher's security, + * but it does affect its compatibility with other implementations. + */ +export class RabbitLegacyAlgo extends StreamCipher { + constructor(...args) { + super(...args); + + this.blockSize = 128 / 32; + this.ivSize = 64 / 32; + } + + _doReset() { + // Shortcuts + const K = this._key.words; + const { iv } = this.cfg; + + // Generate initial state values + this._X = [ + K[0], (K[3] << 16) | (K[2] >>> 16), + K[1], (K[0] << 16) | (K[3] >>> 16), + K[2], (K[1] << 16) | (K[0] >>> 16), + K[3], (K[2] << 16) | (K[1] >>> 16), + ]; + const X = this._X; + + // Generate initial counter values + this._C = [ + (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), + (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), + (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), + (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff), + ]; + const C = this._C; + + // Carry bit + this._b = 0; + + // Iterate the system four times + for (let i = 0; i < 4; i++) { + nextState.call(this); + } + + // Modify the counters + for (let i = 0; i < 8; i++) { + C[i] ^= X[(i + 4) & 7]; + } + + // IV setup + if (iv) { + // Shortcuts + const IV = iv.words; + const IV_0 = IV[0]; + const IV_1 = IV[1]; + + // Generate four subvectors + const i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) + | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); + const i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) + | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); + const i1 = (i0 >>> 16) | (i2 & 0xffff0000); + const i3 = (i2 << 16) | (i0 & 0x0000ffff); + + // Modify counter values + C[0] ^= i0; + C[1] ^= i1; + C[2] ^= i2; + C[3] ^= i3; + C[4] ^= i0; + C[5] ^= i1; + C[6] ^= i2; + C[7] ^= i3; + + // Iterate the system four times + for (let i = 0; i < 4; i++) { + nextState.call(this); + } + } + } + + _doProcessBlock(M, offset) { + const _M = M; + + // Shortcut + const X = this._X; + + // Iterate the system + nextState.call(this); + + // Generate four keystream words + S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); + S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); + S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); + S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); + + for (let i = 0; i < 4; i++) { + // Swap endian + S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) + | (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00); + + // Encrypt + _M[offset + i] ^= S[i]; + } + } +} + +/** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg); + */ +export const RabbitLegacy = StreamCipher._createHelper(RabbitLegacyAlgo); diff --git a/src/encryption/rabbit.js b/src/encryption/rabbit.js new file mode 100644 index 0000000..83e1917 --- /dev/null +++ b/src/encryption/rabbit.js @@ -0,0 +1,177 @@ +import { + StreamCipher +} from '../core/cipher-core.js'; + +// Reusable objects +const S = []; +const C_ = []; +const G = []; + +function nextState() { + // Shortcuts + const X = this._X; + const C = this._C; + + // Save old counter values + for (let i = 0; i < 8; i++) { + C_[i] = C[i]; + } + + // Calculate new counter values + C[0] = (C[0] + 0x4d34d34d + this._b) | 0; + C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0; + C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0; + C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0; + C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0; + C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0; + C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0; + C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0; + this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0; + + // Calculate the g-values + for (let i = 0; i < 8; i++) { + const gx = X[i] + C[i]; + + // Construct high and low argument for squaring + const ga = gx & 0xffff; + const gb = gx >>> 16; + + // Calculate high and low result of squaring + const gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; + const gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); + + // High XOR low + G[i] = gh ^ gl; + } + + // Calculate new state values + X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; + X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; + X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; + X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; + X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; + X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; + X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; + X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; +} + +/** + * Rabbit stream cipher algorithm + */ +export class RabbitAlgo extends StreamCipher { + constructor(...args) { + super(...args); + + this.blockSize = 128 / 32; + this.ivSize = 64 / 32; + } + + _doReset() { + // Shortcuts + const K = this._key.words; + const { iv } = this.cfg; + + // Swap endian + for (let i = 0; i < 4; i++) { + K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) + | (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00); + } + + // Generate initial state values + this._X = [ + K[0], (K[3] << 16) | (K[2] >>> 16), + K[1], (K[0] << 16) | (K[3] >>> 16), + K[2], (K[1] << 16) | (K[0] >>> 16), + K[3], (K[2] << 16) | (K[1] >>> 16), + ]; + const X = this._X; + + // Generate initial counter values + this._C = [ + (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), + (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), + (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), + (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff), + ]; + const C = this._C; + + // Carry bit + this._b = 0; + + // Iterate the system four times + for (let i = 0; i < 4; i++) { + nextState.call(this); + } + + // Modify the counters + for (let i = 0; i < 8; i++) { + C[i] ^= X[(i + 4) & 7]; + } + + // IV setup + if (iv) { + // Shortcuts + const IV = iv.words; + const IV_0 = IV[0]; + const IV_1 = IV[1]; + + // Generate four subvectors + const i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) + | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); + const i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) + | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); + const i1 = (i0 >>> 16) | (i2 & 0xffff0000); + const i3 = (i2 << 16) | (i0 & 0x0000ffff); + + // Modify counter values + C[0] ^= i0; + C[1] ^= i1; + C[2] ^= i2; + C[3] ^= i3; + C[4] ^= i0; + C[5] ^= i1; + C[6] ^= i2; + C[7] ^= i3; + + // Iterate the system four times + for (let i = 0; i < 4; i++) { + nextState.call(this); + } + } + } + + _doProcessBlock(M, offset) { + const _M = M; + + // Shortcut + const X = this._X; + + // Iterate the system + nextState.call(this); + + // Generate four keystream words + S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); + S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); + S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); + S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); + + for (let i = 0; i < 4; i++) { + // Swap endian + S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) + | (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00); + + // Encrypt + _M[offset + i] ^= S[i]; + } + } +} + +/** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg); + * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg); + */ +export const Rabbit = StreamCipher._createHelper(RabbitAlgo); diff --git a/src/encryption/rc4.js b/src/encryption/rc4.js new file mode 100644 index 0000000..aa15044 --- /dev/null +++ b/src/encryption/rc4.js @@ -0,0 +1,124 @@ +import { + StreamCipher +} from '../core/cipher-core.js'; + +function generateKeystreamWord() { + // Shortcuts + const S = this._S; + let i = this._i; + let j = this._j; + + // Generate keystream word + let keystreamWord = 0; + for (let n = 0; n < 4; n++) { + i = (i + 1) % 256; + j = (j + S[i]) % 256; + + // Swap + const t = S[i]; + S[i] = S[j]; + S[j] = t; + + keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8); + } + + // Update counters + this._i = i; + this._j = j; + + return keystreamWord; +} + +/** + * RC4 stream cipher algorithm. + */ +export class RC4Algo extends StreamCipher { + constructor(...args) { + super(...args); + + this.keySize = 256 / 32; + this.ivSize = 0; + } + + _doReset() { + // Shortcuts + const key = this._key; + const keyWords = key.words; + const keySigBytes = key.sigBytes; + + // Init sbox + this._S = []; + const S = this._S; + for (let i = 0; i < 256; i++) { + S[i] = i; + } + + // Key setup + for (let i = 0, j = 0; i < 256; i++) { + const keyByteIndex = i % keySigBytes; + const keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff; + + j = (j + S[i] + keyByte) % 256; + + // Swap + const t = S[i]; + S[i] = S[j]; + S[j] = t; + } + + // Counters + this._j = 0; + this._i = this._j; + } + + _doProcessBlock(M, offset) { + const _M = M; + + _M[offset] ^= generateKeystreamWord.call(this); + } +} + +/** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg); + */ +export const RC4 = StreamCipher._createHelper(RC4Algo); + +/** + * Modified RC4 stream cipher algorithm. + */ +export class RC4DropAlgo extends RC4Algo { + constructor(...args) { + super(...args); + + /** + * Configuration options. + * + * @property {number} drop The number of keystream words to drop. Default 192 + */ + Object.assign(this.cfg, { drop: 192 }); + } + + _doReset() { + super._doReset.call(this); + + // Drop + for (let i = this.cfg.drop; i > 0; i--) { + generateKeystreamWord.call(this); + } + } +} + +/** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg); + */ +export const RC4Drop = StreamCipher._createHelper(RC4DropAlgo); diff --git a/src/encryption/tripledes.js b/src/encryption/tripledes.js new file mode 100644 index 0000000..678d383 --- /dev/null +++ b/src/encryption/tripledes.js @@ -0,0 +1,759 @@ +import { + WordArray +} from '../core/core.js'; +import { + BlockCipher +} from '../core/cipher-core.js'; + +// Permuted Choice 1 constants +const PC1 = [ + 57, 49, 41, 33, 25, 17, 9, 1, + 58, 50, 42, 34, 26, 18, 10, 2, + 59, 51, 43, 35, 27, 19, 11, 3, + 60, 52, 44, 36, 63, 55, 47, 39, + 31, 23, 15, 7, 62, 54, 46, 38, + 30, 22, 14, 6, 61, 53, 45, 37, + 29, 21, 13, 5, 28, 20, 12, 4, +]; + +// Permuted Choice 2 constants +const PC2 = [ + 14, 17, 11, 24, 1, 5, + 3, 28, 15, 6, 21, 10, + 23, 19, 12, 4, 26, 8, + 16, 7, 27, 20, 13, 2, + 41, 52, 31, 37, 47, 55, + 30, 40, 51, 45, 33, 48, + 44, 49, 39, 56, 34, 53, + 46, 42, 50, 36, 29, 32, +]; + +// Cumulative bit shift constants +const BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28]; + +// SBOXes and round permutation constants +const SBOX_P = [ + { + 0x0: 0x808200, + 0x10000000: 0x8000, + 0x20000000: 0x808002, + 0x30000000: 0x2, + 0x40000000: 0x200, + 0x50000000: 0x808202, + 0x60000000: 0x800202, + 0x70000000: 0x800000, + 0x80000000: 0x202, + 0x90000000: 0x800200, + 0xa0000000: 0x8200, + 0xb0000000: 0x808000, + 0xc0000000: 0x8002, + 0xd0000000: 0x800002, + 0xe0000000: 0x0, + 0xf0000000: 0x8202, + 0x8000000: 0x0, + 0x18000000: 0x808202, + 0x28000000: 0x8202, + 0x38000000: 0x8000, + 0x48000000: 0x808200, + 0x58000000: 0x200, + 0x68000000: 0x808002, + 0x78000000: 0x2, + 0x88000000: 0x800200, + 0x98000000: 0x8200, + 0xa8000000: 0x808000, + 0xb8000000: 0x800202, + 0xc8000000: 0x800002, + 0xd8000000: 0x8002, + 0xe8000000: 0x202, + 0xf8000000: 0x800000, + 0x1: 0x8000, + 0x10000001: 0x2, + 0x20000001: 0x808200, + 0x30000001: 0x800000, + 0x40000001: 0x808002, + 0x50000001: 0x8200, + 0x60000001: 0x200, + 0x70000001: 0x800202, + 0x80000001: 0x808202, + 0x90000001: 0x808000, + 0xa0000001: 0x800002, + 0xb0000001: 0x8202, + 0xc0000001: 0x202, + 0xd0000001: 0x800200, + 0xe0000001: 0x8002, + 0xf0000001: 0x0, + 0x8000001: 0x808202, + 0x18000001: 0x808000, + 0x28000001: 0x800000, + 0x38000001: 0x200, + 0x48000001: 0x8000, + 0x58000001: 0x800002, + 0x68000001: 0x2, + 0x78000001: 0x8202, + 0x88000001: 0x8002, + 0x98000001: 0x800202, + 0xa8000001: 0x202, + 0xb8000001: 0x808200, + 0xc8000001: 0x800200, + 0xd8000001: 0x0, + 0xe8000001: 0x8200, + 0xf8000001: 0x808002 + }, + { + 0x0: 0x40084010, + 0x1000000: 0x4000, + 0x2000000: 0x80000, + 0x3000000: 0x40080010, + 0x4000000: 0x40000010, + 0x5000000: 0x40084000, + 0x6000000: 0x40004000, + 0x7000000: 0x10, + 0x8000000: 0x84000, + 0x9000000: 0x40004010, + 0xa000000: 0x40000000, + 0xb000000: 0x84010, + 0xc000000: 0x80010, + 0xd000000: 0x0, + 0xe000000: 0x4010, + 0xf000000: 0x40080000, + 0x800000: 0x40004000, + 0x1800000: 0x84010, + 0x2800000: 0x10, + 0x3800000: 0x40004010, + 0x4800000: 0x40084010, + 0x5800000: 0x40000000, + 0x6800000: 0x80000, + 0x7800000: 0x40080010, + 0x8800000: 0x80010, + 0x9800000: 0x0, + 0xa800000: 0x4000, + 0xb800000: 0x40080000, + 0xc800000: 0x40000010, + 0xd800000: 0x84000, + 0xe800000: 0x40084000, + 0xf800000: 0x4010, + 0x10000000: 0x0, + 0x11000000: 0x40080010, + 0x12000000: 0x40004010, + 0x13000000: 0x40084000, + 0x14000000: 0x40080000, + 0x15000000: 0x10, + 0x16000000: 0x84010, + 0x17000000: 0x4000, + 0x18000000: 0x4010, + 0x19000000: 0x80000, + 0x1a000000: 0x80010, + 0x1b000000: 0x40000010, + 0x1c000000: 0x84000, + 0x1d000000: 0x40004000, + 0x1e000000: 0x40000000, + 0x1f000000: 0x40084010, + 0x10800000: 0x84010, + 0x11800000: 0x80000, + 0x12800000: 0x40080000, + 0x13800000: 0x4000, + 0x14800000: 0x40004000, + 0x15800000: 0x40084010, + 0x16800000: 0x10, + 0x17800000: 0x40000000, + 0x18800000: 0x40084000, + 0x19800000: 0x40000010, + 0x1a800000: 0x40004010, + 0x1b800000: 0x80010, + 0x1c800000: 0x0, + 0x1d800000: 0x4010, + 0x1e800000: 0x40080010, + 0x1f800000: 0x84000 + }, + { + 0x0: 0x104, + 0x100000: 0x0, + 0x200000: 0x4000100, + 0x300000: 0x10104, + 0x400000: 0x10004, + 0x500000: 0x4000004, + 0x600000: 0x4010104, + 0x700000: 0x4010000, + 0x800000: 0x4000000, + 0x900000: 0x4010100, + 0xa00000: 0x10100, + 0xb00000: 0x4010004, + 0xc00000: 0x4000104, + 0xd00000: 0x10000, + 0xe00000: 0x4, + 0xf00000: 0x100, + 0x80000: 0x4010100, + 0x180000: 0x4010004, + 0x280000: 0x0, + 0x380000: 0x4000100, + 0x480000: 0x4000004, + 0x580000: 0x10000, + 0x680000: 0x10004, + 0x780000: 0x104, + 0x880000: 0x4, + 0x980000: 0x100, + 0xa80000: 0x4010000, + 0xb80000: 0x10104, + 0xc80000: 0x10100, + 0xd80000: 0x4000104, + 0xe80000: 0x4010104, + 0xf80000: 0x4000000, + 0x1000000: 0x4010100, + 0x1100000: 0x10004, + 0x1200000: 0x10000, + 0x1300000: 0x4000100, + 0x1400000: 0x100, + 0x1500000: 0x4010104, + 0x1600000: 0x4000004, + 0x1700000: 0x0, + 0x1800000: 0x4000104, + 0x1900000: 0x4000000, + 0x1a00000: 0x4, + 0x1b00000: 0x10100, + 0x1c00000: 0x4010000, + 0x1d00000: 0x104, + 0x1e00000: 0x10104, + 0x1f00000: 0x4010004, + 0x1080000: 0x4000000, + 0x1180000: 0x104, + 0x1280000: 0x4010100, + 0x1380000: 0x0, + 0x1480000: 0x10004, + 0x1580000: 0x4000100, + 0x1680000: 0x100, + 0x1780000: 0x4010004, + 0x1880000: 0x10000, + 0x1980000: 0x4010104, + 0x1a80000: 0x10104, + 0x1b80000: 0x4000004, + 0x1c80000: 0x4000104, + 0x1d80000: 0x4010000, + 0x1e80000: 0x4, + 0x1f80000: 0x10100 + }, + { + 0x0: 0x80401000, + 0x10000: 0x80001040, + 0x20000: 0x401040, + 0x30000: 0x80400000, + 0x40000: 0x0, + 0x50000: 0x401000, + 0x60000: 0x80000040, + 0x70000: 0x400040, + 0x80000: 0x80000000, + 0x90000: 0x400000, + 0xa0000: 0x40, + 0xb0000: 0x80001000, + 0xc0000: 0x80400040, + 0xd0000: 0x1040, + 0xe0000: 0x1000, + 0xf0000: 0x80401040, + 0x8000: 0x80001040, + 0x18000: 0x40, + 0x28000: 0x80400040, + 0x38000: 0x80001000, + 0x48000: 0x401000, + 0x58000: 0x80401040, + 0x68000: 0x0, + 0x78000: 0x80400000, + 0x88000: 0x1000, + 0x98000: 0x80401000, + 0xa8000: 0x400000, + 0xb8000: 0x1040, + 0xc8000: 0x80000000, + 0xd8000: 0x400040, + 0xe8000: 0x401040, + 0xf8000: 0x80000040, + 0x100000: 0x400040, + 0x110000: 0x401000, + 0x120000: 0x80000040, + 0x130000: 0x0, + 0x140000: 0x1040, + 0x150000: 0x80400040, + 0x160000: 0x80401000, + 0x170000: 0x80001040, + 0x180000: 0x80401040, + 0x190000: 0x80000000, + 0x1a0000: 0x80400000, + 0x1b0000: 0x401040, + 0x1c0000: 0x80001000, + 0x1d0000: 0x400000, + 0x1e0000: 0x40, + 0x1f0000: 0x1000, + 0x108000: 0x80400000, + 0x118000: 0x80401040, + 0x128000: 0x0, + 0x138000: 0x401000, + 0x148000: 0x400040, + 0x158000: 0x80000000, + 0x168000: 0x80001040, + 0x178000: 0x40, + 0x188000: 0x80000040, + 0x198000: 0x1000, + 0x1a8000: 0x80001000, + 0x1b8000: 0x80400040, + 0x1c8000: 0x1040, + 0x1d8000: 0x80401000, + 0x1e8000: 0x400000, + 0x1f8000: 0x401040 + }, + { + 0x0: 0x80, + 0x1000: 0x1040000, + 0x2000: 0x40000, + 0x3000: 0x20000000, + 0x4000: 0x20040080, + 0x5000: 0x1000080, + 0x6000: 0x21000080, + 0x7000: 0x40080, + 0x8000: 0x1000000, + 0x9000: 0x20040000, + 0xa000: 0x20000080, + 0xb000: 0x21040080, + 0xc000: 0x21040000, + 0xd000: 0x0, + 0xe000: 0x1040080, + 0xf000: 0x21000000, + 0x800: 0x1040080, + 0x1800: 0x21000080, + 0x2800: 0x80, + 0x3800: 0x1040000, + 0x4800: 0x40000, + 0x5800: 0x20040080, + 0x6800: 0x21040000, + 0x7800: 0x20000000, + 0x8800: 0x20040000, + 0x9800: 0x0, + 0xa800: 0x21040080, + 0xb800: 0x1000080, + 0xc800: 0x20000080, + 0xd800: 0x21000000, + 0xe800: 0x1000000, + 0xf800: 0x40080, + 0x10000: 0x40000, + 0x11000: 0x80, + 0x12000: 0x20000000, + 0x13000: 0x21000080, + 0x14000: 0x1000080, + 0x15000: 0x21040000, + 0x16000: 0x20040080, + 0x17000: 0x1000000, + 0x18000: 0x21040080, + 0x19000: 0x21000000, + 0x1a000: 0x1040000, + 0x1b000: 0x20040000, + 0x1c000: 0x40080, + 0x1d000: 0x20000080, + 0x1e000: 0x0, + 0x1f000: 0x1040080, + 0x10800: 0x21000080, + 0x11800: 0x1000000, + 0x12800: 0x1040000, + 0x13800: 0x20040080, + 0x14800: 0x20000000, + 0x15800: 0x1040080, + 0x16800: 0x80, + 0x17800: 0x21040000, + 0x18800: 0x40080, + 0x19800: 0x21040080, + 0x1a800: 0x0, + 0x1b800: 0x21000000, + 0x1c800: 0x1000080, + 0x1d800: 0x40000, + 0x1e800: 0x20040000, + 0x1f800: 0x20000080 + }, + { + 0x0: 0x10000008, + 0x100: 0x2000, + 0x200: 0x10200000, + 0x300: 0x10202008, + 0x400: 0x10002000, + 0x500: 0x200000, + 0x600: 0x200008, + 0x700: 0x10000000, + 0x800: 0x0, + 0x900: 0x10002008, + 0xa00: 0x202000, + 0xb00: 0x8, + 0xc00: 0x10200008, + 0xd00: 0x202008, + 0xe00: 0x2008, + 0xf00: 0x10202000, + 0x80: 0x10200000, + 0x180: 0x10202008, + 0x280: 0x8, + 0x380: 0x200000, + 0x480: 0x202008, + 0x580: 0x10000008, + 0x680: 0x10002000, + 0x780: 0x2008, + 0x880: 0x200008, + 0x980: 0x2000, + 0xa80: 0x10002008, + 0xb80: 0x10200008, + 0xc80: 0x0, + 0xd80: 0x10202000, + 0xe80: 0x202000, + 0xf80: 0x10000000, + 0x1000: 0x10002000, + 0x1100: 0x10200008, + 0x1200: 0x10202008, + 0x1300: 0x2008, + 0x1400: 0x200000, + 0x1500: 0x10000000, + 0x1600: 0x10000008, + 0x1700: 0x202000, + 0x1800: 0x202008, + 0x1900: 0x0, + 0x1a00: 0x8, + 0x1b00: 0x10200000, + 0x1c00: 0x2000, + 0x1d00: 0x10002008, + 0x1e00: 0x10202000, + 0x1f00: 0x200008, + 0x1080: 0x8, + 0x1180: 0x202000, + 0x1280: 0x200000, + 0x1380: 0x10000008, + 0x1480: 0x10002000, + 0x1580: 0x2008, + 0x1680: 0x10202008, + 0x1780: 0x10200000, + 0x1880: 0x10202000, + 0x1980: 0x10200008, + 0x1a80: 0x2000, + 0x1b80: 0x202008, + 0x1c80: 0x200008, + 0x1d80: 0x0, + 0x1e80: 0x10000000, + 0x1f80: 0x10002008 + }, + { + 0x0: 0x100000, + 0x10: 0x2000401, + 0x20: 0x400, + 0x30: 0x100401, + 0x40: 0x2100401, + 0x50: 0x0, + 0x60: 0x1, + 0x70: 0x2100001, + 0x80: 0x2000400, + 0x90: 0x100001, + 0xa0: 0x2000001, + 0xb0: 0x2100400, + 0xc0: 0x2100000, + 0xd0: 0x401, + 0xe0: 0x100400, + 0xf0: 0x2000000, + 0x8: 0x2100001, + 0x18: 0x0, + 0x28: 0x2000401, + 0x38: 0x2100400, + 0x48: 0x100000, + 0x58: 0x2000001, + 0x68: 0x2000000, + 0x78: 0x401, + 0x88: 0x100401, + 0x98: 0x2000400, + 0xa8: 0x2100000, + 0xb8: 0x100001, + 0xc8: 0x400, + 0xd8: 0x2100401, + 0xe8: 0x1, + 0xf8: 0x100400, + 0x100: 0x2000000, + 0x110: 0x100000, + 0x120: 0x2000401, + 0x130: 0x2100001, + 0x140: 0x100001, + 0x150: 0x2000400, + 0x160: 0x2100400, + 0x170: 0x100401, + 0x180: 0x401, + 0x190: 0x2100401, + 0x1a0: 0x100400, + 0x1b0: 0x1, + 0x1c0: 0x0, + 0x1d0: 0x2100000, + 0x1e0: 0x2000001, + 0x1f0: 0x400, + 0x108: 0x100400, + 0x118: 0x2000401, + 0x128: 0x2100001, + 0x138: 0x1, + 0x148: 0x2000000, + 0x158: 0x100000, + 0x168: 0x401, + 0x178: 0x2100400, + 0x188: 0x2000001, + 0x198: 0x2100000, + 0x1a8: 0x0, + 0x1b8: 0x2100401, + 0x1c8: 0x100401, + 0x1d8: 0x400, + 0x1e8: 0x2000400, + 0x1f8: 0x100001 + }, + { + 0x0: 0x8000820, + 0x1: 0x20000, + 0x2: 0x8000000, + 0x3: 0x20, + 0x4: 0x20020, + 0x5: 0x8020820, + 0x6: 0x8020800, + 0x7: 0x800, + 0x8: 0x8020000, + 0x9: 0x8000800, + 0xa: 0x20800, + 0xb: 0x8020020, + 0xc: 0x820, + 0xd: 0x0, + 0xe: 0x8000020, + 0xf: 0x20820, + 0x80000000: 0x800, + 0x80000001: 0x8020820, + 0x80000002: 0x8000820, + 0x80000003: 0x8000000, + 0x80000004: 0x8020000, + 0x80000005: 0x20800, + 0x80000006: 0x20820, + 0x80000007: 0x20, + 0x80000008: 0x8000020, + 0x80000009: 0x820, + 0x8000000a: 0x20020, + 0x8000000b: 0x8020800, + 0x8000000c: 0x0, + 0x8000000d: 0x8020020, + 0x8000000e: 0x8000800, + 0x8000000f: 0x20000, + 0x10: 0x20820, + 0x11: 0x8020800, + 0x12: 0x20, + 0x13: 0x800, + 0x14: 0x8000800, + 0x15: 0x8000020, + 0x16: 0x8020020, + 0x17: 0x20000, + 0x18: 0x0, + 0x19: 0x20020, + 0x1a: 0x8020000, + 0x1b: 0x8000820, + 0x1c: 0x8020820, + 0x1d: 0x20800, + 0x1e: 0x820, + 0x1f: 0x8000000, + 0x80000010: 0x20000, + 0x80000011: 0x800, + 0x80000012: 0x8020020, + 0x80000013: 0x20820, + 0x80000014: 0x20, + 0x80000015: 0x8020000, + 0x80000016: 0x8000000, + 0x80000017: 0x8000820, + 0x80000018: 0x8020820, + 0x80000019: 0x8000020, + 0x8000001a: 0x8000800, + 0x8000001b: 0x0, + 0x8000001c: 0x20800, + 0x8000001d: 0x820, + 0x8000001e: 0x20020, + 0x8000001f: 0x8020800 + } +]; + +// Masks that select the SBOX input +const SBOX_MASK = [ + 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000, + 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f +]; + +// Swap bits across the left and right words +function exchangeLR(offset, mask) { + const t = ((this._lBlock >>> offset) ^ this._rBlock) & mask; + this._rBlock ^= t; + this._lBlock ^= t << offset; +} + +function exchangeRL(offset, mask) { + const t = ((this._rBlock >>> offset) ^ this._lBlock) & mask; + this._lBlock ^= t; + this._rBlock ^= t << offset; +} + +/** + * DES block cipher algorithm. + */ +export class DESAlgo extends BlockCipher { + constructor(...args) { + super(...args); + + this.keySize = 64 / 32; + this.ivSize = 64 / 32; + this.blockSize = 64 / 32; + } + + _doReset() { + // Shortcuts + const key = this._key; + const keyWords = key.words; + + // Select 56 bits according to PC1 + const keyBits = []; + for (let i = 0; i < 56; i++) { + const keyBitPos = PC1[i] - 1; + keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - (keyBitPos % 32))) & 1; + } + + // Assemble 16 subkeys + this._subKeys = []; + const subKeys = this._subKeys; + for (let nSubKey = 0; nSubKey < 16; nSubKey++) { + // Create subkey + subKeys[nSubKey] = []; + const subKey = subKeys[nSubKey]; + + // Shortcut + const bitShift = BIT_SHIFTS[nSubKey]; + + // Select 48 bits according to PC2 + for (let i = 0; i < 24; i++) { + // Select from the left 28 key bits + subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - (i % 6)); + + // Select from the right 28 key bits + subKey[4 + ((i / 6) | 0)] + |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] + << (31 - (i % 6)); + } + + // Since each subkey is applied to an expanded 32-bit input, + // the subkey can be broken into 8 values scaled to 32-bits, + // which allows the key to be used without expansion + subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31); + for (let i = 1; i < 7; i++) { + subKey[i] >>>= ((i - 1) * 4 + 3); + } + subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27); + } + + // Compute inverse subkeys + this._invSubKeys = []; + const invSubKeys = this._invSubKeys; + for (let i = 0; i < 16; i++) { + invSubKeys[i] = subKeys[15 - i]; + } + } + + encryptBlock(M, offset) { + this._doCryptBlock(M, offset, this._subKeys); + } + + decryptBlock(M, offset) { + this._doCryptBlock(M, offset, this._invSubKeys); + } + + _doCryptBlock(M, offset, subKeys) { + const _M = M; + + // Get input + this._lBlock = M[offset]; + this._rBlock = M[offset + 1]; + + // Initial permutation + exchangeLR.call(this, 4, 0x0f0f0f0f); + exchangeLR.call(this, 16, 0x0000ffff); + exchangeRL.call(this, 2, 0x33333333); + exchangeRL.call(this, 8, 0x00ff00ff); + exchangeLR.call(this, 1, 0x55555555); + + // Rounds + for (let round = 0; round < 16; round++) { + // Shortcuts + const subKey = subKeys[round]; + const lBlock = this._lBlock; + const rBlock = this._rBlock; + + // Feistel function + let f = 0; + for (let i = 0; i < 8; i++) { + f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0]; + } + this._lBlock = rBlock; + this._rBlock = lBlock ^ f; + } + + // Undo swap from last round + const t = this._lBlock; + this._lBlock = this._rBlock; + this._rBlock = t; + + // Final permutation + exchangeLR.call(this, 1, 0x55555555); + exchangeRL.call(this, 8, 0x00ff00ff); + exchangeRL.call(this, 2, 0x33333333); + exchangeLR.call(this, 16, 0x0000ffff); + exchangeLR.call(this, 4, 0x0f0f0f0f); + + // Set output + _M[offset] = this._lBlock; + _M[offset + 1] = this._rBlock; + } +} + +/** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg); + */ +export const DES = BlockCipher._createHelper(DESAlgo); + +/** + * Triple-DES block cipher algorithm. + */ +export class TripleDESAlgo extends BlockCipher { + constructor(...args) { + super(...args); + + this.keySize = 192 / 32; + this.ivSize = 64 / 32; + this.blockSize = 64 / 32; + } + + _doReset() { + // Shortcuts + const key = this._key; + const keyWords = key.words; + + // Create DES instances + this._des1 = DESAlgo.createEncryptor(new WordArray(keyWords.slice(0, 2))); + this._des2 = DESAlgo.createEncryptor(new WordArray(keyWords.slice(2, 4))); + this._des3 = DESAlgo.createEncryptor(new WordArray(keyWords.slice(4, 6))); + } + + encryptBlock(M, offset) { + this._des1.encryptBlock(M, offset); + this._des2.decryptBlock(M, offset); + this._des3.encryptBlock(M, offset); + } + + decryptBlock(M, offset) { + this._des3.decryptBlock(M, offset); + this._des2.encryptBlock(M, offset); + this._des1.decryptBlock(M, offset); + } +} + +/** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg); + */ +export const TripleDES = BlockCipher._createHelper(TripleDESAlgo); diff --git a/src/format/format-hex.js b/src/format/format-hex.js new file mode 100644 index 0000000..5792d81 --- /dev/null +++ b/src/format/format-hex.js @@ -0,0 +1,43 @@ +import { + CipherParams +} from '../core/cipher-core.js'; +import { + Hex +} from '../encoding/enc-hax.js'; + +export const HexFormatter = { + /** + * Converts the ciphertext of a cipher params object to a hexadecimally encoded string. + * + * @param {CipherParams} cipherParams The cipher params object. + * + * @return {string} The hexadecimally encoded string. + * + * @static + * + * @example + * + * let hexString = CryptoJS.format.Hex.stringify(cipherParams); + */ + stringify(cipherParams) { + return cipherParams.ciphertext.toString(Hex); + }, + + /** + * Converts a hexadecimally encoded ciphertext string to a cipher params object. + * + * @param {string} input The hexadecimally encoded string. + * + * @return {CipherParams} The cipher params object. + * + * @static + * + * @example + * + * let cipherParams = CryptoJS.format.Hex.parse(hexString); + */ + parse(input) { + const ciphertext = Hex.parse(input); + return new CipherParams({ ciphertext }); + } +}; diff --git a/src/hmac.js b/src/hmac.js deleted file mode 100644 index 62f853d..0000000 --- a/src/hmac.js +++ /dev/null @@ -1,3 +0,0 @@ -export { - HMAC -} from './core.js'; diff --git a/src/index.js b/src/index.js index 0df8cda..7a54fab 100644 --- a/src/index.js +++ b/src/index.js @@ -1,32 +1,69 @@ import { Base, WordArray, - Hex, - Latin1, - Utf8, - BufferedBlockAlgorithm, - Hasher -} from './core.js'; + BufferedBlockAlgorithm +} from './core/core.js'; +import { Hasher } from './core/hasher'; import { X64Word, X64WordArray -} from './x64-core.js'; +} from './core/x64-core.js'; import { Cipher, StreamCipher, BlockCipherMode, CBC, - Pkcs7, BlockCipher, CipherParams, OpenSSLFormatter, SerializableCipher, OpenSSLKdf, PasswordBasedCipher -} from './cipher-core.js'; +} from './core/cipher-core.js'; -import { MD5Algo, MD5, HmacMD5 } from './md5.js'; -import { HMAC } from './hmac.js'; +import { Utf16, Utf16BE, Utf16LE } from './encoding/enc-utf16.js'; +import { Latin1 } from './encoding/enc-latin1'; +import { Utf8 } from './encoding/enc-utf8'; +import { Hex } from './encoding/enc-hax'; +import { Base64 } from './encoding/enc-base64.js'; +import { HMAC } from './algo/hmac/hmac.js'; +import { MD5Algo, MD5, HmacMD5 } from './algo/hash/md5.js'; +import { SHA1Algo, SHA1, HmacSHA1 } from './algo/hash/sha1.js'; +import { SHA224Algo, SHA224, HmacSHA224 } from './algo/hash/sha224.js'; +import { SHA256Algo, SHA256, HmacSHA256 } from './algo/hash/sha256.js'; +import { SHA384Algo, SHA384, HmacSHA384 } from './algo/hash/sha384.js'; +import { SHA512Algo, SHA512, HmacSHA512 } from './algo/hash/sha512.js'; +import { SHA3Algo, SHA3, HmacSHA3 } from './algo/hash/sha3.js'; +import { RIPEMD160Algo, RIPEMD160, HmacRIPEMD160 } from './algo/hash/ripemd160.js'; +import { PBKDF2Algo, PBKDF2 } from './algo/pbkdf2/pbkdf2.js'; +import { EvpKDFAlgo, EvpKDF } from './encryption/evpkdf.js'; +import { AESAlgo, AES } from './encryption/aes.js'; +import { + DESAlgo, + DES, + TripleDESAlgo, + TripleDES +} from './encryption/tripledes.js'; +import { RabbitAlgo, Rabbit } from './encryption/rabbit.js'; +import { RabbitLegacyAlgo, RabbitLegacy } from './encryption/rabbit-legacy.js'; +import { + RC4Algo, + RC4, + RC4DropAlgo, + RC4Drop +} from './encryption/rc4.js'; +import { CFB } from './mode/mode-cfb.js'; +import { CTR } from './mode/mode-ctr.js'; +import { CTRGladman } from './mode/mode-ctr-gladman.js'; +import { ECB } from './mode/mode-ecb.js'; +import { OFB } from './mode/mode-ofb.js'; +import { Pkcs7 } from './pad/pad-pkcs7.js'; +import { AnsiX923 } from './pad/pad-ansix923.js'; +import { Iso10126 } from './pad/pad-iso10126.js'; +import { Iso97971 } from './pad/pad-iso97971.js'; +import { NoPadding } from './pad/pad-nopadding.js'; +import { ZeroPadding } from './pad/pad-zeropadding.js'; +import { HexFormatter } from './format/format-hex.js'; export default { lib: { @@ -51,24 +88,57 @@ export default { enc: { Hex, Latin1, - Utf8 + Utf8, + Utf16, + Utf16BE, + Utf16LE, + Base64 }, algo: { HMAC, - MD5: MD5Algo + MD5: MD5Algo, + SHA1: SHA1Algo, + SHA224: SHA224Algo, + SHA256: SHA256Algo, + SHA384: SHA384Algo, + SHA512: SHA512Algo, + SHA3: SHA3Algo, + RIPEMD160: RIPEMD160Algo, + + PBKDF2: PBKDF2Algo, + EvpKDF: EvpKDFAlgo, + + AES: AESAlgo, + DES: DESAlgo, + TripleDES: TripleDESAlgo, + Rabbit: RabbitAlgo, + RabbitLegacy: RabbitLegacyAlgo, + RC4: RC4Algo, + RC4Drop: RC4DropAlgo }, mode: { - CBC + CBC, + CFB, + CTR, + CTRGladman, + ECB, + OFB }, pad: { - Pkcs7 + Pkcs7, + AnsiX923, + Iso10126, + Iso97971, + NoPadding, + ZeroPadding }, format: { - OpenSSL: OpenSSLFormatter + OpenSSL: OpenSSLFormatter, + Hex: HexFormatter }, kdf: { @@ -76,5 +146,30 @@ export default { }, MD5, - HmacMD5 + HmacMD5, + SHA1, + HmacSHA1, + SHA224, + HmacSHA224, + SHA256, + HmacSHA256, + SHA384, + HmacSHA384, + SHA512, + HmacSHA512, + SHA3, + HmacSHA3, + RIPEMD160, + HmacRIPEMD160, + + PBKDF2, + EvpKDF, + + AES, + DES, + TripleDES, + Rabbit, + RabbitLegacy, + RC4, + RC4Drop }; diff --git a/src/mode/mode-cfb.js b/src/mode/mode-cfb.js new file mode 100644 index 0000000..77f2532 --- /dev/null +++ b/src/mode/mode-cfb.js @@ -0,0 +1,63 @@ +import { + BlockCipherMode +} from '../core/cipher-core.js'; + +function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) { + const _words = words; + let keystream; + + // Shortcut + const iv = this._iv; + + // Generate keystream + if (iv) { + keystream = iv.slice(0); + + // Remove IV for subsequent blocks + this._iv = undefined; + } else { + keystream = this._prevBlock; + } + cipher.encryptBlock(keystream, 0); + + // Encrypt + for (let i = 0; i < blockSize; i++) { + _words[offset + i] ^= keystream[i]; + } +} + +/** + * Cipher Feedback block mode. + */ +export class CFB extends BlockCipherMode { + + static Encryptor(){} + +} +CFB.Encryptor = class extends CFB { + processBlock(words, offset) { + // Shortcuts + const cipher = this._cipher; + const { blockSize } = cipher; + + generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher); + + // Remember this block to use with next block + this._prevBlock = words.slice(offset, offset + blockSize); + } +}; +CFB.Decryptor = class extends CFB { + processBlock(words, offset) { + // Shortcuts + const cipher = this._cipher; + const { blockSize } = cipher; + + // Remember this block to use with next block + const thisBlock = words.slice(offset, offset + blockSize); + + generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher); + + // This block becomes the previous block + this._prevBlock = thisBlock; + } +}; diff --git a/src/mode/mode-ctr-gladman.js b/src/mode/mode-ctr-gladman.js new file mode 100644 index 0000000..6678831 --- /dev/null +++ b/src/mode/mode-ctr-gladman.js @@ -0,0 +1,87 @@ +import { + BlockCipherMode +} from '../core/cipher-core.js'; + +const incWord = (word) => { + let _word = word; + + if (((word >> 24) & 0xff) === 0xff) { // overflow + let b1 = (word >> 16) & 0xff; + let b2 = (word >> 8) & 0xff; + let b3 = word & 0xff; + + if (b1 === 0xff) { // overflow b1 + b1 = 0; + if (b2 === 0xff) { + b2 = 0; + if (b3 === 0xff) { + b3 = 0; + } else { + b3++; + } + } else { + b2++; + } + } else { + b1++; + } + + _word = 0; + _word += (b1 << 16); + _word += (b2 << 8); + _word += b3; + } else { + _word += (0x01 << 24); + } + return _word; +}; + +const incCounter = (counter) => { + const _counter = counter; + _counter[0] = incWord(_counter[0]); + + if (_counter[0] === 0) { + // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8 + _counter[1] = incWord(_counter[1]); + } + return _counter; +}; + +/** @preserve + * Counter block mode compatible with Dr Brian Gladman fileenc.c + * derived from CryptoJS.mode.CTR + * Jan Hruby jhruby.web@gmail.com + */ +export class CTRGladman extends BlockCipherMode { +} +CTRGladman.Encryptor = class extends CTRGladman { + processBlock(words, offset) { + const _words = words; + + // Shortcuts + const cipher = this._cipher; + const { blockSize } = cipher; + const iv = this._iv; + let counter = this._counter; + + // Generate keystream + if (iv) { + this._counter = iv.slice(0); + counter = this._counter; + + // Remove IV for subsequent blocks + this._iv = undefined; + } + + incCounter(counter); + + const keystream = counter.slice(0); + cipher.encryptBlock(keystream, 0); + + // Encrypt + for (let i = 0; i < blockSize; i++) { + _words[offset + i] ^= keystream[i]; + } + } +}; +CTRGladman.Decryptor = CTRGladman.Encryptor; diff --git a/src/mode/mode-ctr.js b/src/mode/mode-ctr.js new file mode 100644 index 0000000..804d6f8 --- /dev/null +++ b/src/mode/mode-ctr.js @@ -0,0 +1,40 @@ +/** + * Counter block mode. + */ +import { + BlockCipherMode +} from '../core/cipher-core.js'; + +export class CTR extends BlockCipherMode { +} +CTR.Encryptor = class extends CTR { + processBlock(words, offset) { + const _words = words; + + // Shortcuts + const cipher = this._cipher; + const { blockSize } = cipher; + const iv = this._iv; + let counter = this._counter; + + // Generate keystream + if (iv) { + this._counter = iv.slice(0); + counter = this._counter; + + // Remove IV for subsequent blocks + this._iv = undefined; + } + const keystream = counter.slice(0); + cipher.encryptBlock(keystream, 0); + + // Increment counter + counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0; + + // Encrypt + for (let i = 0; i < blockSize; i++) { + _words[offset + i] ^= keystream[i]; + } + } +}; +CTR.Decryptor = CTR.Encryptor; diff --git a/src/mode/mode-ecb.js b/src/mode/mode-ecb.js new file mode 100644 index 0000000..c35ca49 --- /dev/null +++ b/src/mode/mode-ecb.js @@ -0,0 +1,19 @@ +/** + * Electronic Codebook block mode. + */ +import { + BlockCipherMode +} from '../core/cipher-core.js'; + +export class ECB extends BlockCipherMode { +} +ECB.Encryptor = class extends ECB { + processBlock(words, offset) { + this._cipher.encryptBlock(words, offset); + } +}; +ECB.Decryptor = class extends ECB { + processBlock(words, offset) { + this._cipher.decryptBlock(words, offset); + } +}; diff --git a/src/mode/mode-ofb.js b/src/mode/mode-ofb.js new file mode 100644 index 0000000..5fb9f58 --- /dev/null +++ b/src/mode/mode-ofb.js @@ -0,0 +1,36 @@ +/** + * Output Feedback block mode. + */ +import { + BlockCipherMode +} from '../core/cipher-core.js'; + +export class OFB extends BlockCipherMode { +} +OFB.Encryptor = class extends OFB { + processBlock(words, offset) { + const _words = words; + + // Shortcuts + const cipher = this._cipher; + const { blockSize } = cipher; + const iv = this._iv; + let keystream = this._keystream; + + // Generate keystream + if (iv) { + this._keystream = iv.slice(0); + keystream = this._keystream; + + // Remove IV for subsequent blocks + this._iv = undefined; + } + cipher.encryptBlock(keystream, 0); + + // Encrypt + for (let i = 0; i < blockSize; i++) { + _words[offset + i] ^= keystream[i]; + } + } +}; +OFB.Decryptor = OFB.Encryptor; diff --git a/src/pad/pad-ansix923.js b/src/pad/pad-ansix923.js new file mode 100644 index 0000000..233eff7 --- /dev/null +++ b/src/pad/pad-ansix923.js @@ -0,0 +1,33 @@ +/** + * ANSI X.923 padding strategy. + */ +export const AnsiX923 = { + pad(data, blockSize) { + const _data = data; + + // Shortcuts + const dataSigBytes = _data.sigBytes; + const blockSizeBytes = blockSize * 4; + + // Count padding bytes + const nPaddingBytes = blockSizeBytes - (dataSigBytes % blockSizeBytes); + + // Compute last byte position + const lastBytePos = dataSigBytes + nPaddingBytes - 1; + + // Pad + _data.clamp(); + _data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8); + _data.sigBytes += nPaddingBytes; + }, + + unpad(data) { + const _data = data; + + // Get number of padding bytes from last byte + const nPaddingBytes = _data.words[(_data.sigBytes - 1) >>> 2] & 0xff; + + // Remove padding + _data.sigBytes -= nPaddingBytes; + } +}; diff --git a/src/pad/pad-iso10126.js b/src/pad/pad-iso10126.js new file mode 100644 index 0000000..ad3e8be --- /dev/null +++ b/src/pad/pad-iso10126.js @@ -0,0 +1,30 @@ +import { + WordArray, +} from '../core/core.js'; + +/** + * ISO 10126 padding strategy. + */ +export const Iso10126 = { + pad(data, blockSize) { + // Shortcut + const blockSizeBytes = blockSize * 4; + + // Count padding bytes + const nPaddingBytes = blockSizeBytes - (data.sigBytes % blockSizeBytes); + + // Pad + data + .concat(WordArray.random(nPaddingBytes - 1)) + .concat(new WordArray([nPaddingBytes << 24], 1)); + }, + + unpad(data) { + const _data = data; + // Get number of padding bytes from last byte + const nPaddingBytes = _data.words[(_data.sigBytes - 1) >>> 2] & 0xff; + + // Remove padding + _data.sigBytes -= nPaddingBytes; + } +}; diff --git a/src/pad/pad-iso97971.js b/src/pad/pad-iso97971.js new file mode 100644 index 0000000..fd0d446 --- /dev/null +++ b/src/pad/pad-iso97971.js @@ -0,0 +1,29 @@ +import { + WordArray, +} from '../core/core.js'; +import { + ZeroPadding, +} from './pad-zeropadding.js'; + +/** + * ISO/IEC 9797-1 Padding Method 2. + */ +export const Iso97971 = { + pad(data, blockSize) { + // Add 0x80 byte + data.concat(new WordArray([0x80000000], 1)); + + // Zero pad the rest + ZeroPadding.pad(data, blockSize); + }, + + unpad(data) { + const _data = data; + + // Remove zero padding + ZeroPadding.unpad(_data); + + // Remove one more byte -- the 0x80 byte + _data.sigBytes--; + } +}; diff --git a/src/pad/pad-nopadding.js b/src/pad/pad-nopadding.js new file mode 100644 index 0000000..e1ffc0a --- /dev/null +++ b/src/pad/pad-nopadding.js @@ -0,0 +1,10 @@ +/** + * A noop padding strategy. + */ +export const NoPadding = { + pad() { + }, + + unpad() { + } +}; diff --git a/src/pad/pad-pkcs7.js b/src/pad/pad-pkcs7.js new file mode 100644 index 0000000..3cba2bb --- /dev/null +++ b/src/pad/pad-pkcs7.js @@ -0,0 +1,63 @@ +import { WordArray } from '../core/core'; + +/** + * PKCS #5/7 padding strategy. + */ +export const Pkcs7 = { + /** + * Pads data using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to pad. + * @param {number} blockSize The multiple that the data should be padded to. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.pad(wordArray, 4); + */ + pad(data, blockSize) { + // Shortcut + const blockSizeBytes = blockSize * 4; + + // Count padding bytes + const nPaddingBytes = blockSizeBytes - (data.sigBytes % blockSizeBytes); + + // Create padding word + const paddingWord = (nPaddingBytes << 24) | + (nPaddingBytes << 16) | + (nPaddingBytes << 8) | + nPaddingBytes; + + // Create padding + const paddingWords = []; + for (let i = 0; i < nPaddingBytes; i += 4) { + paddingWords.push(paddingWord); + } + const padding = new WordArray(paddingWords, nPaddingBytes); + + // Add padding + data.concat(padding); + }, + + /** + * Unpads data that had been padded using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to unpad. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.unpad(wordArray); + */ + unpad(data) { + const _data = data; + + // Get number of padding bytes from last byte + const nPaddingBytes = _data.words[(_data.sigBytes - 1) >>> 2] & 0xff; + + // Remove padding + _data.sigBytes -= nPaddingBytes; + } +}; \ No newline at end of file diff --git a/src/pad/pad-zeropadding.js b/src/pad/pad-zeropadding.js new file mode 100644 index 0000000..276fa53 --- /dev/null +++ b/src/pad/pad-zeropadding.js @@ -0,0 +1,30 @@ +/** + * Zero padding strategy. + */ +export const ZeroPadding = { + pad(data, blockSize) { + const _data = data; + + // Shortcut + const blockSizeBytes = blockSize * 4; + + // Pad + _data.clamp(); + _data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes); + }, + + unpad(data) { + const _data = data; + + // Shortcut + const dataWords = _data.words; + + // Unpad + for (let i = _data.sigBytes - 1; i >= 0; i--) { + if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) { + _data.sigBytes = i + 1; + break; + } + } + } +}; diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 0000000..51581ce --- /dev/null +++ b/src/utils.js @@ -0,0 +1,61 @@ +const toStringPro = Object.prototype.toString; + +/** + * Determine if a value is a String + * + * @param {Object} val The value to test + * @returns {Boolean} True if value is a String, otherwise false + */ +export const isString = (val) => typeof val === 'string'; + +/** + * Determine if a value is a Number + * + * @param {Object} val The value to test + * @returns {Boolean} True if value is a Number, otherwise false + */ +export const isNumber = (val) => typeof val === 'number'; + +/** + * Determine if a value is a undefined + * + * @param {Object} val The value to test + * @returns {Boolean} True if value is a undefined, otherwise false + */ +export const isUndefined = (val) => typeof val === 'undefined'; + +/** + * Determine if a value is a Function + * + * @param {Object} val The value to test + * @returns {Boolean} True if value is a Function, otherwise false + */ +export const isFunction = (val) => toStringPro.call(val) === '[object Function]'; + +/** + * Determine if a value is a Array + * + * @param {Object} val The value to test + * @returns {Boolean} True if value is a Array, otherwise false + */ +export const isArray = (val) => toStringPro.call(val) === '[object, Array]'; + +/** + * Determine if a value is a Object + * + * @param {Object} val The value to test + * @returns {Boolean} True if value is a Object, otherwise false + */ +export const isObject = (val) => toStringPro.call(val) === '[object, object]'; + +/** + * Accepts varargs expecting each argument to be an object, then + * immutably merges the properties of each object and returns result. + * + * When multiple objects contain the same key the later object in + * the arguments list will take precedence. + * + * @param {Object} args Object to merge + * @returns {Object} Result of all merge properties + */ +export const merge = (...args) => args.length && Object.assign(...args); \ No newline at end of file diff --git a/test/aes.profile.test.js b/test/aes.profile.test.js new file mode 100644 index 0000000..695147a --- /dev/null +++ b/test/aes.profile.test.js @@ -0,0 +1,30 @@ +import C from '../src/index.js'; + +let data = {}; +beforeAll(() => { + data.key = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'); + data.iv = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'); +}); + +describe('algo-aes-profile', () => { + + test('profileSinglePartMessage', () => { + let singlePartMessage = ''; + for (let i = 0; i < 500; i++) { + singlePartMessage += '12345678901234567890123456789012345678901234567890'; + } + C.algo.AES.createEncryptor(data.key, { + iv: data.iv + }).finalize(singlePartMessage) + ''; + }); + + test('profileMultiPartMessage', () => { + let aes = C.algo.AES.createEncryptor(data.key, { + iv: data.iv + }); + for (let i = 0; i < 500; i++) { + aes.process('12345678901234567890123456789012345678901234567890') + ''; + } + aes.finalize() + ''; + }); +}); \ No newline at end of file diff --git a/test/aes.test.js b/test/aes.test.js new file mode 100644 index 0000000..f136b30 --- /dev/null +++ b/test/aes.test.js @@ -0,0 +1,101 @@ +import C from '../src/index.js'; + + +const ENCRYPT_KEY_SIZE = [ + [128, '00112233445566778899aabbccddeeff', '000102030405060708090a0b0c0d0e0f', '69c4e0d86a7b0430d8cdb78070b4c55a'], + [192, '00112233445566778899aabbccddeeff', '000102030405060708090a0b0c0d0e0f1011121314151617', 'dda97ca4864cdfe06eaf70a0ec0d7191'], + [256, '00112233445566778899aabbccddeeff', '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', '8ea2b7ca516745bfeafc49904b496089'] +]; + +const DECRYPT_KEY_SIZE = [ + [128, '69c4e0d86a7b0430d8cdb78070b4c55a', '000102030405060708090a0b0c0d0e0f', '00112233445566778899aabbccddeeff'], + [192, 'dda97ca4864cdfe06eaf70a0ec0d7191', '000102030405060708090a0b0c0d0e0f1011121314151617', '00112233445566778899aabbccddeeff'], + [256, '8ea2b7ca516745bfeafc49904b496089', '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', '00112233445566778899aabbccddeeff'] +]; + +describe('algo-aes-test', () => { + test.each(ENCRYPT_KEY_SIZE)( + 'testEncryptKeySize%i', + (a, b, c, expected) => { + expect(C.AES.encrypt(C.enc.Hex.parse(b), C.enc.Hex.parse(c), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).ciphertext.toString()).toBe(expected); + } + ); + + test.each(DECRYPT_KEY_SIZE)( + 'testDecryptKeySize%i', + (a, b, c, expected) => { + expect(C.AES.decrypt(new C.lib.CipherParams({ + ciphertext: C.enc.Hex.parse(b) + }), C.enc.Hex.parse(c), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()).toBe(expected); + } + ); + + test('testMultiPart', () => { + let aes = C.algo.AES.createEncryptor(C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }); + let ciphertext1 = aes.process(C.enc.Hex.parse('001122334455')); + let ciphertext2 = aes.process(C.enc.Hex.parse('66778899aa')); + let ciphertext3 = aes.process(C.enc.Hex.parse('bbccddeeff')); + let ciphertext4 = aes.finalize(); + expect(ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString()).toBe('69c4e0d86a7b0430d8cdb78070b4c55a'); + }); + + test('testInputIntegrity', () => { + let message = C.enc.Hex.parse('00112233445566778899aabbccddeeff'); + let key = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'); + let iv = C.enc.Hex.parse('101112131415161718191a1b1c1d1e1f'); + let expectedMessage = message.toString(); + let expectedKey = key.toString(); + let expectedIv = iv.toString(); + C.AES.encrypt(message, key, { + iv: iv + }); + expect(message.toString()).toBe(expectedMessage); + expect(key.toString()).toBe(expectedKey); + expect(iv.toString()).toBe(expectedIv); + }); + + test('testHelper', () => { + // Save original random method + let random = C.lib.WordArray.random; + // Replace random method with one that returns a predictable value + C.lib.WordArray.random = function (nBytes) { + let words = []; + for (let i = 0; i < nBytes; i += 4) { + words.push([0x11223344]); + } + return new C.lib.WordArray(words, nBytes); + }; + expect(C.AES.encrypt('Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).ciphertext.toString()).toBe(C.algo.AES.createEncryptor(C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).finalize('Hi There').toString()); + expect(C.AES.encrypt('Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()).toBe(C.lib.SerializableCipher.encrypt(C.algo.AES, 'Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()); + expect(C.AES.encrypt('Hi There', 'Jefe', { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()).toBe(C.lib.PasswordBasedCipher.encrypt(C.algo.AES, 'Hi There', 'Jefe', { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()); + // Restore random method + C.lib.WordArray.random = random; + }); +}); \ No newline at end of file diff --git a/test/algo.pbkdf2.profile.test.js b/test/algo.pbkdf2.profile.test.js new file mode 100644 index 0000000..2df2b2f --- /dev/null +++ b/test/algo.pbkdf2.profile.test.js @@ -0,0 +1,10 @@ +import C from '../src/index'; + +describe('algo-pbkdf2-profile', () => { + test('profileKeySize256Iterations20', () => { + new C.algo.PBKDF2({ + keySize: 256 / 32, + iterations: 20 + }).compute('password', 'ATHENA.MIT.EDUraeburn'); + }); +}); \ No newline at end of file diff --git a/test/algo.pbkdf2.test.js b/test/algo.pbkdf2.test.js new file mode 100644 index 0000000..77576f4 --- /dev/null +++ b/test/algo.pbkdf2.test.js @@ -0,0 +1,119 @@ +import C from '../src/index'; + +describe('algo-pbkdf2-test', () => { + test('testKeySize128', () => { + expect(C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { + keySize: 128 / 32 + }).toString()).toBe('cdedb5281bb2f801565a1122b2563515'); + }); + + test('testKeySize256', () => { + expect(C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { + keySize: 256 / 32 + }).toString()).toBe('cdedb5281bb2f801565a1122b25635150ad1f7a04bb9f3a333ecc0e2e1f70837'); + }); + + test('testKeySize128Iterations2', () => { + expect(C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { + keySize: 128 / 32, + iterations: 2 + }).toString()).toBe('01dbee7f4a9e243e988b62c73cda935d'); + }); + + test('testKeySize256Iterations2', () => { + expect(C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { + keySize: 256 / 32, + iterations: 2 + }).toString()).toBe('01dbee7f4a9e243e988b62c73cda935da05378b93244ec8f48a99e61ad799d86'); + }); + + test('testKeySize128Iterations1200', () => { + expect(C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { + keySize: 128 / 32, + iterations: 1200 + }).toString()).toBe('5c08eb61fdf71e4e4ec3cf6ba1f5512b'); + }); + + test('testKeySize256Iterations1200', () => { + expect(C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { + keySize: 256 / 32, + iterations: 1200 + }).toString()).toBe('5c08eb61fdf71e4e4ec3cf6ba1f5512ba7e52ddbc5e5142f708a31e2e62b1e13'); + }); + + test('testKeySize128Iterations5', () => { + expect(C.PBKDF2('password', C.enc.Hex.parse('1234567878563412'), { + keySize: 128 / 32, + iterations: 5 + }).toString()).toBe('d1daa78615f287e6a1c8b120d7062a49'); + }); + + test('testKeySize256Iterations5', () => { + expect(C.PBKDF2('password', C.enc.Hex.parse('1234567878563412'), { + keySize: 256 / 32, + iterations: 5 + }).toString()).toBe('d1daa78615f287e6a1c8b120d7062a493f98d203e6be49a6adf4fa574b6e64ee'); + }); + + test('testKeySize128Iterations1200PassPhraseEqualsBlockSize', () => { + expect(C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase equals block size', { + keySize: 128 / 32, + iterations: 1200 + }).toString()).toBe('139c30c0966bc32ba55fdbf212530ac9'); + }); + + test('testKeySize256Iterations1200PassPhraseEqualsBlockSize', () => { + expect(C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase equals block size', { + keySize: 256 / 32, + iterations: 1200 + }).toString()).toBe('139c30c0966bc32ba55fdbf212530ac9c5ec59f1a452f5cc9ad940fea0598ed1'); + }); + + test('testKeySize128Iterations1200PassPhraseExceedsBlockSize', () => { + expect(C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase exceeds block size', { + keySize: 128 / 32, + iterations: 1200 + }).toString()).toBe('9ccad6d468770cd51b10e6a68721be61'); + }); + + test('testKeySize256Iterations1200PassPhraseExceedsBlockSize', () => { + expect(C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase exceeds block size', { + keySize: 256 / 32, + iterations: 1200 + }).toString()).toBe('9ccad6d468770cd51b10e6a68721be611a8b4d282601db3b36be9246915ec82a'); + }); + + test('testKeySize128Iterations50', () => { + expect(C.PBKDF2(C.enc.Hex.parse('f09d849e'), 'EXAMPLE.COMpianist', { + keySize: 128 / 32, + iterations: 50 + }).toString()).toBe('6b9cf26d45455a43a5b8bb276a403b39'); + }); + + test('testKeySize256Iterations50', () => { + expect(C.PBKDF2(C.enc.Hex.parse('f09d849e'), 'EXAMPLE.COMpianist', { + keySize: 256 / 32, + iterations: 50 + }).toString()).toBe('6b9cf26d45455a43a5b8bb276a403b39e7fe37a0c41e02c281ff3069e1e94f52'); + }); + + test('testInputIntegrity', () => { + let password = new C.lib.WordArray([0x12345678]); + let salt = new C.lib.WordArray([0x12345678]); + + let expectedPassword = password.toString(); + let expectedSalt = salt.toString(); + + C.PBKDF2(password, salt); + expect(password.toString()).toBe(expectedPassword); + expect(salt.toString()).toBe(expectedSalt); + }); + + test('testHelper', () => { + expect(C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { + keySize: 128 / 32 + }).toString()).toBe(new C.algo.PBKDF2({ + keySize: 128 / 32 + }).compute('password', 'ATHENA.MIT.EDUraeburn').toString()); + }); +}); \ No newline at end of file diff --git a/test/algo.rabbit.legacy.test.js b/test/algo.rabbit.legacy.test.js new file mode 100644 index 0000000..83a0697 --- /dev/null +++ b/test/algo.rabbit.legacy.test.js @@ -0,0 +1,115 @@ +import C from '../src/index'; + +describe('algo-rabbit-legacy-test', () => { + test('testVector1', () => { + expect(C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000')).ciphertext.toString()) + .toBe('02f74a1c26456bf5ecd6a536f05457b1'); + }); + + test('testVector2', () => { + expect(C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('dc51c3ac3bfc62f12e3d36fe91281329')).ciphertext.toString()) + .toBe('9c51e28784c37fe9a127f63ec8f32d3d'); + }); + + test('testVector3', () => { + expect(C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('c09b0043e9e9ab0187e0c73383957415')).ciphertext.toString()) + .toBe('9b60d002fd5ceb32accd41a0cd0db10c'); + }); + + test('testVector4', () => { + expect(C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000'), { + iv: C.enc.Hex.parse('0000000000000000') + }).ciphertext.toString()) + .toBe('edb70567375dcd7cd89554f85e27a7c6'); + }); + + test('testVector5', () => { + expect(C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000'), { + iv: C.enc.Hex.parse('597e26c175f573c3') + }).ciphertext.toString()) + .toBe('6d7d012292ccdce0e2120058b94ecd1f'); + }); + + test('testVector6', () => { + expect(C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000'), { + iv: C.enc.Hex.parse('2717f4d21a56eba6') + }).ciphertext.toString()) + .toBe('4d1051a123afb670bf8d8505c8d85a44'); + }); + + test('testMultiPart', () => { + const rabbit = C.algo.RabbitLegacy.createEncryptor(C.enc.Hex.parse('00000000000000000000000000000000')); + const ciphertext1 = rabbit.process(C.enc.Hex.parse('000000000000')); + const ciphertext2 = rabbit.process(C.enc.Hex.parse('0000000000')); + const ciphertext3 = rabbit.process(C.enc.Hex.parse('0000000000')); + const ciphertext4 = rabbit.finalize(); + + expect(ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString()) + .toBe('02f74a1c26456bf5ecd6a536f05457b1'); + }); + + test('testInputIntegrity', () => { + const message = C.enc.Hex.parse('00000000000000000000000000000000'); + const key = C.enc.Hex.parse('00000000000000000000000000000000'); + const iv = C.enc.Hex.parse('0000000000000000'); + + const expectedMessage = message.toString(); + const expectedKey = key.toString(); + const expectedIv = iv.toString(); + + C.RabbitLegacy.encrypt(message, key, { + iv + }); + + expect(message.toString()).toBe(expectedMessage); + expect(key.toString()).toBe(expectedKey); + expect(iv.toString()).toBe(expectedIv); + }); + + test('testHelper', () => { + // Save original random method + const { + random + } = C.lib.WordArray; + + // Replace random method with one that returns a predictable value + C.lib.WordArray.random = (nBytes) => { + const words = []; + for (let i = 0; i < nBytes; i += 4) { + words.push([0x11223344]); + } + + return new C.lib.WordArray(words, nBytes); + }; + + expect(C.RabbitLegacy.encrypt('Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).ciphertext.toString()) + .toBe(C.algo.RabbitLegacy.createEncryptor(C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).finalize('Hi There').toString()); + + expect(C.RabbitLegacy.encrypt('Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()) + .toBe(C.lib.SerializableCipher.encrypt(C.algo.RabbitLegacy, 'Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()); + + expect(C.RabbitLegacy.encrypt('Hi There', 'Jefe', { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()) + .toBe(C.lib.PasswordBasedCipher.encrypt(C.algo.RabbitLegacy, 'Hi There', 'Jefe', { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()); + + // Restore random method + C.lib.WordArray.random = random; + }); +}); \ No newline at end of file diff --git a/test/algo.rabbit.profile.test.js b/test/algo.rabbit.profile.test.js new file mode 100644 index 0000000..c74d359 --- /dev/null +++ b/test/algo.rabbit.profile.test.js @@ -0,0 +1,26 @@ +import C from '../src/index'; + +const data = {}; + +beforeAll(() => { + data.key = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'); +}); + +describe('algo-rabbit-profile', () => { + test('profileSinglePartMessage', () => { + let singlePartMessage = ''; + for (let i = 0; i < 500; i++) { + singlePartMessage += '12345678901234567890123456789012345678901234567890'; + } + + C.algo.Rabbit.createEncryptor(data.key).finalize(singlePartMessage) + ''; + }); + + test('profileMultiPartMessage', () => { + let rabbit = C.algo.Rabbit.createEncryptor(data.key); + for (let i = 0; i < 500; i++) { + rabbit.process('12345678901234567890123456789012345678901234567890') + ''; + } + rabbit.finalize() + ''; + }); +}); \ No newline at end of file diff --git a/test/algo.rabbit.test.js b/test/algo.rabbit.test.js new file mode 100644 index 0000000..a71536d --- /dev/null +++ b/test/algo.rabbit.test.js @@ -0,0 +1,120 @@ +import C from '../src/index'; + +describe('algo-rabbit-test', () => { + test('testVector1', () => { + expect(C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000')).ciphertext.toString()) + .toBe('02f74a1c26456bf5ecd6a536f05457b1'); + }); + + test('testVector2', () => { + expect(C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('c21fcf3881cd5ee8628accb0a9890df8')).ciphertext.toString()) + .toBe('3d02e0c730559112b473b790dee018df'); + }); + + test('testVector3', () => { + expect(C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('1d272c6a2d8e3dfcac14056b78d633a0')).ciphertext.toString()) + .toBe('a3a97abb80393820b7e50c4abb53823d'); + }); + + test('testVector4', () => { + expect(C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0053a6f94c9ff24598eb3e91e4378add'), { + iv: C.enc.Hex.parse('0d74db42a91077de') + }).ciphertext.toString()) + .toBe('75d186d6bc6905c64f1b2dfdd51f7bfc'); + }); + + test('testVector5', () => { + expect(C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0558abfe51a4f74a9df04396e93c8fe2'), { + iv: C.enc.Hex.parse('167de44bb21980e7') + }).ciphertext.toString()) + .toBe('476e2750c73856c93563b5f546f56a6a'); + }); + + test('testVector6', () => { + expect(C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0a5db00356a9fc4fa2f5489bee4194e7'), { + iv: C.enc.Hex.parse('1f86ed54bb2289f0') + }).ciphertext.toString()) + .toBe('921fcf4983891365a7dc901924b5e24b'); + }); + + test('testVector7', () => { + expect(C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0f62b5085bae0154a7fa4da0f34699ec'), { + iv: C.enc.Hex.parse('288ff65dc42b92f9') + }).ciphertext.toString()) + .toBe('613cb0ba96aff6cacf2a459a102a7f78'); + }); + + test('testMultiPart', () => { + const rabbit = C.algo.Rabbit.createEncryptor(C.enc.Hex.parse('00000000000000000000000000000000')); + const ciphertext1 = rabbit.process(C.enc.Hex.parse('000000000000')); + const ciphertext2 = rabbit.process(C.enc.Hex.parse('0000000000')); + const ciphertext3 = rabbit.process(C.enc.Hex.parse('0000000000')); + const ciphertext4 = rabbit.finalize(); + + expect(ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString()) + .toBe('02f74a1c26456bf5ecd6a536f05457b1'); + }); + + test('testInputIntegrity', () => { + const message = C.enc.Hex.parse('00000000000000000000000000000000'); + const key = C.enc.Hex.parse('00000000000000000000000000000000'); + const iv = C.enc.Hex.parse('0000000000000000'); + + const expectedMessage = message.toString(); + const expectedKey = key.toString(); + const expectedIv = iv.toString(); + + C.Rabbit.encrypt(message, key, { + iv + }); + + expect(message.toString()).toBe(expectedMessage); + expect(key.toString()).toBe(expectedKey); + expect(iv.toString()).toBe(expectedIv); + }); + + test('testHelper', () => { + // Save original random method + const { + random + } = C.lib.WordArray; + + // Replace random method with one that returns a predictable value + C.lib.WordArray.random = (nBytes) => { + const words = []; + for (let i = 0; i < nBytes; i += 4) { + words.push([0x11223344]); + } + + return new C.lib.WordArray(words, nBytes); + }; + + expect(C.Rabbit.encrypt('Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).ciphertext.toString()) + .toBe(C.algo.Rabbit.createEncryptor(C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).finalize('Hi There').toString()); + expect(C.Rabbit.encrypt('Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()) + .toBe(C.lib.SerializableCipher.encrypt(C.algo.Rabbit, 'Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()); + expect(C.Rabbit.encrypt('Hi There', 'Jefe', { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()) + .toBe(C.lib.PasswordBasedCipher.encrypt(C.algo.Rabbit, 'Hi There', 'Jefe', { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()); + + // Restore random method + C.lib.WordArray.random = random; + }); +}); \ No newline at end of file diff --git a/test/algo.rc4.profile.test.js b/test/algo.rc4.profile.test.js new file mode 100644 index 0000000..2967a95 --- /dev/null +++ b/test/algo.rc4.profile.test.js @@ -0,0 +1,24 @@ +import C from '../src/index'; + +const data = {}; +beforeAll(() => { + data.key = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'); +}); + +describe('algo-rc4-profile', () => { + test('profileSinglePartMessage', () => { + let singlePartMessage = ''; + for (let i = 0; i < 500; i++) { + singlePartMessage += '12345678901234567890123456789012345678901234567890'; + } + C.algo.RC4.createEncryptor(data.key).finalize(singlePartMessage) + ''; + }); + + test('profileMultiPartMessage', () => { + let rc4 = C.algo.RC4.createEncryptor(data.key); + for (let i = 0; i < 500; i++) { + rc4.process('12345678901234567890123456789012345678901234567890') + ''; + } + rc4.finalize() + ''; + }); +}); \ No newline at end of file diff --git a/test/algo.rc4.test.js b/test/algo.rc4.test.js new file mode 100644 index 0000000..38a90ff --- /dev/null +++ b/test/algo.rc4.test.js @@ -0,0 +1,89 @@ +import C from '../src/index'; + +describe('rc4', () => { + test('testVector1', () => { + expect(C.RC4.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('0123456789abcdef')).ciphertext.toString()) + .toBe('7494c2e7104b0879'); + }); + + test('testVector2', () => { + expect(C.RC4.encrypt(C.enc.Hex.parse('dcee4cf92c'), C.enc.Hex.parse('618a63d2fb')).ciphertext.toString()) + .toBe('f13829c9de'); + }); + + test('drop', () => { + expect(C.RC4Drop.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('0123456789abcdef'), { + drop: 2 + }).ciphertext.toString()) + .toBe(C.RC4.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0123456789abcdef')).ciphertext.toString().substr(16)); + }); + + test('multi part', () => { + const rabbit = C.algo.RC4.createEncryptor(C.enc.Hex.parse('0123456789abcdef')); + const ciphertext1 = rabbit.process(C.enc.Hex.parse('00000000')); + const ciphertext2 = rabbit.process(C.enc.Hex.parse('0000')); + const ciphertext3 = rabbit.process(C.enc.Hex.parse('0000')); + const ciphertext4 = rabbit.finalize(); + + expect(ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString()) + .toBe('7494c2e7104b0879'); + }); + + test('input integrity', () => { + const message = C.enc.Hex.parse('0000000000000000'); + const key = C.enc.Hex.parse('0123456789abcdef'); + + const expectedMessage = message.toString(); + const expectedKey = key.toString(); + + C.RC4.encrypt(message, key); + + expect(message.toString()).toBe(expectedMessage); + expect(key.toString()).toBe(expectedKey); + }); + + test('test helper', () => { + // Save original random method + const { + random + } = C.lib.WordArray; + + // Replace random method with one that returns a predictable value + C.lib.WordArray.random = (nBytes) => { + const words = []; + for (let i = 0; i < nBytes; i += 4) { + words.push([0x11223344]); + } + + return new C.lib.WordArray(words, nBytes); + }; + + expect(C.RC4.encrypt('Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).ciphertext.toString()) + .toBe(C.algo.RC4.createEncryptor(C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).finalize('Hi There').toString()); + expect(C.RC4.encrypt('Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()) + .toBe(C.lib.SerializableCipher.encrypt(C.algo.RC4, 'Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()); + expect(C.RC4.encrypt('Hi There', 'Jefe', { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()) + .toBe(C.lib.PasswordBasedCipher.encrypt(C.algo.RC4, 'Hi There', 'Jefe', { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()); + + // Restore random method + C.lib.WordArray.random = random; + }); +}); \ No newline at end of file diff --git a/test/algo.ripemd160.test.js b/test/algo.ripemd160.test.js new file mode 100644 index 0000000..d0614fd --- /dev/null +++ b/test/algo.ripemd160.test.js @@ -0,0 +1,16 @@ +import C from '../src/index'; + +const VERTOR_TEST_CONFIG = [ + [1, 'The quick brown fox jumps over the lazy dog', '37f332f68db77bd9d7edd4969571ad671cf9dd3b'], + [2, 'The quick brown fox jumps over the lazy cog', '132072df690933835eb8b6ad0b77e7b6f14acad7'], + [3, '', '9c1185a5c5e9fc54612808977ee8f548b2258d31'] +]; + +describe('algo-ripemd160-test', () => { + test.each(VERTOR_TEST_CONFIG)( + 'testVector%i', + (a, b, expected) => { + expect(C.RIPEMD160(b).toString()).toBe(expected); + } + ); +}); \ No newline at end of file diff --git a/test/algo.sha1.profile.test.js b/test/algo.sha1.profile.test.js new file mode 100644 index 0000000..352ed59 --- /dev/null +++ b/test/algo.sha1.profile.test.js @@ -0,0 +1,20 @@ +import C from '../src/index'; + +describe('algo-sha1-profile', () => { + test('profileSinglePartMessage', () => { + let singlePartMessage = ''; + for (let i = 0; i < 500; i++) { + singlePartMessage += '12345678901234567890123456789012345678901234567890'; + } + + new C.algo.SHA1().finalize(singlePartMessage) + ''; + }); + + test('profileMultiPartMessage', () => { + let sha1 = new C.algo.SHA1(); + for (let i = 0; i < 500; i++) { + sha1.update('12345678901234567890123456789012345678901234567890'); + } + sha1.finalize() + ''; + }); +}); \ No newline at end of file diff --git a/test/algo.sha1.test.js b/test/algo.sha1.test.js new file mode 100644 index 0000000..c5744e7 --- /dev/null +++ b/test/algo.sha1.test.js @@ -0,0 +1,56 @@ +import C from '../src/index'; + +const VECTOR_CONFIG_TEST = [ + [1, '', 'da39a3ee5e6b4b0d3255bfef95601890afd80709'], + [2, 'a', '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8'], + [3, 'abc', 'a9993e364706816aba3e25717850c26c9cd0d89d'], + [4, 'message digest', 'c12252ceda8be8994d5fa0290a47231c1d16aae3'], + [5, 'abcdefghijklmnopqrstuvwxyz', '32d10c7b8cf96570ca04ce37f2a19d84240d3a89'], + [6, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', '761c457bf73b14d27e9e9265c46f4b4dda11f940'], + [7, '12345678901234567890123456789012345678901234567890123456789012345678901234567890', '50abf5706a150990a08b2c5ea40fa0e585554732'] +]; + +describe('algo-sha1-test', () => { + test.each(VECTOR_CONFIG_TEST)( + 'testVector%i', + (a, b, expected) => { + expect(C.SHA1(b).toString()).toBe(expected); + } + ); + + test('testUpdateAndLongMessage', () => { + const sha1 = new C.algo.SHA1(); + for (let i = 0; i < 100; i++) { + sha1.update('12345678901234567890123456789012345678901234567890'); + } + + expect(sha1.finalize().toString()).toBe('85e4c4b3933d5553ebf82090409a9d90226d845c'); + }); + + test('testClone', () => { + const sha1 = new C.algo.SHA1(); + + expect(sha1.update('a').clone().finalize().toString()).toBe(C.SHA1('a').toString()); + expect(sha1.update('b').clone().finalize().toString()).toBe(C.SHA1('ab').toString()); + expect(sha1.update('c').clone().finalize().toString()).toBe(C.SHA1('abc').toString()); + }); + + test('testInputIntegrity', () => { + const message = new C.lib.WordArray([0x12345678]); + + const expected = message.toString(); + + C.SHA1(message); + + expect(message.toString()).toBe(expected); + }); + + test('testHelper', () => { + expect(C.SHA1('').toString()).toBe(new C.algo.SHA1().finalize('').toString()); + }); + + test('testHmacHelper', () => { + expect(C.HmacSHA1('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()) + .toBe(new C.algo.HMAC(C.algo.SHA1, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString()); + }); +}); \ No newline at end of file diff --git a/test/algo.sha224.test.js b/test/algo.sha224.test.js new file mode 100644 index 0000000..3cf1aa1 --- /dev/null +++ b/test/algo.sha224.test.js @@ -0,0 +1,16 @@ +import C from '../src/index'; + +const VECTOR_TEST_CONFIG = [ + [1, '', 'd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f'], + [1, 'The quick brown fox jumps over the lazy dog', '730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525'], + [1, 'The quick brown fox jumps over the lazy dog.', '619cba8e8e05826e9b8c519c0a5c68f4fb653e8a3d8aa04bb2c8cd4c'] +]; + +describe('algo-sha224-test', () => { + test.each(VECTOR_TEST_CONFIG)( + 'testVector%i', + (a, b, expected) => { + expect(C.SHA224(b).toString()).toBe(expected); + } + ); +}); \ No newline at end of file diff --git a/test/algo.sha256.profile.test.js b/test/algo.sha256.profile.test.js new file mode 100644 index 0000000..5875baf --- /dev/null +++ b/test/algo.sha256.profile.test.js @@ -0,0 +1,19 @@ +import C from '../src/index'; + +describe('algo-sha256-profile', () => { + test('profileSinglePartMessage', () => { + let singlePartMessage = ''; + for (let i = 0; i < 500; i++) { + singlePartMessage += '12345678901234567890123456789012345678901234567890'; + } + new C.algo.SHA256().finalize(singlePartMessage) + ''; + }); + + test('profileMultiPartMessage', () => { + let sha256 = new C.algo.SHA256(); + for (let i = 0; i < 500; i++) { + sha256.update('12345678901234567890123456789012345678901234567890'); + } + sha256.finalize() + ''; + }); +}); \ No newline at end of file diff --git a/test/algo.sha256.test.js b/test/algo.sha256.test.js new file mode 100644 index 0000000..d5a40d6 --- /dev/null +++ b/test/algo.sha256.test.js @@ -0,0 +1,50 @@ +import C from '../src/index'; + +const VECTOR_CONFIG_TEST = [ + [1, '', 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'], + [2, 'a', 'ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb'], + [3, 'abc', 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'], + [4, 'message digest', 'f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650'], + [5, 'abcdefghijklmnopqrstuvwxyz', '71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73'], + [6, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0'], + [7, '12345678901234567890123456789012345678901234567890123456789012345678901234567890', 'f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e'] +]; + +describe('algo-sha256-test', () => { + test.each(VECTOR_CONFIG_TEST)( + 'testVector%i', + (a, b, expected) => { + expect(C.SHA256(b).toString()).toBe(expected); + } + ); + + test('testUpdateAndLongMessage', () => { + let sha256 = new C.algo.SHA256(); + for (let i = 0; i < 100; i++) { + sha256.update('12345678901234567890123456789012345678901234567890'); + } + expect(sha256.finalize().toString()).toBe('f8146961d9b73d8da49ccd526fca65439cdd5b402f76971556d5f52fd129843e'); + }); + + test('testClone', () => { + let sha256 = new C.algo.SHA256(); + expect(sha256.update('a').clone().finalize().toString()).toBe(C.SHA256('a').toString()); + expect(sha256.update('b').clone().finalize().toString()).toBe(C.SHA256('ab').toString()); + expect(sha256.update('c').clone().finalize().toString()).toBe(C.SHA256('abc').toString()); + }); + + test('testInputIntegrity', () => { + let message = new C.lib.WordArray([0x12345678]); + let expected = message.toString(); + C.SHA256(message); + expect(message.toString()).toBe(expected); + }); + + test('testHelper', () => { + expect(C.SHA256('').toString()).toBe(new C.algo.SHA256().finalize('').toString()); + }); + + test('testHmacHelper', () => { + expect(C.HmacSHA256('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()).toBe(new C.algo.HMAC(C.algo.SHA256, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString()); + }); +}); \ No newline at end of file diff --git a/test/algo.sha3.profile.test.js b/test/algo.sha3.profile.test.js new file mode 100644 index 0000000..0a4518c --- /dev/null +++ b/test/algo.sha3.profile.test.js @@ -0,0 +1,20 @@ +import C from '../src/index'; + +describe('algo-sha3-profile', () => { + test('profileSinglePartMessage', () => { + let singlePartMessage = ''; + for (let i = 0; i < 500; i++) { + singlePartMessage += '12345678901234567890123456789012345678901234567890'; + } + + new C.algo.SHA3().finalize(singlePartMessage) + ''; + }); + + test('profileMultiPartMessage', () => { + let sha3 = new C.algo.SHA3(); + for (let i = 0; i < 500; i++) { + sha3.update('12345678901234567890123456789012345678901234567890'); + } + sha3.finalize() + ''; + }); +}); \ No newline at end of file diff --git a/test/algo.sha3.test.js b/test/algo.sha3.test.js new file mode 100644 index 0000000..9df38a1 --- /dev/null +++ b/test/algo.sha3.test.js @@ -0,0 +1,96 @@ +import C from '../src/index'; + +describe('algo-sha3-test', () => { + test('testVector1', () => { + expect(C.SHA3('', { + outputLength: 512 + }).toString()) + .toBe('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e'); + }); + + test('testVector2', () => { + expect(C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { + outputLength: 512 + }).toString()) + .toBe('81950e7096d31d4f22e3db71cac725bf59e81af54c7ca9e6aeee71c010fc5467466312a01aa5c137cfb140646941556796f612c9351268737c7e9a2b9631d1fa'); + }); + + test('testVector3', () => { + expect(C.SHA3('', { + outputLength: 384 + }).toString()) + .toBe('2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff'); + }); + + test('testVector4', () => { + expect(C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { + outputLength: 384 + }).toString()) + .toBe('6bff1c8405a3fe594e360e3bccea1ebcd509310dc79b9e45c263783d7a5dd662c6789b18bd567dbdda1554f5bee6a860'); + }); + + test('testVector5', () => { + expect(C.SHA3('', { + outputLength: 256 + }).toString()) + .toBe('c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'); + }); + + test('testVector6', () => { + expect(C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { + outputLength: 256 + }).toString()) + .toBe('348fb774adc970a16b1105669442625e6adaa8257a89effdb5a802f161b862ea'); + }); + + test('testVector7', () => { + expect(C.SHA3('', { + outputLength: 224 + }).toString()) + .toBe('f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd'); + }); + + test('testVector8', () => { + expect(C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { + outputLength: 224 + }).toString()) + .toBe('5af56987ea9cf11fcd0eac5ebc14b037365e9b1123e31cb2dfc7929a'); + }); + + test('testDefaultOutputLength', () => { + expect(C.SHA3('').toString()) + .toBe('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e'); + }); + + test('testClone', () => { + const sha3 = new C.algo.SHA3(); + + expect(sha3.update('a').clone().finalize().toString()).toBe(C.SHA3('a').toString()); + expect(sha3.update('b').clone().finalize().toString()).toBe(C.SHA3('ab').toString()); + expect(sha3.update('c').clone().finalize().toString()).toBe(C.SHA3('abc').toString()); + }); + + test('testInputIntegrity', () => { + const message = new C.lib.WordArray([0x12345678]); + + const expected = message.toString(); + + C.SHA3(message); + + expect(message.toString()).toBe(expected); + }); + + test('testHelper', () => { + expect(C.SHA3('', { + outputLength: 256 + }).toString()) + .toBe(new C.algo.SHA3({ + outputLength: 256 + }).finalize('').toString()); + }); + + test('testHmacHelper', () => { + expect(C.HmacSHA3('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()) + .toBe(new C.algo.HMAC(C.algo.SHA3, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString()); + }); +}); \ No newline at end of file diff --git a/test/algo.sha384.test.js b/test/algo.sha384.test.js new file mode 100644 index 0000000..6fd7e52 --- /dev/null +++ b/test/algo.sha384.test.js @@ -0,0 +1,53 @@ +import C from '../src/index'; + +const VECTOR_CONFIG_TEST = [ + [1, '', '38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b'], + [2, 'The quick brown fox jumps over the lazy dog', 'ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1'], + [3, 'The quick brown fox jumps over the lazy dog.', 'ed892481d8272ca6df370bf706e4d7bc1b5739fa2177aae6c50e946678718fc67a7af2819a021c2fc34e91bdb63409d7'] +]; + +describe('algo-sha384-test', () => { + test.each(VECTOR_CONFIG_TEST)( + 'testVector%i', + (a, b, expected) => { + expect(C.SHA384(b).toString()).toBe(expected); + } + ); + + test('testUpdateAndLongMessage', () => { + const sha384 = new C.algo.SHA384(); + for (let i = 0; i < 100; i++) { + sha384.update('12345678901234567890123456789012345678901234567890'); + } + + expect(sha384.finalize().toString()) + .toBe('297a519246d6f639a4020119e1f03fc8d77171647b2ff75ea4125b7150fed0cdcc93f8dca1c3c6a624d5e88d780d82cd'); + }); + + test('testClone', () => { + const sha384 = new C.algo.SHA384(); + + expect(sha384.update('a').clone().finalize().toString()).toBe(C.SHA384('a').toString()); + expect(sha384.update('b').clone().finalize().toString()).toBe(C.SHA384('ab').toString()); + expect(sha384.update('c').clone().finalize().toString()).toBe(C.SHA384('abc').toString()); + }); + + test('testInputIntegrity', () => { + const message = new C.lib.WordArray([0x12345678]); + + const expected = message.toString(); + + C.SHA384(message); + + expect(message.toString()).toBe(expected); + }); + + test('testHelper', () => { + expect(C.SHA384('').toString()).toBe(new C.algo.SHA384().finalize('').toString()); + }); + + test('testHmacHelper', () => { + expect(C.HmacSHA384('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()) + .toBe(new C.algo.HMAC(C.algo.SHA384, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString()); + }); +}); \ No newline at end of file diff --git a/test/algo.sha512.profile.test.js b/test/algo.sha512.profile.test.js new file mode 100644 index 0000000..189bd50 --- /dev/null +++ b/test/algo.sha512.profile.test.js @@ -0,0 +1,19 @@ +import C from '../src/index'; + +describe('algo-sha512-profile', () => { + test('profileSinglePartMessage', () => { + let singlePartMessage = ''; + for (let i = 0; i < 500; i++) { + singlePartMessage += '12345678901234567890123456789012345678901234567890'; + } + new C.algo.SHA512().finalize(singlePartMessage) + ''; + }); + + test('profileMultiPartMessage', () => { + let sha512 = new C.algo.SHA512(); + for (let i = 0; i < 500; i++) { + sha512.update('12345678901234567890123456789012345678901234567890'); + } + sha512.finalize() + ''; + }); +}); \ No newline at end of file diff --git a/test/algo.sha512.test.js b/test/algo.sha512.test.js new file mode 100644 index 0000000..7b0f9ce --- /dev/null +++ b/test/algo.sha512.test.js @@ -0,0 +1,53 @@ +import C from '../src/index'; + +const VECTOR_CONFIG_TEST = [ + [1, '', 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'], + [2, 'The quick brown fox jumps over the lazy dog', '07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6'], + [3, 'The quick brown fox jumps over the lazy dog.', '91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bbc6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed'] +]; + +describe('algo-sha512-test', () => { + test.each(VECTOR_CONFIG_TEST)( + 'testVector%i', + (a, b, expected) => { + expect(C.SHA512(b).toString()).toBe(expected); + } + ); + + test('testUpdateAndLongMessage', () => { + const sha512 = new C.algo.SHA512(); + for (let i = 0; i < 100; i++) { + sha512.update('12345678901234567890123456789012345678901234567890'); + } + + expect(sha512.finalize().toString()) + .toBe('9bc64f37c54606dff234b6607e06683c7ba248558d0ec74a11525d9f59e0be566489cc9413c00ca5e9db705fc52ba71214bcf118f65072fe284af8f8cf9500af'); + }); + + test('testClone', () => { + const sha512 = new C.algo.SHA512(); + + expect(sha512.update('a').clone().finalize().toString()).toBe(C.SHA512('a').toString()); + expect(sha512.update('b').clone().finalize().toString()).toBe(C.SHA512('ab').toString()); + expect(sha512.update('c').clone().finalize().toString()).toBe(C.SHA512('abc').toString()); + }); + + test('testInputIntegrity', () => { + const message = new C.lib.WordArray([0x12345678]); + + const expected = message.toString(); + + C.SHA512(message); + + expect(message.toString()).toBe(expected); + }); + + test('testHelper', () => { + expect(C.SHA512('').toString()).toBe(new C.algo.SHA512().finalize('').toString()); + }); + + test('testHmacHelper', () => { + expect(C.HmacSHA512('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()) + .toBe(new C.algo.HMAC(C.algo.SHA512, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString()); + }); +}); \ No newline at end of file diff --git a/test/algo.tripledes.profile.test.js b/test/algo.tripledes.profile.test.js new file mode 100644 index 0000000..e5ba48f --- /dev/null +++ b/test/algo.tripledes.profile.test.js @@ -0,0 +1,30 @@ +import C from '../src/index'; + +const data = {}; +beforeAll(() => { + data.key = C.enc.Hex.parse('0001020304050607'); + data.iv = C.enc.Hex.parse('08090a0b0c0d0e0f'); +}); + +describe('algo-tripledes-profile', () => { + test('profileSinglePartMessage', () => { + let singlePartMessage = ''; + for (let i = 0; i < 100; i++) { + singlePartMessage += '12345678901234567890123456789012345678901234567890'; + } + + C.algo.TripleDES.createEncryptor(data.key, { + iv: data.iv + }).finalize(singlePartMessage) + ''; + }); + + test('profileMultiPartMessage', () => { + let des = C.algo.TripleDES.createEncryptor(data.key, { + iv: data.iv + }); + for (let i = 0; i < 100; i++) { + des.process('12345678901234567890123456789012345678901234567890') + ''; + } + des.finalize() + ''; + }); +}); \ No newline at end of file diff --git a/test/algo.tripledes.test.js b/test/algo.tripledes.test.js new file mode 100644 index 0000000..3ee21f5 --- /dev/null +++ b/test/algo.tripledes.test.js @@ -0,0 +1,111 @@ +import C from '../src/index'; + +const ENCRYPT_TEST_CONFIG = [ + [1, '0000000000000000', '800101010101010180010101010101018001010101010101', '95a8d72813daa94d'], + [1, '0000000000000000', '010101010101010201010101010101020101010101010102', '869efd7f9f265a09'], + [1, '8000000000000000', '010101010101010101010101010101010101010101010101', '95f8a5e5dd31d900'], + [1, '0000000000000001', '010101010101010101010101010101010101010101010101', '166b40b44aba4bd6'] +]; + +const DECRYPT_TEST_CONFIG = [ + [1, '95a8d72813daa94d', '800101010101010180010101010101018001010101010101', '0000000000000000'], + [1, '869efd7f9f265a09', '010101010101010201010101010101020101010101010102', '0000000000000000'], + [1, '95f8a5e5dd31d900', '010101010101010101010101010101010101010101010101', '8000000000000000'], + [1, '166b40b44aba4bd6', '010101010101010101010101010101010101010101010101', '0000000000000001'] +]; + +describe('algo-tripledes-test', () => { + test.each(ENCRYPT_TEST_CONFIG)( + 'testEncrypt%i', + (a, b, c, expected) => { + expect(C.TripleDES.encrypt(C.enc.Hex.parse(b), C.enc.Hex.parse(c), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).ciphertext.toString()).toBe(expected); + } + ); + + test.each(DECRYPT_TEST_CONFIG)( + 'testDecrypt%i', + (a, b, c, expected) => { + expect(C.TripleDES.decrypt(new C.lib.CipherParams({ + ciphertext: C.enc.Hex.parse(b) + }), C.enc.Hex.parse(c), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()).toBe(expected); + } + ); + + test('testMultiPart', () => { + let des = C.algo.TripleDES.createEncryptor(C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }); + let ciphertext1 = des.process(C.enc.Hex.parse('001122334455')); + let ciphertext2 = des.process(C.enc.Hex.parse('66778899aa')); + let ciphertext3 = des.process(C.enc.Hex.parse('bbccddeeff')); + let ciphertext4 = des.finalize(); + expect(ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString()).toBe(C.TripleDES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).ciphertext.toString()); + }); + + test('testInputIntegrity', () => { + let message = C.enc.Hex.parse('00112233445566778899aabbccddeeff'); + let key = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'); + let iv = C.enc.Hex.parse('08090a0b0c0d0e0f'); + + let expectedMessage = message.toString(); + let expectedKey = key.toString(); + let expectedIv = iv.toString(); + + C.TripleDES.encrypt(message, key, { + iv: iv + }); + + expect(message.toString()).toBe(expectedMessage); + expect(key.toString()).toBe(expectedKey); + expect(iv.toString()).toBe(expectedIv); + }); + + test('testHelper', () => { + // Save original random method + let random = C.lib.WordArray.random; + + // Replace random method with one that returns a predictable value + C.lib.WordArray.random = function (nBytes) { + let words = []; + for (let i = 0; i < nBytes; i += 4) { + words.push([0x11223344]); + } + + return new C.lib.WordArray(words, nBytes); + }; + + expect(C.TripleDES.encrypt('Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).ciphertext.toString()).toBe(C.algo.TripleDES.createEncryptor(C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).finalize('Hi There').toString()); + expect(C.TripleDES.encrypt('Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()).toBe(C.lib.SerializableCipher.encrypt(C.algo.TripleDES, 'Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()); + expect(C.TripleDES.encrypt('Hi There', 'Jefe', { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()).toBe(C.lib.PasswordBasedCipher.encrypt(C.algo.TripleDES, 'Hi There', 'Jefe', { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()); + // Restore random method + C.lib.WordArray.random = random; + }); +}); \ No newline at end of file diff --git a/test/cipher.test.js b/test/cipher.test.js new file mode 100644 index 0000000..32013b5 --- /dev/null +++ b/test/cipher.test.js @@ -0,0 +1,516 @@ +import C from '../src/index'; +import { + isString, + isArray, + isFunction +} from '../src/utils'; + +function extendWithCMAC(C) { + function createExt(C) { + /* + * The MIT License (MIT) + * + * Copyright (c) 2015 artjomb + */ + // put on ext property in CryptoJS + let ext; + if (!Object.prototype.hasOwnProperty.call(C, 'ext')) { + ext = C.ext = {}; + } else { + ext = C.ext; + } + + // Shortcuts + let WordArray = C.lib.WordArray; + + // Constants + ext.const_Zero = new WordArray([0x00000000, 0x00000000, 0x00000000, 0x00000000]); + ext.const_One = new WordArray([0x00000000, 0x00000000, 0x00000000, 0x00000001]); + ext.const_Rb = new WordArray([0x00000000, 0x00000000, 0x00000000, 0x00000087]); // 00..0010000111 + ext.const_Rb_Shifted = new WordArray([0x80000000, 0x00000000, 0x00000000, 0x00000043]); // 100..001000011 + ext.const_nonMSB = new WordArray([0xFFFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF]); // 1^64 || 0^1 || 1^31 || 0^1 || 1^31 + + /** + * Looks into the object to see if it is a WordArray. + * + * @param obj Some object + * + * @returns {boolean} + */ + ext.isWordArray = function (obj) { + return obj && isFunction(obj.clamp) && isFunction(obj.concat) && isArray(obj.words); + }; + + /** + * This padding is a 1 bit followed by as many 0 bits as needed to fill + * up the block. This implementation doesn't work on bits directly, + * but on bytes. Therefore the granularity is much bigger. + */ + C.pad.OneZeroPadding = { + pad: function (data, blocksize) { + // Shortcut + let blockSizeBytes = blocksize * 4; + + // Count padding bytes + let nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; + + // Create padding + let paddingWords = []; + for (let i = 0; i < nPaddingBytes; i += 4) { + let paddingWord = 0x00000000; + if (i === 0) { + paddingWord = 0x80000000; + } + paddingWords.push(paddingWord); + } + let padding = new WordArray(paddingWords, nPaddingBytes); + + // Add padding + data.concat(padding); + }, + unpad: function () { + // TODO: implement + } + }; + + /** + * No padding is applied. This is necessary for streaming cipher modes + * like CTR. + */ + C.pad.NoPadding = { + pad: function () {}, + unpad: function () {} + }; + + /** + * Returns the n leftmost bytes of the WordArray. + * + * @param {WordArray} wordArray WordArray to work on + * @param {int} n Bytes to retrieve + * + * @returns new WordArray + */ + ext.leftmostBytes = function (wordArray, n) { + let lmArray = wordArray.clone(); + lmArray.sigBytes = n; + lmArray.clamp(); + return lmArray; + }; + + /** + * Returns the n rightmost bytes of the WordArray. + * + * @param {WordArray} wordArray WordArray to work on + * @param {int} n Bytes to retrieve (must be positive) + * + * @returns new WordArray + */ + ext.rightmostBytes = function (wordArray, n) { + wordArray.clamp(); + let wordSize = 32; + let rmArray = wordArray.clone(); + let bitsToShift = (rmArray.sigBytes - n) * 8; + if (bitsToShift >= wordSize) { + let popCount = Math.floor(bitsToShift / wordSize); + bitsToShift -= popCount * wordSize; + rmArray.words.splice(0, popCount); + rmArray.sigBytes -= popCount * wordSize / 8; + } + if (bitsToShift > 0) { + ext.bitshift(rmArray, bitsToShift); + rmArray.sigBytes -= bitsToShift / 8; + } + return rmArray; + }; + + /** + * Returns the n rightmost words of the WordArray. It assumes + * that the current WordArray has at least n words. + * + * @param {WordArray} wordArray WordArray to work on + * @param {int} n Words to retrieve (must be positive) + * + * @returns popped words as new WordArray + */ + ext.popWords = function (wordArray, n) { + let left = wordArray.words.splice(0, n); + wordArray.sigBytes -= n * 4; + return new WordArray(left); + }; + + /** + * Shifts the array to the left and returns the shifted dropped elements + * as WordArray. The initial WordArray must contain at least n bytes and + * they have to be significant. + * + * @param {WordArray} wordArray WordArray to work on (is modified) + * @param {int} n Bytes to shift (must be positive, default 16) + * + * @returns new WordArray + */ + ext.shiftBytes = function (wordArray, n) { + n = n || 16; + let r = n % 4; + n -= r; + + let shiftedArray = new WordArray(); + for (let i = 0; i < n; i += 4) { + shiftedArray.words.push(wordArray.words.shift()); + wordArray.sigBytes -= 4; + shiftedArray.sigBytes += 4; + } + if (r > 0) { + shiftedArray.words.push(wordArray.words[0]); + shiftedArray.sigBytes += r; + + ext.bitshift(wordArray, r * 8); + wordArray.sigBytes -= r; + } + return shiftedArray; + }; + + /** + * XORs arr2 to the end of arr1 array. This doesn't modify the current + * array aside from clamping. + * + * @param {WordArray} arr1 Bigger array + * @param {WordArray} arr2 Smaller array to be XORed to the end + * + * @returns new WordArray + */ + ext.xorendBytes = function (arr1, arr2) { + // TODO: more efficient + return ext.leftmostBytes(arr1, arr1.sigBytes - arr2.sigBytes) + .concat(ext.xor(ext.rightmostBytes(arr1, arr2.sigBytes), arr2)); + }; + + /** + * Doubling operation on a 128-bit value. This operation modifies the + * passed array. + * + * @param {WordArray} wordArray WordArray to work on + * + * @returns passed WordArray + */ + ext.dbl = function (wordArray) { + let carry = ext.msb(wordArray); + ext.bitshift(wordArray, 1); + ext.xor(wordArray, carry === 1 ? ext.const_Rb : ext.const_Zero); + return wordArray; + }; + + /** + * Inverse operation on a 128-bit value. This operation modifies the + * passed array. + * + * @param {WordArray} wordArray WordArray to work on + * + * @returns passed WordArray + */ + ext.inv = function (wordArray) { + let carry = wordArray.words[4] & 1; + ext.bitshift(wordArray, -1); + ext.xor(wordArray, carry === 1 ? ext.const_Rb_Shifted : ext.const_Zero); + return wordArray; + }; + + /** + * Check whether the word arrays are equal. + * + * @param {WordArray} arr1 Array 1 + * @param {WordArray} arr2 Array 2 + * + * @returns boolean + */ + ext.equals = function (arr1, arr2) { + if (!arr2 || !arr2.words || arr1.sigBytes !== arr2.sigBytes) { + return false; + } + arr1.clamp(); + arr2.clamp(); + let equal = 0; + for (let i = 0; i < arr1.words.length; i++) { + equal |= arr1.words[i] ^ arr2.words[i]; + } + return equal === 0; + }; + + /** + * Retrieves the most significant bit of the WordArray as an Integer. + * + * @param {WordArray} arr + * + * @returns Integer + */ + ext.msb = function (arr) { + return arr.words[0] >>> 31; + }; + } + + function createExtBit(C) { + /* + * The MIT License (MIT) + * + * Copyright (c) 2015 artjomb + */ + // put on ext property in CryptoJS + let ext; + if (!Object.prototype.hasOwnProperty.call(C, 'ext')) { + ext = C.ext = {}; + } else { + ext = C.ext; + } + + /** + * Shifts the array by n bits to the left. Zero bits are added as the + * least significant bits. This operation modifies the current array. + * + * @param {WordArray} wordArray WordArray to work on + * @param {int} n Bits to shift by + * + * @returns the WordArray that was passed in + */ + ext.bitshift = function (wordArray, n) { + let carry = 0, + words = wordArray.words, + wres, + skipped = 0, + carryMask; + if (n > 0) { + while (n > 31) { + // delete first element: + words.splice(0, 1); + + // add `0` word to the back + words.push(0); + + n -= 32; + skipped++; + } + if (n == 0) { + // 1. nothing to shift if the shift amount is on a word boundary + // 2. This has to be done, because the following algorithm computes + // wrong values only for n==0 + return carry; + } + for (let i = words.length - skipped - 1; i >= 0; i--) { + wres = words[i]; + words[i] <<= n; + words[i] |= carry; + carry = wres >>> (32 - n); + } + } else if (n < 0) { + while (n < -31) { + // insert `0` word to the front: + words.splice(0, 0, 0); + + // remove last element: + words.length--; + + n += 32; + skipped++; + } + if (n == 0) { + // nothing to shift if the shift amount is on a word boundary + return carry; + } + n = -n; + carryMask = (1 << n) - 1; + for (let i = skipped; i < words.length; i++) { + wres = words[i] & carryMask; + words[i] >>>= n; + words[i] |= carry; + carry = wres << (32 - n); + } + } + return carry; + }; + + /** + * Negates all bits in the WordArray. This manipulates the given array. + * + * @param {WordArray} wordArray WordArray to work on + * + * @returns the WordArray that was passed in + */ + ext.neg = function (wordArray) { + let words = wordArray.words; + for (let i = 0; i < words.length; i++) { + words[i] = ~words[i]; + } + return wordArray; + }; + + /** + * Applies XOR on both given word arrays and returns a third resulting + * WordArray. The initial word arrays must have the same length + * (significant bytes). + * + * @param {WordArray} wordArray1 WordArray + * @param {WordArray} wordArray2 WordArray + * + * @returns first passed WordArray (modified) + */ + ext.xor = function (wordArray1, wordArray2) { + for (let i = 0; i < wordArray1.words.length; i++) { + wordArray1.words[i] ^= wordArray2.words[i]; + } + return wordArray1; + }; + + /** + * Logical AND between the two passed arrays. Both arrays must have the + * same length. + * + * @param {WordArray} arr1 Array 1 + * @param {WordArray} arr2 Array 2 + * + * @returns new WordArray + */ + ext.bitand = function (arr1, arr2) { + let newArr = arr1.clone(), + tw = newArr.words, + ow = arr2.words; + for (let i = 0; i < tw.length; i++) { + tw[i] &= ow[i]; + } + return newArr; + }; + } + + function createCMAC(C) { + /* + * The MIT License (MIT) + * + * Copyright (c) 2015 artjomb + */ + // Shortcuts + let Base = C.lib.Base; + let WordArray = C.lib.WordArray; + let AES = C.algo.AES; + let ext = C.ext; + let OneZeroPadding = C.pad.OneZeroPadding; + + let CMAC = C.algo.CMAC = class CMAC extends Base { + constructor(key) { + super(); + // generate sub keys... + this._aes = AES.createEncryptor(key, { + iv: new WordArray(), + padding: C.pad.NoPadding + }); + + this._isTwo = false; + + // Step 1 + let L = this._aes.finalize(ext.const_Zero); + + // Step 2 + let K1 = L.clone(); + ext.dbl(K1); + + // Step 3 + let K2; + if (!this._isTwo) { + K2 = K1.clone(); + ext.dbl(K2); + } else { + K2 = L.clone(); + ext.inv(K2); + } + + this._K1 = K1; + this._K2 = K2; + + this._const_Bsize = 16; + + this.reset(); + } + + reset() { + this._x = ext.const_Zero.clone(); + this._counter = 0; + this._buffer = new WordArray(); + } + + update(messageUpdate) { + if (!messageUpdate) { + return this; + } + + // Shortcuts + let buffer = this._buffer; + let bsize = this._const_Bsize; + + if (isString(messageUpdate)) { + messageUpdate = C.enc.Utf8.parse(messageUpdate); + } + + buffer.concat(messageUpdate); + + while (buffer.sigBytes > bsize) { + let M_i = ext.shiftBytes(buffer, bsize); + ext.xor(this._x, M_i); + this._x.clamp(); + this._aes.reset(); + this._x = this._aes.finalize(this._x); + this._counter++; + } + + // Chainable + return this; + } + + finalize(messageUpdate) { + this.update(messageUpdate); + + // Shortcuts + let buffer = this._buffer; + let bsize = this._const_Bsize; + + let M_last = buffer.clone(); + if (buffer.sigBytes === bsize) { + ext.xor(M_last, this._K1); + } else { + OneZeroPadding.pad(M_last, bsize / 4); + ext.xor(M_last, this._K2); + } + + ext.xor(M_last, this._x); + + this.reset(); // Can be used immediately afterwards + + this._aes.reset(); + return this._aes.finalize(M_last); + } + }; + + /** + * Directly invokes the CMAC and returns the calculated MAC. + * + * @param {WordArray} key The key to be used for CMAC + * @param {WordArray|string} message The data to be MAC'ed (either WordArray or UTF-8 encoded string) + * + * @returns {WordArray} MAC + */ + C.CMAC = function (key, message) { + return new CMAC(key).finalize(message); + }; + + C.algo.OMAC1 = CMAC; + C.algo.OMAC2 = new CMAC({ + _isTwo: true + }); + } + + createExt(C); + createExtBit(C); + createCMAC(C); +} + +describe('cipher-core-test', () => { + extendWithCMAC(C); + test('testCMAC', () => { + expect(C.CMAC('69c4e0d86a7b0430d8cdb78070b4c55a', 'Test message').toString()).toBe('35e1872b95ce5d99bb5dbbbbd79b9b9b'); + }); +}); \ No newline at end of file diff --git a/test/des.profile.test.js b/test/des.profile.test.js new file mode 100644 index 0000000..a1293a5 --- /dev/null +++ b/test/des.profile.test.js @@ -0,0 +1,29 @@ +import C from '../src/index'; + +let data = {}; +beforeAll(() => { + data.key = C.enc.Hex.parse('0001020304050607'); + data.iv = C.enc.Hex.parse('08090a0b0c0d0e0f'); +}); + +describe('algo-des-profile', () => { + test('profileSinglePartMessage', () => { + let singlePartMessage = ''; + for (let i = 0; i < 100; i++) { + singlePartMessage += '12345678901234567890123456789012345678901234567890'; + } + C.algo.DES.createEncryptor(data.key, { + iv: data.iv + }).finalize(singlePartMessage) + ''; + }); + + test('profileMultiPartMessage', () => { + let des = C.algo.DES.createEncryptor(data.key, { + iv: data.iv + }); + for (let i = 0; i < 100; i++) { + des.process('12345678901234567890123456789012345678901234567890') + ''; + } + des.finalize() + ''; + }); +}); \ No newline at end of file diff --git a/test/des.test.js b/test/des.test.js new file mode 100644 index 0000000..b9db9be --- /dev/null +++ b/test/des.test.js @@ -0,0 +1,114 @@ +import C from '../src/index'; + +const ENCRYPT_TEST_CONFIG = [ + [1, '0000000000000000', '8000000000000000', '95a8d72813daa94d'], + [2, '0000000000000000', '0000000000002000', '1de5279dae3bed6f'], + [3, '0000000000002000', '0000000000000000', '1d1ca853ae7c0c5f'], + [4, '3232323232323232', '3232323232323232', 'ac978c247863388f'], + [5, '6464646464646464', '6464646464646464', '3af1703d76442789'], + [6, '9696969696969696', '9696969696969696', 'a020003c5554f34c'] +]; + +const DECRYPT_TEST_CONFIG = [ + [1, '95a8d72813daa94d', '8000000000000000', '0000000000000000'], + [2, '1de5279dae3bed6f', '0000000000002000', '0000000000000000'], + [3, '1d1ca853ae7c0c5f', '0000000000000000', '0000000000002000'], + [4, 'ac978c247863388f', '3232323232323232', '3232323232323232'], + [5, '3af1703d76442789', '6464646464646464', '6464646464646464'], + [6, 'a020003c5554f34c', '9696969696969696', '9696969696969696'] +]; + +describe('algo-des-test', () => { + test.each(ENCRYPT_TEST_CONFIG)( + 'testEncrypt%i', + (a, b, c, expected) => { + expect(C.DES.encrypt(C.enc.Hex.parse(b), C.enc.Hex.parse(c), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).ciphertext.toString()).toBe(expected); + } + ); + + test.each(DECRYPT_TEST_CONFIG)( + 'testDercrypt%i', + (a, b, c, expected) => { + expect(C.DES.decrypt(new C.lib.CipherParams({ + ciphertext: C.enc.Hex.parse(b) + }), C.enc.Hex.parse(c), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()).toBe(expected); + } + ); + + test('testMultiPart', () => { + let des = C.algo.DES.createEncryptor(C.enc.Hex.parse('0123456789abcdef'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }); + let ciphertext1 = des.process(C.enc.Hex.parse('001122334455')); + let ciphertext2 = des.process(C.enc.Hex.parse('66778899aa')); + let ciphertext3 = des.process(C.enc.Hex.parse('bbccddeeff')); + let ciphertext4 = des.finalize(); + expect(ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString()).toBe(C.DES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('0123456789abcdef'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).ciphertext.toString()); + }); + + test('testInputIntegrity', () => { + let message = C.enc.Hex.parse('00112233445566778899aabbccddeeff'); + let key = C.enc.Hex.parse('0001020304050607'); + let iv = C.enc.Hex.parse('08090a0b0c0d0e0f'); + + let expectedMessage = message.toString(); + let expectedKey = key.toString(); + let expectedIv = iv.toString(); + + C.DES.encrypt(message, key, { + iv: iv + }); + + expect(message.toString()).toBe(expectedMessage); + expect(key.toString()).toBe(expectedKey); + expect(iv.toString()).toBe(expectedIv); + }); + + test('testHelper', () => { + // Save original random method + let random = C.lib.WordArray.random; + + // Replace random method with one that returns a predictable value + C.lib.WordArray.random = function (nBytes) { + let words = []; + for (let i = 0; i < nBytes; i += 4) { + words.push([0x11223344]); + } + + return new C.lib.WordArray(words, nBytes); + }; + expect(C.DES.encrypt('Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).ciphertext.toString()).toBe(C.algo.DES.createEncryptor(C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).finalize('Hi There').toString()); + expect(C.DES.encrypt('Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()).toBe(C.lib.SerializableCipher.encrypt(C.algo.DES, 'Hi There', C.SHA256('Jefe'), { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()); + expect(C.DES.encrypt('Hi There', 'Jefe', { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()).toBe(C.lib.PasswordBasedCipher.encrypt(C.algo.DES, 'Hi There', 'Jefe', { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).toString()); + // Restore random method + C.lib.WordArray.random = random; + }); +}); \ No newline at end of file diff --git a/test/enc.base64.test.js b/test/enc.base64.test.js new file mode 100644 index 0000000..17a9362 --- /dev/null +++ b/test/enc.base64.test.js @@ -0,0 +1,45 @@ +import C from '../src/index'; + +const STRINGFY_TEST_CONFIG = [ + [0, 0, ''], + [1, 1, 'Zg=='], + [2, 2, 'Zm8='], + [3, 3, 'Zm9v'], + [4, 4, 'Zm9vYg=='], + [5, 5, 'Zm9vYmE='], + [6, 6, 'Zm9vYmFy'] +]; + +const PARSE_TEST_CONFIG = [ + [0, '', 0], + [1, 'Zg==', 1], + [2, 'Zm8=', 2], + [3, 'Zm9v', 3], + [4, 'Zm9vYg==', 4], + [5, 'Zm9vYmE=', 5], + [6, 'Zm9vYmFy', 6] +]; + +describe('enc-base64-test', () => { + test.each(STRINGFY_TEST_CONFIG)( + 'testStringfy%i', + (a, b, expected) => { + expect(C.enc.Base64.stringify(new C.lib.WordArray([0x666f6f62, 0x61720000], b))).toBe(expected); + } + ); + + test('testStringify15', () => { + expect(C.enc.Base64.stringify(new C.lib.WordArray([0x3e3e3e3f, 0x3f3f3e3e, 0x3e3f3f3f, 0x3d2f2b00], 15))).toBe('Pj4+Pz8/Pj4+Pz8/PS8r'); + }); + + test.each(PARSE_TEST_CONFIG)( + 'testParse%i', + (a, b, expected) => { + expect(C.enc.Base64.parse(b).toString()).toBe(new C.lib.WordArray([0x666f6f62, 0x61720000], expected).toString()); + } + ); + + test('testParse15', () => { + expect(C.enc.Base64.parse('Pj4+Pz8/Pj4+Pz8/PS8r').toString()).toBe(new C.lib.WordArray([0x3e3e3e3f, 0x3f3f3e3e, 0x3e3f3f3f, 0x3d2f2b00], 15).toString()); + }); +}); \ No newline at end of file diff --git a/test/enc.hex.test.js b/test/enc.hex.test.js new file mode 100644 index 0000000..206adcf --- /dev/null +++ b/test/enc.hex.test.js @@ -0,0 +1,11 @@ +import C from '../src/index'; + +describe('enc-hex-test', () => { + test('testStringify', () => { + expect(C.enc.Hex.stringify(new C.lib.WordArray([0x12345678]))).toBe('12345678'); + }); + + test('testParse', () => { + expect(C.enc.Hex.parse('12345678').toString()).toBe(new C.lib.WordArray([0x12345678]).toString()); + }); +}); \ No newline at end of file diff --git a/test/enc.latain1.test.js b/test/enc.latain1.test.js new file mode 100644 index 0000000..7ff5293 --- /dev/null +++ b/test/enc.latain1.test.js @@ -0,0 +1,11 @@ +import C from '../src/index'; + +describe('enc-latin1-test', () => { + test('testStringify', () => { + expect( C.enc.Latin1.stringify(new C.lib.WordArray([0x12345678]))).toBe('\x12\x34\x56\x78'); + }); + + test('testParse', () => { + expect(C.enc.Latin1.parse('\x12\x34\x56\x78').toString()).toBe(new C.lib.WordArray([0x12345678]).toString()); + }); +}); \ No newline at end of file diff --git a/test/enc.utf16.test.js b/test/enc.utf16.test.js new file mode 100644 index 0000000..9c074d5 --- /dev/null +++ b/test/enc.utf16.test.js @@ -0,0 +1,41 @@ +import C from '../src/index'; + +const STRINGFY_TEST_CONFIG = [ + [1, 0x007a0000, 2, 'z'], + [2, 0x6c340000, 2, '水'], + [3, 0xd800dc00, 4, '𐀀'], + [4, 0xd834dd1e, 4, '𝄞'], + [5, 0xdbffdffd, 4, '􏿽'] +]; + +const PARSE_TEST_CONFIG = [ + [1, 'z', 0x007a0000, 2], + [2, '水', 0x6c340000, 2], + [3, '𐀀', 0xd800dc00, 4], + [4, '𝄞', 0xd834dd1e, 4], + [5, '􏿽', 0xdbffdffd, 4] +]; + +describe('enc-utf16-test', () => { + test.each(STRINGFY_TEST_CONFIG)( + 'testString%i', + (a, b, c, expected) => { + expect(C.enc.Utf16.stringify(new C.lib.WordArray([b], c))).toBe(expected); + } + ); + + test('testStringifyLE', () => { + expect(C.enc.Utf16LE.stringify(new C.lib.WordArray([0xffdbfddf], 4))).toBe('􏿽'); + }); + + test.each(PARSE_TEST_CONFIG)( + 'testParse%i', + (a, expected, b, c) => { + expect(C.enc.Utf16.parse(expected).toString()).toBe(new C.lib.WordArray([b], c).toString()); + } + ); + + test('testParseLE', () => { + expect(C.enc.Utf16LE.parse('􏿽').toString()).toBe(new C.lib.WordArray([0xffdbfddf], 4).toString()); + }); +}); diff --git a/test/enc.utf8.test.js b/test/enc.utf8.test.js new file mode 100644 index 0000000..f9d3417 --- /dev/null +++ b/test/enc.utf8.test.js @@ -0,0 +1,31 @@ +import C from '../src/index'; + +const STRINGFY_TEST_CONFIG = [ + [1, 1, 0x24000000, '$'], + [2, 2, 0xc2a20000, '¢'], + [3, 3, 0xe282ac00, '€'], + [4, 4, 0xf0a4ada2, '𤭢'] +]; + +const PARSE_TEST_CONFIG = [ + [1, '$', 0x24000000, 1], + [2, '¢', 0xc2a20000, 2], + [3, '€', 0xe282ac00, 3], + [4, '𤭢', 0xf0a4ada2, 4] +]; + +describe('enc-utf8-tes', () => { + test.each(STRINGFY_TEST_CONFIG)( + 'testStringfy%i', + (a, b, c, expected) => { + expect(C.enc.Utf8.stringify(new C.lib.WordArray([c], b))).toBe(expected); + } + ); + + test.each(PARSE_TEST_CONFIG)( + 'testParse%i', + (a, b, c, expected) => { + expect(C.enc.Utf8.parse(b).toString()).toBe(new C.lib.WordArray([c], expected).toString()); + } + ); +}); \ No newline at end of file diff --git a/test/evpkdf.profile.test.js b/test/evpkdf.profile.test.js new file mode 100644 index 0000000..a27db10 --- /dev/null +++ b/test/evpkdf.profile.test.js @@ -0,0 +1,7 @@ +import C from '../src/index'; + +describe('algo-evpkdf-profile', () => { + test('profileKeySize256Iterations20', () => { + new C.algo.EvpKDF({ keySize: 256/32, iterations: 20 }).compute('password', 'ATHENA.MIT.EDUraeburn'); + }); +}); \ No newline at end of file diff --git a/test/evpkdf.test.js b/test/evpkdf.test.js new file mode 100644 index 0000000..028f388 --- /dev/null +++ b/test/evpkdf.test.js @@ -0,0 +1,27 @@ +import C from '../src/index'; + +describe('algo-evpkdf-test', () => { + test('testVector', () => { + expect(C.EvpKDF('password', 'saltsalt', { keySize: (256+128)/32 }).toString()).toBe('fdbdf3419fff98bdb0241390f62a9db35f4aba29d77566377997314ebfc709f20b5ca7b1081f94b1ac12e3c8ba87d05a'); + }); + + // There are no official test vectors that I could find, and the EVP implementation is short on comments. + // Need to use the C code to generate more test vectors. + // The iteration count in particular needs to be tested. + test('testInputIntegrity', () => { + let password = new C.lib.WordArray([0x12345678]); + let salt = new C.lib.WordArray([0x12345678]); + + let expectedPassword = password.toString(); + let expectedSalt = salt.toString(); + + C.EvpKDF(password, salt); + + expect(password.toString()).toBe(expectedPassword); + expect(salt.toString()).toBe(expectedSalt); + }); + + test('testHelper', () => { + expect(C.EvpKDF('password', 'saltsalt', { keySize: (256+128)/32 }).toString()).toBe(new C.algo.EvpKDF({ keySize: (256+128)/32 }).compute('password', 'saltsalt').toString()); + }); +}); \ No newline at end of file diff --git a/test/format.openssl.test.js b/test/format.openssl.test.js new file mode 100644 index 0000000..fe5be04 --- /dev/null +++ b/test/format.openssl.test.js @@ -0,0 +1,40 @@ +import C from '../src/index'; + +const data = {}; +beforeAll(() => { + data.ciphertext = new C.lib.WordArray([0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f]); + data.salt = new C.lib.WordArray([0x01234567, 0x89abcdef]); +}); + +describe('format-openssl-test', () => { + test('testSaltedToString', () => { + expect(C.format.OpenSSL.stringify(new C.lib.CipherParams({ + ciphertext: data.ciphertext, + salt: data.salt + }))).toBe(C.enc.Latin1.parse('Salted__').concat(data.salt).concat(data.ciphertext).toString(C.enc.Base64)); + }); + + test('testUnsaltedToString', () => { + expect(C.format.OpenSSL.stringify(new C.lib.CipherParams({ + ciphertext: data.ciphertext + }))).toBe(data.ciphertext.toString(C.enc.Base64)); + }); + + test('testSaltedFromString', () => { + let openSSLStr = C.format.OpenSSL.stringify(new C.lib.CipherParams({ + ciphertext: data.ciphertext, + salt: data.salt + })); + let cipherParams = C.format.OpenSSL.parse(openSSLStr); + expect(cipherParams.ciphertext.toString()).toBe(data.ciphertext.toString()); + expect(cipherParams.salt.toString()).toBe(data.salt.toString()); + }); + + test('testUnsaltedFromString', () => { + let openSSLStr = C.format.OpenSSL.stringify(new C.lib.CipherParams({ + ciphertext: data.ciphertext + })); + let cipherParams = C.format.OpenSSL.parse(openSSLStr); + expect(cipherParams.ciphertext.toString()).toBe(data.ciphertext.toString()); + }); +}); \ No newline at end of file diff --git a/test/hmac.md5.profile.test.js b/test/hmac.md5.profile.test.js new file mode 100644 index 0000000..97054e6 --- /dev/null +++ b/test/hmac.md5.profile.test.js @@ -0,0 +1,24 @@ +import C from '../src/index'; + +let data = {}; +beforeAll(() => { + data.key = C.lib.WordArray.random(128/8); +}); + +describe('algo-hmac-md5-profile', () => { + test('profileSinglePartMessage', () => { + let singlePartMessage = ''; + for (let i = 0; i < 500; i++) { + singlePartMessage += '12345678901234567890123456789012345678901234567890'; + } + new C.algo.HMAC(C.algo.MD5, data.key).finalize(singlePartMessage) + ''; + }); + + test('profileMultiPartMessage', () => { + let hmac = new C.algo.HMAC(C.algo.MD5, data.key); + for (let i = 0; i < 500; i++) { + hmac.update('12345678901234567890123456789012345678901234567890'); + } + hmac.finalize() + ''; + }); +}); \ No newline at end of file diff --git a/test/hmac.md5.test.js b/test/hmac.md5.test.js new file mode 100644 index 0000000..7bf7124 --- /dev/null +++ b/test/hmac.md5.test.js @@ -0,0 +1,53 @@ +import C from '../src/index'; + +describe('algo-hmac-md5-test', () => { + test('testVector1', () => { + expect(C.HmacMD5('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()).toBe('9294727a3638bb1c13f48ef8158bfc9d'); + }); + + test('testVector2', () => { + expect(C.HmacMD5('what do ya want for nothing?', 'Jefe').toString()).toBe('750c783e6ab0b503eaa86e310a5db738'); + }); + + test('testVector3', () => { + expect(C.HmacMD5(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()).toBe('56be34521d144c88dbb8c733f0e8b3f6'); + }); + + test('testVector4', () => { + expect(C.HmacMD5('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString()).toBe('7ee2a3cc979ab19865704644ce13355c'); + }); + + test('testVector5', () => { + expect(C.HmacMD5('abcdefghijklmnopqrstuvwxyz', 'A').toString()).toBe('0e1bd89c43e3e6e3b3f8cf1d5ba4f77a'); + }); + + test('testUpdate', () => { + let hmac = new C.algo.HMAC(C.algo.MD5, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); + expect(hmac.finalize().toString()).toBe(C.HmacMD5(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()); + }); + + test('testInputIntegrity', () => { + let message = new C.lib.WordArray([0x12345678]); + let key = new C.lib.WordArray([0x12345678]); + + let expectedMessage = message.toString(); + let expectedKey = key.toString(); + + C.HmacMD5(message, key); + expect(message.toString()).toBe(expectedMessage); + expect(key.toString()).toBe(expectedKey); + }); + + test('testRespectKeySigBytes', () => { + let key = C.lib.WordArray.random(8); + key.sigBytes = 4; + + let keyClamped = key.clone(); + keyClamped.clamp(); + + expect(C.HmacMD5('Message', key).toString()).toBe(C.HmacMD5('Message', keyClamped).toString()); + }); +}); \ No newline at end of file diff --git a/test/hmac.sha224.test.js b/test/hmac.sha224.test.js new file mode 100644 index 0000000..98cebd5 --- /dev/null +++ b/test/hmac.sha224.test.js @@ -0,0 +1,54 @@ +import C from '../src/index'; + +describe('algo-hmac-sha224-test', () => { + test('testVector1', () => { + expect(C.HmacSHA224('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()).toBe('4e841ce7a4ae83fbcf71e3cd64bfbf277f73a14680aae8c518ac7861'); + }); + + test('testVector2', () => { + expect(C.HmacSHA224('what do ya want for nothing?', 'Jefe').toString()).toBe('a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44'); + }); + + test('testVector3', () => { + expect(C.HmacSHA224(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()).toBe('cbff7c2716bbaa7c77bed4f491d3e8456cb6c574e92f672b291acf5b'); + }); + + test('testVector4', () => { + expect(C.HmacSHA224('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString()).toBe('61bf669da4fdcd8e5c3bd09ebbb4a986d3d1b298d3ca05c511f7aeff'); + }); + + test('testVector5', () => { + expect(C.HmacSHA224('abcdefghijklmnopqrstuvwxyz', 'A').toString()).toBe('16fc69ada3c3edc1fe9144d6b98d93393833ae442bedf681110a1176'); + }); + + test('testUpdate', () => { + let hmac = new C.algo.HMAC(C.algo.SHA224, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); + expect(hmac.finalize().toString()).toBe(C.HmacSHA224(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()); + }); + + test('testInputIntegrity', () => { + let message = new C.lib.WordArray([0x12345678]); + let key = new C.lib.WordArray([0x12345678]); + + let expectedMessage = message.toString(); + let expectedKey = key.toString(); + + C.HmacSHA224(message, key); + + expect(message.toString()).toBe(expectedMessage); + expect(key.toString()).toBe(expectedKey); + }); + + test('testRespectKeySigBytes', () => { + let key = C.lib.WordArray.random(8); + key.sigBytes = 4; + + let keyClamped = key.clone(); + keyClamped.clamp(); + + expect(C.HmacSHA224('Message', key).toString()).toBe(C.HmacSHA224('Message', keyClamped).toString()); + }); +}); \ No newline at end of file diff --git a/test/hmac.sha256.test.js b/test/hmac.sha256.test.js new file mode 100644 index 0000000..bf15e4e --- /dev/null +++ b/test/hmac.sha256.test.js @@ -0,0 +1,53 @@ +import C from '../src/index'; + +describe('algo-hmac-sha256-test', () => { + test('testVector1', () => { + expect(C.HmacSHA256('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()).toBe('492ce020fe2534a5789dc3848806c78f4f6711397f08e7e7a12ca5a4483c8aa6'); + }); + + test('testVector2', () => { + expect(C.HmacSHA256('what do ya want for nothing?', 'Jefe').toString()).toBe('5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843'); + }); + + test('testVector3', () => { + expect(C.HmacSHA256(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()).toBe('7dda3cc169743a6484649f94f0eda0f9f2ff496a9733fb796ed5adb40a44c3c1'); + }); + + test('testVector4', () => { + expect(C.HmacSHA256('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString()).toBe('a89dc8178c1184a62df87adaa77bf86e93064863d93c5131140b0ae98b866687'); + }); + + test('testVector5', () => { + expect(C.HmacSHA256('abcdefghijklmnopqrstuvwxyz', 'A').toString()).toBe('d8cb78419c02fe20b90f8b77427dd9f81817a751d74c2e484e0ac5fc4e6ca986'); + }); + + test('testUpdate', () => { + let hmac = new C.algo.HMAC(C.algo.SHA256, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); + + expect(hmac.finalize().toString()).toBe(C.HmacSHA256(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()); + }); + + test('testInputIntegrity', () => { + let message = new C.lib.WordArray([0x12345678]); + let key = new C.lib.WordArray([0x12345678]); + + let expectedMessage = message.toString(); + let expectedKey = key.toString(); + + C.HmacSHA256(message, key); + + expect(message.toString()).toBe(expectedMessage); + expect(key.toString()).toBe(expectedKey); + }); + + test('testRespectKeySigBytes', () => { + let key = C.lib.WordArray.random(8); + key.sigBytes = 4; + let keyClamped = key.clone(); + keyClamped.clamp(); + expect(C.HmacSHA256('Message', key).toString()).toBe(C.HmacSHA256('Message', keyClamped).toString()); + }); +}); \ No newline at end of file diff --git a/test/hmac.sha384.test.js b/test/hmac.sha384.test.js new file mode 100644 index 0000000..bc16a9c --- /dev/null +++ b/test/hmac.sha384.test.js @@ -0,0 +1,48 @@ +import C from '../src/index'; + +describe('algo-hmac-sha384-test', () => { + test('testVector1', () => { + expect(C.HmacSHA384('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()).toBe('7afaa633e20d379b02395915fbc385ff8dc27dcd3885e1068ab942eeab52ec1f20ad382a92370d8b2e0ac8b83c4d53bf'); + }); + test('testVector2', () => { + expect(C.HmacSHA384('what do ya want for nothing?', 'Jefe').toString()).toBe('af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649'); + }); + test('testVector3', () => { + expect(C.HmacSHA384(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()).toBe('1383e82e28286b91f4cc7afbd13d5b5c6f887c05e7c4542484043a37a5fe45802a9470fb663bd7b6570fe2f503fc92f5'); + }); + test('testVector4', () => { + expect(C.HmacSHA384('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString()).toBe('365dfb271adb8e30fe6c74220b75df1b38c2d19b9d37f2e5a0ec2f3f22bd0406bf5b786e98d81b82c36d3d8a1be6cd07'); + }); + test('testVector5', () => { + expect(C.HmacSHA384('abcdefghijklmnopqrstuvwxyz', 'A').toString()).toBe('a8357d5e84da64140e41545562ae0782e2a58e39c6cd98939fad8d9080e774c84b7eaca4ba07f6dbf0f12eab912c5285'); + }); + + test('testUpdate', () => { + let hmac = new C.algo.HMAC(C.algo.SHA384, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); + expect(hmac.finalize().toString()).toBe(C.HmacSHA384(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()); + }); + + test('testInputIntegrity', () => { + let message = new C.lib.WordArray([0x12345678]); + let key = new C.lib.WordArray([0x12345678]); + + let expectedMessage = message.toString(); + let expectedKey = key.toString(); + + C.HmacSHA384(message, key); + expect(message.toString()).toBe(expectedMessage); + expect(key.toString()).toBe(expectedKey); + }); + + test('testRespectKeySigBytes', () => { + let key = C.lib.WordArray.random(8); + key.sigBytes = 4; + + let keyClamped = key.clone(); + keyClamped.clamp(); + expect(C.HmacSHA384('Message', key).toString()).toBe(C.HmacSHA384('Message', keyClamped).toString()); + }); +}); \ No newline at end of file diff --git a/test/hmac.sha512.test.js b/test/hmac.sha512.test.js new file mode 100644 index 0000000..f3a9d68 --- /dev/null +++ b/test/hmac.sha512.test.js @@ -0,0 +1,48 @@ +import C from '../src/index'; + +describe('algo-hmac-sha512-test', () => { + test('testVector1', () => { + expect(C.HmacSHA512('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString()).toBe('7641c48a3b4aa8f887c07b3e83f96affb89c978fed8c96fcbbf4ad596eebfe496f9f16da6cd080ba393c6f365ad72b50d15c71bfb1d6b81f66a911786c6ce932'); + }); + test('testVector2', () => { + expect(C.HmacSHA512('what do ya want for nothing?', 'Jefe').toString()).toBe('164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737'); + }); + test('testVector3', () => { + expect(C.HmacSHA512(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()).toBe('ad9b5c7de72693737cd5e9d9f41170d18841fec1201c1c1b02e05cae116718009f771cad9946ddbf7e3cde3e818d9ae85d91b2badae94172d096a44a79c91e86'); + }); + test('testVector4', () => { + expect(C.HmacSHA512('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString()).toBe('a303979f7c94bb39a8ab6ce05cdbe28f0255da8bb305263e3478ef7e855f0242729bf1d2be55398f14da8e63f0302465a8a3f76c297bd584ad028d18ed7f0195'); + }); + test('testVector5', () => { + expect(C.HmacSHA512('abcdefghijklmnopqrstuvwxyz', 'A').toString()).toBe('8c2d56f7628325e62124c0a870ad98d101327fc42696899a06ce0d7121454022fae597e42c25ac3a4c380fd514f553702a5b0afaa9b5a22050902f024368e9d9'); + }); + + test('testUpdate', () => { + let hmac = new C.algo.HMAC(C.algo.SHA512, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); + hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd')); + expect(hmac.finalize().toString()).toBe(C.HmacSHA512(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString()); + }); + + test('testInputIntegrity', () => { + let message = new C.lib.WordArray([0x12345678]); + let key = new C.lib.WordArray([0x12345678]); + + let expectedMessage = message.toString(); + let expectedKey = key.toString(); + + C.HmacSHA512(message, key); + expect(message.toString()).toBe(expectedMessage); + expect(key.toString()).toBe(expectedKey); + }); + + test('testRespectKeySigBytes', () => { + let key = C.lib.WordArray.random(8); + key.sigBytes = 4; + + let keyClamped = key.clone(); + keyClamped.clamp(); + expect(C.HmacSHA512('Message', key).toString()).toBe(C.HmacSHA512('Message', keyClamped).toString()); + }) +}); \ No newline at end of file diff --git a/test/kdf.openssl.test.js b/test/kdf.openssl.test.js new file mode 100644 index 0000000..a14fd86 --- /dev/null +++ b/test/kdf.openssl.test.js @@ -0,0 +1,10 @@ +import C from '../src/index'; + +describe('kdf-openssl-test', () => { + test('testVector', () => { + let derivedParams = C.kdf.OpenSSL.execute('password', 256 / 32, 128 / 32, C.enc.Hex.parse('0a9d8620cf7219f1')); + expect(derivedParams.key.toString()).toBe('50f32e0ec9408e02ff42364a52aac95c3694fc027256c6f488bf84b8e60effcd'); + expect(derivedParams.iv.toString()).toBe('81381e39b94fd692dff7e2239a298cb6'); + expect(derivedParams.salt.toString()).toBe('0a9d8620cf7219f1'); + }); +}); \ No newline at end of file diff --git a/test/lib.base.test.js b/test/lib.base.test.js new file mode 100644 index 0000000..3b9ad4d --- /dev/null +++ b/test/lib.base.test.js @@ -0,0 +1,57 @@ +import C from '../src/index'; + +let data = {}; +beforeAll(() => { + data.mixins = { + mixinMethod: function () {} + }; + data.Obj = class Obj extends C.lib.Base { + constructor(arg) { + super(); + this.initFired = true; + this.initArg = arg; + } + toString() { + return 'ObjToString'; + } + }; + data.obj = new data.Obj('argValue'); + data.obj.mixIn(data.mixins); + data.objClone = data.obj.clone(); +}); + +describe('lib-base-test', () => { + test('testClassInheritance', () => { + expect(data.Obj.__proto__).toBe(C.lib.Base); + }); + + test('testObjectInheritance', () => { + expect(data.obj.__proto__.__proto__).toBe(C.lib.Base.prototype); + }); + + test('testToString', () => { + expect(data.obj.toString()).toBe('ObjToString'); + }); + + test('testConstructor', () => { + expect(data.obj.initFired).toBeTruthy(); + expect(data.obj.initArg).toBe('argValue'); + }); + + test('testMixIn', () => { + expect(data.obj.mixinMethod).toBe(data.mixins.mixinMethod); + }); + + test('testCloneDistinct', () => { + expect(data.objClone).not.toBe(data.obj); + }); + + test('testCloneCopy', () => { + expect(data.objClone.initArg).toBe(data.obj.initArg); + }); + + test('testCloneIndependent', () => { + data.obj.initArg = 'newValue'; + expect(data.objClone.initArg).not.toBe(data.obj.initArg); + }); +}); \ No newline at end of file diff --git a/test/lib.cipherparams.test.js b/test/lib.cipherparams.test.js new file mode 100644 index 0000000..18adc76 --- /dev/null +++ b/test/lib.cipherparams.test.js @@ -0,0 +1,52 @@ +import C from '../src/index'; + +const data = {}; +beforeAll(() => { + data.ciphertext = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'); + data.key = C.enc.Hex.parse('101112131415161718191a1b1c1d1e1f'); + data.iv = C.enc.Hex.parse('202122232425262728292a2b2c2d2e2f'); + data.salt = C.enc.Hex.parse('0123456789abcdef'); + data.algorithm = C.algo.AES; + data.mode = C.mode.CBC; + data.padding = C.pad.PKCS7; + data.blockSize = data.algorithm.blockSize; + data.formatter = C.format.OpenSSL; + data.cipherParams = new C.lib.CipherParams({ + ciphertext: data.ciphertext, + key: data.key, + iv: data.iv, + salt: data.salt, + algorithm: data.algorithm, + mode: data.mode, + padding: data.padding, + blockSize: data.blockSize, + formatter: data.formatter + }); +}); + +describe('lib-cipherparams-test', () => { + test('testInit', () => { + expect(data.cipherParams.ciphertext).toBe(data.ciphertext); + expect(data.cipherParams.key).toBe(data.key); + expect(data.cipherParams.iv).toBe(data.iv); + expect(data.cipherParams.salt).toBe(data.salt); + expect(data.cipherParams.algorithm).toBe(data.algorithm); + expect(data.cipherParams.mode).toBe(data.mode); + expect(data.cipherParams.padding).toBe(data.padding); + expect(data.cipherParams.blockSize).toBe(data.blockSize); + expect(data.cipherParams.formatter).toBe(data.formatter); + }); + + test('testToString0', () => { + expect(data.cipherParams.toString()).toBe(C.format.OpenSSL.stringify(data.cipherParams)); + }); + + test('testToString1', () => { + const JsonFormatter = { + stringify: function (cipherParams) { + return '{ ct: ' + cipherParams.ciphertext + ', iv: ' + cipherParams.iv + ' }'; + } + }; + expect(data.cipherParams.toString(JsonFormatter)).toBe(JsonFormatter.stringify(data.cipherParams)); + }); +}); \ No newline at end of file diff --git a/test/lib.passwordbasedcipher.test.js b/test/lib.passwordbasedcipher.test.js new file mode 100644 index 0000000..9d54e05 --- /dev/null +++ b/test/lib.passwordbasedcipher.test.js @@ -0,0 +1,21 @@ +import C from '../src/index'; + +describe('lib-passwordbasedcipher-test', () => { + test('testEncrypt', () => { + // Compute actual + let actual = C.lib.PasswordBasedCipher.encrypt(C.algo.AES, 'Hello, World!', 'password'); + + // Compute expected + let aes = C.algo.AES.createEncryptor(actual.key, { + iv: actual.iv + }); + let expected = aes.finalize('Hello, World!'); + expect(actual.ciphertext.toString()).toBe(expected.toString()); + }); + + test('testDecrypt', () => { + let ciphertext = C.lib.PasswordBasedCipher.encrypt(C.algo.AES, 'Hello, World!', 'password'); + let plaintext = C.lib.PasswordBasedCipher.decrypt(C.algo.AES, ciphertext, 'password'); + expect(plaintext.toString(C.enc.Utf8)).toBe('Hello, World!'); + }); +}); \ No newline at end of file diff --git a/test/lib.serializablecipher.test.js b/test/lib.serializablecipher.test.js new file mode 100644 index 0000000..b7b00c8 --- /dev/null +++ b/test/lib.serializablecipher.test.js @@ -0,0 +1,51 @@ +import C from '../src/index'; + +let data = {}; + +beforeAll(() => { + data.message = new C.lib.WordArray([0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f]); + data.key = new C.lib.WordArray([0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f]); + data.iv = new C.lib.WordArray([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); +}); + +describe('lib-serializablecipher-test', () => { + test('testEncrypt', () => { + // Compute expected + let aes = C.algo.AES.createEncryptor(data.key, { + iv: data.iv + }); + let ciphertext = aes.finalize(data.message); + let expected = new C.lib.CipherParams({ + ciphertext: ciphertext, + key: data.key, + iv: data.iv, + algorithm: C.algo.AES, + mode: aes.cfg.mode, + padding: aes.cfg.padding, + blockSize: aes.blockSize, + formatter: C.format.OpenSSL + }); + let actual = C.lib.SerializableCipher.encrypt(C.algo.AES, data.message, data.key, { + iv: data.iv + }); + + expect(actual.toString()).toBe(expected.toString()); + expect(actual.ciphertext.toString()).toBe(expected.ciphertext.toString()); + expect(actual.key.toString()).toBe(expected.key.toString()); + expect(actual.iv.toString()).toBe(expected.iv.toString()); + expect(actual.algorithm).toBe(expected.algorithm); + expect(actual.mode).toBe(expected.mode); + expect(actual.padding).toBe(expected.padding); + expect(actual.blockSize).toBe(expected.blockSize); + }); + + test('testDecrypt', () => { + let encrypted = C.lib.SerializableCipher.encrypt(C.algo.AES, data.message, data.key, { + iv: data.iv + }) + ''; + let decrypted = C.lib.SerializableCipher.decrypt(C.algo.AES, encrypted, data.key, { + iv: data.iv + }); + expect(decrypted.toString()).toBe(data.message.toString()); + }); +}); \ No newline at end of file diff --git a/test/lib.typedarrays.test.js b/test/lib.typedarrays.test.js new file mode 100644 index 0000000..cfb4901 --- /dev/null +++ b/test/lib.typedarrays.test.js @@ -0,0 +1,50 @@ +import C from '../src/index'; + +const data = {}; +beforeAll(() => { + data.buffer = new ArrayBuffer(8); + + let uint8View = new Uint8Array(data.buffer); + uint8View[0] = 0x01; + uint8View[1] = 0x23; + uint8View[2] = 0x45; + uint8View[3] = 0x67; + uint8View[4] = 0x89; + uint8View[5] = 0xab; + uint8View[6] = 0xcd; + uint8View[7] = 0xef; +}); + +describe('lib-wordarray-test', () => { + test('testInt8Array', () => { + expect(new C.lib.WordArray(new Int8Array(data.buffer)).toString()).toBe('0123456789abcdef'); + }); + + test('testUint8Array', () => { + expect(new C.lib.WordArray(new Uint8Array(data.buffer)).toString()).toBe('0123456789abcdef'); + }); + + test('testUint8ClampedArray', () => { + expect(new C.lib.WordArray(new Uint8ClampedArray(data.buffer)).toString()).toBe('0123456789abcdef'); + }); + + test('testInt16Array', () => { + expect(new C.lib.WordArray(new Int16Array(data.buffer)).toString()).toBe('0123456789abcdef'); + }); + + test('testUint16Array', () => { + expect(new C.lib.WordArray(new Uint16Array(data.buffer)).toString()).toBe('0123456789abcdef'); + }); + + test('testInt32Array', () => { + expect(new C.lib.WordArray(new Int32Array(data.buffer)).toString()).toBe('0123456789abcdef'); + }); + + test('testUint32Array', () => { + expect(new C.lib.WordArray(new Uint32Array(data.buffer)).toString()).toBe('0123456789abcdef'); + }); + + test('testPartialView', () => { + expect(new C.lib.WordArray(new Int16Array(data.buffer, 2, 2)).toString()).toBe('456789ab'); + }); +}); \ No newline at end of file diff --git a/test/lib.wordarray.test.js b/test/lib.wordarray.test.js new file mode 100644 index 0000000..a3a02e5 --- /dev/null +++ b/test/lib.wordarray.test.js @@ -0,0 +1,76 @@ +import C from '../src/index'; + +describe('lib-wordarray-test', () => { + test('testInit0', () => { + expect(new C.lib.WordArray().toString()).toBe(''); + }); + + test('testInit1', () => { + expect(new C.lib.WordArray([0x12345678]).toString()).toBe('12345678'); + }); + + test('testInit2', () => { + expect(new C.lib.WordArray([0x12345678], 2).toString()).toBe('1234'); + }); + + test('testToStringPassedEncoder', () => { + expect(new C.lib.WordArray([0x12345678]).toString(C.enc.Latin1)).toBe('\x12\x34\x56\x78'); + }); + + test('testToStringDefaultEncoder', () => { + expect(new C.lib.WordArray([0x12345678]).toString()).toBe('12345678'); + }); + + test('testConcat3', () => { + let wordArray1 = new C.lib.WordArray([0x12345678], 3); + let wordArray2 = new C.lib.WordArray([0x12345678], 3); + expect(wordArray1.concat(wordArray2).toString()).toBe('123456123456'); + expect(wordArray1.toString()).toBe('123456123456'); + }); + + test('testConcat4', () => { + let wordArray1 = new C.lib.WordArray([0x12345678], 4); + let wordArray2 = new C.lib.WordArray([0x12345678], 3); + expect(wordArray1.concat(wordArray2).toString()).toBe('12345678123456'); + expect(wordArray1.toString()).toBe('12345678123456'); + }); + + test('testConcat5', () => { + let wordArray1 = new C.lib.WordArray([0x12345678], 5); + let wordArray2 = new C.lib.WordArray([0x12345678], 3); + expect(wordArray1.concat(wordArray2).toString()).toBe('1234567800123456'); + expect(wordArray1.toString()).toBe('1234567800123456'); + }); + + test('testConcatLong', () => { + let wordArray1 = new C.lib.WordArray(); + let wordArray2 = new C.lib.WordArray(); + let wordArray3 = new C.lib.WordArray(); + for (let i = 0; i < 500000; i++) { + wordArray2.words[i] = i; + wordArray3.words[i] = i; + } + wordArray2.sigBytes = 500000; + wordArray3.sigBytes = 500000; + const expected = wordArray2.toString() + wordArray3.toString(); + expect(wordArray1.concat(wordArray2.concat(wordArray3)).toString()).toBe(expected); + }); + + test('testClamp', () => { + let wordArray = new C.lib.WordArray([0x12345678, 0x12345678], 3); + wordArray.clamp(); + expect(wordArray.words.toString()).toBe([0x12345600].toString()); + }); + + test('testClone', () => { + let wordArray = new C.lib.WordArray([0x12345678]); + let clone = wordArray.clone(); + clone.words[0] = 0; + expect(clone.toString()).not.toBe(wordArray.toString()); + }); + + test('testRandom', () => { + expect(C.lib.WordArray.random(8).toString()).not.toBe(C.lib.WordArray.random(8).toString()); + expect(C.lib.WordArray.random(8).sigBytes).toBe(8); + }); +}); \ No newline at end of file diff --git a/test/md5.profile.test.js b/test/md5.profile.test.js index a198fbf..9ca91d1 100644 --- a/test/md5.profile.test.js +++ b/test/md5.profile.test.js @@ -17,7 +17,7 @@ describe('algo-md5-profile', () => { test('profileMultiPartMessage', () => { let i = 0; - const md5 =new C.algo.MD5(); + const md5 = new C.algo.MD5(); while (i < 500) { md5.update('12345678901234567890123456789012345678901234567890'); i++; diff --git a/test/md5.test.js b/test/md5.test.js index fbb219b..51dd682 100644 --- a/test/md5.test.js +++ b/test/md5.test.js @@ -1,4 +1,4 @@ -import C from '../src/index.js'; +import C from '../src/index'; const VECTOR_TEST_CONFIG = [ [1, '', 'd41d8cd98f00b204e9800998ecf8427e'], @@ -17,17 +17,15 @@ const CLONE_TEST_CONFIG = [ ]; describe('algo-md5-test', () => { - describe.each(VECTOR_TEST_CONFIG)( + test.each(VECTOR_TEST_CONFIG)( 'testVector%i', - (a, b, expected) => { - test(`return ${expected}`, () => { - expect(C.MD5(b).toString()).toBe(expected); - }); + (a,b, expected) => { + expect(C.MD5(b).toString()).toBe(expected); } ); describe('testClone', () => { - const md5 =new C.algo.MD5(); + const md5 = new C.algo.MD5(); test.each(CLONE_TEST_CONFIG)( 'return %s, %s', (a, expected) => { @@ -38,7 +36,7 @@ describe('algo-md5-test', () => { test('testUpdateAndLongMessage', () => { let i = 0; - const md5 =new C.algo.MD5(); + const md5 = new C.algo.MD5(); while (i < 100) { md5.update('12345678901234567890123456789012345678901234567890'); i++; @@ -47,7 +45,7 @@ describe('algo-md5-test', () => { }); test('testInputIntegrity', () => { - const message =new C.lib.WordArray([0x12345678]); + const message = new C.lib.WordArray([0x12345678]); const expected = message.toString(); C.MD5(message); expect(message.toString()).toBe(expected); diff --git a/test/mode.cbc.test.js b/test/mode.cbc.test.js new file mode 100644 index 0000000..899f57a --- /dev/null +++ b/test/mode.cbc.test.js @@ -0,0 +1,53 @@ +import C from '../src/index'; + +let data = {}; +beforeAll(() => { + data.message = new C.lib.WordArray([ + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f + ]); + data.key = new C.lib.WordArray([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); + data.iv = new C.lib.WordArray([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); +}); + +describe('mode-cbc-test', () => { + test('testEncryptor', () => { + // Compute expected + let expected = data.message.clone(); + let aes = C.algo.AES.createEncryptor(data.key); + + // First block XORed with IV, then encrypted + for (let i = 0; i < 4; i++) { + expected.words[i] ^= data.iv.words[i]; + } + aes.encryptBlock(expected.words, 0); + + // Subsequent blocks XORed with previous crypted block, then encrypted + for (let i = 4; i < 8; i++) { + expected.words[i] ^= expected.words[i - 4]; + } + aes.encryptBlock(expected.words, 4); + + // Compute actual + let actual = C.AES.encrypt(data.message, data.key, { + iv: data.iv, + mode: C.mode.CBC, + padding: C.pad.NoPadding + }).ciphertext; + expect(actual.toString()).toBe(expected.toString()); + }); + + test('testDecryptor', () => { + let encrypted = C.AES.encrypt(data.message, data.key, { + iv: data.iv, + mode: C.mode.CBC, + padding: C.pad.NoPadding + }); + let decrypted = C.AES.decrypt(encrypted, data.key, { + iv: data.iv, + mode: C.mode.CBC, + padding: C.pad.NoPadding + }); + expect(decrypted.toString()).toBe(data.message.toString()); + }); +}); \ No newline at end of file diff --git a/test/mode.cfb.test.js b/test/mode.cfb.test.js new file mode 100644 index 0000000..f1a5c95 --- /dev/null +++ b/test/mode.cfb.test.js @@ -0,0 +1,56 @@ +import C from '../src/index'; + +const data = {}; +beforeAll(() => { + data.message = new C.lib.WordArray([ + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f + ]); + data.key = new C.lib.WordArray([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); + data.iv = new C.lib.WordArray([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); +}); + +describe('mode-cfb-test', () => { + test('testEncryptor', () => { + // Compute expected + let expected = data.message.clone(); + let aes = C.algo.AES.createEncryptor(data.key); + + // First block XORed with encrypted IV + let keystream = data.iv.words.slice(0); + aes.encryptBlock(keystream, 0); + for (let i = 0; i < 4; i++) { + expected.words[i] ^= keystream[i]; + } + + // Subsequent blocks XORed with encrypted previous crypted block + keystream = expected.words.slice(0, 4); + aes.encryptBlock(keystream, 0); + for (let i = 4; i < 8; i++) { + expected.words[i] ^= keystream[i % 4]; + } + + // Compute actual + let actual = C.AES.encrypt(data.message, data.key, { + iv: data.iv, + mode: C.mode.CFB, + padding: C.pad.NoPadding + }).ciphertext; + expect(actual.toString()).toBe(expected.toString()); + }); + + test('testDecryptor', () => { + let encrypted = C.AES.encrypt(data.message, data.key, { + iv: data.iv, + mode: C.mode.CFB, + padding: C.pad.NoPadding + }); + let decrypted = C.AES.decrypt(encrypted, data.key, { + iv: data.iv, + mode: C.mode.CFB, + padding: C.pad.NoPadding + }); + expect(decrypted.toString()).toBe(data.message.toString()); + + }); +}); \ No newline at end of file diff --git a/test/mode.ctr.test.js b/test/mode.ctr.test.js new file mode 100644 index 0000000..0b9bc26 --- /dev/null +++ b/test/mode.ctr.test.js @@ -0,0 +1,59 @@ +import C from '../src/index'; + +const data = {}; +beforeAll(() => { + data.message = new C.lib.WordArray([ + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f + ]); + data.key = new C.lib.WordArray([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); + data.iv = new C.lib.WordArray([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); +}); + +describe('mode-ctr-test', () => { + test('testEncryptor', () => { + // Compute expected + let expected = data.message.clone(); + let aes = C.algo.AES.createEncryptor(data.key); + + // Counter initialized with IV + let counter = data.iv.words.slice(0); + + // First block XORed with encrypted counter + let keystream = counter.slice(0); + aes.encryptBlock(keystream, 0); + for (let i = 0; i < 4; i++) { + expected.words[i] ^= keystream[i]; + } + + // Subsequent blocks XORed with encrypted incremented counter + counter[3]++; + keystream = counter.slice(0); + aes.encryptBlock(keystream, 0); + for (let i = 4; i < 8; i++) { + expected.words[i] ^= keystream[i % 4]; + } + + // Compute actual + let actual = C.AES.encrypt(data.message, data.key, { + iv: data.iv, + mode: C.mode.CTR, + padding: C.pad.NoPadding + }).ciphertext; + expect(actual.toString()).toBe(expected.toString()); + }); + + test('testDecryptor', () => { + let encrypted = C.AES.encrypt(data.message, data.key, { + iv: data.iv, + mode: C.mode.CTR, + padding: C.pad.NoPadding + }); + let decrypted = C.AES.decrypt(encrypted, data.key, { + iv: data.iv, + mode: C.mode.CTR, + padding: C.pad.NoPadding + }); + expect(decrypted.toString()).toBe(data.message.toString()); + }); +}); \ No newline at end of file diff --git a/test/mode.ecb.test.js b/test/mode.ecb.test.js new file mode 100644 index 0000000..3670c48 --- /dev/null +++ b/test/mode.ecb.test.js @@ -0,0 +1,40 @@ +import C from '../src/index'; + +const data = {}; + +beforeAll(() => { + data.message = new C.lib.WordArray([ + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f + ]); + data.key = new C.lib.WordArray([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); +}); + +describe('node-ecb-test', () => { + test('testEncryptor', () => { + // Compute expected + let expected = data.message.clone(); + let aes = C.algo.AES.createEncryptor(data.key); + aes.encryptBlock(expected.words, 0); + aes.encryptBlock(expected.words, 4); + + // Compute actual + let actual = C.AES.encrypt(data.message, data.key, { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }).ciphertext; + expect(actual.toString()).toBe(expected.toString()); + }); + + test('testDecryptor', () => { + let encrypted = C.AES.encrypt(data.message, data.key, { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }); + let decrypted = C.AES.decrypt(encrypted, data.key, { + mode: C.mode.ECB, + padding: C.pad.NoPadding + }); + expect(decrypted.toString()).toBe(data.message.toString()); + }); +}); \ No newline at end of file diff --git a/test/mode.ofb.test.js b/test/mode.ofb.test.js new file mode 100644 index 0000000..926b877 --- /dev/null +++ b/test/mode.ofb.test.js @@ -0,0 +1,55 @@ +import C from '../src/index'; + +const data = {}; + +beforeAll(() => { + data.message = new C.lib.WordArray([ + 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, + 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f + ]); + data.key = new C.lib.WordArray([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]); + data.iv = new C.lib.WordArray([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]); +}); + +describe('mode-ofb-test', () => { + test('testEncryptor', () => { + // Compute expected + let expected = data.message.clone(); + let aes = C.algo.AES.createEncryptor(data.key); + + // First block XORed with encrypted IV + let keystream = data.iv.words.slice(0); + aes.encryptBlock(keystream, 0); + for (let i = 0; i < 4; i++) { + expected.words[i] ^= keystream[i]; + } + + // Subsequent blocks XORed with encrypted previous keystream + aes.encryptBlock(keystream, 0); + for (let i = 4; i < 8; i++) { + expected.words[i] ^= keystream[i % 4]; + } + + // Compute actual + let actual = C.AES.encrypt(data.message, data.key, { + iv: data.iv, + mode: C.mode.OFB, + padding: C.pad.NoPadding + }).ciphertext; + expect(actual.toString()).toBe(expected.toString()); + }); + + test('testDecryptor', () => { + let encrypted = C.AES.encrypt(data.message, data.key, { + iv: data.iv, + mode: C.mode.OFB, + padding: C.pad.NoPadding + }); + let decrypted = C.AES.decrypt(encrypted, data.key, { + iv: data.iv, + mode: C.mode.OFB, + padding: C.pad.NoPadding + }); + expect(decrypted.toString()).toBe(data.message.toString()); + }) +}); \ No newline at end of file diff --git a/test/pad.ansix923.test.js b/test/pad.ansix923.test.js new file mode 100644 index 0000000..1cfef36 --- /dev/null +++ b/test/pad.ansix923.test.js @@ -0,0 +1,21 @@ +import C from '../src/index'; + +describe('pad-ansix923-test', () => { + test('testPad', () => { + let data = new C.lib.WordArray([0xdddddd00], 3); + C.pad.AnsiX923.pad(data, 2); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd00, 0x00000005]).toString()); + }); + + test('testPadClamp', () => { + let data = new C.lib.WordArray([0xdddddddd, 0xdddddddd], 3); + C.pad.AnsiX923.pad(data, 2); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd00, 0x00000005]).toString()); + }); + + test('testUnpad', () => { + let data = new C.lib.WordArray([0xdddddd00, 0x00000005]); + C.pad.AnsiX923.unpad(data); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd00], 3).toString()); + }); +}); \ No newline at end of file diff --git a/test/pad.iso10126.test.js b/test/pad.iso10126.test.js new file mode 100644 index 0000000..b9921ec --- /dev/null +++ b/test/pad.iso10126.test.js @@ -0,0 +1,42 @@ +import C from '../src/index'; + +const _data = {}; +beforeAll(() => { + // Save original random method + _data.random = C.lib.WordArray.random; + + // Replace random method with one that returns a predictable value + C.lib.WordArray.random = function (nBytes) { + let words = []; + for (let i = 0; i < nBytes; i += 4) { + words.push([0x11223344]); + } + + return new C.lib.WordArray(words, nBytes); + }; +}); + +afterAll(() => { + // Restore random method + C.lib.WordArray.random = _data.random; +}); + +describe('pad-iso10126-test', () => { + test('testPad', () => { + let data = new C.lib.WordArray([0xdddddd00], 3); + C.pad.Iso10126.pad(data, 2); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd11, 0x22334405]).toString()); + }); + + test('testPadClamp', () => { + let data = new C.lib.WordArray([0xdddddddd, 0xdddddddd], 3); + C.pad.Iso10126.pad(data, 2); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd11, 0x22334405]).toString()); + }); + + test('testUnpad', () => { + let data = new C.lib.WordArray([0xdddddd11, 0x22334405]); + C.pad.Iso10126.unpad(data); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd00], 3).toString()); + }); +}); \ No newline at end of file diff --git a/test/pad.iso97971.test.js b/test/pad.iso97971.test.js new file mode 100644 index 0000000..c3d367b --- /dev/null +++ b/test/pad.iso97971.test.js @@ -0,0 +1,27 @@ +import C from '../src/index'; + +describe('pad-iso97971-test', () => { + test('testPad1', () => { + let data = new C.lib.WordArray([0xdddddd00], 3); + C.pad.Iso97971.pad(data, 1); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd80]).toString()); + }); + + test('testPad2', () => { + let data = new C.lib.WordArray([0xdddddd00], 3); + C.pad.Iso97971.pad(data, 2); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd80, 0x00000000]).toString()); + }); + + test('testPadClamp', () => { + let data = new C.lib.WordArray([0xdddddddd, 0xdddddddd], 3); + C.pad.Iso97971.pad(data, 2); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd80, 0x00000000]).toString()); + }); + + test('testUnpad', () => { + let data = new C.lib.WordArray([0xdddddd80, 0x00000000]); + C.pad.Iso97971.unpad(data); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd00], 3).toString()); + }); +}); \ No newline at end of file diff --git a/test/pad.pkcs7.test.js b/test/pad.pkcs7.test.js new file mode 100644 index 0000000..03ae1b5 --- /dev/null +++ b/test/pad.pkcs7.test.js @@ -0,0 +1,21 @@ +import C from '../src/index'; + +describe('pad-pkcs7-test', () => { + test('testPad', () => { + let data = new C.lib.WordArray([0xdddddd00], 3); + C.pad.Pkcs7.pad(data, 2); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd05, 0x05050505]).toString()); + }); + + test('testPadClamp', () => { + const data = new C.lib.WordArray([0xdddddddd, 0xdddddddd], 3); + C.pad.Pkcs7.pad(data, 2); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd05, 0x05050505]).toString()); + }); + + test('testUnpad', () => { + let data = new C.lib.WordArray([0xdddddd05, 0x05050505]); + C.pad.Pkcs7.unpad(data); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd00], 3).toString()); + }); +}); \ No newline at end of file diff --git a/test/pad.zeropadding.test.js b/test/pad.zeropadding.test.js new file mode 100644 index 0000000..039ceda --- /dev/null +++ b/test/pad.zeropadding.test.js @@ -0,0 +1,21 @@ +import C from '../src/index'; + +describe('pad-zeropadding-test', () => { + test('testPad', () => { + let data = new C.lib.WordArray([0xdddddd00], 3); + C.pad.ZeroPadding.pad(data, 2); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd00, 0x00000000]).toString()); + }); + + test('testPadClamp', () => { + let data = new C.lib.WordArray([0xdddddddd, 0xdddddddd], 3); + C.pad.ZeroPadding.pad(data, 2); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd00, 0x00000000]).toString()); + }); + + test('testUnpad', () => { + let data = new C.lib.WordArray([0xdddddd00, 0x00000000]); + C.pad.ZeroPadding.unpad(data); + expect(data.toString()).toBe(new C.lib.WordArray([0xdddddd00], 3).toString()); + }); +}); \ No newline at end of file diff --git a/test/x64.word.test.js b/test/x64.word.test.js new file mode 100644 index 0000000..df788d8 --- /dev/null +++ b/test/x64.word.test.js @@ -0,0 +1,9 @@ +import C from '../src/index'; + +describe('x64-word-test', () => { + test('testInit', () => { + let word = new C.x64.Word(0x00010203, 0x04050607); + expect(word.high).toBe(0x00010203); + expect(word.low).toBe(0x04050607); + }); +}); \ No newline at end of file diff --git a/test/x64.wordarray.test.js b/test/x64.wordarray.test.js new file mode 100644 index 0000000..7b0ed8e --- /dev/null +++ b/test/x64.wordarray.test.js @@ -0,0 +1,24 @@ +import C from '../src/index'; + +describe('x64-wordarray-test', () => { + test('testInit0', () => { + expect(new C.x64.WordArray().toX32().toString()).toBe(''); + }); + + test('testInit1', () => { + let wordArray = new C.x64.WordArray([ + new C.x64.Word(0x00010203, 0x04050607), + new C.x64.Word(0x18191a1b, 0x1c1d1e1f) + ]); + expect(wordArray.toX32().toString()).toBe('000102030405060718191a1b1c1d1e1f'); + }); + + test('testInit2', () => { + let wordArray = new C.x64.WordArray([ + new C.x64.Word(0x00010203, 0x04050607), + new C.x64.Word(0x18191a1b, 0x1c1d1e1f) + ], 10); + + expect(wordArray.toX32().toString()).toBe('00010203040506071819'); + }); +}); \ No newline at end of file