Merge remote-tracking branch 'upstream/master' into feature-octal
commit
a36c9ca339
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"presets": [
|
||||
["env", {
|
||||
"targets": {
|
||||
"chrome": 40,
|
||||
"firefox": 35,
|
||||
"edge": 14
|
||||
},
|
||||
"modules": false
|
||||
}]
|
||||
]
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
node_modules
|
||||
npm-debug.log
|
||||
build/dev
|
||||
build/test
|
||||
build
|
||||
docs/*
|
||||
!docs/*.conf.json
|
||||
!docs/*.ico
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- node
|
||||
install: npm install
|
||||
before_script:
|
||||
- npm install -g grunt
|
||||
script:
|
||||
- grunt lint
|
||||
- grunt test
|
||||
- grunt docs
|
||||
- grunt node
|
||||
- grunt prod
|
||||
before_deploy:
|
||||
- grunt copy:ghPages
|
||||
deploy:
|
||||
- provider: pages
|
||||
skip_cleanup: true
|
||||
github_token: $GITHUB_TOKEN
|
||||
local_dir: build/prod/
|
||||
target_branch: gh-pages
|
||||
on:
|
||||
branch: master
|
||||
- provider: releases
|
||||
skip_cleaup: true
|
||||
api_key:
|
||||
secure: $GITHUB_API_KEY
|
||||
file:
|
||||
- build/prod/cyberchef.htm
|
||||
- build/node/CyberChef.js
|
||||
on:
|
||||
repo: gchq/CyberChef
|
||||
tags: true
|
647
Gruntfile.js
647
Gruntfile.js
|
@ -1,38 +1,40 @@
|
|||
/* eslint-env node */
|
||||
var webpack = require("webpack"),
|
||||
ExtractTextPlugin = require("extract-text-webpack-plugin"),
|
||||
HtmlWebpackPlugin = require("html-webpack-plugin"),
|
||||
Inliner = require("web-resource-inliner");
|
||||
|
||||
module.exports = function(grunt) {
|
||||
module.exports = function (grunt) {
|
||||
grunt.file.defaultEncoding = "utf8";
|
||||
grunt.file.preserveBOM = false;
|
||||
|
||||
// Tasks
|
||||
grunt.registerTask("dev",
|
||||
"A persistent task which creates a development build whenever source files are modified.",
|
||||
["clean:dev", "concat:css", "concat:js", "copy:htmlDev", "copy:staticDev", "chmod:build", "watch"]);
|
||||
["clean:dev", "webpack:webDev"]);
|
||||
|
||||
grunt.registerTask("node",
|
||||
"Compiles CyberChef into a single NodeJS module.",
|
||||
["clean:node", "webpack:node", "chmod:build"]);
|
||||
|
||||
grunt.registerTask("test",
|
||||
"A task which runs all the tests in test/tests.",
|
||||
["clean:test", "concat:jsTest", "copy:htmlTest", "chmod:build", "execute:test"]);
|
||||
|
||||
grunt.registerTask("prod",
|
||||
"Creates a production-ready build. Use the --msg flag to add a compile message.",
|
||||
["eslint", "exec:stats", "clean", "jsdoc", "concat", "copy:htmlDev", "copy:htmlProd", "copy:htmlInline",
|
||||
"copy:staticDev", "copy:staticProd", "cssmin", "uglify:prod", "inline", "htmlmin", "chmod", "test"]);
|
||||
["clean:test", "webpack:tests", "execute:test"]);
|
||||
|
||||
grunt.registerTask("docs",
|
||||
"Compiles documentation in the /docs directory.",
|
||||
["clean:docs", "jsdoc", "chmod:docs"]);
|
||||
|
||||
grunt.registerTask("stats",
|
||||
"Provides statistics about the code base such as how many lines there are as well as details of file sizes before and after compression.",
|
||||
["concat:js", "uglify:prod", "exec:stats", "exec:repoSize", "exec:displayStats"]);
|
||||
|
||||
grunt.registerTask("release",
|
||||
"Prepares and deploys a production version of CyberChef to the gh-pages branch.",
|
||||
["copy:ghPages", "exec:deployGhPages"]);
|
||||
grunt.registerTask("prod",
|
||||
"Creates a production-ready build. Use the --msg flag to add a compile message.",
|
||||
["eslint", "clean:prod", "webpack:webProd", "inline", "chmod"]);
|
||||
|
||||
grunt.registerTask("default",
|
||||
"Lints the code base and shows stats",
|
||||
["eslint", "exec:stats", "exec:displayStats"]);
|
||||
"Lints the code base",
|
||||
["eslint", "exec:repoSize"]);
|
||||
|
||||
grunt.registerTask("inline",
|
||||
"Compiles a production build of CyberChef into a single, portable web page.",
|
||||
runInliner);
|
||||
|
||||
grunt.registerTask("doc", "docs");
|
||||
grunt.registerTask("tests", "test");
|
||||
|
@ -41,179 +43,79 @@ module.exports = function(grunt) {
|
|||
|
||||
// Load tasks provided by each plugin
|
||||
grunt.loadNpmTasks("grunt-eslint");
|
||||
grunt.loadNpmTasks("grunt-webpack");
|
||||
grunt.loadNpmTasks("grunt-jsdoc");
|
||||
grunt.loadNpmTasks("grunt-contrib-clean");
|
||||
grunt.loadNpmTasks("grunt-contrib-concat");
|
||||
grunt.loadNpmTasks("grunt-contrib-copy");
|
||||
grunt.loadNpmTasks("grunt-contrib-uglify");
|
||||
grunt.loadNpmTasks("grunt-contrib-cssmin");
|
||||
grunt.loadNpmTasks("grunt-contrib-htmlmin");
|
||||
grunt.loadNpmTasks("grunt-inline-alt");
|
||||
grunt.loadNpmTasks("grunt-chmod");
|
||||
grunt.loadNpmTasks("grunt-exec");
|
||||
grunt.loadNpmTasks("grunt-execute");
|
||||
grunt.loadNpmTasks("grunt-contrib-watch");
|
||||
|
||||
|
||||
// JS includes
|
||||
var jsIncludes = [
|
||||
// Third party framework libraries
|
||||
"src/js/lib/jquery-2.1.1.js",
|
||||
"src/js/lib/bootstrap-3.3.6.js",
|
||||
"src/js/lib/split.js",
|
||||
"src/js/lib/bootstrap-switch.js",
|
||||
"src/js/lib/yahoo.js",
|
||||
"src/js/lib/snowfall.jquery.js",
|
||||
|
||||
// Third party operation libraries
|
||||
"src/js/lib/cryptojs/core.js",
|
||||
"src/js/lib/cryptojs/x64-core.js",
|
||||
"src/js/lib/cryptojs/enc-base64.js",
|
||||
"src/js/lib/cryptojs/enc-utf16.js",
|
||||
"src/js/lib/cryptojs/md5.js",
|
||||
"src/js/lib/cryptojs/evpkdf.js",
|
||||
"src/js/lib/cryptojs/cipher-core.js",
|
||||
"src/js/lib/cryptojs/mode-cfb.js",
|
||||
"src/js/lib/cryptojs/mode-ctr-gladman.js",
|
||||
"src/js/lib/cryptojs/mode-ctr.js",
|
||||
"src/js/lib/cryptojs/mode-ecb.js",
|
||||
"src/js/lib/cryptojs/mode-ofb.js",
|
||||
"src/js/lib/cryptojs/format-hex.js",
|
||||
"src/js/lib/cryptojs/lib-typedarrays.js",
|
||||
"src/js/lib/cryptojs/pad-ansix923.js",
|
||||
"src/js/lib/cryptojs/pad-iso10126.js",
|
||||
"src/js/lib/cryptojs/pad-iso97971.js",
|
||||
"src/js/lib/cryptojs/pad-nopadding.js",
|
||||
"src/js/lib/cryptojs/pad-zeropadding.js",
|
||||
"src/js/lib/cryptojs/aes.js",
|
||||
"src/js/lib/cryptojs/hmac.js",
|
||||
"src/js/lib/cryptojs/rabbit-legacy.js",
|
||||
"src/js/lib/cryptojs/rabbit.js",
|
||||
"src/js/lib/cryptojs/ripemd160.js",
|
||||
"src/js/lib/cryptojs/sha1.js",
|
||||
"src/js/lib/cryptojs/sha256.js",
|
||||
"src/js/lib/cryptojs/sha224.js",
|
||||
"src/js/lib/cryptojs/sha512.js",
|
||||
"src/js/lib/cryptojs/sha384.js",
|
||||
"src/js/lib/cryptojs/sha3.js",
|
||||
"src/js/lib/cryptojs/tripledes.js",
|
||||
"src/js/lib/cryptojs/rc4.js",
|
||||
"src/js/lib/cryptojs/pbkdf2.js",
|
||||
"src/js/lib/cryptoapi/crypto-api.js",
|
||||
"src/js/lib/cryptoapi/hasher.md2.js",
|
||||
"src/js/lib/cryptoapi/hasher.md4.js",
|
||||
"src/js/lib/cryptoapi/hasher.sha0.js",
|
||||
"src/js/lib/jsbn/jsbn.js",
|
||||
"src/js/lib/jsbn/jsbn2.js",
|
||||
"src/js/lib/jsbn/base64.js",
|
||||
"src/js/lib/jsbn/ec.js",
|
||||
"src/js/lib/jsbn/prng4.js",
|
||||
"src/js/lib/jsbn/rng.js",
|
||||
"src/js/lib/jsbn/rsa.js",
|
||||
"src/js/lib/jsbn/sec.js",
|
||||
"src/js/lib/jsrasign/asn1-1.0.js",
|
||||
"src/js/lib/jsrasign/asn1hex-1.1.js",
|
||||
"src/js/lib/jsrasign/asn1x509-1.0.js",
|
||||
"src/js/lib/jsrasign/base64x-1.1.js",
|
||||
"src/js/lib/jsrasign/crypto-1.1.js",
|
||||
"src/js/lib/jsrasign/dsa-modified-1.0.js",
|
||||
"src/js/lib/jsrasign/ecdsa-modified-1.0.js",
|
||||
"src/js/lib/jsrasign/ecparam-1.0.js",
|
||||
"src/js/lib/jsrasign/keyutil-1.0.js",
|
||||
"src/js/lib/jsrasign/x509-1.1.js",
|
||||
"src/js/lib/blowfish.dojo.js",
|
||||
"src/js/lib/rawdeflate.js",
|
||||
"src/js/lib/rawinflate.js",
|
||||
"src/js/lib/zip.js",
|
||||
"src/js/lib/unzip.js",
|
||||
"src/js/lib/zlib_and_gzip.js",
|
||||
"src/js/lib/bzip2.js",
|
||||
"src/js/lib/punycode.js",
|
||||
"src/js/lib/uas_parser.js",
|
||||
"src/js/lib/esprima.js",
|
||||
"src/js/lib/escodegen.browser.js",
|
||||
"src/js/lib/esmangle.min.js",
|
||||
"src/js/lib/diff.js",
|
||||
"src/js/lib/moment.js",
|
||||
"src/js/lib/moment-timezone.js",
|
||||
"src/js/lib/prettify.js",
|
||||
"src/js/lib/vkbeautify.js",
|
||||
"src/js/lib/Sortable.js",
|
||||
"src/js/lib/bootstrap-colorpicker.js",
|
||||
"src/js/lib/es6-promise.auto.js",
|
||||
"src/js/lib/xpath.js",
|
||||
|
||||
// Custom libraries
|
||||
"src/js/lib/canvascomponents.js",
|
||||
|
||||
// Utility functions
|
||||
"src/js/core/Utils.js",
|
||||
|
||||
// Operation objects
|
||||
"src/js/operations/*.js",
|
||||
|
||||
// Core framework objects
|
||||
"src/js/core/*.js",
|
||||
"src/js/config/Categories.js",
|
||||
"src/js/config/OperationConfig.js",
|
||||
|
||||
// HTML view objects
|
||||
"src/js/views/html/*.js",
|
||||
"!src/js/views/html/main.js",
|
||||
|
||||
];
|
||||
|
||||
var jsAppFiles = jsIncludes.concat([
|
||||
// Start the main app!
|
||||
"src/js/views/html/main.js",
|
||||
]);
|
||||
|
||||
var jsTestFiles = jsIncludes.concat([
|
||||
"test/TestRegister.js",
|
||||
"test/tests/**/*.js",
|
||||
"test/TestRunner.js",
|
||||
]);
|
||||
|
||||
var banner = '/**\n\
|
||||
* CyberChef - The Cyber Swiss Army Knife\n\
|
||||
*\n\
|
||||
* @copyright Crown Copyright 2016\n\
|
||||
* @license Apache-2.0\n\
|
||||
*\n\
|
||||
* Copyright 2016 Crown Copyright\n\
|
||||
*\n\
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");\n\
|
||||
* you may not use this file except in compliance with the License.\n\
|
||||
* You may obtain a copy of the License at\n\
|
||||
*\n\
|
||||
* http://www.apache.org/licenses/LICENSE-2.0\n\
|
||||
*\n\
|
||||
* Unless required by applicable law or agreed to in writing, software\n\
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,\n\
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\
|
||||
* See the License for the specific language governing permissions and\n\
|
||||
* limitations under the License.\n\
|
||||
*/\n';
|
||||
|
||||
var templateOptions = {
|
||||
data: {
|
||||
compileTime: grunt.template.today("dd/mm/yyyy HH:MM:ss") + " UTC",
|
||||
compileMsg: grunt.option("compile-msg") || grunt.option("msg") || "",
|
||||
codebaseStats: grunt.file.read("src/static/stats.txt").split("\n").join("<br>")
|
||||
}
|
||||
};
|
||||
|
||||
// Project configuration
|
||||
var compileTime = grunt.template.today("dd/mm/yyyy HH:MM:ss") + " UTC",
|
||||
banner = "/**\n" +
|
||||
"* CyberChef - The Cyber Swiss Army Knife\n" +
|
||||
"*\n" +
|
||||
"* @copyright Crown Copyright 2016\n" +
|
||||
"* @license Apache-2.0\n" +
|
||||
"*\n" +
|
||||
"* Copyright 2016 Crown Copyright\n" +
|
||||
"*\n" +
|
||||
'* Licensed under the Apache License, Version 2.0 (the "License");\n' +
|
||||
"* you may not use this file except in compliance with the License.\n" +
|
||||
"* You may obtain a copy of the License at\n" +
|
||||
"*\n" +
|
||||
"* http://www.apache.org/licenses/LICENSE-2.0\n" +
|
||||
"*\n" +
|
||||
"* Unless required by applicable law or agreed to in writing, software\n" +
|
||||
'* distributed under the License is distributed on an "AS IS" BASIS,\n' +
|
||||
"* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
|
||||
"* See the License for the specific language governing permissions and\n" +
|
||||
"* limitations under the License.\n" +
|
||||
"*/\n";
|
||||
|
||||
/**
|
||||
* Compiles a production build of CyberChef into a single, portable web page.
|
||||
*/
|
||||
function runInliner() {
|
||||
var inlinerError = false;
|
||||
Inliner.html({
|
||||
relativeTo: "build/prod/",
|
||||
fileContent: grunt.file.read("build/prod/cyberchef.htm"),
|
||||
images: true,
|
||||
svgs: true,
|
||||
scripts: true,
|
||||
links: true,
|
||||
strict: true
|
||||
}, function(error, result) {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
inlinerError = true;
|
||||
return false;
|
||||
}
|
||||
grunt.file.write("build/prod/cyberchef.htm", result);
|
||||
});
|
||||
|
||||
return !inlinerError;
|
||||
}
|
||||
|
||||
grunt.initConfig({
|
||||
clean: {
|
||||
dev: ["build/dev/*"],
|
||||
prod: ["build/prod/*"],
|
||||
test: ["build/test/*"],
|
||||
node: ["build/node/*"],
|
||||
docs: ["docs/*", "!docs/*.conf.json", "!docs/*.ico"],
|
||||
},
|
||||
eslint: {
|
||||
options: {
|
||||
configFile: "src/js/.eslintrc.json"
|
||||
configFile: "src/.eslintrc.json"
|
||||
},
|
||||
gruntfile: ["Gruntfile.js"],
|
||||
core: ["src/js/core/**/*.js"],
|
||||
config: ["src/js/config/**/*.js"],
|
||||
views: ["src/js/views/**/*.js"],
|
||||
operations: ["src/js/operations/**/*.js"],
|
||||
configs: ["Gruntfile.js"],
|
||||
core: ["src/core/**/*.js", "!src/core/lib/**/*"],
|
||||
web: ["src/web/**/*.js"],
|
||||
node: ["src/node/**/*.js"],
|
||||
tests: ["test/**/*.js"],
|
||||
},
|
||||
jsdoc: {
|
||||
|
@ -226,209 +128,183 @@ module.exports = function(grunt) {
|
|||
},
|
||||
all: {
|
||||
src: [
|
||||
"src/js/**/*.js",
|
||||
"!src/js/lib/**/*",
|
||||
"src/**/*.js",
|
||||
"!src/core/lib/**/*",
|
||||
],
|
||||
}
|
||||
},
|
||||
clean: {
|
||||
dev: ["build/dev/*"],
|
||||
prod: ["build/prod/*"],
|
||||
test: ["build/test/*"],
|
||||
docs: ["docs/*", "!docs/*.conf.json", "!docs/*.ico"],
|
||||
},
|
||||
concat: {
|
||||
webpack: {
|
||||
options: {
|
||||
process: templateOptions
|
||||
},
|
||||
css: {
|
||||
options: {
|
||||
banner: banner.replace(/\/\*\*/g, "/*!"),
|
||||
process: function(content, srcpath) {
|
||||
// Change special comments from /** to /*! to comply with cssmin
|
||||
content = content.replace(/^\/\*\* /g, "/*! ");
|
||||
return grunt.template.process(content);
|
||||
plugins: [
|
||||
new webpack.ProvidePlugin({
|
||||
$: "jquery",
|
||||
jQuery: "jquery",
|
||||
moment: "moment-timezone"
|
||||
}),
|
||||
new webpack.BannerPlugin({
|
||||
banner: banner,
|
||||
raw: true,
|
||||
entryOnly: true
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
COMPILE_TIME: JSON.stringify(compileTime),
|
||||
COMPILE_MSG: JSON.stringify(grunt.option("compile-msg") || grunt.option("msg") || "")
|
||||
}),
|
||||
new ExtractTextPlugin("styles.css"),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
jquery: "jquery/src/jquery"
|
||||
}
|
||||
},
|
||||
src: [
|
||||
"src/css/lib/**/*.css",
|
||||
"src/css/structure/**/*.css",
|
||||
"src/css/themes/classic.css"
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
loader: "babel-loader?compact=false"
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: ExtractTextPlugin.extract({
|
||||
use: "css-loader?minimize"
|
||||
})
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
use: ExtractTextPlugin.extract({
|
||||
use: [
|
||||
{ loader: "css-loader?minimize" },
|
||||
{ loader: "less-loader" }
|
||||
]
|
||||
})
|
||||
},
|
||||
{
|
||||
test: /\.(ico|eot|ttf|woff|woff2)$/,
|
||||
loader: "url-loader",
|
||||
options: {
|
||||
limit: 10000
|
||||
}
|
||||
},
|
||||
{ // First party images are saved as files to be cached
|
||||
test: /\.(png|jpg|gif|svg)$/,
|
||||
exclude: /node_modules/,
|
||||
loader: "file-loader",
|
||||
options: {
|
||||
name: "images/[name].[ext]"
|
||||
}
|
||||
},
|
||||
{ // Third party images are inlined
|
||||
test: /\.(png|jpg|gif|svg)$/,
|
||||
exclude: /web\/static/,
|
||||
loader: "url-loader",
|
||||
options: {
|
||||
limit: 10000
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
stats: {
|
||||
children: false
|
||||
}
|
||||
},
|
||||
webDev: {
|
||||
target: "web",
|
||||
entry: "./src/web/index.js",
|
||||
output: {
|
||||
filename: "scripts.js",
|
||||
path: __dirname + "/build/dev"
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
filename: "index.html",
|
||||
template: "./src/web/html/index.html",
|
||||
compileTime: compileTime
|
||||
})
|
||||
],
|
||||
dest: "build/dev/styles.css"
|
||||
watch: true
|
||||
},
|
||||
js: {
|
||||
options: {
|
||||
banner: '"use strict";\n'
|
||||
webProd: {
|
||||
target: "web",
|
||||
entry: "./src/web/index.js",
|
||||
output: {
|
||||
filename: "scripts.js",
|
||||
path: __dirname + "/build/prod"
|
||||
},
|
||||
src: jsAppFiles,
|
||||
dest: "build/dev/scripts.js"
|
||||
plugins: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
"screw_ie8": true,
|
||||
"dead_code": true,
|
||||
"unused": true,
|
||||
"warnings": false
|
||||
},
|
||||
comments: false,
|
||||
}),
|
||||
new HtmlWebpackPlugin({ // Main version
|
||||
filename: "index.html",
|
||||
template: "./src/web/html/index.html",
|
||||
compileTime: compileTime,
|
||||
minify: {
|
||||
removeComments: true,
|
||||
collapseWhitespace: true,
|
||||
minifyJS: true,
|
||||
minifyCSS: true
|
||||
}
|
||||
}),
|
||||
new HtmlWebpackPlugin({ // Inline version
|
||||
filename: "cyberchef.htm",
|
||||
template: "./src/web/html/index.html",
|
||||
compileTime: compileTime,
|
||||
inline: true,
|
||||
minify: {
|
||||
removeComments: true,
|
||||
collapseWhitespace: true,
|
||||
minifyJS: true,
|
||||
minifyCSS: true
|
||||
}
|
||||
}),
|
||||
]
|
||||
},
|
||||
jsTest: {
|
||||
options: {
|
||||
banner: '"use strict";\n'
|
||||
},
|
||||
src: jsTestFiles,
|
||||
dest: "build/test/tests.js"
|
||||
tests: {
|
||||
target: "node",
|
||||
entry: "./test/index.js",
|
||||
output: {
|
||||
filename: "index.js",
|
||||
path: __dirname + "/build/test"
|
||||
}
|
||||
},
|
||||
node: {
|
||||
target: "node",
|
||||
entry: "./src/node/index.js",
|
||||
output: {
|
||||
filename: "CyberChef.js",
|
||||
path: __dirname + "/build/node",
|
||||
library: "CyberChef",
|
||||
libraryTarget: "commonjs2"
|
||||
}
|
||||
}
|
||||
},
|
||||
copy: {
|
||||
htmlDev: {
|
||||
options: {
|
||||
process: function(content, srcpath) {
|
||||
return grunt.template.process(content, templateOptions);
|
||||
}
|
||||
},
|
||||
src: "src/html/index.html",
|
||||
dest: "build/dev/index.html"
|
||||
},
|
||||
htmlTest: {
|
||||
src: "test/test.html",
|
||||
dest: "build/test/index.html"
|
||||
},
|
||||
htmlProd: {
|
||||
options: {
|
||||
process: function(content, srcpath) {
|
||||
return grunt.template.process(content, templateOptions);
|
||||
}
|
||||
},
|
||||
src: "src/html/index.html",
|
||||
dest: "build/prod/index.html"
|
||||
},
|
||||
htmlInline: {
|
||||
options: {
|
||||
process: function(content, srcpath) {
|
||||
// TODO: Do all this in Jade
|
||||
content = content.replace(
|
||||
'<a href="cyberchef.htm" style="float: left; margin-left: 10px; margin-right: 80px;" download>Download CyberChef<img src="images/download-24x24.png" /></a>',
|
||||
'<span style="float: left; margin-left: 10px;">Compile time: ' + grunt.template.today("dd/mm/yyyy HH:MM:ss") + " UTC</span>");
|
||||
return grunt.template.process(content, templateOptions);
|
||||
}
|
||||
},
|
||||
src: "src/html/index.html",
|
||||
dest: "build/prod/cyberchef.htm"
|
||||
},
|
||||
staticDev: {
|
||||
files: [
|
||||
{
|
||||
expand: true,
|
||||
cwd: "src/static/",
|
||||
src: [
|
||||
"**/*",
|
||||
"**/.*",
|
||||
"!stats.txt",
|
||||
"!ga.html"
|
||||
],
|
||||
dest: "build/dev/"
|
||||
}
|
||||
]
|
||||
},
|
||||
staticProd: {
|
||||
files: [
|
||||
{
|
||||
expand: true,
|
||||
cwd: "src/static/",
|
||||
src: [
|
||||
"**/*",
|
||||
"**/.*",
|
||||
"!stats.txt",
|
||||
"!ga.html"
|
||||
],
|
||||
dest: "build/prod/"
|
||||
}
|
||||
]
|
||||
},
|
||||
ghPages: {
|
||||
options: {
|
||||
process: function(content, srcpath) {
|
||||
process: function (content, srcpath) {
|
||||
// Add Google Analytics code to index.html
|
||||
content = content.replace("</body></html>",
|
||||
grunt.file.read("src/static/ga.html") + "</body></html>");
|
||||
return grunt.template.process(content, templateOptions);
|
||||
grunt.file.read("src/web/static/ga.html") + "</body></html>");
|
||||
return grunt.template.process(content);
|
||||
}
|
||||
},
|
||||
src: "build/prod/index.html",
|
||||
dest: "build/prod/index.html"
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
options: {
|
||||
preserveComments: function(node, comment) {
|
||||
if (comment.value.indexOf("* @license") === 0) return true;
|
||||
return false;
|
||||
},
|
||||
screwIE8: true,
|
||||
ASCIIOnly: true,
|
||||
beautify: {
|
||||
beautify: false,
|
||||
inline_script: true, // eslint-disable-line camelcase
|
||||
ascii_only: true, // eslint-disable-line camelcase
|
||||
screw_ie8: true // eslint-disable-line camelcase
|
||||
},
|
||||
compress: {
|
||||
screw_ie8: true // eslint-disable-line camelcase
|
||||
},
|
||||
banner: banner
|
||||
},
|
||||
prod: {
|
||||
src: "build/dev/scripts.js",
|
||||
dest: "build/prod/scripts.js"
|
||||
}
|
||||
},
|
||||
cssmin: {
|
||||
prod: {
|
||||
src: "build/dev/styles.css",
|
||||
dest: "build/prod/styles.css"
|
||||
}
|
||||
},
|
||||
htmlmin: {
|
||||
prod: {
|
||||
options: {
|
||||
removeComments: true,
|
||||
collapseWhitespace: true,
|
||||
minifyJS: true,
|
||||
minifyCSS: true
|
||||
},
|
||||
src: "build/prod/index.html",
|
||||
dest: "build/prod/index.html"
|
||||
},
|
||||
inline: {
|
||||
options: {
|
||||
removeComments: true,
|
||||
collapseWhitespace: true,
|
||||
minifyJS: false,
|
||||
minifyCSS: false
|
||||
},
|
||||
src: "build/prod/cyberchef.htm",
|
||||
dest: "build/prod/cyberchef.htm"
|
||||
}
|
||||
},
|
||||
inline: {
|
||||
options: {
|
||||
tag: "",
|
||||
inlineTagAttributes: {
|
||||
js: "type='application/javascript'",
|
||||
css: "type='text/css'"
|
||||
}
|
||||
},
|
||||
compiled: {
|
||||
src: "build/prod/cyberchef.htm",
|
||||
dest: "build/prod/cyberchef.htm"
|
||||
},
|
||||
prod: {
|
||||
options: {
|
||||
tag: "__inline"
|
||||
},
|
||||
src: "build/prod/index.html",
|
||||
dest: "build/prod/index.html"
|
||||
}
|
||||
},
|
||||
chmod: {
|
||||
build: {
|
||||
options: {
|
||||
mode: "755",
|
||||
},
|
||||
src: ["build/**/*", "build/**/.htaccess", "build/"]
|
||||
src: ["build/**/*", "build/"]
|
||||
},
|
||||
docs: {
|
||||
options: {
|
||||
|
@ -445,75 +321,12 @@ module.exports = function(grunt) {
|
|||
].join(";"),
|
||||
stderr: false
|
||||
},
|
||||
stats: {
|
||||
command: "rm src/static/stats.txt;" +
|
||||
[
|
||||
"ls src/ -R1 | grep '^$' -v | grep ':$' -v | wc -l | xargs printf '%b\tsource files\n'",
|
||||
"find src/ -regex '.*\..*' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
|
||||
"du -hs src/ | pcregrep -o '^[^\t]*' | xargs printf '%b\tsize\n'",
|
||||
|
||||
"ls src/js/ -R1 | grep '\.js$' | wc -l | xargs printf '\n%b\tJavaScript source files\n'",
|
||||
"find src/js/ -regex '.*\.js' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
|
||||
"find src/js/ -regex '.*\.js' -exec du -hcs {} \+ | tail -n1 | egrep -o '^[^\t]*' | xargs printf '%b\tsize\n'",
|
||||
|
||||
"find src/js/ -regex '.*/lib/.*\.js' -print | wc -l | xargs printf '\n%b\tthird party JavaScript source files\n'",
|
||||
"find src/js/ -regex '.*/lib/.*\.js' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
|
||||
"find src/js/ -regex '.*/lib/.*\.js' -exec du -hcs {} \+ | tail -n1 | egrep -o '^[^\t]*' | xargs printf '%b\tsize\n'",
|
||||
|
||||
"find src/js/ -regex '.*\.js' -not -regex '.*/lib/.*' -print | wc -l | xargs printf '\n%b\tfirst party JavaScript source files\n'",
|
||||
"find src/js/ -regex '.*\.js' -not -regex '.*/lib/.*' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
|
||||
"find src/js/ -regex '.*\.js' -not -regex '.*/lib/.*' -exec du -hcs {} \+ | tail -n1 | egrep -o '^[^\t]*' | xargs printf '%b\tsize\n'",
|
||||
|
||||
"du build/dev/scripts.js -h | egrep -o '^[^\t]*' | xargs printf '\n%b\tuncompressed JavaScript size\n'",
|
||||
"du build/prod/scripts.js -h | egrep -o '^[^\t]*' | xargs printf '%b\tcompressed JavaScript size\n'",
|
||||
|
||||
"grep -E '^\\s+name: ' src/js/config/Categories.js | wc -l | xargs printf '\n%b\tcategories\n'",
|
||||
"grep -E '^\\s+\"[A-Za-z0-9 \\-]+\": {' src/js/config/OperationConfig.js | wc -l | xargs printf '%b\toperations\n'",
|
||||
|
||||
].join(" >> src/static/stats.txt;") + " >> src/static/stats.txt;",
|
||||
stderr: false
|
||||
},
|
||||
displayStats: {
|
||||
command: "cat src/static/stats.txt"
|
||||
},
|
||||
cleanGit: {
|
||||
command: "git gc --prune=now --aggressive"
|
||||
},
|
||||
deployGhPages: {
|
||||
command: [
|
||||
"git add build/prod/index.html -v",
|
||||
"COMMIT_HASH=$(git rev-parse HEAD)",
|
||||
"git commit -m \"GitHub Pages release for ${COMMIT_HASH}\"",
|
||||
"git push origin `git subtree split --prefix build/prod master`:gh-pages --force",
|
||||
"git reset HEAD~",
|
||||
"git checkout build/prod/index.html"
|
||||
].join(";")
|
||||
}
|
||||
},
|
||||
execute: {
|
||||
test: "test/NodeRunner.js"
|
||||
},
|
||||
watch: {
|
||||
css: {
|
||||
files: "src/css/**/*.css",
|
||||
tasks: ["concat:css", "chmod:build"]
|
||||
},
|
||||
js: {
|
||||
files: "src/js/**/*.js",
|
||||
tasks: ["concat:js", "chmod:build"]
|
||||
},
|
||||
html: {
|
||||
files: "src/html/**/*.html",
|
||||
tasks: ["copy:htmlDev", "chmod:build"]
|
||||
},
|
||||
static: {
|
||||
files: ["src/static/**/*", "src/static/**/.*"],
|
||||
tasks: ["copy:staticDev", "chmod:build"]
|
||||
},
|
||||
grunt: {
|
||||
files: "Gruntfile.js",
|
||||
tasks: ["clean:dev", "concat:css", "concat:js", "copy:htmlDev", "copy:staticDev", "chmod:build"]
|
||||
}
|
||||
test: "build/test/index.js"
|
||||
},
|
||||
});
|
||||
|
||||
|
|
11
README.md
11
README.md
|
@ -1,6 +1,6 @@
|
|||
# CyberChef
|
||||
|
||||
####*The Cyber Swiss Army Knife*
|
||||
#### *The Cyber Swiss Army Knife*
|
||||
|
||||
CyberChef is a simple, intuitive web app for carrying out all manner of "cyber" operations within a web browser. These operations include creating hexdumps, simple encoding like XOR or Base64, more complex encryption like AES, DES and Blowfish, data compression and decompression, calculating hashes and checksums, IPv6 and X.509 parsing, and much more.
|
||||
|
||||
|
@ -13,7 +13,6 @@ CyberChef is still under active development. As a result, it shouldn't be consid
|
|||
Cryptographic operations in CyberChef should not be relied upon to provide security in any situation. No guarantee is offered for their correctness.
|
||||
|
||||
[A live demo can be found here][1] - have fun!
|
||||
Note: Use Chrome or Firefox, see the Browser Support section below for details.
|
||||
|
||||
|
||||
## How it works
|
||||
|
@ -63,11 +62,7 @@ You can use as many operations as you like in simple or complex ways. Some examp
|
|||
|
||||
## Browser support
|
||||
|
||||
CyberChef works well in modern versions of Google Chrome and Mozilla Firefox.
|
||||
|
||||
To aid in the efficient development of new features and operations, there has been no attempt to maintain support for any version of Microsoft Internet Explorer.
|
||||
|
||||
Microsoft Edge is currently unsupported, but if anyone would like to contribute compatibility fixes, they would be appreciated.
|
||||
CyberChef is built to support Google Chrome 40+, Mozilla Firefox 35+ and Microsoft Edge 14+.
|
||||
|
||||
|
||||
## Contributing
|
||||
|
@ -91,4 +86,4 @@ CyberChef is released under the [Apache 2.0 Licence](https://www.apache.org/lice
|
|||
[5]: https://gchq.github.io/CyberChef/?recipe=%5B%7B%22op%22%3A%22From%20Hexdump%22%2C%22args%22%3A%5B%5D%7D%2C%7B%22op%22%3A%22Gunzip%22%2C%22args%22%3A%5B%5D%7D%5D&input=MDAwMDAwMDAgIDFmIDhiIDA4IDAwIDEyIGJjIGYzIDU3IDAwIGZmIDBkIGM3IGMxIDA5IDAwIDIwICB8Li4uLi6881cu%2Fy7HwS4uIHwKMDAwMDAwMTAgIDA4IDA1IGQwIDU1IGZlIDA0IDJkIGQzIDA0IDFmIGNhIDhjIDQ0IDIxIDViIGZmICB8Li7QVf4uLdMuLsouRCFb%2F3wKMDAwMDAwMjAgIDYwIGM3IGQ3IDAzIDE2IGJlIDQwIDFmIDc4IDRhIDNmIDA5IDg5IDBiIDlhIDdkICB8YMfXLi6%2BQC54Sj8uLi4ufXwKMDAwMDAwMzAgIDRlIGM4IDRlIDZkIDA1IDFlIDAxIDhiIDRjIDI0IDAwIDAwIDAwICAgICAgICAgICB8TshObS4uLi5MJC4uLnw
|
||||
[6]: https://gchq.github.io/CyberChef/?recipe=%5B%7B%22op%22%3A%22Fork%22%2C%22args%22%3A%5B%22%5C%5Cn%22%2C%22%5C%5Cn%22%5D%7D%2C%7B%22op%22%3A%22From%20UNIX%20Timestamp%22%2C%22args%22%3A%5B%22Seconds%20(s)%22%5D%7D%5D&input=OTc4MzQ2ODAwCjEwMTI2NTEyMDAKMTA0NjY5NjQwMAoxMDgxMDg3MjAwCjExMTUzMDUyMDAKMTE0OTYwOTYwMA
|
||||
[7]: https://gchq.github.io/CyberChef/?recipe=%5B%7B%22op%22%3A%22Fork%22%2C%22args%22%3A%5B%22%5C%5Cn%22%2C%22%5C%5Cn%22%5D%7D%2C%7B%22op%22%3A%22Conditional%20Jump%22%2C%22args%22%3A%5B%221%22%2C%222%22%2C%2210%22%5D%7D%2C%7B%22op%22%3A%22To%20Hex%22%2C%22args%22%3A%5B%22Space%22%5D%7D%2C%7B%22op%22%3A%22Return%22%2C%22args%22%3A%5B%5D%7D%2C%7B%22op%22%3A%22To%20Base64%22%2C%22args%22%3A%5B%22A-Za-z0-9%2B%2F%3D%22%5D%7D%5D&input=U29tZSBkYXRhIHdpdGggYSAxIGluIGl0ClNvbWUgZGF0YSB3aXRoIGEgMiBpbiBpdA
|
||||
[8]: https://gchq.github.io/CyberChef/?recipe=%5B%7B%22op%22%3A%22XOR%22%2C%22args%22%3A%5B%7B%22option%22%3A%22Hex%22%2C%22string%22%3A%223a%22%7D%2Cfalse%2Cfalse%5D%7D%2C%7B%22op%22%3A%22To%20Hexdump%22%2C%22args%22%3A%5B%2216%22%2Cfalse%2Cfalse%5D%7D%5D&input=VGhlIGFuc3dlciB0byB0aGUgdWx0aW1hdGUgcXVlc3Rpb24gb2YgbGlmZSwgdGhlIFVuaXZlcnNlLCBhbmQgZXZlcnl0aGluZyBpcyA0Mi4
|
||||
[8]: https://gchq.github.io/CyberChef/?recipe=%5B%7B%22op%22%3A%22XOR%22%2C%22args%22%3A%5B%7B%22option%22%3A%22Hex%22%2C%22string%22%3A%223a%22%7D%2Cfalse%2Cfalse%5D%7D%2C%7B%22op%22%3A%22To%20Hexdump%22%2C%22args%22%3A%5B%2216%22%2Cfalse%2Cfalse%5D%7D%5D&input=VGhlIGFuc3dlciB0byB0aGUgdWx0aW1hdGUgcXVlc3Rpb24gb2YgbGlmZSwgdGhlIFVuaXZlcnNlLCBhbmQgZXZlcnl0aGluZyBpcyA0Mi4
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
# Serve up .htm files as binary files rather than text/html.
|
||||
# This allows cyberchef.htm to be downloaded rather than opened in the browser.
|
||||
AddType application/octet-stream .htm
|
||||
|
||||
# Fix Apache bug #45023 where "-gzip" is appended to all ETags, preventing 304 responses
|
||||
<IfModule mod_headers.c>
|
||||
RequestHeader edit "If-None-Match" "^\"(.*)-gzip\"$" "\"$1\""
|
||||
Header edit "ETag" "^\"(.*[^g][^z][^i][^p])\"$" "\"$1-gzip\""
|
||||
</IfModule>
|
||||
|
||||
# Set gzip compression on all resources that support it
|
||||
<IfModule mod_deflate.c>
|
||||
SetOutputFilter DEFLATE
|
||||
</IfModule>
|
||||
|
||||
# Set Expires headers on various resources
|
||||
<IfModule mod_expires.c>
|
||||
ExpiresActive On
|
||||
|
||||
# 10 minutes
|
||||
ExpiresDefault "access plus 600 seconds"
|
||||
|
||||
# 30 days
|
||||
ExpiresByType image/x-icon "access plus 2592000 seconds"
|
||||
ExpiresByType image/jpeg "access plus 2592000 seconds"
|
||||
ExpiresByType image/png "access plus 2592000 seconds"
|
||||
ExpiresByType image/gif "access plus 2592000 seconds"
|
||||
|
||||
# 7 days
|
||||
ExpiresByType text/css "access plus 604800 seconds"
|
||||
ExpiresByType text/javascript "access plus 604800 seconds"
|
||||
ExpiresByType application/javascript "access plus 604800 seconds"
|
||||
ExpiresByType text/html "access plus 604800 seconds"
|
||||
</IfModule>
|
||||
|
||||
# Set Cache-Control headers on various resources
|
||||
<IfModule mod_headers.c>
|
||||
<FilesMatch "\\.(ico|jpe?g|png|gif)$">
|
||||
Header set Cache-Control "max-age=2592000, public"
|
||||
</FilesMatch>
|
||||
<FilesMatch "\\.(css)$">
|
||||
Header set Cache-Control "max-age=600, public"
|
||||
</FilesMatch>
|
||||
<FilesMatch "\\.(js)$">
|
||||
Header set Cache-Control "max-age=600, private, must-revalidate"
|
||||
</FilesMatch>
|
||||
<FilesMatch "\\.(x?html?)$">
|
||||
Header set Cache-Control "max-age=600, private, must-revalidate"
|
||||
</FilesMatch>
|
||||
</IfModule>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
57
package.json
57
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "cyberchef",
|
||||
"version": "4.0.0",
|
||||
"version": "5.0.1",
|
||||
"description": "CyberChef is a simple, intuitive web app for analysing and decoding data within a web browser.",
|
||||
"author": "n1474335 <n1474335@gmail.com>",
|
||||
"homepage": "https://gchq.github.io/CyberChef",
|
||||
|
@ -26,21 +26,60 @@
|
|||
"url": "https://github.com/gchq/CyberChef/"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "~1.0.1",
|
||||
"babel-core": "^6.24.0",
|
||||
"babel-loader": "^6.4.0",
|
||||
"babel-polyfill": "^6.23.0",
|
||||
"babel-preset-env": "^1.2.2",
|
||||
"css-loader": "^0.27.3",
|
||||
"exports-loader": "^0.6.4",
|
||||
"extract-text-webpack-plugin": "^2.1.0",
|
||||
"file-loader": "^0.10.1",
|
||||
"grunt": ">=0.4.5",
|
||||
"grunt-chmod": "~1.1.1",
|
||||
"grunt-contrib-clean": "~1.0.0",
|
||||
"grunt-contrib-concat": "~1.0.0",
|
||||
"grunt-contrib-copy": "~1.0.0",
|
||||
"grunt-contrib-cssmin": "~1.0.2",
|
||||
"grunt-contrib-htmlmin": "~2.0.0",
|
||||
"grunt-contrib-uglify": "~2.0.0",
|
||||
"grunt-contrib-watch": "~1.0.0",
|
||||
"grunt-eslint": "^19.0.0",
|
||||
"grunt-exec": "~1.0.1",
|
||||
"grunt-execute": "^0.2.2",
|
||||
"grunt-inline-alt": "~0.3.10",
|
||||
"grunt-jsdoc": "^2.1.0",
|
||||
"grunt-webpack": "^2.0.1",
|
||||
"html-webpack-plugin": "^2.28.0",
|
||||
"imports-loader": "^0.7.1",
|
||||
"ink-docstrap": "^1.1.4",
|
||||
"phantomjs-prebuilt": "^2.1.14"
|
||||
"less": "^2.7.2",
|
||||
"less-loader": "^4.0.2",
|
||||
"style-loader": "^0.15.0",
|
||||
"url-loader": "^0.5.8",
|
||||
"web-resource-inliner": "^4.1.0",
|
||||
"webpack": "^2.2.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"bootstrap": "^3.3.7",
|
||||
"bootstrap-colorpicker": "^2.5.1",
|
||||
"bootstrap-switch": "^3.3.4",
|
||||
"crypto-api": "^0.6.2",
|
||||
"crypto-js": "^3.1.9-1",
|
||||
"diff": "^3.2.0",
|
||||
"escodegen": "^1.8.1",
|
||||
"esmangle": "^1.0.1",
|
||||
"esprima": "^3.1.3",
|
||||
"google-code-prettify": "^1.0.5",
|
||||
"jquery": "^3.1.1",
|
||||
"jsbn": "^1.1.0",
|
||||
"jsrsasign": "^7.1.0",
|
||||
"moment": "^2.17.1",
|
||||
"moment-timezone": "^0.5.11",
|
||||
"sladex-blowfish": "^0.8.1",
|
||||
"sortablejs": "^1.5.1",
|
||||
"split.js": "^1.2.0",
|
||||
"vkbeautify": "^0.99.1",
|
||||
"xmldom": "^0.1.27",
|
||||
"xpath": "0.0.24",
|
||||
"zlibjs": "^0.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "grunt prod",
|
||||
"test": "grunt test",
|
||||
"docs": "grunt docs"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
"ecmaVersion": 6,
|
||||
"ecmaFeatures": {
|
||||
"impliedStrict": true
|
||||
}
|
||||
},
|
||||
"sourceType": "module"
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"jquery": true,
|
||||
"es6": true,
|
||||
"node": false
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"rules": {
|
||||
|
@ -28,7 +28,11 @@
|
|||
// modify rules from base configurations
|
||||
"no-unused-vars": ["error", {
|
||||
"args": "none",
|
||||
"vars": "local"
|
||||
"vars": "local",
|
||||
// Allow vars that start with a capital letter to be unused.
|
||||
// This is mainly for exported module names which are useful to indicate
|
||||
// the name of the module and may be used to refer to itself in future.
|
||||
"varsIgnorePattern": "^[A-Z]"
|
||||
}],
|
||||
"no-empty": ["error", {
|
||||
"allowEmptyCatch": true
|
||||
|
@ -83,36 +87,11 @@
|
|||
"space-in-parens": "error"
|
||||
},
|
||||
"globals": {
|
||||
/* core/* */
|
||||
"Chef": false,
|
||||
"Dish": false,
|
||||
"Recipe": false,
|
||||
"Ingredient": false,
|
||||
"Operation": false,
|
||||
"Utils": false,
|
||||
|
||||
/* config/* */
|
||||
"Categories": false,
|
||||
"OperationConfig": false,
|
||||
|
||||
/* views/html/* */
|
||||
"HTMLApp": false,
|
||||
"HTMLCategory": false,
|
||||
"HTMLOperation": false,
|
||||
"HTMLIngredient": false,
|
||||
"Manager": false,
|
||||
"ControlsWaiter": false,
|
||||
"HighlighterWaiter": false,
|
||||
"InputWaiter": false,
|
||||
"OperationsWaiter": false,
|
||||
"OptionsWaiter": false,
|
||||
"OutputWaiter": false,
|
||||
"RecipeWaiter": false,
|
||||
"SeasonalWaiter": false,
|
||||
"WindowWaiter": false,
|
||||
"$": false,
|
||||
"jQuery": false,
|
||||
"moment": false,
|
||||
|
||||
/* tests */
|
||||
"TestRegister": false,
|
||||
"TestRunner": false
|
||||
"COMPILE_TIME": false,
|
||||
"COMPILE_MSG": false
|
||||
}
|
||||
}
|
|
@ -1,3 +1,7 @@
|
|||
import Dish from "./Dish.js";
|
||||
import Recipe from "./Recipe.js";
|
||||
|
||||
|
||||
/**
|
||||
* The main controller for CyberChef.
|
||||
*
|
||||
|
@ -20,7 +24,7 @@ var Chef = function() {
|
|||
* @param {Object} options - The options object storing various user choices
|
||||
* @param {boolean} options.attempHighlight - Whether or not to attempt highlighting
|
||||
* @param {number} progress - The position in the recipe to start from
|
||||
* @param {number} [step] - The number of operations to execute
|
||||
* @param {number} [step] - Whether to only execute one operation in the recipe
|
||||
*
|
||||
* @returns {Object} response
|
||||
* @returns {string} response.result - The output of the recipe
|
||||
|
@ -118,3 +122,5 @@ Chef.prototype.silentBake = function(recipeConfig) {
|
|||
}
|
||||
return new Date().getTime() - startTime;
|
||||
};
|
||||
|
||||
export default Chef;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "./Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* The data being operated on by each operation.
|
||||
*
|
||||
|
@ -200,3 +203,5 @@ Dish.prototype.valid = function() {
|
|||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export default Dish;
|
|
@ -1,3 +1,7 @@
|
|||
import Recipe from "./Recipe.js";
|
||||
import Dish from "./Dish.js";
|
||||
|
||||
|
||||
/**
|
||||
* Flow Control operations.
|
||||
*
|
||||
|
@ -7,7 +11,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var FlowControl = {
|
||||
const FlowControl = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -190,3 +194,5 @@ var FlowControl = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default FlowControl;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "./Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* The arguments to operations.
|
||||
*
|
||||
|
@ -83,3 +86,5 @@ Ingredient.prepare = function(data, type) {
|
|||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
export default Ingredient;
|
|
@ -1,3 +1,7 @@
|
|||
import Dish from "./Dish.js";
|
||||
import Ingredient from "./Ingredient.js";
|
||||
|
||||
|
||||
/**
|
||||
* The Operation specified by the user to be run.
|
||||
*
|
||||
|
@ -155,3 +159,5 @@ Operation.prototype.isDisabled = function() {
|
|||
Operation.prototype.isFlowControl = function() {
|
||||
return this.flowControl;
|
||||
};
|
||||
|
||||
export default Operation;
|
|
@ -1,3 +1,7 @@
|
|||
import Operation from "./Operation.js";
|
||||
import OperationConfig from "./config/OperationConfig.js";
|
||||
|
||||
|
||||
/**
|
||||
* The Recipe controls a list of Operations and the Dish they operate on.
|
||||
*
|
||||
|
@ -212,3 +216,5 @@ Recipe.prototype.fromString = function(recipeStr) {
|
|||
var recipeConfig = JSON.parse(recipeStr);
|
||||
this._parseConfig(recipeConfig);
|
||||
};
|
||||
|
||||
export default Recipe;
|
|
@ -1,4 +1,5 @@
|
|||
/* globals CryptoJS, moment */
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
|
||||
/**
|
||||
* Utility functions for use in operations, the core framework and the stage.
|
||||
|
@ -9,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Utils = {
|
||||
const Utils = {
|
||||
|
||||
/**
|
||||
* Translates an ordinal into a character.
|
||||
|
@ -387,7 +388,7 @@ var Utils = {
|
|||
var wordArray = CryptoJS.enc.Utf8.parse(str),
|
||||
byteArray = Utils.wordArrayToByteArray(wordArray);
|
||||
|
||||
if (str.length !== wordArray.sigBytes)
|
||||
if (window && str.length !== wordArray.sigBytes)
|
||||
window.app.options.attemptHighlight = false;
|
||||
return byteArray;
|
||||
},
|
||||
|
@ -439,7 +440,7 @@ var Utils = {
|
|||
var wordArray = new CryptoJS.lib.WordArray.init(words, byteArray.length),
|
||||
str = CryptoJS.enc.Utf8.stringify(wordArray);
|
||||
|
||||
if (str.length !== wordArray.sigBytes)
|
||||
if (window && str.length !== wordArray.sigBytes)
|
||||
window.app.options.attemptHighlight = false;
|
||||
return str;
|
||||
} catch (err) {
|
||||
|
@ -1185,35 +1186,7 @@ var Utils = {
|
|||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A jQuery function to select a range of text.
|
||||
*
|
||||
* @param {number} start
|
||||
* @param {number} end
|
||||
*
|
||||
* @example
|
||||
* // Highlights the 4th, 5th and 6th characters in the element #input-text.
|
||||
* $("#input-text").selectRange(3,5);
|
||||
*
|
||||
* // Places the cursor at the beginning of the element #input-text.
|
||||
* $("#input-text").selectRange(0);
|
||||
*/
|
||||
$.fn.selectRange = function(start, end) {
|
||||
if (!end) end = start;
|
||||
return this.each(function() {
|
||||
if (this.setSelectionRange) {
|
||||
this.focus();
|
||||
this.setSelectionRange(start, end);
|
||||
} else if (this.createTextRange) {
|
||||
var range = this.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd("character", end);
|
||||
range.moveStart("character", start);
|
||||
range.select();
|
||||
}
|
||||
});
|
||||
};
|
||||
export default Utils;
|
||||
|
||||
|
||||
/**
|
|
@ -17,7 +17,7 @@
|
|||
* @constant
|
||||
* @type {CatConf[]}
|
||||
*/
|
||||
var Categories = [
|
||||
const Categories = [
|
||||
{
|
||||
name: "Favourites",
|
||||
ops: []
|
||||
|
@ -293,3 +293,5 @@ var Categories = [
|
|||
]
|
||||
},
|
||||
];
|
||||
|
||||
export default Categories;
|
|
@ -1,8 +1,41 @@
|
|||
/*
|
||||
* Tell eslint to ignore "'Object' is not defined" errors in this file, as it references every
|
||||
* single operation object by definition.
|
||||
*/
|
||||
/* eslint no-undef: "off" */
|
||||
import FlowControl from "../FlowControl.js";
|
||||
import Base from "../operations/Base.js";
|
||||
import Base58 from "../operations/Base58.js";
|
||||
import Base64 from "../operations/Base64.js";
|
||||
import BitwiseOp from "../operations/BitwiseOp.js";
|
||||
import ByteRepr from "../operations/ByteRepr.js";
|
||||
import CharEnc from "../operations/CharEnc.js";
|
||||
import Checksum from "../operations/Checksum.js";
|
||||
import Cipher from "../operations/Cipher.js";
|
||||
import Code from "../operations/Code.js";
|
||||
import Compress from "../operations/Compress.js";
|
||||
import Convert from "../operations/Convert.js";
|
||||
import DateTime from "../operations/DateTime.js";
|
||||
import Endian from "../operations/Endian.js";
|
||||
import Entropy from "../operations/Entropy.js";
|
||||
import Extract from "../operations/Extract.js";
|
||||
import FileType from "../operations/FileType.js";
|
||||
import Hash from "../operations/Hash.js";
|
||||
import Hexdump from "../operations/Hexdump.js";
|
||||
import HTML from "../operations/HTML.js";
|
||||
import HTTP from "../operations/HTTP.js";
|
||||
import IP from "../operations/IP.js";
|
||||
import JS from "../operations/JS.js";
|
||||
import MAC from "../operations/MAC.js";
|
||||
import MorseCode from "../operations/MorseCode.js";
|
||||
import NetBIOS from "../operations/NetBIOS.js";
|
||||
import Numberwang from "../operations/Numberwang.js";
|
||||
import OS from "../operations/OS.js";
|
||||
import PublicKey from "../operations/PublicKey.js";
|
||||
import Punycode from "../operations/Punycode.js";
|
||||
import QuotedPrintable from "../operations/QuotedPrintable.js";
|
||||
import Rotate from "../operations/Rotate.js";
|
||||
import SeqUtils from "../operations/SeqUtils.js";
|
||||
import StrUtils from "../operations/StrUtils.js";
|
||||
import Tidy from "../operations/Tidy.js";
|
||||
import Unicode from "../operations/Unicode.js";
|
||||
import URL_ from "../operations/URL.js";
|
||||
import UUID from "../operations/UUID.js";
|
||||
|
||||
|
||||
/**
|
||||
|
@ -45,7 +78,7 @@
|
|||
* @constant
|
||||
* @type {Object.<string, OpConf>}
|
||||
*/
|
||||
var OperationConfig = {
|
||||
const OperationConfig = {
|
||||
"Fork": {
|
||||
description: "Split the input data up based on the specified delimiter and run all subsequent operations on each branch separately.<br><br>For example, to decode multiple Base64 strings, enter them all on separate lines then add the 'Fork' and 'From Base64' operations to the recipe. Each string will be decoded separately.",
|
||||
run: FlowControl.runFork,
|
||||
|
@ -3165,3 +3198,5 @@ var OperationConfig = {
|
|||
]
|
||||
}
|
||||
};
|
||||
|
||||
export default OperationConfig;
|
|
@ -10,7 +10,7 @@
|
|||
* @constant
|
||||
* @namespace
|
||||
*/
|
||||
var CanvasComponents = {
|
||||
const CanvasComponents = {
|
||||
|
||||
drawLine: function(ctx, startX, startY, endX, endY) {
|
||||
ctx.beginPath();
|
||||
|
@ -182,3 +182,5 @@ var CanvasComponents = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default CanvasComponents;
|
|
@ -24,9 +24,10 @@
|
|||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
var UAS_parser = {
|
||||
import Utils from "../Utils.js";
|
||||
|
||||
const UAS_parser = {
|
||||
|
||||
parse: function (userAgent) {
|
||||
var result = {
|
||||
|
@ -133,7 +134,7 @@ var UAS_parser = {
|
|||
}
|
||||
};
|
||||
|
||||
var UAS_cache = {
|
||||
const UAS_cache = {
|
||||
version: '20131025-01',
|
||||
robots: {
|
||||
'3': {
|
||||
|
@ -25814,4 +25815,7 @@ var UAS_cache = {
|
|||
'35'
|
||||
]
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export {UAS_parser, UAS_cache};
|
||||
export default UAS_parser;
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Base = {
|
||||
const Base = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -46,7 +46,21 @@ var Base = {
|
|||
if (radix < 2 || radix > 36) {
|
||||
throw "Error: Radix argument must be between 2 and 36";
|
||||
}
|
||||
return parseInt(input.replace(/\s/g, ""), radix);
|
||||
|
||||
var number = input.replace(/\s/g, "").split("."),
|
||||
result = parseInt(number[0], radix) || 0;
|
||||
|
||||
if (number.length === 1) return result;
|
||||
|
||||
// Fractional part
|
||||
for (var i = 0; i < number[1].length; i++) {
|
||||
var digit = parseInt(number[1][i], radix);
|
||||
result += digit / Math.pow(radix, i+1);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
export default Base;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* Base58 operations.
|
||||
*
|
||||
|
@ -7,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Base58 = {
|
||||
const Base58 = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -130,3 +133,5 @@ var Base58 = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Base58;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* Base64 operations.
|
||||
*
|
||||
|
@ -7,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Base64 = {
|
||||
const Base64 = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -340,3 +343,5 @@ var Base64 = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Base64;
|
|
@ -1,4 +1,6 @@
|
|||
/* globals CryptoJS */
|
||||
import Utils from "../Utils.js";
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
|
||||
/**
|
||||
* Bitwise operations.
|
||||
|
@ -9,7 +11,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var BitwiseOp = {
|
||||
const BitwiseOp = {
|
||||
|
||||
/**
|
||||
* Runs bitwise operations across the input data.
|
||||
|
@ -304,3 +306,5 @@ var BitwiseOp = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default BitwiseOp;
|
|
@ -1,4 +1,6 @@
|
|||
/* globals app */
|
||||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* Byte representation operations.
|
||||
|
@ -9,7 +11,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var ByteRepr = {
|
||||
const ByteRepr = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -114,11 +116,11 @@ var ByteRepr = {
|
|||
else if (ordinal < 4294967296) padding = 8;
|
||||
else padding = 2;
|
||||
|
||||
if (padding > 2) app.options.attemptHighlight = false;
|
||||
if (padding > 2 && app) app.options.attemptHighlight = false;
|
||||
|
||||
output += Utils.hex(ordinal, padding) + delim;
|
||||
} else {
|
||||
app.options.attemptHighlight = false;
|
||||
if (app) app.options.attemptHighlight = false;
|
||||
output += ordinal.toString(base) + delim;
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +146,7 @@ var ByteRepr = {
|
|||
throw "Error: Base argument must be between 2 and 36";
|
||||
}
|
||||
|
||||
if (base !== 16) {
|
||||
if (base !== 16 && app) {
|
||||
app.options.attemptHighlight = false;
|
||||
}
|
||||
|
||||
|
@ -419,3 +421,5 @@ var ByteRepr = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default ByteRepr;
|
|
@ -1,4 +1,6 @@
|
|||
/* globals CryptoJS */
|
||||
import Utils from "../Utils.js";
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
|
||||
/**
|
||||
* Character encoding operations.
|
||||
|
@ -9,7 +11,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var CharEnc = {
|
||||
const CharEnc = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -44,3 +46,5 @@ var CharEnc = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default CharEnc;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* Checksum operations.
|
||||
*
|
||||
|
@ -7,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Checksum = {
|
||||
const Checksum = {
|
||||
|
||||
/**
|
||||
* Fletcher-8 Checksum operation.
|
||||
|
@ -121,7 +124,7 @@ var Checksum = {
|
|||
* @returns {string}
|
||||
*/
|
||||
runCRC32: function(input, args) {
|
||||
var crcTable = window.crcTable || (window.crcTable = Checksum._genCRCTable()),
|
||||
var crcTable = global.crcTable || (global.crcTable = Checksum._genCRCTable()),
|
||||
crc = 0 ^ (-1);
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
|
@ -188,3 +191,5 @@ var Checksum = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Checksum;
|
|
@ -1,4 +1,7 @@
|
|||
/* globals CryptoJS, blowfish */
|
||||
import Utils from "../Utils.js";
|
||||
import CryptoJS from "crypto-js";
|
||||
import {blowfish as Blowfish} from "sladex-blowfish";
|
||||
|
||||
|
||||
/**
|
||||
* Cipher operations.
|
||||
|
@ -9,7 +12,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Cipher = {
|
||||
const Cipher = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -263,7 +266,7 @@ var Cipher = {
|
|||
|
||||
if (key.length === 0) return "Enter a key";
|
||||
|
||||
var encHex = blowfish.encrypt(input, key, {
|
||||
var encHex = Blowfish.encrypt(input, key, {
|
||||
outputType: 1,
|
||||
cipherMode: Cipher.BLOWFISH_MODES.indexOf(mode)
|
||||
}),
|
||||
|
@ -289,7 +292,7 @@ var Cipher = {
|
|||
|
||||
input = Utils.format[inputFormat].parse(input);
|
||||
|
||||
return blowfish.decrypt(input.toString(CryptoJS.enc.Base64), key, {
|
||||
return Blowfish.decrypt(input.toString(CryptoJS.enc.Base64), key, {
|
||||
outputType: 0, // This actually means inputType. The library is weird.
|
||||
cipherMode: Cipher.BLOWFISH_MODES.indexOf(mode)
|
||||
});
|
||||
|
@ -614,6 +617,8 @@ var Cipher = {
|
|||
|
||||
};
|
||||
|
||||
export default Cipher;
|
||||
|
||||
|
||||
/**
|
||||
* Overwriting the CryptoJS OpenSSL key derivation function so that it is possible to not pass a
|
|
@ -1,4 +1,9 @@
|
|||
/* globals prettyPrintOne, vkbeautify, xpath */
|
||||
import Utils from "../Utils.js";
|
||||
import vkbeautify from "vkbeautify";
|
||||
import {DOMParser as dom} from "xmldom";
|
||||
import xpath from "xpath";
|
||||
import prettyPrintOne from "imports-loader?window=>global!exports-loader?prettyPrintOne!google-code-prettify/bin/prettify.min.js";
|
||||
|
||||
|
||||
/**
|
||||
* Code operations.
|
||||
|
@ -9,7 +14,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Code = {
|
||||
const Code = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -332,36 +337,25 @@ var Code = {
|
|||
var query = args[0],
|
||||
delimiter = args[1];
|
||||
|
||||
var xml;
|
||||
var doc;
|
||||
try {
|
||||
xml = $.parseXML(input);
|
||||
doc = new dom().parseFromString(input);
|
||||
} catch (err) {
|
||||
return "Invalid input XML.";
|
||||
}
|
||||
|
||||
var result;
|
||||
var nodes;
|
||||
try {
|
||||
result = xpath.evaluate(xml, query);
|
||||
nodes = xpath.select(query, doc);
|
||||
} catch (err) {
|
||||
return "Invalid XPath. Details:\n" + err.message;
|
||||
}
|
||||
|
||||
var serializer = new XMLSerializer();
|
||||
var nodeToString = function(node) {
|
||||
switch (node.nodeType) {
|
||||
case Node.ELEMENT_NODE: return serializer.serializeToString(node);
|
||||
case Node.ATTRIBUTE_NODE: return node.value;
|
||||
case Node.COMMENT_NODE: return node.data;
|
||||
case Node.DOCUMENT_NODE: return serializer.serializeToString(node);
|
||||
default: throw new Error("Unknown Node Type: " + node.nodeType);
|
||||
}
|
||||
return node.toString();
|
||||
};
|
||||
|
||||
return Object.keys(result).map(function(key) {
|
||||
return result[key];
|
||||
}).slice(0, -1) // all values except last (length)
|
||||
.map(nodeToString)
|
||||
.join(delimiter);
|
||||
return nodes.map(nodeToString).join(delimiter);
|
||||
},
|
||||
|
||||
|
||||
|
@ -429,3 +423,5 @@ var Code = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Code;
|
|
@ -1,4 +1,22 @@
|
|||
/* globals Zlib, bzip2 */
|
||||
import Utils from "../Utils.js";
|
||||
import rawdeflate from "zlibjs/bin/rawdeflate.min";
|
||||
import rawinflate from "zlibjs/bin/rawinflate.min";
|
||||
import zlibAndGzip from "zlibjs/bin/zlib_and_gzip.min";
|
||||
import zip from "zlibjs/bin/zip.min";
|
||||
import unzip from "zlibjs/bin/unzip.min";
|
||||
import bzip2 from "exports-loader?bzip2!../lib/bzip2.js";
|
||||
|
||||
var Zlib = {
|
||||
RawDeflate: rawdeflate.Zlib.RawDeflate,
|
||||
RawInflate: rawinflate.Zlib.RawInflate,
|
||||
Deflate: zlibAndGzip.Zlib.Deflate,
|
||||
Inflate: zlibAndGzip.Zlib.Inflate,
|
||||
Gzip: zlibAndGzip.Zlib.Gzip,
|
||||
Gunzip: zlibAndGzip.Zlib.Gunzip,
|
||||
Zip: zip.Zlib.Zip,
|
||||
Unzip: unzip.Zlib.Unzip,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Compression operations.
|
||||
|
@ -9,7 +27,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Compress = {
|
||||
const Compress = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -556,3 +574,5 @@ var Compress = {
|
|||
return Utils.displayFilesAsHTML(files);
|
||||
},
|
||||
};
|
||||
|
||||
export default Compress;
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Convert = {
|
||||
const Convert = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -410,3 +410,5 @@ var Convert = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Convert;
|
|
@ -1,5 +1,3 @@
|
|||
/* globals moment */
|
||||
|
||||
/**
|
||||
* Date and time operations.
|
||||
*
|
||||
|
@ -9,7 +7,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var DateTime = {
|
||||
const DateTime = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -450,5 +448,6 @@ var DateTime = {
|
|||
</tbody>\
|
||||
</table>",
|
||||
|
||||
|
||||
};
|
||||
|
||||
export default DateTime;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* Endian operations.
|
||||
*
|
||||
|
@ -7,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Endian = {
|
||||
const Endian = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -92,3 +95,5 @@ var Endian = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Endian;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* Entropy operations.
|
||||
*
|
||||
|
@ -7,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Entropy = {
|
||||
const Entropy = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -164,3 +167,5 @@ var Entropy = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Entropy;
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Extract = {
|
||||
const Extract = {
|
||||
|
||||
/**
|
||||
* Runs search operations across the input data using regular expressions.
|
||||
|
@ -295,3 +295,5 @@ var Extract = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Extract;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* File type operations.
|
||||
*
|
||||
|
@ -7,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var FileType = {
|
||||
const FileType = {
|
||||
|
||||
/**
|
||||
* Detect File Type operation.
|
||||
|
@ -524,3 +527,5 @@ var FileType = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default FileType;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* HTML operations.
|
||||
*
|
||||
|
@ -7,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var HTML = {
|
||||
const HTML = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -848,3 +851,5 @@ var HTML = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default HTML;
|
|
@ -1,4 +1,5 @@
|
|||
/* globals UAS_parser */
|
||||
import {UAS_parser as UAParser} from "../lib/uas_parser.js";
|
||||
|
||||
|
||||
/**
|
||||
* HTTP operations.
|
||||
|
@ -9,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var HTTP = {
|
||||
const HTTP = {
|
||||
|
||||
/**
|
||||
* Strip HTTP headers operation.
|
||||
|
@ -34,7 +35,7 @@ var HTTP = {
|
|||
* @returns {string}
|
||||
*/
|
||||
runParseUserAgent: function(input, args) {
|
||||
var ua = UAS_parser.parse(input); // eslint-disable-line camelcase
|
||||
var ua = UAParser.parse(input);
|
||||
|
||||
return "Type: " + ua.type + "\n" +
|
||||
"Family: " + ua.uaFamily + "\n" +
|
||||
|
@ -51,3 +52,5 @@ var HTTP = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default HTTP;
|
|
@ -1,4 +1,8 @@
|
|||
/* globals CryptoApi, CryptoJS, Checksum */
|
||||
import Utils from "../Utils.js";
|
||||
import CryptoJS from "crypto-js";
|
||||
import CryptoApi from "crypto-api";
|
||||
import Checksum from "./Checksum.js";
|
||||
|
||||
|
||||
/**
|
||||
* Hashing operations.
|
||||
|
@ -9,7 +13,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Hash = {
|
||||
const Hash = {
|
||||
|
||||
/**
|
||||
* MD2 operation.
|
||||
|
@ -381,3 +385,5 @@ var Hash = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Hash;
|
|
@ -1,4 +1,6 @@
|
|||
/* globals app */
|
||||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* Hexdump operations.
|
||||
|
@ -9,7 +11,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Hexdump = {
|
||||
const Hexdump = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -90,7 +92,7 @@ var Hexdump = {
|
|||
var w = (width - 13) / 4;
|
||||
// w should be the specified width of the hexdump and therefore a round number
|
||||
if (Math.floor(w) !== w || input.indexOf("\r") !== -1 || output.indexOf(13) !== -1) {
|
||||
app.options.attemptHighlight = false;
|
||||
if (app) app.options.attemptHighlight = false;
|
||||
}
|
||||
return output;
|
||||
},
|
||||
|
@ -196,3 +198,5 @@ var Hexdump = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Hexdump;
|
|
@ -1,4 +1,7 @@
|
|||
/* globals BigInteger, Checksum */
|
||||
import Utils from "../Utils.js";
|
||||
import Checksum from "./Checksum.js";
|
||||
import {BigInteger} from "jsbn";
|
||||
|
||||
|
||||
/**
|
||||
* Internet Protocol address operations.
|
||||
|
@ -9,7 +12,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var IP = {
|
||||
const IP = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -1073,5 +1076,6 @@ var IP = {
|
|||
255: {keyword: "Reserved", protocol: ""}
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
export default IP;
|
|
@ -1,4 +1,7 @@
|
|||
/* globals esprima, escodegen, esmangle */
|
||||
import esprima from "esprima";
|
||||
import escodegen from "escodegen";
|
||||
import esmangle from "esmangle";
|
||||
|
||||
|
||||
/**
|
||||
* JavaScript operations.
|
||||
|
@ -9,7 +12,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var JS = {
|
||||
const JS = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -157,3 +160,5 @@ var JS = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default JS;
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var MAC = {
|
||||
const MAC = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -86,3 +86,5 @@ var MAC = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default MAC;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* Morse Code translation operations.
|
||||
*
|
||||
|
@ -7,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var MorseCode = {
|
||||
const MorseCode = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -183,3 +186,5 @@ var MorseCode = {
|
|||
})(),
|
||||
|
||||
};
|
||||
|
||||
export default MorseCode;
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var NetBIOS = {
|
||||
const NetBIOS = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -55,3 +55,5 @@ var NetBIOS = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default NetBIOS;
|
|
@ -4,7 +4,7 @@
|
|||
* @author Unknown Male 282
|
||||
* @namespace
|
||||
*/
|
||||
var Numberwang = {
|
||||
const Numberwang = {
|
||||
|
||||
/**
|
||||
* Numberwang operation. Remain indoors.
|
||||
|
@ -25,3 +25,5 @@ var Numberwang = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Numberwang;
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var OS = {
|
||||
const OS = {
|
||||
|
||||
/**
|
||||
* Parse UNIX file permissions operation.
|
||||
|
@ -307,3 +307,5 @@ var OS = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default OS;
|
|
@ -1,4 +1,6 @@
|
|||
/* globals X509, KJUR, ASN1HEX, KEYUTIL, BigInteger */
|
||||
import Utils from "../Utils.js";
|
||||
import * as r from "jsrsasign";
|
||||
|
||||
|
||||
/**
|
||||
* Public Key operations.
|
||||
|
@ -9,7 +11,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var PublicKey = {
|
||||
const PublicKey = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -25,7 +27,7 @@ var PublicKey = {
|
|||
* @returns {string}
|
||||
*/
|
||||
runParseX509: function (input, args) {
|
||||
var cert = new X509(),
|
||||
var cert = new r.X509(),
|
||||
inputFormat = args[0];
|
||||
|
||||
if (!input.length) {
|
||||
|
@ -36,39 +38,39 @@ var PublicKey = {
|
|||
case "DER Hex":
|
||||
input = input.replace(/\s/g, "");
|
||||
cert.hex = input;
|
||||
cert.pem = KJUR.asn1.ASN1Util.getPEMStringFromHex(input, "CERTIFICATE");
|
||||
cert.pem = r.KJUR.asn1.ASN1Util.getPEMStringFromHex(input, "CERTIFICATE");
|
||||
break;
|
||||
case "PEM":
|
||||
cert.hex = X509.pemToHex(input);
|
||||
cert.hex = r.X509.pemToHex(input);
|
||||
cert.pem = input;
|
||||
break;
|
||||
case "Base64":
|
||||
cert.hex = Utils.toHex(Utils.fromBase64(input, null, "byteArray"), "");
|
||||
cert.pem = KJUR.asn1.ASN1Util.getPEMStringFromHex(cert.hex, "CERTIFICATE");
|
||||
cert.pem = r.KJUR.asn1.ASN1Util.getPEMStringFromHex(cert.hex, "CERTIFICATE");
|
||||
break;
|
||||
case "Raw":
|
||||
cert.hex = Utils.toHex(Utils.strToByteArray(input), "");
|
||||
cert.pem = KJUR.asn1.ASN1Util.getPEMStringFromHex(cert.hex, "CERTIFICATE");
|
||||
cert.pem = r.KJUR.asn1.ASN1Util.getPEMStringFromHex(cert.hex, "CERTIFICATE");
|
||||
break;
|
||||
default:
|
||||
throw "Undefined input format";
|
||||
}
|
||||
|
||||
var version = ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 0, 0]),
|
||||
var version = r.ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 0, 0]),
|
||||
sn = cert.getSerialNumberHex(),
|
||||
algorithm = KJUR.asn1.x509.OID.oid2name(KJUR.asn1.ASN1Util.oidHexToInt(ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 2, 0]))),
|
||||
algorithm = r.KJUR.asn1.x509.OID.oid2name(r.KJUR.asn1.ASN1Util.oidHexToInt(r.ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 2, 0]))),
|
||||
issuer = cert.getIssuerString(),
|
||||
notBefore = cert.getNotBefore(),
|
||||
notAfter = cert.getNotAfter(),
|
||||
subject = cert.getSubjectString(),
|
||||
pkAlgorithm = KJUR.asn1.x509.OID.oid2name(KJUR.asn1.ASN1Util.oidHexToInt(ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 6, 0, 0]))),
|
||||
pk = X509.getPublicKeyFromCertPEM(cert.pem),
|
||||
pkAlgorithm = r.KJUR.asn1.x509.OID.oid2name(r.KJUR.asn1.ASN1Util.oidHexToInt(r.ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 6, 0, 0]))),
|
||||
pk = r.X509.getPublicKeyFromCertPEM(cert.pem),
|
||||
pkFields = [],
|
||||
pkStr = "",
|
||||
certSigAlg = KJUR.asn1.x509.OID.oid2name(KJUR.asn1.ASN1Util.oidHexToInt(ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [1, 0]))),
|
||||
certSig = ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [2]).substr(2),
|
||||
certSigAlg = r.KJUR.asn1.x509.OID.oid2name(r.KJUR.asn1.ASN1Util.oidHexToInt(r.ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [1, 0]))),
|
||||
certSig = r.ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [2]).substr(2),
|
||||
sigStr = "",
|
||||
extensions = ASN1HEX.dump(ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 7]));
|
||||
extensions = r.ASN1HEX.dump(r.ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 7]));
|
||||
|
||||
// Public Key fields
|
||||
if (pk.type === "EC") { // ECDSA
|
||||
|
@ -78,7 +80,7 @@ var PublicKey = {
|
|||
});
|
||||
pkFields.push({
|
||||
key: "Length",
|
||||
value: (((new BigInteger(pk.pubKeyHex, 16)).bitLength()-3) /2) + " bits"
|
||||
value: (((new r.BigInteger(pk.pubKeyHex, 16)).bitLength()-3) /2) + " bits"
|
||||
});
|
||||
pkFields.push({
|
||||
key: "pub",
|
||||
|
@ -122,9 +124,9 @@ var PublicKey = {
|
|||
}
|
||||
|
||||
// Signature fields
|
||||
if (ASN1HEX.dump(certSig).indexOf("SEQUENCE") === 0) { // DSA or ECDSA
|
||||
sigStr = " r: " + PublicKey._formatByteStr(ASN1HEX.getDecendantHexVByNthList(certSig, 0, [0]), 16, 18) + "\n" +
|
||||
" s: " + PublicKey._formatByteStr(ASN1HEX.getDecendantHexVByNthList(certSig, 0, [1]), 16, 18) + "\n";
|
||||
if (r.ASN1HEX.dump(certSig).indexOf("SEQUENCE") === 0) { // DSA or ECDSA
|
||||
sigStr = " r: " + PublicKey._formatByteStr(r.ASN1HEX.getDecendantHexVByNthList(certSig, 0, [0]), 16, 18) + "\n" +
|
||||
" s: " + PublicKey._formatByteStr(r.ASN1HEX.getDecendantHexVByNthList(certSig, 0, [1]), 16, 18) + "\n";
|
||||
} else { // RSA
|
||||
sigStr = " Signature: " + PublicKey._formatByteStr(certSig, 16, 18) + "\n";
|
||||
}
|
||||
|
@ -145,7 +147,7 @@ var PublicKey = {
|
|||
subjectStr = PublicKey._formatDnStr(subject, 2);
|
||||
|
||||
var output = "Version: " + (parseInt(version, 16) + 1) + " (0x" + version + ")\n" +
|
||||
"Serial number: " + new BigInteger(sn, 16).toString() + " (0x" + sn + ")\n" +
|
||||
"Serial number: " + new r.BigInteger(sn, 16).toString() + " (0x" + sn + ")\n" +
|
||||
"Algorithm ID: " + algorithm + "\n" +
|
||||
"Validity\n" +
|
||||
" Not Before: " + nbDate + " (dd-mm-yy hh:mm:ss) (" + notBefore + ")\n" +
|
||||
|
@ -183,7 +185,7 @@ var PublicKey = {
|
|||
// Add footer so that the KEYUTIL function works
|
||||
input = input + "-----END CERTIFICATE-----";
|
||||
}
|
||||
return KEYUTIL.getHexFromPEM(input);
|
||||
return r.KEYUTIL.getHexFromPEM(input);
|
||||
},
|
||||
|
||||
|
||||
|
@ -201,7 +203,7 @@ var PublicKey = {
|
|||
* @returns {string}
|
||||
*/
|
||||
runHexToPem: function(input, args) {
|
||||
return KJUR.asn1.ASN1Util.getPEMStringFromHex(input.replace(/\s/g, ""), args[0]);
|
||||
return r.KJUR.asn1.ASN1Util.getPEMStringFromHex(input.replace(/\s/g, ""), args[0]);
|
||||
},
|
||||
|
||||
|
||||
|
@ -213,7 +215,7 @@ var PublicKey = {
|
|||
* @returns {string}
|
||||
*/
|
||||
runHexToObjectIdentifier: function(input, args) {
|
||||
return KJUR.asn1.ASN1Util.oidHexToInt(input.replace(/\s/g, ""));
|
||||
return r.KJUR.asn1.ASN1Util.oidHexToInt(input.replace(/\s/g, ""));
|
||||
},
|
||||
|
||||
|
||||
|
@ -225,7 +227,7 @@ var PublicKey = {
|
|||
* @returns {string}
|
||||
*/
|
||||
runObjectIdentifierToHex: function(input, args) {
|
||||
return KJUR.asn1.ASN1Util.oidIntToHex(input);
|
||||
return r.KJUR.asn1.ASN1Util.oidIntToHex(input);
|
||||
},
|
||||
|
||||
|
||||
|
@ -245,7 +247,7 @@ var PublicKey = {
|
|||
runParseAsn1HexString: function(input, args) {
|
||||
var truncateLen = args[1],
|
||||
index = args[0];
|
||||
return ASN1HEX.dump(input.replace(/\s/g, ""), {
|
||||
return r.ASN1HEX.dump(input.replace(/\s/g, ""), {
|
||||
"ommitLongOctet": truncateLen
|
||||
}, index);
|
||||
},
|
||||
|
@ -334,6 +336,8 @@ var PublicKey = {
|
|||
|
||||
};
|
||||
|
||||
export default PublicKey;
|
||||
|
||||
|
||||
/**
|
||||
* Overwrite X509.hex2dn function so as to join RDNs with a string which can be split on without
|
||||
|
@ -342,12 +346,12 @@ var PublicKey = {
|
|||
* @param {string} hDN - Hex DN string
|
||||
* @returns {string}
|
||||
*/
|
||||
X509.hex2dn = function(hDN) {
|
||||
r.X509.hex2dn = function(hDN) {
|
||||
var s = "";
|
||||
var a = ASN1HEX.getPosArrayOfChildren_AtObj(hDN, 0);
|
||||
var a = r.ASN1HEX.getPosArrayOfChildren_AtObj(hDN, 0);
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
var hRDN = ASN1HEX.getHexOfTLV_AtObj(hDN, a[i]);
|
||||
s = s + ",/|" + X509.hex2rdn(hRDN);
|
||||
var hRDN = r.ASN1HEX.getHexOfTLV_AtObj(hDN, a[i]);
|
||||
s = s + ",/|" + r.X509.hex2rdn(hRDN);
|
||||
}
|
||||
return s;
|
||||
};
|
||||
|
@ -361,7 +365,7 @@ X509.hex2dn = function(hDN) {
|
|||
*
|
||||
* @constant
|
||||
*/
|
||||
X509.DN_ATTRHEX = {
|
||||
r.X509.DN_ATTRHEX = {
|
||||
"0603550403" : "commonName",
|
||||
"0603550404" : "surname",
|
||||
"0603550406" : "countryName",
|
|
@ -1,4 +1,5 @@
|
|||
/* globals punycode */
|
||||
import punycode from "punycode";
|
||||
|
||||
|
||||
/**
|
||||
* Punycode operations.
|
||||
|
@ -9,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Punycode = {
|
||||
const Punycode = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -28,7 +29,7 @@ var Punycode = {
|
|||
var idn = args[0];
|
||||
|
||||
if (idn) {
|
||||
return punycode.ToASCII(input);
|
||||
return punycode.toASCII(input);
|
||||
} else {
|
||||
return punycode.encode(input);
|
||||
}
|
||||
|
@ -46,10 +47,12 @@ var Punycode = {
|
|||
var idn = args[0];
|
||||
|
||||
if (idn) {
|
||||
return punycode.ToUnicode(input);
|
||||
return punycode.toUnicode(input);
|
||||
} else {
|
||||
return punycode.decode(input);
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
export default Punycode;
|
|
@ -30,7 +30,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var QuotedPrintable = {
|
||||
const QuotedPrintable = {
|
||||
|
||||
/**
|
||||
* To Quoted Printable operation.
|
||||
|
@ -268,3 +268,5 @@ var QuotedPrintable = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default QuotedPrintable;
|
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* @todo Support for UTF16
|
||||
*/
|
||||
var Rotate = {
|
||||
const Rotate = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -240,3 +240,5 @@ var Rotate = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Rotate;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* Sequence utility operations.
|
||||
*
|
||||
|
@ -7,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var SeqUtils = {
|
||||
const SeqUtils = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -218,3 +221,5 @@ var SeqUtils = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default SeqUtils;
|
|
@ -1,4 +1,6 @@
|
|||
/* globals JsDiff */
|
||||
import Utils from "../Utils.js";
|
||||
import * as JsDiff from "diff";
|
||||
|
||||
|
||||
/**
|
||||
* String utility operations.
|
||||
|
@ -9,7 +11,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var StrUtils = {
|
||||
const StrUtils = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -536,3 +538,5 @@ var StrUtils = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default StrUtils;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* Tidy operations.
|
||||
*
|
||||
|
@ -7,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Tidy = {
|
||||
const Tidy = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -236,3 +239,5 @@ var Tidy = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Tidy;
|
|
@ -1,4 +1,6 @@
|
|||
/* globals unescape */
|
||||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* URL operations.
|
||||
|
@ -10,7 +12,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var URL_ = {
|
||||
const URL_ = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -56,6 +58,10 @@ var URL_ = {
|
|||
* @returns {string}
|
||||
*/
|
||||
runParse: function(input, args) {
|
||||
if (!document) {
|
||||
throw "This operation only works in a browser.";
|
||||
}
|
||||
|
||||
var a = document.createElement("a");
|
||||
|
||||
// Overwrite base href which will be the current CyberChef URL to reduce confusion.
|
||||
|
@ -128,3 +134,5 @@ var URL_ = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default URL_;
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var UUID = {
|
||||
const UUID = {
|
||||
|
||||
/**
|
||||
* Generate UUID operation.
|
||||
|
@ -17,7 +17,7 @@ var UUID = {
|
|||
* @returns {string}
|
||||
*/
|
||||
runGenerateV4: function(input, args) {
|
||||
if (typeof(window.crypto) !== "undefined" && typeof(window.crypto.getRandomValues) !== "undefined") {
|
||||
if (window && typeof(window.crypto) !== "undefined" && typeof(window.crypto.getRandomValues) !== "undefined") {
|
||||
var buf = new Uint32Array(4),
|
||||
i = 0;
|
||||
window.crypto.getRandomValues(buf);
|
||||
|
@ -37,3 +37,5 @@ var UUID = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default UUID;
|
|
@ -1,3 +1,6 @@
|
|||
import Utils from "../Utils.js";
|
||||
|
||||
|
||||
/**
|
||||
* Unicode operations.
|
||||
*
|
||||
|
@ -7,7 +10,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var Unicode = {
|
||||
const Unicode = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -60,3 +63,5 @@ var Unicode = {
|
|||
},
|
||||
|
||||
};
|
||||
|
||||
export default Unicode;
|
File diff suppressed because one or more lines are too long
|
@ -1,221 +0,0 @@
|
|||
/** @license
|
||||
========================================================================
|
||||
bootstrap-switch - v3.1.0
|
||||
http://www.bootstrap-switch.org
|
||||
Copyright 2012-2013 Mattia Larentis
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
.bootstrap-switch {
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
border: 1px solid;
|
||||
border-color: #cccccc;
|
||||
position: relative;
|
||||
text-align: left;
|
||||
overflow: hidden;
|
||||
line-height: 8px;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
vertical-align: middle;
|
||||
min-width: 100px;
|
||||
-webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
|
||||
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-mini {
|
||||
min-width: 71px;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-on,
|
||||
.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-handle-off,
|
||||
.bootstrap-switch.bootstrap-switch-mini .bootstrap-switch-label {
|
||||
padding-bottom: 4px;
|
||||
padding-top: 4px;
|
||||
font-size: 10px;
|
||||
line-height: 9px;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-small {
|
||||
min-width: 79px;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-on,
|
||||
.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-handle-off,
|
||||
.bootstrap-switch.bootstrap-switch-small .bootstrap-switch-label {
|
||||
padding-bottom: 3px;
|
||||
padding-top: 3px;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-large {
|
||||
min-width: 120px;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-on,
|
||||
.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-off,
|
||||
.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-label {
|
||||
padding-bottom: 9px;
|
||||
padding-top: 9px;
|
||||
font-size: 16px;
|
||||
line-height: normal;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-disabled,
|
||||
.bootstrap-switch.bootstrap-switch-readonly,
|
||||
.bootstrap-switch.bootstrap-switch-indeterminate {
|
||||
opacity: 0.5;
|
||||
filter: alpha(opacity=50);
|
||||
cursor: default !important;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-on,
|
||||
.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-on,
|
||||
.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-on,
|
||||
.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-handle-off,
|
||||
.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-handle-off,
|
||||
.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-handle-off,
|
||||
.bootstrap-switch.bootstrap-switch-disabled .bootstrap-switch-label,
|
||||
.bootstrap-switch.bootstrap-switch-readonly .bootstrap-switch-label,
|
||||
.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-label {
|
||||
cursor: default !important;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-animate .bootstrap-switch-container {
|
||||
-webkit-transition: margin-left 0.5s;
|
||||
transition: margin-left 0.5s;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-on {
|
||||
border-bottom-left-radius: 0;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-right-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-inverse .bootstrap-switch-handle-off {
|
||||
border-bottom-right-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-left-radius: 3px;
|
||||
border-top-left-radius: 3px;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-focused {
|
||||
border-color: #66afe9;
|
||||
outline: 0;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
|
||||
box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-container,
|
||||
.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-container {
|
||||
margin-left: 0%;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-on .bootstrap-switch-label,
|
||||
.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-label {
|
||||
border-bottom-right-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-container,
|
||||
.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-container {
|
||||
margin-left: -50%;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-off .bootstrap-switch-label,
|
||||
.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-label {
|
||||
border-bottom-left-radius: 3px;
|
||||
border-top-left-radius: 3px;
|
||||
}
|
||||
.bootstrap-switch.bootstrap-switch-indeterminate .bootstrap-switch-container,
|
||||
.bootstrap-switch.bootstrap-switch-inverse.bootstrap-switch-indeterminate .bootstrap-switch-container {
|
||||
margin-left: -25%;
|
||||
}
|
||||
.bootstrap-switch .bootstrap-switch-container {
|
||||
display: inline-block;
|
||||
width: 150%;
|
||||
top: 0;
|
||||
border-radius: 4px;
|
||||
-webkit-transform: translate3d(0, 0, 0);
|
||||
transform: translate3d(0, 0, 0);
|
||||
}
|
||||
.bootstrap-switch .bootstrap-switch-handle-on,
|
||||
.bootstrap-switch .bootstrap-switch-handle-off,
|
||||
.bootstrap-switch .bootstrap-switch-label {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
display: inline-block !important;
|
||||
height: 100%;
|
||||
padding-bottom: 4px;
|
||||
padding-top: 4px;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
}
|
||||
.bootstrap-switch .bootstrap-switch-handle-on,
|
||||
.bootstrap-switch .bootstrap-switch-handle-off {
|
||||
text-align: center;
|
||||
z-index: 1;
|
||||
width: 33.333333333%;
|
||||
}
|
||||
.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-primary,
|
||||
.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-primary {
|
||||
color: #fff;
|
||||
background: #428bca;
|
||||
}
|
||||
.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-info,
|
||||
.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-info {
|
||||
color: #fff;
|
||||
background: #5bc0de;
|
||||
}
|
||||
.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-success,
|
||||
.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-success {
|
||||
color: #fff;
|
||||
background: #5cb85c;
|
||||
}
|
||||
.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-warning,
|
||||
.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-warning {
|
||||
background: #f0ad4e;
|
||||
color: #fff;
|
||||
}
|
||||
.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-danger,
|
||||
.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-danger {
|
||||
color: #fff;
|
||||
background: #d9534f;
|
||||
}
|
||||
.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-default,
|
||||
.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-default {
|
||||
color: #000;
|
||||
background: #eeeeee;
|
||||
}
|
||||
.bootstrap-switch .bootstrap-switch-label {
|
||||
text-align: center;
|
||||
margin-top: -1px;
|
||||
margin-bottom: -1px;
|
||||
z-index: 100;
|
||||
width: 33.333333333%;
|
||||
color: #333333;
|
||||
background: #ffffff;
|
||||
}
|
||||
.bootstrap-switch .bootstrap-switch-handle-on {
|
||||
border-bottom-left-radius: 3px;
|
||||
border-top-left-radius: 3px;
|
||||
}
|
||||
.bootstrap-switch .bootstrap-switch-handle-off {
|
||||
border-bottom-right-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
}
|
||||
.bootstrap-switch input[type='radio'],
|
||||
.bootstrap-switch input[type='checkbox'] {
|
||||
position: absolute !important;
|
||||
top: 0;
|
||||
left: 0;
|
||||
opacity: 0;
|
||||
filter: alpha(opacity=0);
|
||||
z-index: -1;
|
||||
}
|
||||
.bootstrap-switch input[type='radio'].form-control,
|
||||
.bootstrap-switch input[type='checkbox'].form-control {
|
||||
height: auto;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,68 +0,0 @@
|
|||
/** @license
|
||||
========================================================================
|
||||
StyleSheet for Google Code Prettify
|
||||
Copyright (C) 2006 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/* SPAN elements with the classes below are added by prettyprint. */
|
||||
.pln { color: #000 } /* plain text */
|
||||
|
||||
@media screen {
|
||||
.str { color: #080 } /* string content */
|
||||
.kwd { color: #008 } /* a keyword */
|
||||
.com { color: #800 } /* a comment */
|
||||
.typ { color: #606 } /* a type name */
|
||||
.lit { color: #066 } /* a literal value */
|
||||
/* punctuation, lisp open bracket, lisp close bracket */
|
||||
.pun, .opn, .clo { color: #660 }
|
||||
.tag { color: #008 } /* a markup tag name */
|
||||
.atn { color: #606 } /* a markup attribute name */
|
||||
.atv { color: #080 } /* a markup attribute value */
|
||||
.dec, .var { color: #606 } /* a declaration; a variable name */
|
||||
.fun { color: red } /* a function name */
|
||||
}
|
||||
|
||||
/* Use higher contrast and text-weight for printable form. */
|
||||
@media print, projection {
|
||||
.str { color: #060 }
|
||||
.kwd { color: #006; font-weight: bold }
|
||||
.com { color: #600; font-style: italic }
|
||||
.typ { color: #404; font-weight: bold }
|
||||
.lit { color: #044 }
|
||||
.pun, .opn, .clo { color: #440 }
|
||||
.tag { color: #006; font-weight: bold }
|
||||
.atn { color: #404 }
|
||||
.atv { color: #060 }
|
||||
}
|
||||
|
||||
/* Put a border around prettyprinted code snippets. */
|
||||
pre.prettyprint { padding: 2px; border: 1px solid #888 }
|
||||
|
||||
/* Specify class=linenums on a pre to get line numbering */
|
||||
ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
|
||||
li.L0,
|
||||
li.L1,
|
||||
li.L2,
|
||||
li.L3,
|
||||
li.L5,
|
||||
li.L6,
|
||||
li.L7,
|
||||
li.L8 { list-style-type: none }
|
||||
/* Alternate shading for lines */
|
||||
li.L1,
|
||||
li.L3,
|
||||
li.L5,
|
||||
li.L7,
|
||||
li.L9 { background: #eee }
|
File diff suppressed because it is too large
Load Diff
|
@ -1,649 +0,0 @@
|
|||
/** @license
|
||||
========================================================================
|
||||
Blowfish.js from Dojo Toolkit 1.8.1
|
||||
Cut of by Sladex (xslade@gmail.com)
|
||||
|
||||
Created based on the C# implementation by Marcus Hahn (http://www.hotpixel.net/)
|
||||
Unsigned math based on Paul Johnstone and Peter Wood patches.
|
||||
2005-12-08
|
||||
|
||||
The Dojo Toolkit (including this package) is dual licensed under BSD 3-Clause and AFL.
|
||||
The Dojo Toolkit is Copyright (c) 2005-2016, The Dojo Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Blowfish.js from Dojo Toolkit 1.8.1
|
||||
* Cut of by Sladex (xslade@gmail.com)
|
||||
*
|
||||
* Usage:
|
||||
* blowfish.encrypt(String 'subj to encrypt', String 'key', Object {outputType: 1, cipherMode: 0});
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
(function(global){
|
||||
|
||||
var crypto = {};
|
||||
|
||||
|
||||
|
||||
/* dojo-release-1.8.1/dojox/encoding/crypto/_base.js.uncompressed.js */
|
||||
|
||||
crypto.cipherModes = {
|
||||
// summary:
|
||||
// Enumeration for various cipher modes.
|
||||
ECB:0, CBC:1, PCBC:2, CFB:3, OFB:4, CTR:5
|
||||
};
|
||||
crypto.outputTypes = {
|
||||
// summary:
|
||||
// Enumeration for input and output encodings.
|
||||
Base64:0, Hex:1, String:2, Raw:3
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* dojo-release-1.8.1/dojox/encoding/base64.js.uncompressed.js */
|
||||
|
||||
var base64 = {};
|
||||
var p="=";
|
||||
var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
base64.encode=function(/* byte[] */ba){
|
||||
// summary:
|
||||
// Encode an array of bytes as a base64-encoded string
|
||||
var s=[], l=ba.length;
|
||||
var rm=l%3;
|
||||
var x=l-rm;
|
||||
for (var i=0; i<x;){
|
||||
var t=ba[i++]<<16|ba[i++]<<8|ba[i++];
|
||||
s.push(tab.charAt((t>>>18)&0x3f));
|
||||
s.push(tab.charAt((t>>>12)&0x3f));
|
||||
s.push(tab.charAt((t>>>6)&0x3f));
|
||||
s.push(tab.charAt(t&0x3f));
|
||||
}
|
||||
// deal with trailers, based on patch from Peter Wood.
|
||||
switch(rm){
|
||||
case 2:{
|
||||
var t=ba[i++]<<16|ba[i++]<<8;
|
||||
s.push(tab.charAt((t>>>18)&0x3f));
|
||||
s.push(tab.charAt((t>>>12)&0x3f));
|
||||
s.push(tab.charAt((t>>>6)&0x3f));
|
||||
s.push(p);
|
||||
break;
|
||||
}
|
||||
case 1:{
|
||||
var t=ba[i++]<<16;
|
||||
s.push(tab.charAt((t>>>18)&0x3f));
|
||||
s.push(tab.charAt((t>>>12)&0x3f));
|
||||
s.push(p);
|
||||
s.push(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return s.join(""); // string
|
||||
};
|
||||
|
||||
base64.decode=function(/* string */str){
|
||||
// summary:
|
||||
// Convert a base64-encoded string to an array of bytes
|
||||
var s=str.split(""), out=[];
|
||||
var l=s.length;
|
||||
while(s[--l]==p){ } // strip off trailing padding
|
||||
for (var i=0; i<l;){
|
||||
var t=tab.indexOf(s[i++])<<18;
|
||||
if(i<=l){ t|=tab.indexOf(s[i++])<<12 };
|
||||
if(i<=l){ t|=tab.indexOf(s[i++])<<6 };
|
||||
if(i<=l){ t|=tab.indexOf(s[i++]) };
|
||||
out.push((t>>>16)&0xff);
|
||||
out.push((t>>>8)&0xff);
|
||||
out.push(t&0xff);
|
||||
}
|
||||
// strip off any null bytes
|
||||
while(out[out.length-1]==0){ out.pop(); }
|
||||
return out; // byte[]
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* dojo-release-1.8.1/dojo/_base/lang.js.uncompressed.js */
|
||||
|
||||
var lang = {};
|
||||
lang.isString = function(it){
|
||||
// summary:
|
||||
// Return true if it is a String
|
||||
// it: anything
|
||||
// Item to test.
|
||||
return (typeof it == "string" || it instanceof String); // Boolean
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* dojo-release-1.8.1/dojo/_base/array.js.uncompressed.js */
|
||||
|
||||
var arrayUtil = {};
|
||||
arrayUtil.map = function(arr, callback, thisObject, Ctr){
|
||||
// summary:
|
||||
// applies callback to each element of arr and returns
|
||||
// an Array with the results
|
||||
// arr: Array|String
|
||||
// the array to iterate on. If a string, operates on
|
||||
// individual characters.
|
||||
// callback: Function|String
|
||||
// a function is invoked with three arguments, (item, index,
|
||||
// array), and returns a value
|
||||
// thisObject: Object?
|
||||
// may be used to scope the call to callback
|
||||
// returns: Array
|
||||
// description:
|
||||
// This function corresponds to the JavaScript 1.6 Array.map() method, with one difference: when
|
||||
// run over sparse arrays, this implementation passes the "holes" in the sparse array to
|
||||
// the callback function with a value of undefined. JavaScript 1.6's map skips the holes in the sparse array.
|
||||
// For more details, see:
|
||||
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
|
||||
// example:
|
||||
// | // returns [2, 3, 4, 5]
|
||||
// | array.map([1, 2, 3, 4], function(item){ return item+1 });
|
||||
|
||||
// TODO: why do we have a non-standard signature here? do we need "Ctr"?
|
||||
var i = 0, l = arr && arr.length || 0, out = new (Ctr || Array)(l);
|
||||
if(l && typeof arr == "string") arr = arr.split("");
|
||||
if(typeof callback == "string") callback = cache[callback] || buildFn(callback);
|
||||
if(thisObject){
|
||||
for(; i < l; ++i){
|
||||
out[i] = callback.call(thisObject, arr[i], i, arr);
|
||||
}
|
||||
}else{
|
||||
for(; i < l; ++i){
|
||||
out[i] = callback(arr[i], i, arr);
|
||||
}
|
||||
}
|
||||
return out; // Array
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* dojo-release-1.8.1/dojox/encoding/crypto/Blowfish.js.uncompressed.js */
|
||||
|
||||
/* Blowfish
|
||||
* Created based on the C# implementation by Marcus Hahn (http://www.hotpixel.net/)
|
||||
* Unsigned math based on Paul Johnstone and Peter Wood patches.
|
||||
* 2005-12-08
|
||||
*/
|
||||
crypto.Blowfish = new function(){
|
||||
// summary:
|
||||
// Object for doing Blowfish encryption/decryption.
|
||||
var POW2=Math.pow(2,2);
|
||||
var POW3=Math.pow(2,3);
|
||||
var POW4=Math.pow(2,4);
|
||||
var POW8=Math.pow(2,8);
|
||||
var POW16=Math.pow(2,16);
|
||||
var POW24=Math.pow(2,24);
|
||||
var iv=null; // CBC mode initialization vector
|
||||
var boxes={
|
||||
p:[
|
||||
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
|
||||
0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
|
||||
0x9216d5d9, 0x8979fb1b
|
||||
],
|
||||
s0:[
|
||||
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
|
||||
0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
|
||||
0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
|
||||
0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
|
||||
0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
|
||||
0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
|
||||
0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
|
||||
0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
|
||||
0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
|
||||
0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
|
||||
0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
|
||||
0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
|
||||
0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
|
||||
0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
|
||||
0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
|
||||
0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
|
||||
0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
|
||||
0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
|
||||
0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
|
||||
0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
|
||||
0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
|
||||
0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
|
||||
0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
|
||||
0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
|
||||
0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
|
||||
0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
|
||||
0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
|
||||
0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
|
||||
0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
|
||||
0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
|
||||
0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
|
||||
0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a
|
||||
],
|
||||
s1:[
|
||||
0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
|
||||
0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
|
||||
0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
|
||||
0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
|
||||
0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
|
||||
0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
|
||||
0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
|
||||
0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
|
||||
0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
|
||||
0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
|
||||
0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
|
||||
0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
|
||||
0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
|
||||
0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
|
||||
0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
|
||||
0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
|
||||
0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
|
||||
0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
|
||||
0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
|
||||
0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
|
||||
0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
|
||||
0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
|
||||
0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
|
||||
0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
|
||||
0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
|
||||
0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
|
||||
0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
|
||||
0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
|
||||
0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
|
||||
0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
|
||||
0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
|
||||
0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7
|
||||
],
|
||||
s2:[
|
||||
0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
|
||||
0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
|
||||
0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
|
||||
0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
|
||||
0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
|
||||
0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
|
||||
0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
|
||||
0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
|
||||
0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
|
||||
0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
|
||||
0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
|
||||
0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
|
||||
0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
|
||||
0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
|
||||
0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
|
||||
0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
|
||||
0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
|
||||
0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
|
||||
0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
|
||||
0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
|
||||
0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
|
||||
0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
|
||||
0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
|
||||
0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
|
||||
0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
|
||||
0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
|
||||
0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
|
||||
0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
|
||||
0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
|
||||
0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
|
||||
0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
|
||||
0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0
|
||||
],
|
||||
s3:[
|
||||
0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
|
||||
0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
|
||||
0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
|
||||
0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
|
||||
0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
|
||||
0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
|
||||
0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
|
||||
0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
|
||||
0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
|
||||
0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
|
||||
0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
|
||||
0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
|
||||
0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
|
||||
0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
|
||||
0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
|
||||
0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
|
||||
0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
|
||||
0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
|
||||
0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
|
||||
0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
|
||||
0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
|
||||
0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
|
||||
0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
|
||||
0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
|
||||
0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
|
||||
0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
|
||||
0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
|
||||
0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
|
||||
0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
|
||||
0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
|
||||
0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
|
||||
0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
|
||||
]
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// fixes based on patch submitted by Peter Wood (#5791)
|
||||
function add(x,y){
|
||||
return (((x>>0x10)+(y>>0x10)+(((x&0xffff)+(y&0xffff))>>0x10))<<0x10)|(((x&0xffff)+(y&0xffff))&0xffff);
|
||||
}
|
||||
function xor(x,y){
|
||||
return (((x>>0x10)^(y>>0x10))<<0x10)|(((x&0xffff)^(y&0xffff))&0xffff);
|
||||
}
|
||||
|
||||
function $(v, box){
|
||||
var d=box.s3[v&0xff]; v>>=8;
|
||||
var c=box.s2[v&0xff]; v>>=8;
|
||||
var b=box.s1[v&0xff]; v>>=8;
|
||||
var a=box.s0[v&0xff];
|
||||
|
||||
var r = (((a>>0x10)+(b>>0x10)+(((a&0xffff)+(b&0xffff))>>0x10))<<0x10)|(((a&0xffff)+(b&0xffff))&0xffff);
|
||||
r = (((r>>0x10)^(c>>0x10))<<0x10)|(((r&0xffff)^(c&0xffff))&0xffff);
|
||||
return (((r>>0x10)+(d>>0x10)+(((r&0xffff)+(d&0xffff))>>0x10))<<0x10)|(((r&0xffff)+(d&0xffff))&0xffff);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
function eb(o, box){
|
||||
// TODO: see if this can't be made more efficient
|
||||
var l=o.left;
|
||||
var r=o.right;
|
||||
l=xor(l,box.p[0]);
|
||||
r=xor(r,xor($(l,box),box.p[1]));
|
||||
l=xor(l,xor($(r,box),box.p[2]));
|
||||
r=xor(r,xor($(l,box),box.p[3]));
|
||||
l=xor(l,xor($(r,box),box.p[4]));
|
||||
r=xor(r,xor($(l,box),box.p[5]));
|
||||
l=xor(l,xor($(r,box),box.p[6]));
|
||||
r=xor(r,xor($(l,box),box.p[7]));
|
||||
l=xor(l,xor($(r,box),box.p[8]));
|
||||
r=xor(r,xor($(l,box),box.p[9]));
|
||||
l=xor(l,xor($(r,box),box.p[10]));
|
||||
r=xor(r,xor($(l,box),box.p[11]));
|
||||
l=xor(l,xor($(r,box),box.p[12]));
|
||||
r=xor(r,xor($(l,box),box.p[13]));
|
||||
l=xor(l,xor($(r,box),box.p[14]));
|
||||
r=xor(r,xor($(l,box),box.p[15]));
|
||||
l=xor(l,xor($(r,box),box.p[16]));
|
||||
o.right=l;
|
||||
o.left=xor(r,box.p[17]);
|
||||
}
|
||||
|
||||
function db(o, box){
|
||||
var l=o.left;
|
||||
var r=o.right;
|
||||
l=xor(l,box.p[17]);
|
||||
r=xor(r,xor($(l,box),box.p[16]));
|
||||
l=xor(l,xor($(r,box),box.p[15]));
|
||||
r=xor(r,xor($(l,box),box.p[14]));
|
||||
l=xor(l,xor($(r,box),box.p[13]));
|
||||
r=xor(r,xor($(l,box),box.p[12]));
|
||||
l=xor(l,xor($(r,box),box.p[11]));
|
||||
r=xor(r,xor($(l,box),box.p[10]));
|
||||
l=xor(l,xor($(r,box),box.p[9]));
|
||||
r=xor(r,xor($(l,box),box.p[8]));
|
||||
l=xor(l,xor($(r,box),box.p[7]));
|
||||
r=xor(r,xor($(l,box),box.p[6]));
|
||||
l=xor(l,xor($(r,box),box.p[5]));
|
||||
r=xor(r,xor($(l,box),box.p[4]));
|
||||
l=xor(l,xor($(r,box),box.p[3]));
|
||||
r=xor(r,xor($(l,box),box.p[2]));
|
||||
l=xor(l,xor($(r,box),box.p[1]));
|
||||
o.right=l;
|
||||
o.left=xor(r,box.p[0]);
|
||||
}
|
||||
|
||||
// Note that we aren't caching contexts here; it might take a little longer
|
||||
// but we should be more secure this way.
|
||||
function init(key){
|
||||
var k=key;
|
||||
if(lang.isString(k)){
|
||||
k = arrayUtil.map(k.split(""), function(item){
|
||||
return item.charCodeAt(0) & 0xff;
|
||||
});
|
||||
}
|
||||
|
||||
// init the boxes
|
||||
var pos=0, data=0, res={ left:0, right:0 }, i, j, l;
|
||||
var box = {
|
||||
p: arrayUtil.map(boxes.p.slice(0), function(item){
|
||||
var l=k.length, j;
|
||||
for(j=0; j<4; j++){ data=(data*POW8)|k[pos++ % l]; }
|
||||
return (((item>>0x10)^(data>>0x10))<<0x10)|(((item&0xffff)^(data&0xffff))&0xffff);
|
||||
}),
|
||||
s0:boxes.s0.slice(0),
|
||||
s1:boxes.s1.slice(0),
|
||||
s2:boxes.s2.slice(0),
|
||||
s3:boxes.s3.slice(0)
|
||||
};
|
||||
|
||||
// encrypt p and the s boxes
|
||||
for(i=0, l=box.p.length; i<l;){
|
||||
eb(res, box);
|
||||
box.p[i++]=res.left, box.p[i++]=res.right;
|
||||
}
|
||||
for(i=0; i<4; i++){
|
||||
for(j=0, l=box["s"+i].length; j<l;){
|
||||
eb(res, box);
|
||||
box["s"+i][j++]=res.left, box["s"+i][j++]=res.right;
|
||||
}
|
||||
}
|
||||
return box;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// PUBLIC FUNCTIONS
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
this.getIV=function(/* dojox.encoding.crypto.outputTypes? */ outputType){
|
||||
// summary:
|
||||
// returns the initialization vector in the output format specified by outputType
|
||||
var out=outputType||crypto.outputTypes.Base64;
|
||||
switch(out){
|
||||
case crypto.outputTypes.Hex:{
|
||||
return arrayUtil.map(iv, function(item){
|
||||
return (item<=0xf?'0':'')+item.toString(16);
|
||||
}).join(""); // string
|
||||
}
|
||||
case crypto.outputTypes.String:{
|
||||
return iv.join(""); // string
|
||||
}
|
||||
case crypto.outputTypes.Raw:{
|
||||
return iv; // array
|
||||
}
|
||||
default:{
|
||||
return base64.encode(iv); // string
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.setIV=function(/* string */data, /* dojox.encoding.crypto.outputTypes? */inputType){
|
||||
// summary:
|
||||
// sets the initialization vector to data (as interpreted as inputType)
|
||||
var ip=inputType||crypto.outputTypes.Base64;
|
||||
var ba=null;
|
||||
switch(ip){
|
||||
case crypto.outputTypes.String:{
|
||||
ba = arrayUtil.map(data.split(""), function(item){
|
||||
return item.charCodeAt(0);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case crypto.outputTypes.Hex:{
|
||||
ba=[];
|
||||
for(var i=0, l=data.length-1; i<l; i+=2){
|
||||
ba.push(parseInt(data.substr(i,2), 16));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case crypto.outputTypes.Raw:{
|
||||
ba=data;
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
ba=base64.decode(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// make it a pair of words now
|
||||
iv={};
|
||||
iv.left=ba[0]*POW24|ba[1]*POW16|ba[2]*POW8|ba[3];
|
||||
iv.right=ba[4]*POW24|ba[5]*POW16|ba[6]*POW8|ba[7];
|
||||
};
|
||||
|
||||
this.encrypt = function(/* string */plaintext, /* string */key, /* object? */ao){
|
||||
// summary:
|
||||
// encrypts plaintext using key; allows user to specify output type and cipher mode via keyword object "ao"
|
||||
var out=crypto.outputTypes.Base64;
|
||||
var mode=crypto.cipherModes.ECB;
|
||||
if (ao){
|
||||
if (ao.outputType) out=ao.outputType;
|
||||
if (ao.cipherMode) mode=ao.cipherMode;
|
||||
}
|
||||
|
||||
var bx = init(key), padding = 8-(plaintext.length&7);
|
||||
for (var i=0; i<padding; i++){ plaintext+=String.fromCharCode(padding); }
|
||||
|
||||
var cipher=[], count=plaintext.length >> 3, pos=0, o={}, isCBC=(mode==crypto.cipherModes.CBC);
|
||||
var vector={left:iv.left||null, right:iv.right||null};
|
||||
for(var i=0; i<count; i++){
|
||||
o.left=plaintext.charCodeAt(pos)*POW24
|
||||
|plaintext.charCodeAt(pos+1)*POW16
|
||||
|plaintext.charCodeAt(pos+2)*POW8
|
||||
|plaintext.charCodeAt(pos+3);
|
||||
o.right=plaintext.charCodeAt(pos+4)*POW24
|
||||
|plaintext.charCodeAt(pos+5)*POW16
|
||||
|plaintext.charCodeAt(pos+6)*POW8
|
||||
|plaintext.charCodeAt(pos+7);
|
||||
|
||||
if(isCBC){
|
||||
o.left=(((o.left>>0x10)^(vector.left>>0x10))<<0x10)|(((o.left&0xffff)^(vector.left&0xffff))&0xffff);
|
||||
o.right=(((o.right>>0x10)^(vector.right>>0x10))<<0x10)|(((o.right&0xffff)^(vector.right&0xffff))&0xffff);
|
||||
}
|
||||
|
||||
eb(o, bx); // encrypt the block
|
||||
|
||||
if(isCBC){
|
||||
vector.left=o.left;
|
||||
vector.right=o.right;
|
||||
}
|
||||
|
||||
cipher.push((o.left>>24)&0xff);
|
||||
cipher.push((o.left>>16)&0xff);
|
||||
cipher.push((o.left>>8)&0xff);
|
||||
cipher.push(o.left&0xff);
|
||||
cipher.push((o.right>>24)&0xff);
|
||||
cipher.push((o.right>>16)&0xff);
|
||||
cipher.push((o.right>>8)&0xff);
|
||||
cipher.push(o.right&0xff);
|
||||
pos+=8;
|
||||
}
|
||||
|
||||
switch(out){
|
||||
case crypto.outputTypes.Hex:{
|
||||
return arrayUtil.map(cipher, function(item){
|
||||
return (item<=0xf?'0':'')+item.toString(16);
|
||||
}).join(""); // string
|
||||
}
|
||||
case crypto.outputTypes.String:{
|
||||
return cipher.join(""); // string
|
||||
}
|
||||
case crypto.outputTypes.Raw:{
|
||||
return cipher; // array
|
||||
}
|
||||
default:{
|
||||
return base64.encode(cipher); // string
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.decrypt = function(/* string */ciphertext, /* string */key, /* object? */ao){
|
||||
// summary:
|
||||
// decrypts ciphertext using key; allows specification of how ciphertext is encoded via ao.
|
||||
var ip=crypto.outputTypes.Base64;
|
||||
var mode=crypto.cipherModes.ECB;
|
||||
if (ao){
|
||||
if (ao.outputType) ip=ao.outputType;
|
||||
if (ao.cipherMode) mode=ao.cipherMode;
|
||||
}
|
||||
var bx = init(key);
|
||||
var pt=[];
|
||||
|
||||
var c=null;
|
||||
switch(ip){
|
||||
case crypto.outputTypes.Hex:{
|
||||
c = [];
|
||||
for(var i=0, l=ciphertext.length-1; i<l; i+=2){
|
||||
c.push(parseInt(ciphertext.substr(i,2), 16));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case crypto.outputTypes.String:{
|
||||
c = arrayUtil.map(ciphertext.split(""), function(item){
|
||||
return item.charCodeAt(0);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case crypto.outputTypes.Raw:{
|
||||
c=ciphertext; // should be a byte array
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
c=base64.decode(ciphertext);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var count=c.length >> 3, pos=0, o={}, isCBC=(mode==crypto.cipherModes.CBC);
|
||||
var vector={left:iv.left||null, right:iv.right||null};
|
||||
for(var i=0; i<count; i++){
|
||||
o.left=c[pos]*POW24|c[pos+1]*POW16|c[pos+2]*POW8|c[pos+3];
|
||||
o.right=c[pos+4]*POW24|c[pos+5]*POW16|c[pos+6]*POW8|c[pos+7];
|
||||
|
||||
if(isCBC){
|
||||
var left=o.left;
|
||||
var right=o.right;
|
||||
}
|
||||
|
||||
db(o, bx); // decrypt the block
|
||||
|
||||
if(isCBC){
|
||||
o.left=(((o.left>>0x10)^(vector.left>>0x10))<<0x10)|(((o.left&0xffff)^(vector.left&0xffff))&0xffff);
|
||||
o.right=(((o.right>>0x10)^(vector.right>>0x10))<<0x10)|(((o.right&0xffff)^(vector.right&0xffff))&0xffff);
|
||||
vector.left=left;
|
||||
vector.right=right;
|
||||
}
|
||||
|
||||
pt.push((o.left>>24)&0xff);
|
||||
pt.push((o.left>>16)&0xff);
|
||||
pt.push((o.left>>8)&0xff);
|
||||
pt.push(o.left&0xff);
|
||||
pt.push((o.right>>24)&0xff);
|
||||
pt.push((o.right>>16)&0xff);
|
||||
pt.push((o.right>>8)&0xff);
|
||||
pt.push(o.right&0xff);
|
||||
pos+=8;
|
||||
}
|
||||
|
||||
// check for padding, and remove.
|
||||
if(pt[pt.length-1]==pt[pt.length-2]||pt[pt.length-1]==0x01){
|
||||
var n=pt[pt.length-1];
|
||||
pt.splice(pt.length-n, n);
|
||||
}
|
||||
|
||||
// convert to string
|
||||
return arrayUtil.map(pt, function(item){
|
||||
return String.fromCharCode(item);
|
||||
}).join(""); // string
|
||||
};
|
||||
|
||||
this.setIV("0000000000000000", crypto.outputTypes.Hex);
|
||||
}();
|
||||
|
||||
|
||||
|
||||
if (typeof exports != 'undefined') {
|
||||
exports.blowfish = crypto.Blowfish;
|
||||
} else {
|
||||
global.blowfish = crypto.Blowfish;
|
||||
}
|
||||
|
||||
}(this));
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,583 +0,0 @@
|
|||
/** @license
|
||||
========================================================================
|
||||
bootstrap-switch - v3.1.0
|
||||
http://www.bootstrap-switch.org
|
||||
Copyright 2012-2013 Mattia Larentis
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var __slice = [].slice;
|
||||
|
||||
(function($, window) {
|
||||
"use strict";
|
||||
var BootstrapSwitch;
|
||||
BootstrapSwitch = (function() {
|
||||
function BootstrapSwitch(element, options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
this.$element = $(element);
|
||||
this.options = $.extend({}, $.fn.bootstrapSwitch.defaults, {
|
||||
state: this.$element.is(":checked"),
|
||||
size: this.$element.data("size"),
|
||||
animate: this.$element.data("animate"),
|
||||
disabled: this.$element.is(":disabled"),
|
||||
readonly: this.$element.is("[readonly]"),
|
||||
indeterminate: this.$element.data("indeterminate"),
|
||||
inverse: this.$element.data("inverse"),
|
||||
radioAllOff: this.$element.data("radio-all-off"),
|
||||
onColor: this.$element.data("on-color"),
|
||||
offColor: this.$element.data("off-color"),
|
||||
onText: this.$element.data("on-text"),
|
||||
offText: this.$element.data("off-text"),
|
||||
labelText: this.$element.data("label-text"),
|
||||
baseClass: this.$element.data("base-class"),
|
||||
wrapperClass: this.$element.data("wrapper-class")
|
||||
}, options);
|
||||
this.$wrapper = $("<div>", {
|
||||
"class": (function(_this) {
|
||||
return function() {
|
||||
var classes;
|
||||
classes = ["" + _this.options.baseClass].concat(_this._getClasses(_this.options.wrapperClass));
|
||||
classes.push(_this.options.state ? "" + _this.options.baseClass + "-on" : "" + _this.options.baseClass + "-off");
|
||||
if (_this.options.size != null) {
|
||||
classes.push("" + _this.options.baseClass + "-" + _this.options.size);
|
||||
}
|
||||
if (_this.options.animate) {
|
||||
classes.push("" + _this.options.baseClass + "-animate");
|
||||
}
|
||||
if (_this.options.disabled) {
|
||||
classes.push("" + _this.options.baseClass + "-disabled");
|
||||
}
|
||||
if (_this.options.readonly) {
|
||||
classes.push("" + _this.options.baseClass + "-readonly");
|
||||
}
|
||||
if (_this.options.indeterminate) {
|
||||
classes.push("" + _this.options.baseClass + "-indeterminate");
|
||||
}
|
||||
if (_this.options.inverse) {
|
||||
classes.push("" + _this.options.baseClass + "-inverse");
|
||||
}
|
||||
if (_this.$element.attr("id")) {
|
||||
classes.push("" + _this.options.baseClass + "-id-" + (_this.$element.attr("id")));
|
||||
}
|
||||
return classes.join(" ");
|
||||
};
|
||||
})(this)()
|
||||
});
|
||||
this.$container = $("<div>", {
|
||||
"class": "" + this.options.baseClass + "-container"
|
||||
});
|
||||
this.$on = $("<span>", {
|
||||
html: this.options.onText,
|
||||
"class": "" + this.options.baseClass + "-handle-on " + this.options.baseClass + "-" + this.options.onColor
|
||||
});
|
||||
this.$off = $("<span>", {
|
||||
html: this.options.offText,
|
||||
"class": "" + this.options.baseClass + "-handle-off " + this.options.baseClass + "-" + this.options.offColor
|
||||
});
|
||||
this.$label = $("<label>", {
|
||||
html: this.options.labelText,
|
||||
"class": "" + this.options.baseClass + "-label"
|
||||
});
|
||||
if (this.options.indeterminate) {
|
||||
this.$element.prop("indeterminate", true);
|
||||
}
|
||||
this.$element.on("init.bootstrapSwitch", (function(_this) {
|
||||
return function() {
|
||||
return _this.options.onInit.apply(element, arguments);
|
||||
};
|
||||
})(this));
|
||||
this.$element.on("switchChange.bootstrapSwitch", (function(_this) {
|
||||
return function() {
|
||||
return _this.options.onSwitchChange.apply(element, arguments);
|
||||
};
|
||||
})(this));
|
||||
this.$container = this.$element.wrap(this.$container).parent();
|
||||
this.$wrapper = this.$container.wrap(this.$wrapper).parent();
|
||||
this.$element.before(this.options.inverse ? this.$off : this.$on).before(this.$label).before(this.options.inverse ? this.$on : this.$off).trigger("init.bootstrapSwitch");
|
||||
this._elementHandlers();
|
||||
this._handleHandlers();
|
||||
this._labelHandlers();
|
||||
this._formHandler();
|
||||
}
|
||||
|
||||
BootstrapSwitch.prototype._constructor = BootstrapSwitch;
|
||||
|
||||
BootstrapSwitch.prototype.state = function(value, skip) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.state;
|
||||
}
|
||||
if (this.options.disabled || this.options.readonly) {
|
||||
return this.$element;
|
||||
}
|
||||
if (this.options.state && !this.options.radioAllOff && this.$element.is(':radio')) {
|
||||
return this.$element;
|
||||
}
|
||||
if (this.options.indeterminate) {
|
||||
this.indeterminate(false);
|
||||
value = true;
|
||||
} else {
|
||||
value = !!value;
|
||||
}
|
||||
this.$element.prop("checked", value).trigger("change.bootstrapSwitch", skip);
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.toggleState = function(skip) {
|
||||
if (this.options.disabled || this.options.readonly) {
|
||||
return this.$element;
|
||||
}
|
||||
if (this.options.indeterminate) {
|
||||
this.indeterminate(false);
|
||||
return this.state(true);
|
||||
} else {
|
||||
return this.$element.prop("checked", !this.options.state).trigger("change.bootstrapSwitch", skip);
|
||||
}
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.size = function(value) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.size;
|
||||
}
|
||||
if (this.options.size != null) {
|
||||
this.$wrapper.removeClass("" + this.options.baseClass + "-" + this.options.size);
|
||||
}
|
||||
if (value) {
|
||||
this.$wrapper.addClass("" + this.options.baseClass + "-" + value);
|
||||
}
|
||||
this.options.size = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.animate = function(value) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.animate;
|
||||
}
|
||||
value = !!value;
|
||||
this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-animate");
|
||||
this.options.animate = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.toggleAnimate = function() {
|
||||
this.$wrapper.toggleClass("" + this.options.baseClass + "-animate");
|
||||
this.options.animate = !this.options.animate;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.disabled = function(value) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.disabled;
|
||||
}
|
||||
value = !!value;
|
||||
this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-disabled");
|
||||
this.$element.prop("disabled", value);
|
||||
this.options.disabled = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.toggleDisabled = function() {
|
||||
this.$element.prop("disabled", !this.options.disabled);
|
||||
this.$wrapper.toggleClass("" + this.options.baseClass + "-disabled");
|
||||
this.options.disabled = !this.options.disabled;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.readonly = function(value) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.readonly;
|
||||
}
|
||||
value = !!value;
|
||||
this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-readonly");
|
||||
this.$element.prop("readonly", value);
|
||||
this.options.readonly = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.toggleReadonly = function() {
|
||||
this.$element.prop("readonly", !this.options.readonly);
|
||||
this.$wrapper.toggleClass("" + this.options.baseClass + "-readonly");
|
||||
this.options.readonly = !this.options.readonly;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.indeterminate = function(value) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.indeterminate;
|
||||
}
|
||||
value = !!value;
|
||||
this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-indeterminate");
|
||||
this.$element.prop("indeterminate", value);
|
||||
this.options.indeterminate = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.toggleIndeterminate = function() {
|
||||
this.$element.prop("indeterminate", !this.options.indeterminate);
|
||||
this.$wrapper.toggleClass("" + this.options.baseClass + "-indeterminate");
|
||||
this.options.indeterminate = !this.options.indeterminate;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.inverse = function(value) {
|
||||
var $off, $on;
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.inverse;
|
||||
}
|
||||
value = !!value;
|
||||
this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-inverse");
|
||||
$on = this.$on.clone(true);
|
||||
$off = this.$off.clone(true);
|
||||
this.$on.replaceWith($off);
|
||||
this.$off.replaceWith($on);
|
||||
this.$on = $off;
|
||||
this.$off = $on;
|
||||
this.options.inverse = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.toggleInverse = function() {
|
||||
var $off, $on;
|
||||
this.$wrapper.toggleClass("" + this.options.baseClass + "-inverse");
|
||||
$on = this.$on.clone(true);
|
||||
$off = this.$off.clone(true);
|
||||
this.$on.replaceWith($off);
|
||||
this.$off.replaceWith($on);
|
||||
this.$on = $off;
|
||||
this.$off = $on;
|
||||
this.options.inverse = !this.options.inverse;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.onColor = function(value) {
|
||||
var color;
|
||||
color = this.options.onColor;
|
||||
if (typeof value === "undefined") {
|
||||
return color;
|
||||
}
|
||||
if (color != null) {
|
||||
this.$on.removeClass("" + this.options.baseClass + "-" + color);
|
||||
}
|
||||
this.$on.addClass("" + this.options.baseClass + "-" + value);
|
||||
this.options.onColor = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.offColor = function(value) {
|
||||
var color;
|
||||
color = this.options.offColor;
|
||||
if (typeof value === "undefined") {
|
||||
return color;
|
||||
}
|
||||
if (color != null) {
|
||||
this.$off.removeClass("" + this.options.baseClass + "-" + color);
|
||||
}
|
||||
this.$off.addClass("" + this.options.baseClass + "-" + value);
|
||||
this.options.offColor = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.onText = function(value) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.onText;
|
||||
}
|
||||
this.$on.html(value);
|
||||
this.options.onText = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.offText = function(value) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.offText;
|
||||
}
|
||||
this.$off.html(value);
|
||||
this.options.offText = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.labelText = function(value) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.labelText;
|
||||
}
|
||||
this.$label.html(value);
|
||||
this.options.labelText = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.baseClass = function(value) {
|
||||
return this.options.baseClass;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.wrapperClass = function(value) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.wrapperClass;
|
||||
}
|
||||
if (!value) {
|
||||
value = $.fn.bootstrapSwitch.defaults.wrapperClass;
|
||||
}
|
||||
this.$wrapper.removeClass(this._getClasses(this.options.wrapperClass).join(" "));
|
||||
this.$wrapper.addClass(this._getClasses(value).join(" "));
|
||||
this.options.wrapperClass = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.radioAllOff = function(value) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.radioAllOff;
|
||||
}
|
||||
this.options.radioAllOff = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.onInit = function(value) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.onInit;
|
||||
}
|
||||
if (!value) {
|
||||
value = $.fn.bootstrapSwitch.defaults.onInit;
|
||||
}
|
||||
this.options.onInit = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.onSwitchChange = function(value) {
|
||||
if (typeof value === "undefined") {
|
||||
return this.options.onSwitchChange;
|
||||
}
|
||||
if (!value) {
|
||||
value = $.fn.bootstrapSwitch.defaults.onSwitchChange;
|
||||
}
|
||||
this.options.onSwitchChange = value;
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype.destroy = function() {
|
||||
var $form;
|
||||
$form = this.$element.closest("form");
|
||||
if ($form.length) {
|
||||
$form.off("reset.bootstrapSwitch").removeData("bootstrap-switch");
|
||||
}
|
||||
this.$container.children().not(this.$element).remove();
|
||||
this.$element.unwrap().unwrap().off(".bootstrapSwitch").removeData("bootstrap-switch");
|
||||
return this.$element;
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype._elementHandlers = function() {
|
||||
return this.$element.on({
|
||||
"change.bootstrapSwitch": (function(_this) {
|
||||
return function(e, skip) {
|
||||
var checked;
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
checked = _this.$element.is(":checked");
|
||||
if (checked === _this.options.state) {
|
||||
return;
|
||||
}
|
||||
_this.options.state = checked;
|
||||
_this.$wrapper.removeClass(checked ? "" + _this.options.baseClass + "-off" : "" + _this.options.baseClass + "-on").addClass(checked ? "" + _this.options.baseClass + "-on" : "" + _this.options.baseClass + "-off");
|
||||
if (!skip) {
|
||||
if (_this.$element.is(":radio")) {
|
||||
$("[name='" + (_this.$element.attr('name')) + "']").not(_this.$element).prop("checked", false).trigger("change.bootstrapSwitch", true);
|
||||
}
|
||||
return _this.$element.trigger("switchChange.bootstrapSwitch", [checked]);
|
||||
}
|
||||
};
|
||||
})(this),
|
||||
"focus.bootstrapSwitch": (function(_this) {
|
||||
return function(e) {
|
||||
e.preventDefault();
|
||||
return _this.$wrapper.addClass("" + _this.options.baseClass + "-focused");
|
||||
};
|
||||
})(this),
|
||||
"blur.bootstrapSwitch": (function(_this) {
|
||||
return function(e) {
|
||||
e.preventDefault();
|
||||
return _this.$wrapper.removeClass("" + _this.options.baseClass + "-focused");
|
||||
};
|
||||
})(this),
|
||||
"keydown.bootstrapSwitch": (function(_this) {
|
||||
return function(e) {
|
||||
if (!e.which || _this.options.disabled || _this.options.readonly) {
|
||||
return;
|
||||
}
|
||||
switch (e.which) {
|
||||
case 37:
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
return _this.state(false);
|
||||
case 39:
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
return _this.state(true);
|
||||
}
|
||||
};
|
||||
})(this)
|
||||
});
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype._handleHandlers = function() {
|
||||
this.$on.on("click.bootstrapSwitch", (function(_this) {
|
||||
return function(e) {
|
||||
_this.state(false);
|
||||
return _this.$element.trigger("focus.bootstrapSwitch");
|
||||
};
|
||||
})(this));
|
||||
return this.$off.on("click.bootstrapSwitch", (function(_this) {
|
||||
return function(e) {
|
||||
_this.state(true);
|
||||
return _this.$element.trigger("focus.bootstrapSwitch");
|
||||
};
|
||||
})(this));
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype._labelHandlers = function() {
|
||||
return this.$label.on({
|
||||
"mousemove.bootstrapSwitch touchmove.bootstrapSwitch": (function(_this) {
|
||||
return function(e) {
|
||||
var left, pageX, percent, right;
|
||||
if (!_this.isLabelDragging) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
_this.isLabelDragged = true;
|
||||
pageX = e.pageX || e.originalEvent.touches[0].pageX;
|
||||
percent = ((pageX - _this.$wrapper.offset().left) / _this.$wrapper.width()) * 100;
|
||||
left = 25;
|
||||
right = 75;
|
||||
if (_this.options.animate) {
|
||||
_this.$wrapper.removeClass("" + _this.options.baseClass + "-animate");
|
||||
}
|
||||
if (percent < left) {
|
||||
percent = left;
|
||||
} else if (percent > right) {
|
||||
percent = right;
|
||||
}
|
||||
_this.$container.css("margin-left", "" + (percent - right) + "%");
|
||||
return _this.$element.trigger("focus.bootstrapSwitch");
|
||||
};
|
||||
})(this),
|
||||
"mousedown.bootstrapSwitch touchstart.bootstrapSwitch": (function(_this) {
|
||||
return function(e) {
|
||||
if (_this.isLabelDragging || _this.options.disabled || _this.options.readonly) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
_this.isLabelDragging = true;
|
||||
return _this.$element.trigger("focus.bootstrapSwitch");
|
||||
};
|
||||
})(this),
|
||||
"mouseup.bootstrapSwitch touchend.bootstrapSwitch": (function(_this) {
|
||||
return function(e) {
|
||||
var state;
|
||||
if (!_this.isLabelDragging) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
if (_this.isLabelDragged) {
|
||||
state = parseInt(_this.$container.css("margin-left"), 10) > -(_this.$container.width() / 6);
|
||||
_this.isLabelDragged = false;
|
||||
_this.state(_this.options.inverse ? !state : state);
|
||||
if (_this.options.animate) {
|
||||
_this.$wrapper.addClass("" + _this.options.baseClass + "-animate");
|
||||
}
|
||||
_this.$container.css("margin-left", "");
|
||||
} else {
|
||||
_this.state(!_this.options.state);
|
||||
}
|
||||
return _this.isLabelDragging = false;
|
||||
};
|
||||
})(this),
|
||||
"mouseleave.bootstrapSwitch": (function(_this) {
|
||||
return function(e) {
|
||||
return _this.$label.trigger("mouseup.bootstrapSwitch");
|
||||
};
|
||||
})(this)
|
||||
});
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype._formHandler = function() {
|
||||
var $form;
|
||||
$form = this.$element.closest("form");
|
||||
if ($form.data("bootstrap-switch")) {
|
||||
return;
|
||||
}
|
||||
return $form.on("reset.bootstrapSwitch", function() {
|
||||
return window.setTimeout(function() {
|
||||
return $form.find("input").filter(function() {
|
||||
return $(this).data("bootstrap-switch");
|
||||
}).each(function() {
|
||||
return $(this).bootstrapSwitch("state", this.checked);
|
||||
});
|
||||
}, 1);
|
||||
}).data("bootstrap-switch", true);
|
||||
};
|
||||
|
||||
BootstrapSwitch.prototype._getClasses = function(classes) {
|
||||
var c, cls, _i, _len;
|
||||
if (!$.isArray(classes)) {
|
||||
return ["" + this.options.baseClass + "-" + classes];
|
||||
}
|
||||
cls = [];
|
||||
for (_i = 0, _len = classes.length; _i < _len; _i++) {
|
||||
c = classes[_i];
|
||||
cls.push("" + this.options.baseClass + "-" + c);
|
||||
}
|
||||
return cls;
|
||||
};
|
||||
|
||||
return BootstrapSwitch;
|
||||
|
||||
})();
|
||||
$.fn.bootstrapSwitch = function() {
|
||||
var args, option, ret;
|
||||
option = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
||||
ret = this;
|
||||
this.each(function() {
|
||||
var $this, data;
|
||||
$this = $(this);
|
||||
data = $this.data("bootstrap-switch");
|
||||
if (!data) {
|
||||
$this.data("bootstrap-switch", data = new BootstrapSwitch(this, option));
|
||||
}
|
||||
if (typeof option === "string") {
|
||||
return ret = data[option].apply(data, args);
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
$.fn.bootstrapSwitch.Constructor = BootstrapSwitch;
|
||||
return $.fn.bootstrapSwitch.defaults = {
|
||||
state: true,
|
||||
size: null,
|
||||
animate: true,
|
||||
disabled: false,
|
||||
readonly: false,
|
||||
indeterminate: false,
|
||||
inverse: false,
|
||||
radioAllOff: false,
|
||||
onColor: "primary",
|
||||
offColor: "default",
|
||||
onText: "ON",
|
||||
offText: "OFF",
|
||||
labelText: " ",
|
||||
baseClass: "bootstrap-switch",
|
||||
wrapperClass: "wrapper",
|
||||
onInit: function() {},
|
||||
onSwitchChange: function() {}
|
||||
};
|
||||
})(window.jQuery, window);
|
||||
|
||||
}).call(this);
|
|
@ -1,768 +0,0 @@
|
|||
/** @license
|
||||
========================================================================
|
||||
Crypto API for JavaScript - https://github.com/nf404/crypto-api
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 nf404
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/*global module, require */
|
||||
(/**
|
||||
* @param {Object} root
|
||||
* @returns {CryptoApi}
|
||||
*/
|
||||
function (root) {
|
||||
'use strict';
|
||||
/**
|
||||
* @class CryptoApi
|
||||
* @classdesc Main class
|
||||
* @public
|
||||
*/
|
||||
var CryptoApi = function cryptoApi () {
|
||||
/**
|
||||
* @property Hashers
|
||||
* @type {Hashers}
|
||||
*/
|
||||
this.Hashers = new Hashers();
|
||||
/**
|
||||
* @property Encodes
|
||||
* @type {Encodes}
|
||||
*/
|
||||
this.Encodes = new Encodes();
|
||||
/**
|
||||
* @property Macs
|
||||
* @type {Macs}
|
||||
*/
|
||||
this.Macs = new Macs();
|
||||
/**
|
||||
* @property Tools
|
||||
* @type {Tools}
|
||||
*/
|
||||
this.Tools = new Tools();
|
||||
};
|
||||
|
||||
/**
|
||||
* @interface HasherInterface
|
||||
* @classdesc All hashers MUST implement this interface
|
||||
* @public
|
||||
*/
|
||||
var HasherInterface = function () {};
|
||||
/**
|
||||
* @memberOf HasherInterface
|
||||
* @constructor
|
||||
*/
|
||||
HasherInterface.prototype.constructor = function constructor() {};
|
||||
/**
|
||||
* @desc Process ready block
|
||||
* @memberOf HasherInterface
|
||||
* @method processBlock
|
||||
* @param {number[]} block
|
||||
*/
|
||||
HasherInterface.prototype.processBlock = function processBlock(block) {};
|
||||
/**
|
||||
* Update message
|
||||
* @memberOf HasherInterface
|
||||
* @method update
|
||||
* @param {string} message
|
||||
*/
|
||||
HasherInterface.prototype.update = function update(message) {};
|
||||
/**
|
||||
* @desc Process last block and return hash
|
||||
* @memberOf HasherInterface
|
||||
* @method finalize
|
||||
* @return {HashArray} hash
|
||||
*/
|
||||
HasherInterface.prototype.finalize = function finalize() {};
|
||||
|
||||
/**
|
||||
* @class BaseHasher
|
||||
* @param {string} name
|
||||
* @param {Object} options
|
||||
* @public
|
||||
*/
|
||||
var BaseHasher = function(name, options) {};
|
||||
BaseHasher.prototype.constructor = function (name, options) {
|
||||
/**
|
||||
* @desc Hasher name
|
||||
* @property name
|
||||
* @type {string}
|
||||
*/
|
||||
this.name = name;
|
||||
/**
|
||||
* @desc All algorithm variables that changed during process
|
||||
* @property state
|
||||
* @type {Object}
|
||||
*/
|
||||
this.state = {};
|
||||
/**
|
||||
* @desc Unprocessed Message
|
||||
* @memberof! BaseHasher#
|
||||
* @alias state.message
|
||||
* @type {number[]}
|
||||
*/
|
||||
this.state.message = [];
|
||||
/**
|
||||
* @desc Length of message
|
||||
* @memberof! BaseHasher#
|
||||
* @alias state.length
|
||||
* @type {number}
|
||||
*/
|
||||
this.state.length = 0;
|
||||
/**
|
||||
* @memberof! BaseHasher#
|
||||
* @alias state.options
|
||||
* @type {Object}
|
||||
*/
|
||||
this.state.options = options;
|
||||
this.blockUnits = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* Size of unit in bytes (4 = 32 bits)
|
||||
* @memberOf BaseHasher
|
||||
* @member {number} unitSize
|
||||
* @static
|
||||
*/
|
||||
BaseHasher.prototype.unitSize = 4;
|
||||
/**
|
||||
* Bytes order in unit
|
||||
* 0 - normal
|
||||
* 1 - reverse
|
||||
* @memberOf BaseHasher
|
||||
* @member {number} unitOrder
|
||||
* @static
|
||||
*/
|
||||
BaseHasher.prototype.unitOrder = 0;
|
||||
/**
|
||||
* Size of block in units
|
||||
* @memberOf BaseHasher
|
||||
* @member {number} blockSize
|
||||
* @static
|
||||
*/
|
||||
BaseHasher.prototype.blockSize = 16;
|
||||
/**
|
||||
* Return current state
|
||||
* @memberOf BaseHasher
|
||||
* @method getState
|
||||
* @returns {Object}
|
||||
*/
|
||||
BaseHasher.prototype.getState = function getState() {
|
||||
return JSON.parse(JSON.stringify(this.state));
|
||||
};
|
||||
/**
|
||||
* Set state
|
||||
* @memberOf BaseHasher
|
||||
* @method setState
|
||||
* @param {Object} state
|
||||
* @return {HasherInterface}
|
||||
*/
|
||||
BaseHasher.prototype.setState = function setState(state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update message
|
||||
* @memberOf BaseHasher
|
||||
* @method update
|
||||
* @param {string} message
|
||||
*/
|
||||
BaseHasher.prototype.update = function update(message) {
|
||||
var l = 0;
|
||||
for (var i = 0, msgLen = message.length; i < msgLen; i++) {
|
||||
var charcode = message.charCodeAt(i);
|
||||
if (charcode < 0x80) {
|
||||
this.state.message.push(charcode);
|
||||
l += 1;
|
||||
}
|
||||
else if (charcode < 0x800) {
|
||||
this.state.message.push(0xc0 | (charcode >> 6),
|
||||
0x80 | (charcode & 0x3f));
|
||||
l += 2;
|
||||
}
|
||||
else if (charcode < 0xd800 || charcode >= 0xe000) {
|
||||
this.state.message.push(0xe0 | (charcode >> 12),
|
||||
0x80 | ((charcode >> 6) & 0x3f),
|
||||
0x80 | (charcode & 0x3f));
|
||||
l += 3;
|
||||
}
|
||||
// surrogate pair
|
||||
else {
|
||||
i++;
|
||||
// UTF-16 encodes 0x10000-0x10FFFF by
|
||||
// subtracting 0x10000 and splitting the
|
||||
// 20 bits of 0x0-0xFFFFF into two halves
|
||||
charcode = 0x10000 + (((charcode & 0x3ff) << 10)
|
||||
| (message.charCodeAt(i) & 0x3ff));
|
||||
this.state.message.push(0xf0 | (charcode >> 18),
|
||||
0x80 | ((charcode >> 12) & 0x3f),
|
||||
0x80 | ((charcode >> 6) & 0x3f),
|
||||
0x80 | (charcode & 0x3f));
|
||||
l += 4;
|
||||
}
|
||||
}
|
||||
this.state.length += l;
|
||||
|
||||
this.process();
|
||||
};
|
||||
|
||||
/**
|
||||
* Update message from array
|
||||
* @memberOf BaseHasher
|
||||
* @method updateFromArray
|
||||
* @param {number[]} message
|
||||
* @return {BaseHasher}
|
||||
*/
|
||||
BaseHasher.prototype.updateFromArray = function updateFromArray(message) {
|
||||
this.state.length += message.length;
|
||||
this.state.message = this.state.message.concat(message);
|
||||
this.process();
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Process ready blocks
|
||||
* @memberOf BaseHasher
|
||||
* @method process
|
||||
*/
|
||||
BaseHasher.prototype.process = function process() {
|
||||
while (this.state.message.length >= this.blockSize * this.unitSize) {
|
||||
var j = 0, b = 0, block = this.state.message.splice(0, this.blockSize * this.unitSize);
|
||||
if (this.unitSize > 1) {
|
||||
this.blockUnits = [];
|
||||
for (var i = 0, u = 0; i < block.length; i += this.unitSize, u++) {
|
||||
if (this.unitOrder === 1) {
|
||||
for (j = this.unitSize - 1, b = 0; j >= 0; j--, b += 8) {
|
||||
this.blockUnits[u] |= (block[i + j] << b);
|
||||
}
|
||||
} else {
|
||||
for (j = 0, b = 0; j < this.unitSize; j++, b += 8) {
|
||||
this.blockUnits[u] |= (block[i + j] << b);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.processBlock(this.blockUnits);
|
||||
} else {
|
||||
this.processBlock(block);
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @memberOf CryptoApi
|
||||
* @member {BaseHasher} BaseHasher
|
||||
*/
|
||||
CryptoApi.prototype.BaseHasher = BaseHasher;
|
||||
|
||||
/**
|
||||
* @class Hasher8
|
||||
* @desc Hasher for 32 bit little endian blocks
|
||||
* @extends BaseHasher
|
||||
* @param {string} name
|
||||
* @param {Object} options
|
||||
* @public
|
||||
*/
|
||||
var Hasher8 = function (name, options) {
|
||||
this.constructor(name, options);
|
||||
};
|
||||
Hasher8.prototype = Object.create(BaseHasher.prototype);
|
||||
|
||||
/**
|
||||
* @desc Normal order of bytes
|
||||
* @memberOf Hasher8#
|
||||
* @member {number} unitOrder
|
||||
*/
|
||||
Hasher8.prototype.unitOrder = 0;
|
||||
/**
|
||||
* @desc Size of unit = 1 byte
|
||||
* @memberOf Hasher8#
|
||||
* @member {number} unitSize
|
||||
*/
|
||||
Hasher8.prototype.unitSize = 1;
|
||||
|
||||
/**
|
||||
* @memberOf Hasher8
|
||||
* @constructor
|
||||
* @param {string} name
|
||||
* @param {Object} options
|
||||
*/
|
||||
Hasher8.prototype.constructor = function (name, options) {
|
||||
BaseHasher.prototype.constructor.call(this, name, options);
|
||||
};
|
||||
/**
|
||||
* Process ready blocks
|
||||
* @memberOf Hasher8
|
||||
* @method process
|
||||
*/
|
||||
Hasher8.prototype.process = function process() {
|
||||
while (this.state.message.length >= this.blockSize * this.unitSize) {
|
||||
var block = this.state.message.splice(0, this.blockSize * this.unitSize);
|
||||
this.blockUnits = [];
|
||||
for (var i = 0; i < this.blockSize; i++) {
|
||||
this.blockUnits[i] = (block[i]);
|
||||
}
|
||||
this.processBlock(this.blockUnits);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @memberOf CryptoApi
|
||||
* @member {Hasher8} Hasher8
|
||||
*/
|
||||
CryptoApi.prototype.Hasher8 = Hasher8;
|
||||
|
||||
/**
|
||||
* @class Hasher32le
|
||||
* @desc Hasher for 32 bit little endian blocks
|
||||
* @extends BaseHasher
|
||||
* @param {string} name
|
||||
* @param {Object} options
|
||||
* @public
|
||||
*/
|
||||
var Hasher32le = function (name, options) {
|
||||
this.constructor(name, options);
|
||||
};
|
||||
Hasher32le.prototype = Object.create(BaseHasher.prototype);
|
||||
|
||||
Hasher32le.prototype.unitOrder = 0; // Normal order of bytes
|
||||
|
||||
/**
|
||||
* @memberOf Hasher32le
|
||||
* @constructor
|
||||
* @param {string} name
|
||||
* @param {Object} options
|
||||
*/
|
||||
Hasher32le.prototype.constructor = function (name, options) {
|
||||
BaseHasher.prototype.constructor.call(this, name, options);
|
||||
};
|
||||
/**
|
||||
* Process ready blocks
|
||||
* @memberOf Hasher32le
|
||||
* @method process
|
||||
*/
|
||||
Hasher32le.prototype.process = function process() {
|
||||
while (this.state.message.length >= this.blockSize * this.unitSize) {
|
||||
var block = this.state.message.splice(0, this.blockSize * this.unitSize);
|
||||
this.blockUnits = [];
|
||||
for (var i = 0, b = 0; i < this.blockSize; i++, b+=4) {
|
||||
this.blockUnits[i] = (block[b]);
|
||||
this.blockUnits[i] |= (block[b + 1] << 8);
|
||||
this.blockUnits[i] |= (block[b + 2] << 16);
|
||||
this.blockUnits[i] |= (block[b + 3] << 24);
|
||||
}
|
||||
this.processBlock(this.blockUnits);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @memberOf CryptoApi
|
||||
* @member {Hasher32le} Hasher32
|
||||
*/
|
||||
CryptoApi.prototype.Hasher32le = Hasher32le;
|
||||
|
||||
/**
|
||||
* @class Hasher32be
|
||||
* @desc Hasher for 32 bit big endian blocks
|
||||
* @extends BaseHasher
|
||||
* @param {string} name
|
||||
* @param {Object} options
|
||||
* @public
|
||||
*/
|
||||
var Hasher32be = function (name, options) {
|
||||
this.constructor(name, options);
|
||||
};
|
||||
Hasher32be.prototype = Object.create(BaseHasher.prototype);
|
||||
|
||||
Hasher32be.prototype.unitOrder = 1; // Reverse order of bytes
|
||||
|
||||
/**
|
||||
* @memberOf Hasher32be
|
||||
* @constructor
|
||||
* @param {string} name
|
||||
* @param {Object} options
|
||||
*/
|
||||
Hasher32be.prototype.constructor = function (name, options) {
|
||||
BaseHasher.prototype.constructor.call(this, name, options);
|
||||
};
|
||||
/**
|
||||
* Process ready blocks
|
||||
* @memberOf Hasher32be
|
||||
* @method process
|
||||
*/
|
||||
Hasher32be.prototype.process = function process() {
|
||||
while (this.state.message.length >= this.blockSize * this.unitSize) {
|
||||
var block = this.state.message.splice(0, this.blockSize * this.unitSize);
|
||||
this.blockUnits = [];
|
||||
for (var i = 0, b = 0; i < this.blockSize; i++, b+=4) {
|
||||
this.blockUnits[i] = (block[b] << 24);
|
||||
this.blockUnits[i] |= (block[b + 1] << 16);
|
||||
this.blockUnits[i] |= (block[b + 2] << 8);
|
||||
this.blockUnits[i] |= (block[b + 3]);
|
||||
}
|
||||
this.processBlock(this.blockUnits);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @memberOf CryptoApi
|
||||
* @member {Hasher32be} Hasher32be
|
||||
*/
|
||||
CryptoApi.prototype.Hasher32be = Hasher32be;
|
||||
|
||||
/**
|
||||
* @interface MacInterface
|
||||
* @classdesc All coders MUST implement this interface
|
||||
* @public
|
||||
*/
|
||||
var MacInterface = function () {};
|
||||
/**
|
||||
* @memberOf MacInterface
|
||||
* @param {string|number[]} key
|
||||
* @param {string} hasher
|
||||
* @param {Object} options
|
||||
* @constructor
|
||||
*/
|
||||
MacInterface.prototype.constructor = function constructor(key, hasher, options) {};
|
||||
/**
|
||||
* @desc Process ready block
|
||||
* @memberOf MacInterface
|
||||
* @method processBlock
|
||||
* @param {number[]} block
|
||||
*/
|
||||
MacInterface.prototype.processBlock = function processBlock(block) {};
|
||||
/**
|
||||
* Update message
|
||||
* @memberOf MacInterface
|
||||
* @method update
|
||||
* @param {string|number[]} message
|
||||
* @return {MacInterface}
|
||||
*/
|
||||
MacInterface.prototype.update = function update(message) {};
|
||||
/**
|
||||
* @desc Process last block and return hash
|
||||
* @memberOf MacInterface
|
||||
* @method finalize
|
||||
* @return {HashArray} hash
|
||||
*/
|
||||
MacInterface.prototype.finalize = function finalize() {};
|
||||
|
||||
/**
|
||||
* @class BaseMac
|
||||
* @extends BaseHasher
|
||||
* @param {string|number[]} key
|
||||
* @param {string} hasher
|
||||
* @param {Object} options
|
||||
* @public
|
||||
*/
|
||||
var BaseMac = function(key, hasher, options) {};
|
||||
BaseMac.prototype = Object.create(BaseHasher.prototype);
|
||||
BaseMac.prototype.constructor = function (key, hasher, options) {
|
||||
BaseHasher.prototype.constructor.call(this, hasher, options);
|
||||
};
|
||||
/**
|
||||
* @memberOf CryptoApi
|
||||
* @member {BaseMac} BaseMac
|
||||
*/
|
||||
CryptoApi.prototype.BaseMac = BaseMac;
|
||||
/**
|
||||
* @interface EncodeInterface
|
||||
* @classdesc All encodes MUST implement this interface
|
||||
* @public
|
||||
*/
|
||||
var EncodeInterface = function () {};
|
||||
/**
|
||||
* @memberOf EncodeInterface
|
||||
* @constructor
|
||||
* @param {HashArray} hash
|
||||
*/
|
||||
EncodeInterface.prototype.constructor = function constructor(hash) {};
|
||||
/**
|
||||
* @desc Stringify hash
|
||||
* @memberOf EncodeInterface
|
||||
* @method stringify
|
||||
* @returns {string}
|
||||
*/
|
||||
EncodeInterface.prototype.stringify = function encode() {};
|
||||
|
||||
|
||||
/**
|
||||
* @class BaseEncode
|
||||
* @desc Encode HashArray
|
||||
* @param {HashArray} hash
|
||||
* @public
|
||||
*/
|
||||
var BaseEncode = function (hash) {};
|
||||
/**
|
||||
* @memberOf BaseEncode
|
||||
* @constructor
|
||||
* @param {HashArray} hash
|
||||
*/
|
||||
BaseEncode.prototype.constructor = function constructor(hash) {
|
||||
/**
|
||||
* @property hash
|
||||
* @type {HashArray}
|
||||
*/
|
||||
this.hash = hash;
|
||||
};
|
||||
/**
|
||||
* @memberOf CryptoApi
|
||||
* @member {BaseEncode} BaseEncode
|
||||
*/
|
||||
CryptoApi.prototype.BaseEncode = BaseEncode;
|
||||
|
||||
/**
|
||||
* @class Hashers
|
||||
* @classdesc Collection of hashers
|
||||
*/
|
||||
var Hashers = function hashers() {
|
||||
/**
|
||||
* @property hashers
|
||||
* @type {Object}
|
||||
*/
|
||||
this.hashers = {};
|
||||
};
|
||||
/**
|
||||
* @memberOf Hashers
|
||||
* @method add
|
||||
* @param {string} name
|
||||
* @param {HasherInterface} hasher
|
||||
*/
|
||||
Hashers.prototype.add = function add(name, hasher) {
|
||||
if (hasher === undefined) {
|
||||
throw Error('Error adding hasher: ' + name);
|
||||
}
|
||||
this.hashers[name] = hasher;
|
||||
};
|
||||
/**
|
||||
* @memberOf Hashers
|
||||
* @method add
|
||||
* @param {string} name
|
||||
* @param {Object} options
|
||||
* @returns {HasherInterface}
|
||||
*/
|
||||
Hashers.prototype.get = function get(name, options) {
|
||||
var Hasher = this.hashers[name];
|
||||
if ((Hasher === undefined) && (typeof require !== 'undefined')) {
|
||||
var filename = name;
|
||||
if (filename === 'sha224') {
|
||||
filename = 'sha256';
|
||||
}
|
||||
require('./hasher.' + filename);
|
||||
Hasher = this.hashers[name];
|
||||
}
|
||||
if (Hasher === undefined) {
|
||||
throw Error('No hash algorithm: ' + name);
|
||||
}
|
||||
return new Hasher(name, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Encodes
|
||||
* @classdesc Collection of encodes
|
||||
*/
|
||||
var Encodes = function encodes() {
|
||||
/**
|
||||
* @property encodes
|
||||
* @type {Object}
|
||||
*/
|
||||
this.encodes = {};
|
||||
};
|
||||
/**
|
||||
* @memberOf Encodes
|
||||
* @method add
|
||||
* @param {string} name
|
||||
* @param {BaseEncode} encode
|
||||
*/
|
||||
Encodes.prototype.add = function add(name, encode) {
|
||||
if (encode === undefined) {
|
||||
throw Error('Error adding encode: ' + name);
|
||||
}
|
||||
this.encodes[name] = encode;
|
||||
};
|
||||
/**
|
||||
* @memberOf Encodes
|
||||
* @method get
|
||||
* @param {string} name
|
||||
* @param {HashArray} hash
|
||||
* @returns {BaseEncode}
|
||||
*/
|
||||
Encodes.prototype.get = function get(name, hash) {
|
||||
var Encode = this.encodes[name];
|
||||
if ((Encode === undefined) && (typeof require !== 'undefined')) {
|
||||
require('./enc.' + name);
|
||||
Encode = this.encodes[name];
|
||||
}
|
||||
if (Encode === undefined) {
|
||||
throw Error('No encode type: ' + name);
|
||||
}
|
||||
return new Encode(hash);
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Macs
|
||||
* @classdesc Collection of macs
|
||||
*/
|
||||
var Macs = function macs() {
|
||||
/**
|
||||
* @property macs
|
||||
* @type {Object}
|
||||
*/
|
||||
this.macs = {};
|
||||
};
|
||||
/**
|
||||
* @memberOf Macs
|
||||
* @method add
|
||||
* @param {string} name
|
||||
* @param {BaseMac} mac
|
||||
*/
|
||||
Macs.prototype.add = function add(name, mac) {
|
||||
if (mac === undefined) {
|
||||
throw Error('Error adding mac: ' + name);
|
||||
}
|
||||
this.macs[name] = mac;
|
||||
};
|
||||
/**
|
||||
* @memberOf Macs
|
||||
* @method get
|
||||
* @param {string} name
|
||||
* @param {string|number[]} key
|
||||
* @param {string} hasher
|
||||
* @param {Object} options
|
||||
* @returns {MacInterface}
|
||||
*/
|
||||
Macs.prototype.get = function get(name, key, hasher, options) {
|
||||
var Mac = this.macs[name];
|
||||
if ((Mac === undefined) && (typeof require !== 'undefined')) {
|
||||
require('./mac.' + name);
|
||||
Mac = this.macs[name];
|
||||
}
|
||||
if (Mac === undefined) {
|
||||
throw Error('No mac type: ' + name);
|
||||
}
|
||||
return new Mac(key, hasher, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Tools
|
||||
* @classdesc Helper with some methods
|
||||
*/
|
||||
var Tools = function tools() {};
|
||||
/**
|
||||
* Rotate x to n bits left
|
||||
* @memberOf Tools
|
||||
* @method rotateLeft
|
||||
* @param {number} x
|
||||
* @param {number} n
|
||||
* @returns {number}
|
||||
*/
|
||||
Tools.prototype.rotateLeft = function rotateLeft(x, n) {
|
||||
return ((x << n) | (x >>> (32 - n))) | 0;
|
||||
};
|
||||
/**
|
||||
* Rotate x to n bits right
|
||||
* @memberOf Tools
|
||||
* @method rotateLeft
|
||||
* @param {number} x
|
||||
* @param {number} n
|
||||
* @returns {number}
|
||||
*/
|
||||
Tools.prototype.rotateRight = function rotateLeft(x, n) {
|
||||
return ((x >>> n) | (x << (32 - n))) | 0;
|
||||
};
|
||||
/**
|
||||
* @class HashArray
|
||||
* @classdesc Array of hash bytes
|
||||
* @instanceof {Array}
|
||||
* @param {number[]} hash
|
||||
* @param {Encodes} Encodes
|
||||
* @public
|
||||
*/
|
||||
var HashArray = function (hash, Encodes) {
|
||||
Array.prototype.push.apply(this, hash);
|
||||
/**
|
||||
* @property Encodes
|
||||
* @type {Encodes}
|
||||
*/
|
||||
this.Encodes = Encodes;
|
||||
};
|
||||
HashArray.prototype = Object.create(Array.prototype);
|
||||
HashArray.prototype.constructor = HashArray;
|
||||
|
||||
/**
|
||||
* Get hash as string
|
||||
* @param {string} method
|
||||
* @returns {string|*}
|
||||
*/
|
||||
HashArray.prototype.stringify = function stringify(method) {
|
||||
return this.Encodes.get(method, this).stringify();
|
||||
};
|
||||
|
||||
/**
|
||||
* Hash message with algo
|
||||
*
|
||||
* @memberof CryptoApi
|
||||
* @method hash
|
||||
* @public
|
||||
* @param {string} algo
|
||||
* @param {string} message
|
||||
* @param {Object} options
|
||||
* @return {HashArray} hash
|
||||
*/
|
||||
CryptoApi.prototype.hash = function hash(algo, message, options) {
|
||||
var hash = this.hasher(algo, options);
|
||||
hash.update(message);
|
||||
return hash.finalize();
|
||||
};
|
||||
/**
|
||||
* Get new Hasher object
|
||||
*
|
||||
* @memberof CryptoApi
|
||||
* @method hasher
|
||||
* @public
|
||||
* @param {string} algo
|
||||
* @param {Object} options
|
||||
* @returns {HasherInterface}
|
||||
*/
|
||||
CryptoApi.prototype.hasher = function hasher(algo, options) {
|
||||
return this.Hashers.get(algo, options);
|
||||
};
|
||||
/**
|
||||
* Get new MAC object
|
||||
*
|
||||
* @memberof CryptoApi
|
||||
* @method mac
|
||||
* @public
|
||||
* @param {string} algo
|
||||
* @param {string|number[]} key
|
||||
* @param {string} hasher
|
||||
* @param {Object} options
|
||||
* @returns {MacInterface}
|
||||
*/
|
||||
CryptoApi.prototype.mac = function mac(algo, key, hasher, options) {
|
||||
return this.Macs.get(algo, key, hasher, options);
|
||||
};
|
||||
/**
|
||||
* Get new HashArray
|
||||
*
|
||||
* @memberof CryptoApi
|
||||
* @method hashArray
|
||||
* @public
|
||||
* @param {number[]} hash
|
||||
* @returns {HashArray}
|
||||
*/
|
||||
CryptoApi.prototype.hashArray = function hashArray(hash) {
|
||||
return new HashArray(hash, this.Encodes);
|
||||
};
|
||||
root.CryptoApi = new CryptoApi();
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = root.CryptoApi;
|
||||
} else {
|
||||
return root.CryptoApi;
|
||||
}
|
||||
})(this);
|
|
@ -1,113 +0,0 @@
|
|||
/*global require */
|
||||
(/**
|
||||
* @param {CryptoApi} CryptoApi
|
||||
* @returns {Md2}
|
||||
*/
|
||||
function (CryptoApi) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @class Md2
|
||||
* @extends Hasher8
|
||||
* @implements HasherInterface
|
||||
* @desc Md2 hasher
|
||||
*/
|
||||
var Md2 = function (name, options) {
|
||||
this.constructor(name, options);
|
||||
};
|
||||
Md2.prototype = Object.create(CryptoApi.Hasher8.prototype);
|
||||
/**
|
||||
* @memberOf Md2
|
||||
* @constructor
|
||||
*/
|
||||
Md2.prototype.constructor = function (name, options) {
|
||||
CryptoApi.Hasher8.prototype.constructor.call(this, name, options);
|
||||
/**
|
||||
* @desc Hash state
|
||||
* @memberOf! Md2#
|
||||
* @alias state.hash
|
||||
* @type {number[]}
|
||||
*/
|
||||
this.state.hash = new Array(48);
|
||||
/**
|
||||
* @desc Checksum
|
||||
* @memberOf! Md2#
|
||||
* @alias state.checksum
|
||||
* @type {number[]}
|
||||
*/
|
||||
this.state.checksum = new Array(16);
|
||||
};
|
||||
|
||||
/**
|
||||
* @desc Constants from Pi
|
||||
* @link https://github.com/e-sushi/MD2-S-box-creator
|
||||
* @memberOf Md2#
|
||||
* @member {number[]} piSubst
|
||||
*/
|
||||
Md2.prototype.piSubst = [
|
||||
0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13,
|
||||
0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C, 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA,
|
||||
0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16, 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12,
|
||||
0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49, 0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A,
|
||||
0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, 0x07, 0x3F, 0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21,
|
||||
0x80, 0x7F, 0x5D, 0x9A, 0x5A, 0x90, 0x32, 0x27, 0x35, 0x3E, 0xCC, 0xE7, 0xBF, 0xF7, 0x97, 0x03,
|
||||
0xFF, 0x19, 0x30, 0xB3, 0x48, 0xA5, 0xB5, 0xD1, 0xD7, 0x5E, 0x92, 0x2A, 0xAC, 0x56, 0xAA, 0xC6,
|
||||
0x4F, 0xB8, 0x38, 0xD2, 0x96, 0xA4, 0x7D, 0xB6, 0x76, 0xFC, 0x6B, 0xE2, 0x9C, 0x74, 0x04, 0xF1,
|
||||
0x45, 0x9D, 0x70, 0x59, 0x64, 0x71, 0x87, 0x20, 0x86, 0x5B, 0xCF, 0x65, 0xE6, 0x2D, 0xA8, 0x02,
|
||||
0x1B, 0x60, 0x25, 0xAD, 0xAE, 0xB0, 0xB9, 0xF6, 0x1C, 0x46, 0x61, 0x69, 0x34, 0x40, 0x7E, 0x0F,
|
||||
0x55, 0x47, 0xA3, 0x23, 0xDD, 0x51, 0xAF, 0x3A, 0xC3, 0x5C, 0xF9, 0xCE, 0xBA, 0xC5, 0xEA, 0x26,
|
||||
0x2C, 0x53, 0x0D, 0x6E, 0x85, 0x28, 0x84, 0x09, 0xD3, 0xDF, 0xCD, 0xF4, 0x41, 0x81, 0x4D, 0x52,
|
||||
0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA, 0x24, 0xE1, 0x7B, 0x08, 0x0C, 0xBD, 0xB1, 0x4A,
|
||||
0x78, 0x88, 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D, 0xE9, 0xCB, 0xD5, 0xFE, 0x3B, 0x00, 0x1D, 0x39,
|
||||
0xF2, 0xEF, 0xB7, 0x0E, 0x66, 0x58, 0xD0, 0xE4, 0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A,
|
||||
0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A, 0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14];
|
||||
|
||||
/**
|
||||
* @memberOf Md2
|
||||
* @method processBlock
|
||||
* @param {number[]} block
|
||||
*/
|
||||
Md2.prototype.processBlock = function processBlock(block) {
|
||||
// Append hash
|
||||
for (var i = 0; i < 16; i++) {
|
||||
this.state.hash[16 + i] = block[i];
|
||||
this.state.hash[32 + i] = this.state.hash[16 + i] ^ this.state.hash[i];
|
||||
}
|
||||
|
||||
// 18 Rounds
|
||||
var t = 0;
|
||||
for (i = 0; i < 18; i++) {
|
||||
for (var j = 0; j < 48; j++) {
|
||||
t = this.state.hash[j] ^= this.piSubst[t];
|
||||
}
|
||||
t = (t + i) & 0xff;
|
||||
}
|
||||
|
||||
// Append checksum
|
||||
t = this.state.checksum[15];
|
||||
for (i = 0; i < 16; i++) {
|
||||
t = this.state.checksum[i] ^= this.piSubst[block[i] ^ t];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @memberOf Md2
|
||||
* @method finalize
|
||||
* @return {HashArray}
|
||||
*/
|
||||
Md2.prototype.finalize = function finalize() {
|
||||
var padLen = this.state.message.length & 0xf;
|
||||
this.update(new Array(17 - padLen).join(String.fromCharCode(16 - padLen)));
|
||||
|
||||
// Process checksum
|
||||
this.updateFromArray(this.state.checksum);
|
||||
|
||||
// Return hash
|
||||
return CryptoApi.hashArray(this.state.hash.slice(0, 16));
|
||||
};
|
||||
|
||||
CryptoApi.Hashers.add('md2', Md2);
|
||||
return Md2;
|
||||
})(
|
||||
this.CryptoApi || require('./crypto-api')
|
||||
);
|
|
@ -1,204 +0,0 @@
|
|||
/*global require */
|
||||
(/**
|
||||
* @param {CryptoApi} CryptoApi
|
||||
* @returns {Md4}
|
||||
*/
|
||||
function (CryptoApi) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @class Md4
|
||||
* @desc Md4 hasher
|
||||
* @implements HasherInterface
|
||||
* @extends Hasher32le
|
||||
*/
|
||||
var Md4 = function md4(name, options) {
|
||||
this.constructor(name, options);
|
||||
};
|
||||
Md4.prototype = Object.create(CryptoApi.Hasher32le.prototype);
|
||||
/**
|
||||
* @memberOf Md4
|
||||
* @constructor
|
||||
*/
|
||||
Md4.prototype.constructor = function (name, options) {
|
||||
CryptoApi.Hasher32le.prototype.constructor.call(this, name, options);
|
||||
/**
|
||||
* @desc Hash state
|
||||
* @memberOf! Md4#
|
||||
* @alias state.hash
|
||||
* @type {number[]}
|
||||
*/
|
||||
this.state.hash = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476];
|
||||
};
|
||||
|
||||
/**
|
||||
* @desc Transform constants
|
||||
* @memberOf Md4
|
||||
* @member {number[]} S
|
||||
* @const
|
||||
*/
|
||||
Md4.prototype.S = [
|
||||
[3, 7, 11, 19],
|
||||
[3, 5, 9, 13],
|
||||
[3, 9, 11, 15]
|
||||
];
|
||||
Md4.prototype.F = 0x00000000;
|
||||
Md4.prototype.G = 0x5a827999;
|
||||
Md4.prototype.H = 0x6ed9eba1;
|
||||
|
||||
// Transform functions
|
||||
/**
|
||||
* @param {number} x
|
||||
* @param {number} y
|
||||
* @param {number} z
|
||||
* @returns {number}
|
||||
*/
|
||||
Md4.prototype.FF = function FF(x, y, z) {
|
||||
return (x & y) | ((~x) & z);
|
||||
};
|
||||
/**
|
||||
* @param {number} x
|
||||
* @param {number} y
|
||||
* @param {number} z
|
||||
* @returns {number}
|
||||
*/
|
||||
Md4.prototype.GG = function GG(x, y, z) {
|
||||
return (x & y) | (x & z) | (y & z);
|
||||
};
|
||||
/**
|
||||
* @param {number} x
|
||||
* @param {number} y
|
||||
* @param {number} z
|
||||
* @returns {number}
|
||||
*/
|
||||
Md4.prototype.HH = function HH(x, y, z) {
|
||||
return x ^ y ^ z;
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @param {function} f
|
||||
* @param {number} k
|
||||
* @param {number} a
|
||||
* @param {number} x
|
||||
* @param {number} y
|
||||
* @param {number} z
|
||||
* @param {number} m
|
||||
* @param {number} s
|
||||
* @returns {number}
|
||||
* @constructor
|
||||
*/
|
||||
Md4.prototype.CC = function CC(f, k, a, x, y, z, m, s) {
|
||||
return CryptoApi.Tools.rotateLeft((a + f(x, y, z) + m + k), s) | 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @memberOf Md4
|
||||
* @method processBlock
|
||||
* @param {number[]} block
|
||||
*/
|
||||
Md4.prototype.processBlock = function processBlock(block) {
|
||||
// Working variables
|
||||
var a = this.state.hash[0] | 0;
|
||||
var b = this.state.hash[1] | 0;
|
||||
var c = this.state.hash[2] | 0;
|
||||
var d = this.state.hash[3] | 0;
|
||||
|
||||
// Round 1
|
||||
a = this.CC(this.FF, this.F, a, b, c, d, block[0], this.S[0][0]);
|
||||
d = this.CC(this.FF, this.F, d, a, b, c, block[1], this.S[0][1]);
|
||||
c = this.CC(this.FF, this.F, c, d, a, b, block[2], this.S[0][2]);
|
||||
b = this.CC(this.FF, this.F, b, c, d, a, block[3], this.S[0][3]);
|
||||
a = this.CC(this.FF, this.F, a, b, c, d, block[4], this.S[0][0]);
|
||||
d = this.CC(this.FF, this.F, d, a, b, c, block[5], this.S[0][1]);
|
||||
c = this.CC(this.FF, this.F, c, d, a, b, block[6], this.S[0][2]);
|
||||
b = this.CC(this.FF, this.F, b, c, d, a, block[7], this.S[0][3]);
|
||||
a = this.CC(this.FF, this.F, a, b, c, d, block[8], this.S[0][0]);
|
||||
d = this.CC(this.FF, this.F, d, a, b, c, block[9], this.S[0][1]);
|
||||
c = this.CC(this.FF, this.F, c, d, a, b, block[10], this.S[0][2]);
|
||||
b = this.CC(this.FF, this.F, b, c, d, a, block[11], this.S[0][3]);
|
||||
a = this.CC(this.FF, this.F, a, b, c, d, block[12], this.S[0][0]);
|
||||
d = this.CC(this.FF, this.F, d, a, b, c, block[13], this.S[0][1]);
|
||||
c = this.CC(this.FF, this.F, c, d, a, b, block[14], this.S[0][2]);
|
||||
b = this.CC(this.FF, this.F, b, c, d, a, block[15], this.S[0][3]);
|
||||
|
||||
// Round 2
|
||||
a = this.CC(this.GG, this.G, a, b, c, d, block[0], this.S[1][0]);
|
||||
d = this.CC(this.GG, this.G, d, a, b, c, block[4], this.S[1][1]);
|
||||
c = this.CC(this.GG, this.G, c, d, a, b, block[8], this.S[1][2]);
|
||||
b = this.CC(this.GG, this.G, b, c, d, a, block[12], this.S[1][3]);
|
||||
a = this.CC(this.GG, this.G, a, b, c, d, block[1], this.S[1][0]);
|
||||
d = this.CC(this.GG, this.G, d, a, b, c, block[5], this.S[1][1]);
|
||||
c = this.CC(this.GG, this.G, c, d, a, b, block[9], this.S[1][2]);
|
||||
b = this.CC(this.GG, this.G, b, c, d, a, block[13], this.S[1][3]);
|
||||
a = this.CC(this.GG, this.G, a, b, c, d, block[2], this.S[1][0]);
|
||||
d = this.CC(this.GG, this.G, d, a, b, c, block[6], this.S[1][1]);
|
||||
c = this.CC(this.GG, this.G, c, d, a, b, block[10], this.S[1][2]);
|
||||
b = this.CC(this.GG, this.G, b, c, d, a, block[14], this.S[1][3]);
|
||||
a = this.CC(this.GG, this.G, a, b, c, d, block[3], this.S[1][0]);
|
||||
d = this.CC(this.GG, this.G, d, a, b, c, block[7], this.S[1][1]);
|
||||
c = this.CC(this.GG, this.G, c, d, a, b, block[11], this.S[1][2]);
|
||||
b = this.CC(this.GG, this.G, b, c, d, a, block[15], this.S[1][3]);
|
||||
|
||||
// Round 3
|
||||
a = this.CC(this.HH, this.H, a, b, c, d, block[0], this.S[2][0]);
|
||||
d = this.CC(this.HH, this.H, d, a, b, c, block[8], this.S[2][1]);
|
||||
c = this.CC(this.HH, this.H, c, d, a, b, block[4], this.S[2][2]);
|
||||
b = this.CC(this.HH, this.H, b, c, d, a, block[12], this.S[2][3]);
|
||||
a = this.CC(this.HH, this.H, a, b, c, d, block[2], this.S[2][0]);
|
||||
d = this.CC(this.HH, this.H, d, a, b, c, block[10], this.S[2][1]);
|
||||
c = this.CC(this.HH, this.H, c, d, a, b, block[6], this.S[2][2]);
|
||||
b = this.CC(this.HH, this.H, b, c, d, a, block[14], this.S[2][3]);
|
||||
a = this.CC(this.HH, this.H, a, b, c, d, block[1], this.S[2][0]);
|
||||
d = this.CC(this.HH, this.H, d, a, b, c, block[9], this.S[2][1]);
|
||||
c = this.CC(this.HH, this.H, c, d, a, b, block[5], this.S[2][2]);
|
||||
b = this.CC(this.HH, this.H, b, c, d, a, block[13], this.S[2][3]);
|
||||
a = this.CC(this.HH, this.H, a, b, c, d, block[3], this.S[2][0]);
|
||||
d = this.CC(this.HH, this.H, d, a, b, c, block[11], this.S[2][1]);
|
||||
c = this.CC(this.HH, this.H, c, d, a, b, block[7], this.S[2][2]);
|
||||
b = this.CC(this.HH, this.H, b, c, d, a, block[15], this.S[2][3]);
|
||||
|
||||
this.state.hash = [
|
||||
(this.state.hash[0] + a) | 0,
|
||||
(this.state.hash[1] + b) | 0,
|
||||
(this.state.hash[2] + c) | 0,
|
||||
(this.state.hash[3] + d) | 0
|
||||
];
|
||||
};
|
||||
/**
|
||||
* @memberOf Md4
|
||||
* @method finalize
|
||||
* @return {HashArray} hash
|
||||
*/
|
||||
Md4.prototype.finalize = function finalize() {
|
||||
// Add padding
|
||||
var padLen = this.state.message.length < 56 ? 56 - this.state.message.length : 120 - this.state.message.length;
|
||||
var padding = new Array(padLen);
|
||||
padding[0] = 0x80;
|
||||
|
||||
// Add length
|
||||
var lengthBits = this.state.length * 8;
|
||||
for (var i = 0; i < 4; i++) {
|
||||
padding.push((lengthBits >> (8 * i)) & 0xff);
|
||||
}
|
||||
// @todo fix length to 64 bit
|
||||
for (i = 0; i < 4; i++) {
|
||||
padding.push(0);
|
||||
}
|
||||
this.updateFromArray(padding);
|
||||
|
||||
var hash = [];
|
||||
for (i = 0; i < this.state.hash.length; i++) {
|
||||
for (var j = 0; j < 4; j++) {
|
||||
hash.push((this.state.hash[i] >> 8 * j) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
// Return hash
|
||||
return CryptoApi.hashArray(hash);
|
||||
};
|
||||
|
||||
CryptoApi.Hashers.add('md4', Md4);
|
||||
return Md4;
|
||||
})(
|
||||
this.CryptoApi || require('./crypto-api')
|
||||
);
|
|
@ -1,125 +0,0 @@
|
|||
/*global require */
|
||||
(/**
|
||||
*
|
||||
* @param {CryptoApi} CryptoApi
|
||||
* @returns {Sha0}
|
||||
*/
|
||||
function (CryptoApi) {
|
||||
'use strict';
|
||||
|
||||
// Transform constants
|
||||
var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
|
||||
|
||||
/**
|
||||
* @class Sha0
|
||||
* @desc Sha0 hasher
|
||||
* @implements HasherInterface
|
||||
* @extends Hasher32be
|
||||
*/
|
||||
var Sha0 = function sha0(name, options) {
|
||||
this.constructor(name, options);
|
||||
};
|
||||
Sha0.prototype = Object.create(CryptoApi.Hasher32be.prototype);
|
||||
/**
|
||||
* @memberOf Sha0
|
||||
* @constructor
|
||||
*/
|
||||
Sha0.prototype.constructor = function (name, options) {
|
||||
CryptoApi.Hasher32be.prototype.constructor.call(this, name, options);
|
||||
/**
|
||||
* @desc Hash state
|
||||
* @memberOf! Sha0#
|
||||
* @alias state.hash
|
||||
* @type {number[]}
|
||||
*/
|
||||
this.state.hash = [
|
||||
0x67452301,
|
||||
0xefcdab89,
|
||||
0x98badcfe,
|
||||
0x10325476,
|
||||
0xc3d2e1f0
|
||||
];
|
||||
this.W = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* @memberOf Sha0
|
||||
* @method processBlock
|
||||
* @param {number[]} M
|
||||
*/
|
||||
Sha0.prototype.processBlock = function processBlock(M) {
|
||||
// Working variables
|
||||
var a = this.state.hash[0] | 0;
|
||||
var b = this.state.hash[1] | 0;
|
||||
var c = this.state.hash[2] | 0;
|
||||
var d = this.state.hash[3] | 0;
|
||||
var e = this.state.hash[4] | 0;
|
||||
|
||||
// Calculate hash
|
||||
for (var i = 0; i < 80; i++) {
|
||||
if (i < 16) {
|
||||
this.W[i] = M[i] | 0;
|
||||
} else {
|
||||
this.W[i] = (this.W[i - 3] ^ this.W[i - 8] ^ this.W[i - 14] ^ this.W[i - 16]) | 0;
|
||||
}
|
||||
|
||||
var t = (CryptoApi.Tools.rotateLeft(a, 5) + e + this.W[i] + K[(i / 20) >> 0]) | 0;
|
||||
if (i < 20) {
|
||||
t = (t + ((b & c) | (~b & d))) | 0;
|
||||
} else if (i < 40) {
|
||||
t = (t + (b ^ c ^ d)) | 0;
|
||||
} else if (i < 60) {
|
||||
t = (t + ((b & c) | (b & d) | (c & d))) | 0;
|
||||
} else {
|
||||
t = (t + (b ^ c ^ d)) | 0;
|
||||
}
|
||||
e = d;
|
||||
d = c;
|
||||
c = CryptoApi.Tools.rotateLeft(b, 30) | 0;
|
||||
b = a;
|
||||
a = t;
|
||||
}
|
||||
|
||||
this.state.hash[0] = (this.state.hash[0] + a) | 0;
|
||||
this.state.hash[1] = (this.state.hash[1] + b) | 0;
|
||||
this.state.hash[2] = (this.state.hash[2] + c) | 0;
|
||||
this.state.hash[3] = (this.state.hash[3] + d) | 0;
|
||||
this.state.hash[4] = (this.state.hash[4] + e) | 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @memberOf Sha0
|
||||
* @method finalize
|
||||
* @return {HashArray} hash
|
||||
*/
|
||||
Sha0.prototype.finalize = function finalize() {
|
||||
// Add padding
|
||||
var padLen = this.state.message.length < 56 ? 56 - this.state.message.length : 120 - this.state.message.length;
|
||||
padLen += 4; // @todo fix length to 64 bit
|
||||
var padding = new Array(padLen);
|
||||
padding[0] = 0x80;
|
||||
|
||||
// Add length
|
||||
var lengthBits = this.state.length * 8;
|
||||
for (var i = 3; i >= 0; i--) {
|
||||
padding.push((lengthBits >> (8 * i)) & 0xff);
|
||||
}
|
||||
|
||||
this.updateFromArray(padding);
|
||||
|
||||
var hash = [];
|
||||
for (var k = 0, l = this.state.hash.length; k < l; k++) {
|
||||
for (var j = 3; j >= 0; j--) {
|
||||
hash.push((this.state.hash[k] >> 8 * j) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
// Return hash
|
||||
return CryptoApi.hashArray(hash);
|
||||
};
|
||||
|
||||
CryptoApi.Hashers.add('sha0', Sha0);
|
||||
return Sha0;
|
||||
})(
|
||||
this.CryptoApi || require('./crypto-api')
|
||||
);
|
|
@ -1,213 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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 () {
|
||||
// Shortcuts
|
||||
var key = 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 {
|
||||
var 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);
|
||||
}());
|
|
@ -1,864 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/**
|
||||
* 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) {
|
||||
// Shortcut
|
||||
var iv = this._iv;
|
||||
|
||||
// Choose mixing block
|
||||
if (iv) {
|
||||
var block = iv;
|
||||
|
||||
// Remove IV for subsequent blocks
|
||||
this._iv = undefined;
|
||||
} else {
|
||||
var 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 () {
|
||||
// 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) {
|
||||
var modeCreator = mode.createEncryptor;
|
||||
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
|
||||
var 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);
|
||||
},
|
||||
|
||||
_doProcessBlock: function (words, offset) {
|
||||
this._mode.processBlock(words, offset);
|
||||
},
|
||||
|
||||
_doFinalize: function () {
|
||||
// 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
|
||||
var finalProcessedBlocks = this._process(!!'flush');
|
||||
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
|
||||
// Process final blocks
|
||||
var 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) {
|
||||
// Shortcuts
|
||||
var ciphertext = cipherParams.ciphertext;
|
||||
var salt = cipherParams.salt;
|
||||
|
||||
// Format
|
||||
if (salt) {
|
||||
var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
|
||||
} else {
|
||||
var 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) {
|
||||
// Parse base64
|
||||
var ciphertext = Base64.parse(openSSLStr);
|
||||
|
||||
// Shortcut
|
||||
var ciphertextWords = ciphertext.words;
|
||||
|
||||
// Test for salt
|
||||
if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
|
||||
// Extract salt
|
||||
var 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
|
||||
// MODIFIED: added cfg.salt param
|
||||
var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, cfg.salt);
|
||||
|
||||
// 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;
|
||||
}
|
||||
});
|
||||
}());
|
|
@ -1,713 +0,0 @@
|
|||
/** @license
|
||||
========================================================================
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/**
|
||||
* CryptoJS core components.
|
||||
*/
|
||||
var CryptoJS = CryptoJS || (function (Math, undefined) {
|
||||
/**
|
||||
* CryptoJS namespace.
|
||||
*/
|
||||
var C = {};
|
||||
|
||||
/**
|
||||
* Library namespace.
|
||||
*/
|
||||
var C_lib = C.lib = {};
|
||||
|
||||
/**
|
||||
* Base object for prototypal inheritance.
|
||||
*/
|
||||
var Base = C_lib.Base = (function () {
|
||||
function F() {}
|
||||
|
||||
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
|
||||
F.prototype = this;
|
||||
var subtype = new F();
|
||||
|
||||
// Augment
|
||||
if (overrides) {
|
||||
subtype.mixIn(overrides);
|
||||
}
|
||||
|
||||
// Create default initializer
|
||||
if (!subtype.hasOwnProperty('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 if (thatWords.length > 0xffff) {
|
||||
// Copy one word at a time
|
||||
for (var i = 0; i < thatSigBytes; i += 4) {
|
||||
thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
|
||||
}
|
||||
} else {
|
||||
// Copy all words at once
|
||||
thisWords.push.apply(thisWords, thatWords);
|
||||
}
|
||||
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 = [];
|
||||
for (var i = 0; i < nBytes; i += 4) {
|
||||
words.push((Math.random() * 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) {
|
||||
// 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
|
||||
var 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));
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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;
|
||||
|
||||
var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
|
||||
|
||||
for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
|
||||
base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
|
||||
}
|
||||
}
|
||||
|
||||
// Add padding
|
||||
var paddingChar = map.charAt(64);
|
||||
if (paddingChar) {
|
||||
while (base64Chars.length % 4) {
|
||||
base64Chars.push(paddingChar);
|
||||
}
|
||||
}
|
||||
|
||||
return base64Chars.join('');
|
||||
},
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
// Ignore padding
|
||||
var paddingChar = map.charAt(64);
|
||||
if (paddingChar) {
|
||||
var paddingIndex = base64Str.indexOf(paddingChar);
|
||||
if (paddingIndex != -1) {
|
||||
base64StrLength = paddingIndex;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert
|
||||
var words = [];
|
||||
var nBytes = 0;
|
||||
for (var i = 0; i < base64StrLength; i++) {
|
||||
if (i % 4) {
|
||||
var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
|
||||
var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
|
||||
words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
|
||||
nBytes++;
|
||||
}
|
||||
}
|
||||
|
||||
return WordArray.create(words, nBytes);
|
||||
},
|
||||
|
||||
_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
|
||||
};
|
||||
}());
|
|
@ -1,135 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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);
|
||||
}
|
||||
}());
|
|
@ -1,118 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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) {
|
||||
// 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);
|
||||
}
|
||||
var 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);
|
||||
};
|
||||
}());
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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 });
|
||||
}
|
||||
};
|
||||
}());
|
|
@ -1,131 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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;
|
||||
}
|
||||
});
|
||||
}());
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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 ||
|
||||
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;
|
||||
}());
|
|
@ -1,254 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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 variables
|
||||
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));
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/**
|
||||
* 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) {
|
||||
// Shortcut
|
||||
var iv = this._iv;
|
||||
|
||||
// Generate keystream
|
||||
if (iv) {
|
||||
var keystream = iv.slice(0);
|
||||
|
||||
// Remove IV for subsequent blocks
|
||||
this._iv = undefined;
|
||||
} else {
|
||||
var keystream = this._prevBlock;
|
||||
}
|
||||
cipher.encryptBlock(keystream, 0);
|
||||
|
||||
// Encrypt
|
||||
for (var i = 0; i < blockSize; i++) {
|
||||
words[offset + i] ^= keystream[i];
|
||||
}
|
||||
}
|
||||
|
||||
return CFB;
|
||||
}());
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/** @license
|
||||
========================================================================
|
||||
CryptoJS.mode.CTRGladman
|
||||
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;
|
||||
}());
|
||||
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/**
|
||||
* 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;
|
||||
}());
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/**
|
||||
* 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;
|
||||
}());
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/**
|
||||
* 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;
|
||||
}());
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
};
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
};
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/**
|
||||
* 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--;
|
||||
}
|
||||
};
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/**
|
||||
* A noop padding strategy.
|
||||
*/
|
||||
CryptoJS.pad.NoPadding = {
|
||||
pad: function () {
|
||||
},
|
||||
|
||||
unpad: function () {
|
||||
}
|
||||
};
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/**
|
||||
* 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;
|
||||
while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
|
||||
i--;
|
||||
}
|
||||
data.sigBytes = i + 1;
|
||||
}
|
||||
};
|
|
@ -1,131 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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);
|
||||
};
|
||||
}());
|
|
@ -1,176 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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);
|
||||
}());
|
|
@ -1,178 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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);
|
||||
}());
|
|
@ -1,125 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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);
|
||||
}());
|
|
@ -1,255 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/** @license
|
||||
========================================================================
|
||||
RIPEMD160
|
||||
(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<<n) | (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));
|
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(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);
|
||||
}());
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue