Added Cascade XOR

This commit is contained in:
George J 2018-04-30 20:30:29 +01:00
parent f7729c0fd2
commit 4ce4a8ef52
2 changed files with 7 additions and 3 deletions

View file

@ -377,7 +377,7 @@ const OperationConfig = {
},
"XOR": {
module: "Default",
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>",
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><li>Cascade - key is set to the input byte shifted by one</li></ul>",
highlight: true,
highlightReverse: true,
inputType: "byteArray",

View file

@ -34,7 +34,6 @@ const BitwiseOp = {
k = key[i % key.length];
o = input[i];
x = nullPreserving && (o === 0 || o === k) ? o : func(o, k);
result.push(x);
if (scheme &&
scheme !== "Standard" &&
!(nullPreserving && (o === 0 || o === k))) {
@ -45,8 +44,13 @@ const BitwiseOp = {
case "Output differential":
key[i % key.length] = o;
break;
case "Cascade":
k ^= input[i + 1];
x = nullPreserving && (o === 0 || o === k) ? o : func(o, k);
break;
}
}
result.push(x);
}
return result;
@ -62,7 +66,7 @@ const BitwiseOp = {
* @constant
* @default
*/
XOR_SCHEME: ["Standard", "Input differential", "Output differential"],
XOR_SCHEME: ["Standard", "Input differential", "Output differential", "Cascade"],
/**
* @constant
* @default