mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
XOR operation now supports both input and output differentials. Fixes #17
This commit is contained in:
parent
fc9d0a63c2
commit
20d9903572
7 changed files with 47 additions and 39 deletions
|
@ -445,7 +445,8 @@ module.exports = function(grunt) {
|
||||||
deploy_gh_pages: {
|
deploy_gh_pages: {
|
||||||
command: [
|
command: [
|
||||||
"git add build/prod/index.html -v",
|
"git add build/prod/index.html -v",
|
||||||
"git commit -m 'GitHub Pages release'",
|
"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 push origin `git subtree split --prefix build/prod master`:gh-pages --force",
|
||||||
"git reset HEAD~",
|
"git reset HEAD~",
|
||||||
"git checkout build/prod/index.html"
|
"git checkout build/prod/index.html"
|
||||||
|
|
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
|
@ -209,7 +209,7 @@ var OperationConfig = {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"XOR": {
|
"XOR": {
|
||||||
description: "XOR the input with the given key.<br>e.g. <code>fe023da5</code><br><br><strong>Options</strong><br><u>Null preserving:</u> If the current byte is 0x00 or the same as the key, skip it.<br><br><u>Differential:</u> Set the key to the value of the previously decoded byte.",
|
description: "XOR the input with the given key.<br>e.g. <code>fe023da5</code><br><br><strong>Options</strong><br><u>Null preserving:</u> If the current byte is 0x00 or the same as the key, skip it.<br><br><u>Scheme:</u><ul><li>Standard - key is unchanged after each round</li><li>Input differential - key is set to the value of the previous unprocessed byte</li><li>Output differential - key is set to the value of the previous processed byte</li></ul>",
|
||||||
run: BitwiseOp.run_xor,
|
run: BitwiseOp.run_xor,
|
||||||
highlight: true,
|
highlight: true,
|
||||||
highlight_reverse: true,
|
highlight_reverse: true,
|
||||||
|
@ -222,15 +222,15 @@ var OperationConfig = {
|
||||||
value: "",
|
value: "",
|
||||||
toggle_values: BitwiseOp.KEY_FORMAT
|
toggle_values: BitwiseOp.KEY_FORMAT
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Scheme",
|
||||||
|
type: "option",
|
||||||
|
value: BitwiseOp.XOR_SCHEME
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Null preserving",
|
name: "Null preserving",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
value: BitwiseOp.XOR_PRESERVE_NULLS
|
value: BitwiseOp.XOR_PRESERVE_NULLS
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Differential",
|
|
||||||
type: "boolean",
|
|
||||||
value: BitwiseOp.XOR_DIFFERENTIAL
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,10 +19,10 @@ var BitwiseOp = {
|
||||||
* @param {byte_array} key
|
* @param {byte_array} key
|
||||||
* @param {function} func - The bitwise calculation to carry out
|
* @param {function} func - The bitwise calculation to carry out
|
||||||
* @param {boolean} null_preserving
|
* @param {boolean} null_preserving
|
||||||
* @param {boolean} differential
|
* @param {string} scheme
|
||||||
* @returns {byte_array}
|
* @returns {byte_array}
|
||||||
*/
|
*/
|
||||||
_bit_op: function (input, key, func, null_preserving, differential) {
|
_bit_op: function (input, key, func, null_preserving, scheme) {
|
||||||
if (!key || !key.length) key = [0];
|
if (!key || !key.length) key = [0];
|
||||||
var result = [],
|
var result = [],
|
||||||
x = null,
|
x = null,
|
||||||
|
@ -34,8 +34,15 @@ var BitwiseOp = {
|
||||||
o = input[i];
|
o = input[i];
|
||||||
x = null_preserving && (o === 0 || o == k) ? o : func(o, k);
|
x = null_preserving && (o === 0 || o == k) ? o : func(o, k);
|
||||||
result.push(x);
|
result.push(x);
|
||||||
if (differential && !(null_preserving && (o === 0 || o == k))) {
|
if (scheme != "Standard" && !(null_preserving && (o === 0 || o == k))) {
|
||||||
key[i % key.length] = x;
|
switch (scheme) {
|
||||||
|
case "Input differential":
|
||||||
|
key[i % key.length] = x;
|
||||||
|
break;
|
||||||
|
case "Output differential":
|
||||||
|
key[i % key.length] = o;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +59,7 @@ var BitwiseOp = {
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
XOR_DIFFERENTIAL: false,
|
XOR_SCHEME: ["Standard", "Input differential", "Output differential"],
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
@ -68,12 +75,12 @@ var BitwiseOp = {
|
||||||
*/
|
*/
|
||||||
run_xor: function (input, args) {
|
run_xor: function (input, args) {
|
||||||
var key = Utils.format[args[0].option].parse(args[0].string || ""),
|
var key = Utils.format[args[0].option].parse(args[0].string || ""),
|
||||||
null_preserving = args[1],
|
scheme = args[1],
|
||||||
differential = args[2];
|
null_preserving = args[2];
|
||||||
|
|
||||||
key = Utils.word_array_to_byte_array(key);
|
key = Utils.word_array_to_byte_array(key);
|
||||||
|
|
||||||
return BitwiseOp._bit_op(input, key, BitwiseOp._xor, null_preserving, differential);
|
return BitwiseOp._bit_op(input, key, BitwiseOp._xor, null_preserving, scheme);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
203 source files
|
203 source files
|
||||||
104211 lines
|
104218 lines
|
||||||
4.0M size
|
4.0M size
|
||||||
|
|
||||||
136 JavaScript source files
|
136 JavaScript source files
|
||||||
95121 lines
|
95128 lines
|
||||||
3.4M size
|
3.4M size
|
||||||
|
|
||||||
78 third party JavaScript source files
|
78 third party JavaScript source files
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
2.7M size
|
2.7M size
|
||||||
|
|
||||||
58 first party JavaScript source files
|
58 first party JavaScript source files
|
||||||
18744 lines
|
18751 lines
|
||||||
724K size
|
724K size
|
||||||
|
|
||||||
3.1M uncompressed JavaScript size
|
3.1M uncompressed JavaScript size
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue