This commit is contained in:
vbnt7143 2019-09-06 17:41:43 +02:00
commit 6bd0fd1a2b
582 changed files with 44141 additions and 7796 deletions

12
tests/operations/Dish.mjs Normal file
View file

@ -0,0 +1,12 @@
import TestRegister from "../../lib/TestRegister.mjs";
import Dish from "../../src/core/Dish.mjs";
import it from "../node/assertionHandler.mjs";
import assert from "assert";
TestRegister.addApiTests([
it("Dish - presentAs: should exist", () => {
const dish = new Dish();
assert(dish.presentAs);
}),
]);

View file

@ -1,96 +0,0 @@
/**
* TestRegister.js
*
* This is so individual files can register their tests in one place, and
* ensure that they will get run by the frontend.
*
* @author tlwr [toby@toby.codes]
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import Chef from "../../src/core/Chef";
(function() {
/**
* Object to store and run the list of tests.
*
* @class
* @constructor
*/
function TestRegister() {
this.tests = [];
}
/**
* Add a list of tests to the register.
*
* @param {Object[]} tests
*/
TestRegister.prototype.addTests = function(tests) {
this.tests = this.tests.concat(tests);
};
/**
* Runs all the tests in the register.
*/
TestRegister.prototype.runTests = function() {
return Promise.all(
this.tests.map(function(test, i) {
const chef = new Chef();
return chef.bake(
test.input,
test.recipeConfig,
{},
0,
false
).then(function(result) {
const ret = {
test: test,
status: null,
output: null,
};
if (result.error) {
if (test.expectedError) {
ret.status = "passing";
} else {
ret.status = "erroring";
ret.output = result.error.displayStr;
}
} else {
if (test.expectedError) {
ret.status = "failing";
ret.output = "Expected an error but did not receive one.";
} else if (result.result === test.expectedOutput) {
ret.status = "passing";
} else if (test.hasOwnProperty("expectedMatch") && test.expectedMatch.test(result.result)) {
ret.status = "passing";
} else {
ret.status = "failing";
const expected = test.expectedOutput ? test.expectedOutput :
test.expectedMatch ? test.expectedMatch.toString() : "unknown";
ret.output = [
"Expected",
"\t" + expected.replace(/\n/g, "\n\t"),
"Received",
"\t" + result.result.replace(/\n/g, "\n\t"),
].join("\n");
}
}
return ret;
});
})
);
};
// Singleton TestRegister, keeping things simple and obvious.
global.TestRegister = global.TestRegister || new TestRegister();
})();
export default global.TestRegister;

View file

@ -10,159 +10,105 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import "babel-polyfill";
// Define global environment functions
global.ENVIRONMENT_IS_WORKER = function() {
return typeof importScripts === "function";
};
global.ENVIRONMENT_IS_NODE = function() {
return typeof process === "object" && typeof require === "function";
};
global.ENVIRONMENT_IS_WEB = function() {
return typeof window === "object";
};
import {
setLongTestFailure,
logTestReport,
} from "../lib/utils.mjs";
import TestRegister from "./TestRegister";
import "./tests/BCD";
import "./tests/BSON";
import "./tests/Base58";
import "./tests/Base64";
import "./tests/Base62";
import "./tests/BitwiseOp";
import "./tests/ByteRepr";
import "./tests/CartesianProduct";
import "./tests/CharEnc";
import "./tests/Checksum";
import "./tests/Ciphers";
import "./tests/Code";
import "./tests/Comment";
import "./tests/Compress";
import "./tests/ConditionalJump";
import "./tests/Crypt";
import "./tests/CSV";
import "./tests/DateTime";
import "./tests/ExtractEmailAddresses";
import "./tests/Fork";
import "./tests/FromDecimal";
import "./tests/Hash";
import "./tests/HaversineDistance";
import "./tests/Hexdump";
import "./tests/Image";
import "./tests/Jump";
import "./tests/JSONBeautify";
import "./tests/JSONMinify";
import "./tests/JWTDecode";
import "./tests/JWTSign";
import "./tests/JWTVerify";
import "./tests/MS";
import "./tests/Magic";
import "./tests/MorseCode";
import "./tests/NetBIOS";
import "./tests/OTP";
import "./tests/PGP";
import "./tests/PHP";
import "./tests/ParseIPRange";
import "./tests/ParseQRCode";
import "./tests/PowerSet";
import "./tests/Regex";
import "./tests/Register";
import "./tests/RemoveDiacritics";
import "./tests/Rotate";
import "./tests/SeqUtils";
import "./tests/SetDifference";
import "./tests/SetIntersection";
import "./tests/SetUnion";
import "./tests/StrUtils";
import "./tests/SymmetricDifference";
import "./tests/TextEncodingBruteForce";
import "./tests/TranslateDateTimeFormat";
import "./tests/Magic";
import "./tests/ParseTLV";
import "./tests/Media";
import "./tests/ToFromInsensitiveRegex";
import TestRegister from "../lib/TestRegister.mjs";
import "./tests/BCD.mjs";
import "./tests/BSON.mjs";
import "./tests/BaconCipher.mjs";
import "./tests/Base58.mjs";
import "./tests/Base64.mjs";
import "./tests/Base62.mjs";
import "./tests/BitwiseOp.mjs";
import "./tests/ByteRepr.mjs";
import "./tests/CartesianProduct.mjs";
import "./tests/CharEnc.mjs";
import "./tests/ChangeIPFormat.mjs";
import "./tests/Charts.mjs";
import "./tests/Checksum.mjs";
import "./tests/Ciphers.mjs";
import "./tests/Code.mjs";
import "./tests/Comment.mjs";
import "./tests/Compress.mjs";
import "./tests/ConditionalJump.mjs";
import "./tests/Crypt.mjs";
import "./tests/CSV.mjs";
import "./tests/DateTime.mjs";
import "./tests/ExtractEmailAddresses.mjs";
import "./tests/Fork.mjs";
import "./tests/FromDecimal.mjs";
import "./tests/Hash.mjs";
import "./tests/HaversineDistance.mjs";
import "./tests/Hexdump.mjs";
import "./tests/Image.mjs";
import "./tests/IndexOfCoincidence.mjs";
import "./tests/Jump.mjs";
import "./tests/JSONBeautify.mjs";
import "./tests/JSONMinify.mjs";
import "./tests/JSONtoCSV.mjs";
import "./tests/JWTDecode.mjs";
import "./tests/JWTSign.mjs";
import "./tests/JWTVerify.mjs";
import "./tests/MS.mjs";
import "./tests/Magic.mjs";
import "./tests/MorseCode.mjs";
import "./tests/NetBIOS.mjs";
import "./tests/OTP.mjs";
import "./tests/PGP.mjs";
import "./tests/PHP.mjs";
import "./tests/ParseIPRange.mjs";
import "./tests/ParseQRCode.mjs";
import "./tests/PowerSet.mjs";
import "./tests/Regex.mjs";
import "./tests/Register.mjs";
import "./tests/RemoveDiacritics.mjs";
import "./tests/Rotate.mjs";
import "./tests/SeqUtils.mjs";
import "./tests/SetDifference.mjs";
import "./tests/SetIntersection.mjs";
import "./tests/SetUnion.mjs";
import "./tests/StrUtils.mjs";
import "./tests/SymmetricDifference.mjs";
import "./tests/TextEncodingBruteForce.mjs";
import "./tests/TranslateDateTimeFormat.mjs";
import "./tests/Magic.mjs";
import "./tests/ParseTLV.mjs";
import "./tests/Media.mjs";
import "./tests/ToFromInsensitiveRegex.mjs";
import "./tests/YARA.mjs";
import "./tests/ConvertCoordinateFormat";
import "./tests/operations/ByteStringLiteral";
import "./tests/ConvertCoordinateFormat.mjs";
import "./tests/Enigma.mjs";
import "./tests/Bombe.mjs";
import "./tests/MultipleBombe.mjs";
import "./tests/Typex.mjs";
import "./tests/BLAKE2b.mjs";
import "./tests/BLAKE2s.mjs";
import "./tests/Protobuf.mjs";
import "./tests/ParseSSHHostKey.mjs";
import "./tests/DefangIP.mjs";
import "./tests/ParseUDP.mjs";
import "./tests/ByteStringLiteral.mjs";
// Cannot test operations that use the File type yet
//import "./tests/SplitColourChannels";
// import "./tests/SplitColourChannels.mjs";
let allTestsPassing = true;
const testStatusCounts = {
total: 0,
// import "./tests/nodeApi/nodeApi.mjs";
// import "./tests/nodeApi/ops.mjs";
const testStatus = {
allTestsPassing: true,
counts: {
total: 0,
}
};
setLongTestFailure();
/**
* Helper function to convert a status to an icon.
*
* @param {string} status
* @returns {string}
*/
function statusToIcon(status) {
const icons = {
erroring: "🔥",
failing: "❌",
passing: "✔️️",
};
return icons[status] || "?";
}
/**
* Displays a given test result in the console.
*
* @param {Object} testResult
*/
function handleTestResult(testResult) {
allTestsPassing = allTestsPassing && testResult.status === "passing";
const newCount = (testStatusCounts[testResult.status] || 0) + 1;
testStatusCounts[testResult.status] = newCount;
testStatusCounts.total += 1;
console.log([
statusToIcon(testResult.status),
testResult.test.name
].join(" "));
if (testResult.output) {
console.log(
testResult.output
.trim()
.replace(/^/, "\t")
.replace(/\n/g, "\n\t")
);
}
}
/**
* Fail if the process takes longer than 60 seconds.
*/
setTimeout(function() {
console.log("Tests took longer than 60 seconds to run, returning.");
process.exit(1);
}, 60 * 1000);
const logOpsTestReport = logTestReport.bind(null, testStatus);
TestRegister.runTests()
.then(function(results) {
results.forEach(handleTestResult);
console.log("\n");
for (const testStatus in testStatusCounts) {
const count = testStatusCounts[testStatus];
if (count > 0) {
console.log(testStatus.toUpperCase(), count);
}
}
if (!allTestsPassing) {
console.log("\nFailing tests:\n");
results.filter(r => r.status !== "passing").forEach(handleTestResult);
}
process.exit(allTestsPassing ? 0 : 1);
});
.then(logOpsTestReport);

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,56 @@
/**
* BitwiseOp tests
*
* @author h345983745
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "BLAKE2b: 512 - Hello World",
input: "Hello World",
expectedOutput: "4386a08a265111c9896f56456e2cb61a64239115c4784cf438e36cc851221972da3fb0115f73cd02486254001f878ab1fd126aac69844ef1c1ca152379d0a9bd",
recipeConfig: [
{ "op": "BLAKE2b",
"args": ["512", "Hex", {string: "", option: "UTF8"}] }
]
},
{
name: "BLAKE2b: 384 - Hello World",
input: "Hello World",
expectedOutput: "4d388e82ca8f866e606b6f6f0be910abd62ad6e98c0adfc27cf35acf948986d5c5b9c18b6f47261e1e679eb98edf8e2d",
recipeConfig: [
{ "op": "BLAKE2b",
"args": ["384", "Hex", {string: "", option: "UTF8"}] }
]
},
{
name: "BLAKE2b: 256 - Hello World",
input: "Hello World",
expectedOutput: "1dc01772ee0171f5f614c673e3c7fa1107a8cf727bdf5a6dadb379e93c0d1d00",
recipeConfig: [
{ "op": "BLAKE2b",
"args": ["256", "Hex", {string: "", option: "UTF8"}] }
]
},
{
name: "BLAKE2b: 160 - Hello World",
input: "Hello World",
expectedOutput: "6a8489e6fd6e51fae12ab271ec7fc8134dd5d737",
recipeConfig: [
{ "op": "BLAKE2b",
"args": ["160", "Hex", {string: "", option: "UTF8"}] }
]
},
{
name: "BLAKE2b: Key Test",
input: "message data",
expectedOutput: "3d363ff7401e02026f4a4687d4863ced",
recipeConfig: [
{ "op": "BLAKE2b",
"args": ["128", "Hex", {string: "pseudorandom key", option: "UTF8"}] }
]
}
]);

View file

@ -0,0 +1,47 @@
/**
* BitwiseOp tests
*
* @author h345983745
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "BLAKE2s: 256 - Hello World",
input: "Hello World",
expectedOutput: "7706af019148849e516f95ba630307a2018bb7bf03803eca5ed7ed2c3c013513",
recipeConfig: [
{ "op": "BLAKE2s",
"args": ["256", "Hex", {string: "", option: "UTF8"}] }
]
},
{
name: "BLAKE2s: 160 - Hello World",
input: "Hello World",
expectedOutput: "0e4fcfc2ee0097ac1d72d70b595a39e09a3c7c7e",
recipeConfig: [
{ "op": "BLAKE2s",
"args": ["160", "Hex", {string: "", option: "UTF8"}] }
]
},
{
name: "BLAKE2s: 128 - Hello World",
input: "Hello World",
expectedOutput: "9964ee6f36126626bf864363edfa96f6",
recipeConfig: [
{ "op": "BLAKE2s",
"args": ["128", "Hex", {string: "", option: "UTF8"}] }
]
},
{
name: "BLAKE2s: Key Test",
input: "Hello World",
expectedOutput: "9964ee6f36126626bf864363edfa96f6",
recipeConfig: [
{ "op": "BLAKE2s",
"args": ["128", "Hex", {string: "", option: "UTF8"}] }
]
}
]);

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,433 @@
/**
* Bacon Cipher tests.
*
* @author Karsten Silkenbäumer [github.com/kassi]
* @copyright Karsten Silkenbäumer 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister";
import { BACON_ALPHABETS, BACON_TRANSLATIONS } from "../../../src/core/lib/Bacon";
const alphabets = Object.keys(BACON_ALPHABETS);
const translations = BACON_TRANSLATIONS;
TestRegister.addTests([
{
name: "Bacon Decode: no input",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[0], translations[0], false]
}
],
},
{
name: "Bacon Decode: reduced alphabet 0/1",
input: "00011 00100 00010 01101 00011 01000 01100 00110 00001 00000 00010 01101 01100 10100 01101 10000 01001 10001",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[0], translations[0], false]
}
],
},
{
name: "Bacon Decode: reduced alphabet 0/1 inverse",
input: "11100 11011 11101 10010 11100 10111 10011 11001 11110 11111 11101 10010 10011 01011 10010 01111 10110 01110",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[0], translations[0], true]
}
],
},
{
name: "Bacon Decode: reduced alphabet A/B lower case",
input: "aaabb aabaa aaaba abbab aaabb abaaa abbaa aabba aaaab aaaaa aaaba abbab abbaa babaa abbab baaaa abaab baaab",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[0], translations[1], false]
}
],
},
{
name: "Bacon Decode: reduced alphabet A/B lower case inverse",
input: "bbbaa bbabb bbbab baaba bbbaa babbb baabb bbaab bbbba bbbbb bbbab baaba baabb ababb baaba abbbb babba abbba",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[0], translations[1], true]
}
],
},
{
name: "Bacon Decode: reduced alphabet A/B upper case",
input: "AAABB AABAA AAABA ABBAB AAABB ABAAA ABBAA AABBA AAAAB AAAAA AAABA ABBAB ABBAA BABAA ABBAB BAAAA ABAAB BAAAB",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[0], translations[1], false]
}
],
},
{
name: "Bacon Decode: reduced alphabet A/B upper case inverse",
input: "BBBAA BBABB BBBAB BAABA BBBAA BABBB BAABB BBAAB BBBBA BBBBB BBBAB BAABA BAABB ABABB BAABA ABBBB BABBA ABBBA",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[0], translations[1], true]
}
],
},
{
name: "Bacon Decode: reduced alphabet case code",
input: "thiS IsaN exampLe oF ThE bacON cIpher WIth upPPercasE letters tRanSLaTiNG to OnEs anD LoWErcase To zERoes. KS",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[0], translations[2], false]
}
],
},
{
name: "Bacon Decode: reduced alphabet case code inverse",
input: "THIs iS An EXAMPlE Of tHe BACon CiPHER wiTH UPppERCASe LETTERS TrANslAtIng TO oNeS ANd lOweRCASE tO ZerOES. ks",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[0], translations[2], true]
}
],
},
{
name: "Bacon Decode: reduced alphabet case code",
input: "A little example of the Bacon Cipher to be decoded. It is a working example and shorter than my others, but it anyways works tremendously. And just that's important, correct?",
expectedOutput: "DECODE",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[0], translations[3], false]
}
],
},
{
name: "Bacon Decode: reduced alphabet case code inverse",
input: "Well, there's now another example which will be not only strange to read but sound weird for everyone not knowing what the thing is about. Nevertheless, works great out of the box.",
expectedOutput: "DECODE",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[0], translations[3], true]
}
],
},
{
name: "Bacon Decode: complete alphabet 0/1",
input: "00011 00100 00010 01110 00011 01000 01101 00110 00001 00000 00010 01110 01101 10110 01110 10001 01010 10010",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[1], translations[0], false]
}
],
},
{
name: "Bacon Decode: complete alphabet 0/1 inverse",
input: "11100 11011 11101 10001 11100 10111 10010 11001 11110 11111 11101 10001 10010 01001 10001 01110 10101 01101",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[1], translations[0], true]
}
],
},
{
name: "Bacon Decode: complete alphabet A/B lower case",
input: "aaabb aabaa aaaba abbba aaabb abaaa abbab aabba aaaab aaaaa aaaba abbba abbab babba abbba baaab ababa baaba",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[1], translations[1], false]
}
],
},
{
name: "Bacon Decode: complete alphabet A/B lower case inverse",
input: "bbbaa bbabb bbbab baaab bbbaa babbb baaba bbaab bbbba bbbbb bbbab baaab baaba abaab baaab abbba babab abbab",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[1], translations[1], true]
}
],
},
{
name: "Bacon Decode: complete alphabet A/B upper case",
input: "AAABB AABAA AAABA ABBBA AAABB ABAAA ABBAB AABBA AAAAB AAAAA AAABA ABBBA ABBAB BABBA ABBBA BAAAB ABABA BAABA",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[1], translations[1], false]
}
],
},
{
name: "Bacon Decode: complete alphabet A/B upper case inverse",
input: "BBBAA BBABB BBBAB BAAAB BBBAA BABBB BAABA BBAAB BBBBA BBBBB BBBAB BAAAB BAABA ABAAB BAAAB ABBBA BABAB ABBAB",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[1], translations[1], true]
}
],
},
{
name: "Bacon Decode: complete alphabet case code",
input: "thiS IsaN exampLe oF THe bacON cIpher WItH upPPercasE letters tRanSLAtiNG tO OnES anD LOwErcaSe To ZeRoeS. kS",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[1], translations[2], false]
}
],
},
{
name: "Bacon Decode: complete alphabet case code inverse",
input: "THIs iSAn EXAMPlE Of thE BACon CiPHER wiTh UPppERCASe LETTERS TrANslaTIng To zEroES and LoWERcAsE tO oNEs. Ks",
expectedOutput: "DECODINGBACONWORKS",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[1], translations[2], true]
}
],
},
{
name: "Bacon Decode: complete alphabet case code",
input: "A little example of the Bacon Cipher to be decoded. It is a working example and shorter than the first, but it anyways works tremendously. And just that's important, correct?",
expectedOutput: "DECODE",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[1], translations[3], false]
}
],
},
{
name: "Bacon Decode: complete alphabet case code inverse",
input: "Well, there's now another example which will be not only strange to read but sound weird for everyone knowing nothing what the thing is about. Nevertheless, works great out of the box. ",
expectedOutput: "DECODE",
recipeConfig: [
{
op: "Bacon Cipher Decode",
args: [alphabets[1], translations[3], true]
}
],
},
{
name: "Bacon Encode: no input",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[0], translations[0], false, false]
}
],
},
{
name: "Bacon Encode: reduced alphabet 0/1",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "10010 00111 00100 10000 00100 10001 00000 00101 01101 10101 00000 01100 00011 01000 10010 01000 10011 01011 01110 10001 01101 10011 00100 10000 10010 00111 00100 00101 00100 01100 00010 00100",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[0], translations[0], false, false]
}
],
},
{
name: "Bacon Encode: reduced alphabet 0/1 inverse",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "01101 11000 11011 01111 11011 01110 11111 11010 10010 01010 11111 10011 11100 10111 01101 10111 01100 10100 10001 01110 10010 01100 11011 01111 01101 11000 11011 11010 11011 10011 11101 11011",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[0], translations[0], false, true]
}
],
},
{
name: "Bacon Encode: reduced alphabet 0/1, keeping extra characters",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "1001000111001001000000100'10001 00000 001010110110101, 000000110000011 0100010010 0100010011010110111010001 01101100110010010000 100100011100100 0010100100011000001000100.",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[0], translations[0], true, false]
}
],
},
{
name: "Bacon Encode: reduced alphabet 0/1 inverse, keeping extra characters",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "0110111000110110111111011'01110 11111 110101001001010, 111111001111100 1011101101 1011101100101001000101110 10010011001101101111 011011100011011 1101011011100111110111011.",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[0], translations[0], true, true]
}
],
},
{
name: "Bacon Encode: reduced alphabet A/B",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "BAABA AABBB AABAA BAAAA AABAA BAAAB AAAAA AABAB ABBAB BABAB AAAAA ABBAA AAABB ABAAA BAABA ABAAA BAABB ABABB ABBBA BAAAB ABBAB BAABB AABAA BAAAA BAABA AABBB AABAA AABAB AABAA ABBAA AAABA AABAA",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[0], translations[1], false, false]
}
],
},
{
name: "Bacon Encode: reduced alphabet A/B inverse",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "ABBAB BBAAA BBABB ABBBB BBABB ABBBA BBBBB BBABA BAABA ABABA BBBBB BAABB BBBAA BABBB ABBAB BABBB ABBAA BABAA BAAAB ABBBA BAABA ABBAA BBABB ABBBB ABBAB BBAAA BBABB BBABA BBABB BAABB BBBAB BBABB",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[0], translations[1], false, true]
}
],
},
{
name: "Bacon Encode: reduced alphabet A/B, keeping extra characters",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "BAABAAABBBAABAABAAAAAABAA'BAAAB AAAAA AABABABBABBABAB, AAAAAABBAAAAABB ABAAABAABA ABAAABAABBABABBABBBABAAAB ABBABBAABBAABAABAAAA BAABAAABBBAABAA AABABAABAAABBAAAAABAAABAA.",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[0], translations[1], true, false]
}
],
},
{
name: "Bacon Encode: reduced alphabet A/B inverse, keeping extra characters",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "ABBABBBAAABBABBABBBBBBABB'ABBBA BBBBB BBABABAABAABABA, BBBBBBAABBBBBAA BABBBABBAB BABBBABBAABABAABAAABABBBA BAABAABBAABBABBABBBB ABBABBBAAABBABB BBABABBABBBAABBBBBABBBABB.",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[0], translations[1], true, true]
}
],
},
{
name: "Bacon Encode: complete alphabet 0/1",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "10011 00111 00100 10001 00100 10010 00000 00101 01110 10111 00000 01101 00011 01000 10011 01001 10100 01100 01111 10010 01110 10101 00100 10001 10011 00111 00100 00101 00100 01101 00010 00100",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[1], translations[0], false, false]
}
],
},
{
name: "Bacon Encode: complete alphabet 0/1 inverse",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "01100 11000 11011 01110 11011 01101 11111 11010 10001 01000 11111 10010 11100 10111 01100 10110 01011 10011 10000 01101 10001 01010 11011 01110 01100 11000 11011 11010 11011 10010 11101 11011",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[1], translations[0], false, true]
}
],
},
{
name: "Bacon Encode: complete alphabet 0/1, keeping extra characters",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "1001100111001001000100100'10010 00000 001010111010111, 000000110100011 0100010011 0100110100011000111110010 01110101010010010001 100110011100100 0010100100011010001000100.",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[1], translations[0], true, false]
}
],
},
{
name: "Bacon Encode: complete alphabet 0/1 inverse, keeping extra characters",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "0110011000110110111011011'01101 11111 110101000101000, 111111001011100 1011101100 1011001011100111000001101 10001010101101101110 011001100011011 1101011011100101110111011.",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[1], translations[0], true, true]
}
],
},
{
name: "Bacon Encode: complete alphabet A/B",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "BAABB AABBB AABAA BAAAB AABAA BAABA AAAAA AABAB ABBBA BABBB AAAAA ABBAB AAABB ABAAA BAABB ABAAB BABAA ABBAA ABBBB BAABA ABBBA BABAB AABAA BAAAB BAABB AABBB AABAA AABAB AABAA ABBAB AAABA AABAA",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[1], translations[1], false, false]
}
],
},
{
name: "Bacon Encode: complete alphabet A/B inverse",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "ABBAA BBAAA BBABB ABBBA BBABB ABBAB BBBBB BBABA BAAAB ABAAA BBBBB BAABA BBBAA BABBB ABBAA BABBA ABABB BAABB BAAAA ABBAB BAAAB ABABA BBABB ABBBA ABBAA BBAAA BBABB BBABA BBABB BAABA BBBAB BBABB",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[1], translations[1], false, true]
}
],
},
{
name: "Bacon Encode: complete alphabet A/B, keeping extra characters",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "BAABBAABBBAABAABAAABAABAA'BAABA AAAAA AABABABBBABABBB, AAAAAABBABAAABB ABAAABAABB ABAABBABAAABBAAABBBBBAABA ABBBABABABAABAABAAAB BAABBAABBBAABAA AABABAABAAABBABAAABAAABAA.",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[1], translations[1], true, false]
}
],
},
{
name: "Bacon Encode: complete alphabet A/B inverse, keeping extra characters",
input: "There's a fox, and it jumps over the fence.",
expectedOutput: "ABBAABBAAABBABBABBBABBABB'ABBAB BBBBB BBABABAAABABAAA, BBBBBBAABABBBAA BABBBABBAA BABBAABABBBAABBBAAAAABBAB BAAABABABABBABBABBBA ABBAABBAAABBABB BBABABBABBBAABABBBABBBABB.",
recipeConfig: [
{
op: "Bacon Cipher Encode",
args: [alphabets[1], translations[1], true, true]
}
],
},
]);

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -7,7 +7,7 @@
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,242 @@
/**
* Bombe machine tests.
* @author s2224834
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
// Plugboard for this test is BO LC KE GA
name: "Bombe: 3 rotor (self-stecker)",
input: "BBYFLTHHYIJQAYBBYS",
expectedMatch: /<td>LGA<\/td> {2}<td>SS<\/td> {2}<td>VFISUSGTKSTMPSUNAK<\/td>/,
recipeConfig: [
{
"op": "Bombe",
"args": [
"3-rotor",
"",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"THISISATESTMESSAGE", 0, false
]
}
]
},
{
// This test produces a menu that doesn't use the first letter, which is also a good test
name: "Bombe: 3 rotor (other stecker)",
input: "JBYALIHDYNUAAVKBYM",
expectedMatch: /<td>LGA<\/td> {2}<td>AG<\/td> {2}<td>QFIMUMAFKMQSKMYNGW<\/td>/,
recipeConfig: [
{
"op": "Bombe",
"args": [
"3-rotor",
"",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"THISISATESTMESSAGE", 0, false
]
}
]
},
{
name: "Bombe: crib offset",
input: "AAABBYFLTHHYIJQAYBBYS", // first three chars here are faked
expectedMatch: /<td>LGA<\/td> {2}<td>SS<\/td> {2}<td>VFISUSGTKSTMPSUNAK<\/td>/,
recipeConfig: [
{
"op": "Bombe",
"args": [
"3-rotor",
"",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"THISISATESTMESSAGE", 3, false
]
}
]
},
{
name: "Bombe: multiple stops",
input: "BBYFLTHHYIJQAYBBYS",
expectedMatch: /<td>LGA<\/td> {2}<td>TT<\/td> {2}<td>VFISUSGTKSTMPSUNAK<\/td>/,
recipeConfig: [
{
"op": "Bombe",
"args": [
"3-rotor",
"",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"THISISATESTM", 0, false
]
}
]
},
{
name: "Bombe: checking machine",
input: "BBYFLTHHYIJQAYBBYS",
expectedMatch: /<td>LGA<\/td> {2}<td>TT AG BO CL EK FF HH II JJ SS YY<\/td> {2}<td>THISISATESTMESSAGE<\/td>/,
recipeConfig: [
{
"op": "Bombe",
"args": [
"3-rotor",
"",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"THISISATESTM", 0, true
]
}
]
},
// This test is a bit slow - it takes about 12s on my test hardware
{
name: "Bombe: 4 rotor",
input: "LUOXGJSHGEDSRDOQQX",
expectedMatch: /<td>LHSC<\/td> {2}<td>SS<\/td> {2}<td>HHHSSSGQUUQPKSEKWK<\/td>/,
recipeConfig: [
{
"op": "Bombe",
"args": [
"4-rotor",
"LEYJVCNIXWPBQMDRTAKZGFUHOS", // Beta
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
"AE BN CK DQ FU GY HW IJ LO MP RX SZ TV", // B thin
"THISISATESTMESSAGE", 0, false
]
}
]
},
{
name: "Bombe: no crib",
input: "JBYALIHDYNUAAVKBYM",
expectedMatch: /Crib cannot be empty/,
recipeConfig: [
{
"op": "Bombe",
"args": [
"3-rotor",
"",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"", 0, false
]
}
]
},
{
name: "Bombe: short crib",
input: "JBYALIHDYNUAAVKBYM",
expectedMatch: /Crib is too short/,
recipeConfig: [
{
"op": "Bombe",
"args": [
"3-rotor",
"",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"A", 0, false
]
}
]
},
{
name: "Bombe: invalid crib",
input: "JBYALIHDYNUAAVKBYM",
expectedMatch: /Invalid crib: .* in both ciphertext and crib/,
recipeConfig: [
{
"op": "Bombe",
"args": [
"3-rotor",
"",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"AAAAAAAA", 0, false
]
}
]
},
{
name: "Bombe: long crib",
input: "JBYALIHDYNUAAVKBYM",
expectedMatch: /Crib overruns supplied ciphertext/,
recipeConfig: [
{
"op": "Bombe",
"args": [
"3-rotor",
"",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"CCCCCCCCCCCCCCCCCCCCCC", 0, false
]
}
]
},
{
name: "Bombe: really long crib",
input: "BBBBBBBBBBBBBBBBBBBBBBBBBB",
expectedMatch: /Crib is too long/,
recipeConfig: [
{
"op": "Bombe",
"args": [
"3-rotor",
"",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"AAAAAAAAAAAAAAAAAAAAAAAAAA", 0, false
]
}
]
},
{
name: "Bombe: negative offset",
input: "AAAAA",
expectedMatch: /Offset cannot be negative/,
recipeConfig: [
{
"op": "Bombe",
"args": [
"3-rotor",
"",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"BBBBB", -1, false
]
}
]
},
// Enigma tests cover validation of rotors and reflector
]);

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
const EXAMPLE_CSV = `A,B,C,D,E,F\r
1,2,3,4,5,6\r

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,52 @@
/**
* Change IP format tests.
*
* @author Chris Smith
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Change IP format: Dotted Decimal to Hex",
input: "192.168.1.1",
expectedOutput: "c0a80101",
recipeConfig: [
{
op: "Change IP format",
args: ["Dotted Decimal", "Hex"],
},
],
}, {
name: "Change IP format: Decimal to Dotted Decimal",
input: "3232235777",
expectedOutput: "192.168.1.1",
recipeConfig: [
{
op: "Change IP format",
args: ["Decimal", "Dotted Decimal"],
},
],
}, {
name: "Change IP format: Hex to Octal",
input: "c0a80101",
expectedOutput: "030052000401",
recipeConfig: [
{
op: "Change IP format",
args: ["Hex", "Octal"],
},
],
}, {
name: "Change IP format: Octal to Decimal",
input: "030052000401",
expectedOutput: "3232235777",
recipeConfig: [
{
op: "Change IP format",
args: ["Octal", "Decimal"],
},
],
},
]);

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,55 @@
/**
* Chart tests.
*
* @author Matt C [me@mitt.dev]
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Scatter chart",
input: "100 100\n200 200\n300 300\n400 400\n500 500",
expectedMatch: /^<svg width/,
recipeConfig: [
{
"op": "Scatter chart",
"args": ["Line feed", "Space", false, "time", "stress", "black", 5, false]
}
],
},
{
name: "Hex density chart",
input: "100 100\n200 200\n300 300\n400 400\n500 500",
expectedMatch: /^<svg width/,
recipeConfig: [
{
"op": "Hex Density chart",
"args": ["Line feed", "Space", 25, 15, true, "", "", true, "white", "black", true]
}
],
},
{
name: "Series chart",
input: "100 100 100\n200 200 200\n300 300 300\n400 400 400\n500 500 500",
expectedMatch: /^<svg width/,
recipeConfig: [
{
"op": "Series chart",
"args": ["Line feed", "Space", "", 1, "mediumseagreen, dodgerblue, tomato"]
}
],
},
{
name: "Heatmap chart",
input: "100 100\n200 200\n300 300\n400 400\n500 500",
expectedMatch: /^<svg width/,
recipeConfig: [
{
"op": "Heatmap chart",
"args": ["Line feed", "Space", 25, 25, true, "", "", false, "white", "black"]
}
],
},
]);

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
const BASIC_STRING = "The ships hung in the sky in much the same way that bricks don't.";
const UTF8_STR = "ნუ პანიკას";
@ -29,6 +29,127 @@ const ALL_BYTES = [
].join("");
TestRegister.addTests([
{
name: "CRC-8: nothing",
input: "",
expectedOutput: "00",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8"]
}
]
},
{
name: "CRC-8: default check",
input: "123456789",
expectedOutput: "f4",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8"]
}
]
},
{
name: "CRC-8: CDMA2000",
input: "123456789",
expectedOutput: "da",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/CDMA2000"]
}
]
},
{
name: "CRC-8: DARC",
input: "123456789",
expectedOutput: "15",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/DARC"]
}
]
},
{
name: "CRC-8: DVB-S2",
input: "123456789",
expectedOutput: "bc",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/DVB-S2"]
}
]
},
{
name: "CRC-8: EBU",
input: "123456789",
expectedOutput: "97",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/EBU"]
}
]
},
{
name: "CRC-8: I-CODE",
input: "123456789",
expectedOutput: "7e",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/I-CODE"]
}
]
},
{
name: "CRC-8: ITU",
input: "123456789",
expectedOutput: "a1",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/ITU"]
}
]
},
{
name: "CRC-8: MAXIM",
input: "123456789",
expectedOutput: "a1",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/MAXIM"]
}
]
},
{
name: "CRC-8: ROHC",
input: "123456789",
expectedOutput: "d0",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/ROHC"]
}
]
},
{
name: "CRC-8: WCDMA",
input: "123456789",
expectedOutput: "25",
recipeConfig: [
{
"op": "CRC-8 Checksum",
"args": ["CRC-8/WCDMA"]
}
]
},
{
name: "CRC-16: nothing",
input: "",
@ -116,5 +237,5 @@ TestRegister.addTests([
"args": []
}
]
},
}
]);

View file

@ -7,7 +7,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([

View file

@ -7,7 +7,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
const JSON_TEST_DATA = {
"store": {

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -18,7 +18,7 @@
* UTM: 30N 699456 5709791,
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
/**
@ -18,6 +18,42 @@ TestRegister.addTests([
*
* All random data blocks (binary input, keys and IVs) were generated from /dev/urandom using dd:
* > dd if=/dev/urandom of=key.txt bs=16 count=1
*
*
* The following is a Python script used to generate the AES-GCM tests.
* It uses PyCryptodome (https://www.pycryptodome.org) to handle the AES encryption and decryption.
*
* from Crypto.Cipher import AES
* import binascii
* input_data = "0123456789ABCDEF"
* key = binascii.unhexlify("00112233445566778899aabbccddeeff")
* iv = binascii.unhexlify("ffeeddccbbaa99887766554433221100")
*
* cipher = AES.new(key, AES.MODE_GCM, nonce=iv)
* cipher_text, tag = cipher.encrypt_and_digest(binascii.unhexlify(input_data))
*
* cipher = AES.new(key, AES.MODE_GCM, nonce=iv)
* decrypted = cipher.decrypt_and_verify(cipher_text, tag)
*
* key = binascii.hexlify(key).decode("UTF-8")
* iv = binascii.hexlify(iv).decode("UTF-8")
* cipher_text = binascii.hexlify(cipher_text).decode("UTF-8")
* tag = binascii.hexlify(tag).decode("UTF-8")
* decrypted = binascii.hexlify(decrypted).decode("UTF-8")
*
* print("Key: {}\nIV : {}\nInput data: {}\n\nEncrypted ciphertext: {}\nGCM tag: {}\n\nDecrypted plaintext : {}".format(key, iv, input_data, cipher_text, tag, decrypted))
*
*
* Outputs:
* Key: 00112233445566778899aabbccddeeff
* IV : ffeeddccbbaa99887766554433221100
* Input data: 0123456789ABCDEF
*
* Encrypted ciphertext: 8feeafedfdb2f6f9
* GCM tag: 654ef4957c6e2b0cc6501d8f9bcde032
*
* Decrypted plaintext : 0123456789abcdef
*/
{
name: "AES Encrypt: no key",
@ -54,6 +90,21 @@ The following algorithms will be used based on the size of the key:
}
],
},
{
name: "AES Encrypt: AES-128-CTR, no IV, ASCII",
input: "The quick brown fox jumps over the lazy dog.",
expectedOutput: "a98c9e8e3b7c894384d740e4f0f4ed0be2bbb1e0e13a255812c3c6b0a629e4ad759c075b2469c6f4fb2c0cf9",
recipeConfig: [
{
"op": "AES Encrypt",
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""},
"CTR", "Raw", "Hex"
]
}
],
},
{
name: "AES Encrypt: AES-128-CBC with IV, ASCII",
input: "The quick brown fox jumps over the lazy dog.",
@ -209,9 +260,9 @@ Tag: 16a3e732a605cc9ca29108f742ca0743`,
{
name: "AES Encrypt: AES-128-GCM, Binary",
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
expectedOutput: `fa17fcbf5e8763322c1b0c8562e1512ed9d702ef70c1643572b9de3e34ae6b535e6c1b992432aa6d06fb6f80c861262aef66e7c26035afe77bd3861261e4e092b523f058f8ebef2143db21bc16d02f7a011efb07419300cb41c3b884d1d8d6a766b8963c
expectedOutput: `5a29debb5c5f38cdf8aee421bd94dbbf3399947faddf205f88b3ad8ecb0c51214ec0e28bf78942dfa212d7eb15259bbdcac677b4c05f473eeb9331d74f31d441d97d56eb5c73b586342d72128ca528813543dc0fc7eddb7477172cc9194c18b2e1383e4e
Tag: fa6bbb34c8cde65a3d7b93fb094fc84f`,
Tag: 70fad2ca19412c20f40fd06918736e56`,
recipeConfig: [
{
"op": "AES Encrypt",
@ -301,9 +352,9 @@ Tag: fa6bbb34c8cde65a3d7b93fb094fc84f`,
{
name: "AES Encrypt: AES-192-GCM, Binary",
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
expectedOutput: `ed22946f96964d300b45f5ce2d9601ba87682da1a603c90e6d4f7738729b0602f613ee392c9bfc7792594474f1213fb99185851f02ece4df0e93995e49f97aa4d0a337d7a80d83e4219dae5a3d36658f8659cdd5ed7c32707f98656fab7fb43f7a61e37c
expectedOutput: `318b479d919d506f0cd904f2676fab263a7921b6d7e0514f36e03ae2333b77fa66ef5600babcb2ee9718aeb71fc357412343c1f2cb351d8715bb0aedae4a6468124f9c4aaf6a721b306beddbe63a978bec8baeeba4b663be33ee5bc982746bd4aed1c38b
Tag: be17cb31edb77f648b9d1032b235b33d`,
Tag: 86db597d5302595223cadbd990f1309b`,
recipeConfig: [
{
"op": "AES Encrypt",
@ -393,9 +444,9 @@ Tag: be17cb31edb77f648b9d1032b235b33d`,
{
name: "AES Encrypt: AES-256-GCM, Binary",
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
expectedOutput: `e3f1b236eaf3b9df69df8133a1b417fa42b242d8ad49e4d2f3469aca7e2a41737e4f2c8a0d212143287088fad51743577dc6dfa8ed328ca90113cbeb9b137926b2168cc037bdc371777e6ee02b9d9c017b6054fd83d43b4885fbe9c044a8574f1491a893
expectedOutput: `1287f188ad4d7ab0d9ff69b3c29cb11f861389532d8cb9337181da2e8cfc74a84927e8c0dd7a28a32fd485afe694259a63c199b199b95edd87c7aa95329feac340f2b78b72956a85f367044d821766b1b7135815571df44900695f1518cf3ae38ecb650f
Tag: 23ddbd3ee4de33f98a9ea9a170bdf268`,
Tag: 821b1e5f32dad052e502775a523d957a`,
recipeConfig: [
{
"op": "AES Encrypt",
@ -645,6 +696,22 @@ The following algorithms will be used based on the size of the key:
}
],
},
{
name: "AES Decrypt: AES-128-CTR, no IV, ASCII",
input: "a98c9e8e3b7c894384d740e4f0f4ed0be2bbb1e0e13a255812c3c6b0a629e4ad759c075b2469c6f4fb2c0cf9",
expectedOutput: "The quick brown fox jumps over the lazy dog.",
recipeConfig: [
{
"op": "AES Decrypt",
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""},
"CTR", "Hex", "Raw",
{"option": "Hex", "string": ""}
]
}
],
},
{
name: "AES Decrypt: AES-128-CBC with IV, ASCII",
input: "4fa077d50cc71a57393e7b542c4e3aea0fb75383b97083f2f568ffc13c0e7a47502ec6d9f25744a061a3a5e55fe95e8d",
@ -807,7 +874,7 @@ The following algorithms will be used based on the size of the key:
},
{
name: "AES Decrypt: AES-128-GCM, Binary",
input: "fa17fcbf5e8763322c1b0c8562e1512ed9d702ef70c1643572b9de3e34ae6b535e6c1b992432aa6d06fb6f80c861262aef66e7c26035afe77bd3861261e4e092b523f058f8ebef2143db21bc16d02f7a011efb07419300cb41c3b884d1d8d6a766b8963c",
input: "5a29debb5c5f38cdf8aee421bd94dbbf3399947faddf205f88b3ad8ecb0c51214ec0e28bf78942dfa212d7eb15259bbdcac677b4c05f473eeb9331d74f31d441d97d56eb5c73b586342d72128ca528813543dc0fc7eddb7477172cc9194c18b2e1383e4e",
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
recipeConfig: [
{
@ -816,7 +883,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "fa6bbb34c8cde65a3d7b93fb094fc84f"}
{"option": "Hex", "string": "70fad2ca19412c20f40fd06918736e56"}
]
}
],
@ -903,7 +970,7 @@ The following algorithms will be used based on the size of the key:
},
{
name: "AES Decrypt: AES-192-GCM, Binary",
input: "ed22946f96964d300b45f5ce2d9601ba87682da1a603c90e6d4f7738729b0602f613ee392c9bfc7792594474f1213fb99185851f02ece4df0e93995e49f97aa4d0a337d7a80d83e4219dae5a3d36658f8659cdd5ed7c32707f98656fab7fb43f7a61e37c",
input: "318b479d919d506f0cd904f2676fab263a7921b6d7e0514f36e03ae2333b77fa66ef5600babcb2ee9718aeb71fc357412343c1f2cb351d8715bb0aedae4a6468124f9c4aaf6a721b306beddbe63a978bec8baeeba4b663be33ee5bc982746bd4aed1c38b",
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
recipeConfig: [
{
@ -912,7 +979,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "be17cb31edb77f648b9d1032b235b33d"}
{"option": "Hex", "string": "86db597d5302595223cadbd990f1309b"}
]
}
],
@ -999,7 +1066,7 @@ The following algorithms will be used based on the size of the key:
},
{
name: "AES Decrypt: AES-256-GCM, Binary",
input: "e3f1b236eaf3b9df69df8133a1b417fa42b242d8ad49e4d2f3469aca7e2a41737e4f2c8a0d212143287088fad51743577dc6dfa8ed328ca90113cbeb9b137926b2168cc037bdc371777e6ee02b9d9c017b6054fd83d43b4885fbe9c044a8574f1491a893",
input: "1287f188ad4d7ab0d9ff69b3c29cb11f861389532d8cb9337181da2e8cfc74a84927e8c0dd7a28a32fd485afe694259a63c199b199b95edd87c7aa95329feac340f2b78b72956a85f367044d821766b1b7135815571df44900695f1518cf3ae38ecb650f",
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
recipeConfig: [
{
@ -1008,7 +1075,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "23ddbd3ee4de33f98a9ea9a170bdf268"}
{"option": "Hex", "string": "821b1e5f32dad052e502775a523d957a"}
]
}
],

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,43 @@
/**
* DefangIP tests.
*
* @author h345983745
*
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Defang IP: Valid IPV4",
input: "192.168.1.1",
expectedOutput: "192[.]168[.]1[.]1",
recipeConfig: [
{
op: "Defang IP Addresses",
args: [],
},
],
}, {
name: "Defang IP: Valid IPV6",
input: "2001:0db8:85a3:0000:0000:8a2e:0370:7343",
expectedOutput: "2001[:]0db8[:]85a3[:]0000[:]0000[:]8a2e[:]0370[:]7343",
recipeConfig: [
{
op: "Defang IP Addresses",
args: [],
},
],
}, {
name: "Defang IP: Valid IPV6 Shorthand",
input: "2001:db8:3c4d:15::1a2f:1a2b",
expectedOutput: "2001[:]db8[:]3c4d[:]15[:][:]1a2f[:]1a2b",
recipeConfig: [
{
op: "Defang IP Addresses",
args: [],
},
],
},
]);

View file

@ -0,0 +1,565 @@
/**
* Enigma machine tests.
* @author s2224834
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
// Simplest test: A single keypress in the default position on a basic
// Enigma.
name: "Enigma: basic wiring",
input: "G",
expectedOutput: "P",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
// Note: start on Z because it steps when the key is pressed
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "Z", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
""
]
}
]
},
{
// Rotor position test: single keypress, basic rotors, random start
// positions, no advancement of other rotors.
name: "Enigma: rotor position",
input: "A",
expectedOutput: "T",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "N",
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "F",
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "W",
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW",
""
]
}
]
},
{
// Rotor ring setting test: single keypress, basic rotors, one rotor
// ring offset by one, basic start position, no advancement of other
// rotors.
name: "Enigma: rotor ring setting",
input: "A",
expectedOutput: "O",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A",
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A",
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "B", "Z",
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW",
""
]
}
]
},
{
// Rotor ring setting test: single keypress, basic rotors, random ring
// settings, basic start position, no advancement of other rotors.
name: "Enigma: rotor ring setting 2",
input: "A",
expectedOutput: "F",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "N", "A",
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "F", "A",
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "W", "Z",
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW",
""
]
}
]
},
{
// Stepping: basic configuration, enough input to cause middle rotor to
// step
name: "Enigma: stepping",
input: "AAAAA AAAAA AAAAA AAAAA AAAAA A",
expectedOutput: "UBDZG OWCXL TKSBT MCDLP BMUQO F",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A",
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A",
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "Z",
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW",
""
]
}
]
},
{
// Ensure that we can decrypt an encrypted message.
name: "Enigma: reflectivity",
input: "AAAAA AAAAA AAAAA AAAAA AAAAA A",
expectedOutput: "AAAAA AAAAA AAAAA AAAAA AAAAA A",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A",
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A",
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "Z",
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW",
""
]
},
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A",
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A",
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "Z",
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW",
""
]
}
]
},
{
// Stepping: with rotors set so we're about to trigger the double step
// anomaly
name: "Enigma: double step anomaly",
input: "AAAAA",
expectedOutput: "EQIBM",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A",
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "D",
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "U",
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW",
""
]
}
]
},
{
// Stepping: with rotors set so we're about to trigger the double step
// anomaly
name: "Enigma: double step anomaly 2",
input: "AAAA",
expectedOutput: "BRNC",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A",
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "E",
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "U",
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW",
""
]
}
]
},
{
// Stepping: with rotors set so we're about to trigger the double step
// anomaly
name: "Enigma: double step anomaly 3",
input: "AAAAA AAA",
expectedOutput: "ZEEQI BMG",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A",
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "D",
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "S",
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW",
""
]
}
]
},
{
// Stepping: with a ring setting
name: "Enigma: ring setting stepping",
input: "AAAAA AAAAA AAAAA AAAAA AAAAA A",
expectedOutput: "PBMFE BOUBD ZGOWC XLTKS BTXSH I",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A",
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A",
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "H", "Z",
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW",
""
]
}
]
},
{
// Stepping: with a ring setting and double step
name: "Enigma: ring setting double step",
input: "AAAAA AAAAA AAAAA AAAAA AAAAA A",
expectedOutput: "TEVFK UTIIW EDWVI JPMVP GDEZS P",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "Q", "A",
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "C", "D",
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "H", "F",
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW",
""
]
}
]
},
{
// Four-rotor Enigma, random settings, no plugboard
name: "Enigma: four rotor",
input: "AAAAA AAAAA AAAAA AAAAA AAAAA A",
expectedOutput: "GZXGX QUSUW JPWVI GVBTU DQZNZ J",
recipeConfig: [
{
"op": "Enigma",
"args": [
"4-rotor",
"LEYJVCNIXWPBQMDRTAKZGFUHOS", "A", "X", // Beta
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "O", "E",
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "P", "F",
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "D", "Q",
"AE BN CK DQ FU GY HW IJ LO MP RX SZ TV", // B thin
""
]
}
]
},
{
// Four-rotor Enigma, different wheel set, no plugboard
name: "Enigma: four rotor 2",
input: "AAAAA AAAAA AAAAA AAAAA AAAAA A",
expectedOutput: "HZJLP IKWBZ XNCWF FIHWL EROOZ C",
recipeConfig: [
{
"op": "Enigma",
"args": [
"4-rotor",
"FSOKANUERHMBTIYCWLQPZXVGJD", "A", "L", // Gamma
"JPGVOUMFYQBENHZRDKASXLICTW<AN", "A", "J", // VI
"VZBRGITYUPSDNHLXAWMJQOFECK<A", "M", "G", // V
"ESOVPZJAYQUIRHXLNFTGKDCMWB<K", "W", "U", // IV
"AR BD CO EJ FN GT HK IV LM PW QZ SX UY", // C thin
""
]
}
]
},
{
// Four-rotor Enigma, different wheel set, random plugboard
name: "Enigma: plugboard",
input: "AAAAA AAAAA AAAAA AAAAA AAAAA A",
expectedOutput: "GHLIM OJIUW DKLWM JGNJK DYJVD K",
recipeConfig: [
{
"op": "Enigma",
"args": [
"4-rotor",
"FSOKANUERHMBTIYCWLQPZXVGJD", "A", "I", // Gamma
"NZJHGRCXMYSWBOUFAIVLPEKQDT<AN", "I", "V", // VII
"ESOVPZJAYQUIRHXLNFTGKDCMWB<K", "O", "O", // IV
"FKQHTLXOCBJSPDZRAMEWNIUYGV<AN", "U", "Z", // VIII
"AE BN CK DQ FU GY HW IJ LO MP RX SZ TV", // B thin
"WN MJ LX YB FP QD US IH CE GR"
]
}
]
},
{
// Decryption test on above input
name: "Enigma: decryption",
input: "GHLIM OJIUW DKLWM JGNJK DYJVD K",
expectedOutput: "AAAAA AAAAA AAAAA AAAAA AAAAA A",
recipeConfig: [
{
"op": "Enigma",
"args": [
"4-rotor",
"FSOKANUERHMBTIYCWLQPZXVGJD", "A", "I", // Gamma
"NZJHGRCXMYSWBOUFAIVLPEKQDT<AN", "I", "V", // VII
"ESOVPZJAYQUIRHXLNFTGKDCMWB<K", "O", "O", // IV
"FKQHTLXOCBJSPDZRAMEWNIUYGV<AN", "U", "Z", // VIII
"AE BN CK DQ FU GY HW IJ LO MP RX SZ TV", // B thin
"WN MJ LX YB FP QD US IH CE GR"
]
}
]
},
{
// Decryption test on real message
name: "Enigma: decryption 2",
input: "LANOTCTOUARBBFPMHPHGCZXTDYGAHGUFXGEWKBLKGJWLQXXTGPJJAVTOCKZFSLPPQIHZFXOEBWIIEKFZLCLOAQJULJOYHSSMBBGWHZANVOIIPYRBRTDJQDJJOQKCXWDNBBTYVXLYTAPGVEATXSONPNYNQFUDBBHHVWEPYEYDOHNLXKZDNWRHDUWUJUMWWVIIWZXIVIUQDRHYMNCYEFUAPNHOTKHKGDNPSAKNUAGHJZSMJBMHVTREQEDGXHLZWIFUSKDQVELNMIMITHBHDBWVHDFYHJOQIHORTDJDBWXEMEAYXGYQXOHFDMYUXXNOJAZRSGHPLWMLRECWWUTLRTTVLBHYOORGLGOWUXNXHMHYFAACQEKTHSJW",
expectedOutput: "KRKRALLEXXFOLGENDESISTSOFORTBEKANNTZUGEBENXXICHHABEFOLGELNBEBEFEHLERHALTENXXJANSTERLEDESBISHERIGXNREICHSMARSCHALLSJGOERINGJSETZTDERFUEHRERSIEYHVRRGRZSSADMIRALYALSSEINENNACHFOLGEREINXSCHRIFTLSCHEVOLLMACHTUNTERWEGSXABSOFORTSOLLENSIESAEMTLICHEMASSNAHMENVERFUEGENYDIESICHAUSDERGEGENWAERTIGENLAGEERGEBENXGEZXREICHSLEITEIKKTULPEKKJBORMANNJXXOBXDXMMMDURNHFKSTXKOMXADMXUUUBOOIEXKP",
recipeConfig: [
{
"op": "Enigma",
"args": [
"4-rotor",
"LEYJVCNIXWPBQMDRTAKZGFUHOS", "E", "C", // Beta
"VZBRGITYUPSDNHLXAWMJQOFECK<A", "P", "D", // V
"JPGVOUMFYQBENHZRDKASXLICTW<AN", "E", "S", // VI
"FKQHTLXOCBJSPDZRAMEWNIUYGV<AN", "L", "Z", // VIII
"AR BD CO EJ FN GT HK IV LM PW QZ SX UY", // C thin
"AE BF CM DQ HU JN LX PR SZ VW"
]
}
]
},
{
// Non-alphabet characters drop test
name: "Enigma: non-alphabet drop",
input: "Hello, world. This is a test.",
expectedOutput: "ILBDA AMTAZ MORNZ DDIOT U",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "A", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"", true
]
}
]
},
{
// Non-alphabet characters passthrough test
name: "Enigma: non-alphabet passthrough",
input: "Hello, world. This is a test.",
expectedOutput: "ILBDA, AMTAZ. MORN ZD D IOTU.",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "A", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"", false
]
}
]
},
{
name: "Enigma: rotor validation 1",
input: "Hello, world. This is a test.",
expectedOutput: "Rotor wiring must be 26 unique uppercase letters",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQ", "A", "A", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
""
]
}
]
},
{
name: "Enigma: rotor validation 2",
input: "Hello, world. This is a test.",
expectedOutput: "Rotor wiring must be 26 unique uppercase letters",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQo", "A", "A", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
""
]
}
]
},
{
name: "Enigma: rotor validation 3",
input: "Hello, world. This is a test.",
expectedOutput: "Rotor wiring must have each letter exactly once",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQA", "A", "A", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
""
]
}
]
},
{
name: "Enigma: rotor validation 4",
input: "Hello, world. This is a test.",
expectedOutput: "Rotor steps must be unique",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<RR", "A", "A", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
""
]
}
]
},
{
name: "Enigma: rotor validation 5",
input: "Hello, world. This is a test.",
expectedOutput: "Rotor steps must be 0-26 unique uppercase letters",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<a", "A", "A", // III
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
""
]
}
]
},
// The ring setting and positions are dropdowns in the interface so not
// gonna bother testing them
{
name: "Enigma: reflector validation 1",
input: "Hello, world. This is a test.",
expectedOutput: "Reflector must have exactly 13 pairs covering every letter",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "A", // III
"AY BR CU DH EQ FS GL IP JX KN MO", // B
""
]
}
]
},
{
name: "Enigma: reflector validation 2",
input: "Hello, world. This is a test.",
expectedOutput: "Reflector must have exactly 13 pairs covering every letter",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "A", // III
"AA BR CU DH EQ FS GL IP JX KN MO TZ VV WY", // B
""
]
}
]
},
{
name: "Enigma: reflector validation 3",
input: "Hello, world. This is a test.",
expectedOutput: "Reflector connects A more than once",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "A", // III
"AY AR CU DH EQ FS GL IP JX KN MO TZ", // B
""
]
}
]
},
{
name: "Enigma: reflector validation 4",
input: "Hello, world. This is a test.",
expectedOutput: "Reflector must be a whitespace-separated list of uppercase letter pairs",
recipeConfig: [
{
"op": "Enigma",
"args": [
"3-rotor",
"", "A", "A",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R", "A", "A", // I
"AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "A", "A", // II
"BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "A", "A", // III
"AYBR CU DH EQ FS GL IP JX KN MO TZ", // B
""
]
}
]
},
]);

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2018
* @licence Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,55 @@
/**
* To Geohash tests
*
* @author gchq77703
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "From Geohash",
input: "ww8p1r4t8",
expectedOutput: "37.83238649368286,112.55838632583618",
recipeConfig: [
{
op: "From Geohash",
args: [],
},
],
},
{
name: "From Geohash",
input: "ww8p1r",
expectedOutput: "37.83416748046875,112.5604248046875",
recipeConfig: [
{
op: "From Geohash",
args: [],
},
],
},
{
name: "From Geohash",
input: "ww8",
expectedOutput: "37.265625,113.203125",
recipeConfig: [
{
op: "From Geohash",
args: [],
},
],
},
{
name: "From Geohash",
input: "w",
expectedOutput: "22.5,112.5",
recipeConfig: [
{
op: "From Geohash",
args: [],
},
],
},
]);

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
@ -1033,6 +1033,72 @@ TestRegister.addTests([
}
]
},
{
name: "Streebog-256: Test Case 1",
input: "",
expectedOutput: "3f539a213e97c802cc229d474c6aa32a825a360b2a933a949fd925208d9ce1bb",
recipeConfig: [
{
op: "Streebog",
args: ["256"]
}
]
},
{
name: "Streebog-256: Test Case 2",
input: "The quick brown fox jumps over the lazy dog",
expectedOutput: "3e7dea7f2384b6c5a3d0e24aaa29c05e89ddd762145030ec22c71a6db8b2c1f4",
recipeConfig: [
{
op: "Streebog",
args: ["256"]
}
]
},
{
name: "Streebog-512: Test Case 1",
input: "",
expectedOutput: "8e945da209aa869f0455928529bcae4679e9873ab707b55315f56ceb98bef0a7362f715528356ee83cda5f2aac4c6ad2ba3a715c1bcd81cb8e9f90bf4c1c1a8a",
recipeConfig: [
{
op: "Streebog",
args: ["512"]
}
]
},
{
name: "Streebog-512: Test Case 2",
input: "The quick brown fox jumps over the lazy dog",
expectedOutput: "d2b793a0bb6cb5904828b5b6dcfb443bb8f33efc06ad09368878ae4cdc8245b97e60802469bed1e7c21a64ff0b179a6a1e0bb74d92965450a0adab69162c00fe",
recipeConfig: [
{
op: "Streebog",
args: ["512"]
}
]
},
{
name: "GOST R 34.11-94: Test Case 1",
input: "",
expectedOutput: "981e5f3ca30c841487830f84fb433e13ac1101569b9c13584ac483234cd656c0",
recipeConfig: [
{
op: "GOST hash",
args: ["D-A"]
}
]
},
{
name: "GOST R 34.11-94: Test Case 2",
input: "This is message, length=32 bytes",
expectedOutput: "2cefc2f7b7bdc514e18ea57fa74ff357e7fa17d652c75f69cb1be7893ede48eb",
recipeConfig: [
{
op: "GOST hash",
args: ["D-A"]
}
]
}
/*{ // This takes a LONG time to run (over a minute usually).
name: "Scrypt: RFC test vector 4",
input: "pleaseletmein",

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",

View file

@ -2,12 +2,13 @@
* Image operation tests.
*
* @author tlwr [toby@toby.codes]
* @author Ge0rg3 [georgeomnet+cyberchef@gmail.com]
* @author n1474335 [n1474335@gmail.com]
*
* @copyright Crown Copyright 2017
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
@ -175,4 +176,76 @@ TestRegister.addTests([
},
],
},
{
name: "Extract RGBA",
input: "424d460400000000000036040000280000000400000004000000010008000000000010000000120b0000120b0000000100000001000000c8000000cf000000d7000000df000000e7000000ef000000f7000000ff000083000000ac000000d5000000ff000000000083000000ac000000d5000000ff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f070d05030b01090c040e060008020a",
expectedOutput: "0 200 0 0 0 131 0 215 0 0 0 213 131 0 0 0 231 0 213 0 0 0 247 0 0 223 0 0 0 255 0 207 0 0 0 172 255 0 0 0 255 0 172 0 0 0 239 0",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Extract RGBA",
args: [" ", false]
}
]
},
{
name: "Extract LSB",
input: "89504e470d0a1a0a0000000d4948445200000020000000200806000000737a7af400000449494441547801cc9703782b5914c783b56ddbb659db6e9f6ddbb66dd45e6fddc6aecd24cff67b99397b6ebe9d6216d99bcceebefb7dffbaf9ff0e7347e4e491eeddbbf7f5bcbcbc41b9b9b943376cd8f00ef9194afcfb67094ac0d3ed85870d1b764755555592c562616a6a6a18ad560b28b6a0a0203b3d3d7d4e494989fed75f7fdd45fe5e10e38c8c8c0f2a2b2b7737343468ebeaea8a516aabd50a441c00278d46c392cf2a95eaf475d75d7767525252505656565f67332296c9644330d2cbc48c2f3e005f656565ed08c410656666c653bb63e4ef9acd66ce9c0a8027164b430d20aea8a8d84e4c5c05c02c1ebce9a69b6e27af49d5e5f5f5f56a4700b5b5b5ac0300ae1cad3ffdf4d3321a0809365bc93f007068cea9b8b8584e35197abd7e8e5019c032983103aba8ca306fdebc07dadada2c02f4c0a15b6eb9e50ea746313535f5ade6e6e63a57008870170c14397b9e7cf2c97bc838d20294969636e30eb0a1181ce9de2217ce2d087089060037e139b1587ce7fefdfbfd30fa3ef4e9771140a1501cc3ffbb91deea2a05b8991640a9541ec5ffbb5e2800497272f20f7880afad5bb73273e7ce05bea64c99922ee49de07a9d4ed760341a812fbc9030696969c0574a4a8a11ffef5a979d5fbaffe61be604bf3dc698b9d966cade0add555ffa13ab91c96cbb76ed62e7cf9fdf43b367cf3ef7c5175f78ba9cfac5fe2f6cd62e88828a65f13c25c0595d09542b95cceeddbb212020007c7d7d7bc8c7c7e7b2bbbbfbf34ebbc7bcf3e0a33ba25eb992d8f70330ace8df692e9b1703478b7300dadaec00782784799be7815b9c1b676e070a0a0a2a78f7dd77ef7573737b468a871a60b6e733513ba35e818d612fc111b50cce5768a15f983fcc9c311d4a3233e1427d3dfc9c98c8e6e4e4c07d89f7c1dbd96fc3a8ef47c1f6eddb61c78e1dd0b76fdf8b090909c67efdfa31616161b154e6833e7ef4c96d112f1fe5008e6995f688372f5902512121d0a152c1711cb7cc8d1b01b71d4c2a9b64875893b70648461213138fa1794dfffefd01c54645458da102581df8c26a62ce07e0646b6981530a851d60f5ead5c4b48770f7d77b7b7bfb1180e8e8e82db43764c986d017cbfe0ee05c6d2d5cd268ec003366cce00390516c0c0f0f5f4c007af7ee5d4dfa800640bc2ef8c5744719384300366d62478d1a05a40fba03e0430b8bb5070240141717b792aa0433dd9f76db11f98a8d0fd05d6c6b2b54cae56c76763631e503407c7cbc2130303018cd777dfdf5d78f53df8a17fa3cdb7f7bc4cba7ba03301879bbc904c770024e3637c37eec7834204d4622be826fbd2c07803f5b2e72f584bdf1c0fd13be7e32fe54b9e92417f9653437e3fb40c39e3db067c10216f73eb36edd3a06cb6037479155dcfef9e79f3f2cd87361555e5ec4a5c64633bf0cdc22ea2ecc8265e7ce9dfe22a1cfe4a143ef32ab54532e363434f10038e30e9cffdfd650545424c8404bc0c4c4c47664cd1a83c7274ec41fdeb62d0f58192501a3c04c5e5e9e8d1cf30084683c77e1e9adc80000000049454e44ae426082",
expectedOutput: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000240000000000000000000000208000000000000000000008000000000000000000000000248000000200240000000208908000000200240000000200821000000200240000000061249000000240000000000209b69000001a49b00000000a204a1200001a49b00000009800414000001a49b0000000035db6c00000094924000000086dffc20000df6dec8000001e10014a0000df6dec800002564924b00000df6dec80000009a6db20000007edb4124804177fffba0002fffff69249044e0924bc4002fffff6924905fb2db6d04002fffff692490416d2490040001bfffcc92030dbffffdc00037fffffdb6d302c6db6d700037fffffdb6d327eb6db6148037fffffdb6d30db4000014800dffffeb6d9aefffffff640",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Extract LSB",
args: ["B", "G", "A", "", "Column", 2]
},
{
op: "To Hex",
args: ["None"]
}
]
},
{
name: "View Bit Plane",
input: "89504e470d0a1a0a0000000d4948445200000020000000200806000000737a7af400000449494441547801cc9703782b5914c783b56ddbb659db6e9f6ddbb66dd45e6fddc6aecd24cff67b99397b6ebe9d6216d99bcceebefb7dffbaf9ff0e7347e4e491eeddbbf7f5bcbcbc41b9b9b943376cd8f00ef9194afcfb67094ac0d3ed85870d1b764755555592c562616a6a6a18ad560b28b6a0a0203b3d3d7d4e494989fed75f7fdd45fe5e10e38c8c8c0f2a2b2b7737343468ebeaea8a516aabd50a441c00278d46c392cf2a95eaf475d75d7767525252505656565f67332296c9644330d2cbc48c2f3e005f656565ed08c410656666c653bb63e4ef9acd66ce9c0a8027164b430d20aea8a8d84e4c5c05c02c1ebce9a69b6e27af49d5e5f5f5f56a4700b5b5b5ac0300ae1cad3ffdf4d3321a0809365bc93f007068cea9b8b8584e35197abd7e8e5019c032983103aba8ca306fdebc07dadada2c02f4c0a15b6eb9e50ea746313535f5ade6e6e63a57008870170c14397b9e7cf2c97bc838d20294969636e30eb0a1181ce9de2217ce2d087089060037e139b1587ce7fefdfbfd30fa3ef4e9771140a1501cc3ffbb91deea2a05b8991640a9541ec5ffbb5e2800497272f20f7880afad5bb73273e7ce05bea64c99922ee49de07a9d4ed760341a812fbc9030696969c0574a4a8a11ffef5a979d5fbaffe61be604bf3dc698b9d966cade0add555ffa13ab91c96cbb76ed62e7cf9fdf43b367cf3ef7c5175f78ba9cfac5fe2f6cd62e88828a65f13c25c0595d09542b95cceeddbb212020007c7d7d7bc8c7c7e7b2bbbbfbf34ebbc7bcf3e0a33ba25eb992d8f70330ace8df692e9b1703478b7300dadaec00782784799be7815b9c1b676e070a0a0a2a78f7dd77ef7573737b468a871a60b6e733513ba35e818d612fc111b50cce5768a15f983fcc9c311d4a3233e1427d3dfc9c98c8e6e4e4c07d89f7c1dbd96fc3a8ef47c1f6eddb61c78e1dd0b76fdf8b090909c67efdfa31616161b154e6833e7ef4c96d112f1fe5008e6995f688372f5902512121d0a152c1711cb7cc8d1b01b71d4c2a9b64875893b70648461213138fa1794dfffefd01c54645458da102581df8c26a62ce07e0646b6981530a851d60f5ead5c4b48770f7d77b7b7bfb1180e8e8e82db43764c986d017cbfe0ee05c6d2d5cd268ec003366cce00390516c0c0f0f5f4c007af7ee5d4dfa800640bc2ef8c5744719384300366d62478d1a05a40fba03e0430b8bb5070240141717b792aa0433dd9f76db11f98a8d0fd05d6c6b2b54cae56c76763631e503407c7cbc2130303018cd777dfdf5d78f53df8a17fa3cdb7f7bc4cba7ba03301879bbc904c770024e3637c37eec7834204d4622be826fbd2c07803f5b2e72f584bdf1c0fd13be7e32fe54b9e92417f9653437e3fb40c39e3db067c10216f73eb36edd3a06cb6037479155dcfef9e79f3f2cd87361555e5ec4a5c64633bf0cdc22ea2ecc8265e7ce9dfe22a1cfe4a143ef32ab54532e363434f10038e30e9cffdfd650545424c8404bc0c4c4c47664cd1a83c7274ec41fdeb62d0f58192501a3c04c5e5e9e8d1cf30084683c77e1e9adc80000000049454e44ae426082",
expectedOutput: "89504e470d0a1a0a0000000d4948445200000020000000200806000000737a7af400000140494441547801c5c1416ea3400000c1ee11ffff726fe6808410186ce26c95fde0432a154f0cdea4b2aa505151519954ee1a5c50995454aea8ac54ae2c5ca8982a3ea132551c199c507942e58ec1898adf50f1cae084ca15952b2a152a47067f40a5e2c8e00f54a81c199ca8b85271a542a5e2c8e005159527542ace0c5ea8a8f844c54ae5ccc217555c197c41c55d83ff6cf0052a772ddca052b1a752b1a772d7c2432a4f2c3c50f1d4c20b2a1593ca918a4965afe2cac29b2a562a93ca56c55d0b2754b62a269555c554b15251a9b8637040e5884ac54a654ba5a2624be5cce040c5918a55c55ec5a4a232a9549c197c48655239523155bc3278a862af624be5ccc2072aaea854a8549c5978834a85ca5ec5918a57ec076f50a958a9546ca94c1557ec071754a68a2d958a270637544c2a2abf69e1a68a95ca54b152a978d73f2e08bd57b6f839a00000000049454e44ae426082",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "View Bit Plane",
args: ["Green", 3]
},
{
op: "To Hex",
args: ["None"]
}
]
},
{
name: "Randomize Colour Palette",
"input": "89504e470d0a1a0a0000000d4948445200000020000000200806000000737a7af400000674494441547801c5970394244b1686bf44b9aaddd5fdfcc6330f63af6ddbdea3b56ddbb66ddbdeb16dcf5497d219b137f3d44363ba7b70cede73be74c6fd6f4454e45ffcbfc398ecdef7bef7bd35c562f1c59669de0fc32818467a590ec7bca635bab38fe27823b0278aa29f3cf0810ffc12a02e4680f9fdef7fff1903d5eaa766cd98412e9f2793c91204216118c83e052509b3d96c4aaeb3775d07152b1a8d3a478f1ee5452f7a5101f0384fd88b172f666c6cd8b0215f2e973fb576f56a40e37901be248ce34888514a9192542edcfebcb7a7977a7d844e70e4c891d2a402e401c6c6631ffbd82b92864dd3948ac3b4f1e4bc13c91008a6a0097c1fa7dd927d20421d9acd16beef1fdbba75eb8f5ef9ca577eee6286c010867ef5ab5f1dbfd7bdee858c2569d7cb5ec4488206b55a8d76bb8de7ba64b2198af9025ddddd5c71e5951cd8bf9f37bef18d4f9121fc0f705aa80bc1797b80f1a11392ea034968c8be561be1e4a913d425719ab054a6af7f003b63532a1629e4f3140a058a42d25b3367ce6c02870467aa1eb09938a2fffef7bf6f035e8661d85ac3cd37dfcc82053726e39c56ef380e511c89400bd34ab001b06c9beeee9e00f0264f3eb900f7e52f7ff9e7819f0995bffe6bddcf77ef3f8c8a0fa20123c1209d1771ace47a9cce0b3b63093656363f6a782f4680271c13ce093dcf7ae09d9ef8f47bf77c05a5c964f2686c1a4d9f43474e72e7bbaf65c5da9b3876ec0c9ff8c84fe8abf4b1eff4a118d04c234c260e25381d012756cfee5b15eb1c37ad5c4dbe7b8062ff20f778f0bd78c7c7dfc4fd1e716f8add7dcc98338365775a8c952bb260c6d58f03cc4b1030fa996ac57a96e318acbecb1a9efdba17f28ce73e8585cb1612470aa7ede17b3e9e1771e59503f8a14339977d1490bb1c028c27ace85f6d59e41dd764efcebdd07668b59c74127a92d8f7935531220803dc769b4ac10243171ebf727035605caa804c7fd1783268c2c0e2f73ffb2b5aa9643de82ccb091191ec93c9b86de35e72392bfd290e96cc2701994b1590b550cbb58a29e6234e9d70d9b3f3202a124191240f2479140a8a53c7ce51cae4b06d489eb78c782590bd6401b6a517a838c0204c1bffcd0fff045aa7e31f45b1a0e43466e3bf77808e8845905221b188b81c3d600611bb6215a1421fad7cf6eed8cba986471448a2385d9ef9f7e6bdd4ced688635f0404c46180a8b0a633076c260fe587d131db30e606848045fff09558a6c5f68367f0ddb6ac05a769b49a682d4f784e2a00342d37da04e84bed81e0137f6f3ef7f499c6df5b5ebc1b2b878a5c4c4333dc57c1360d8a390b4bce5bf5b3683343aee70ae7ecb9e696afad77df080497e2880032af7ff3dbeef8d0873dfcb5f3e6cfbb5bc182fffee8ad74570cd0a41f2ad334049346bdc1cd0f78335e0c070f1e3efbef7ffefddd4f7afc63de0f041723c0f8f297bf3c7be1c245df5db850be429d38f09faf523bb20ed3ca25d96fb366a929f1c915079877f797a6823ac6c6dbb973e7ddc45ffc13d0d31d02e3339ff9ccbc952b57ee4a92bb9e475daa6b341d8ce23544dac269d5709da6d0c2711ab49373d7c7ee992bcfd68526c97be2b6f2c2dfa598b58031dd1ec8feec673fdb70bffbdd6fc1b9da48faf93520add8346d4c3bc7b9037fe3e8a6efe33b67b0ed3cc3f3ef4b75eebdc1b2d17188d6f1adcea9afb7873ffce10fe1ddee76b72ec09b8e80ee75ebd68d2c59b2444cc8e9d10ef8162b264252e418345a451d5472065a20d96986aa83ac5fbf8eb7bef56dd701871813f6231ef1083ac177bffb5de3ddef7ef74ab1e2a9058b22459a7f5c244e2915031d630aa374269705952ed9625058b66cd9bc57bdea5547c69a145b928e3aaf56ab6b1301a9ed56112332a67d3d3da831494c6db26bcf1e868786e8aa54c4fd1e1e25a0d56c33343c4cb9524e2ddb8c19331e08fc4150934d42bb542a2defefef97065ae947a53e524f7a6394fd9663418112525714b362c50a962f5f2e7b418ed7ac59239577e3b5db744b01f97c7e39909d6a25cc4af5cb054e9d394bac54cae12347a94895e57209cbb268b7da341a0dec6c8eb3e76af84198625a26ade45ebd91bae96a7520494c75a88a14b614c84c25c0ce66b3c3406a322ccba4bfaf174f8e1bcdc6a83f1c32395314506fd4d37b1dbf28490b527d05dbce10851100b95c2e0fd853fd0a06befded6f7fbfb7b7f78e69825b67fe6d8f1a13bda9c71fca308dfacfa8b46ec9ff8c59c0a9c90454846b8501c1e6f285166ac27e6164b2217085431d9506973702a1cd98f81f11b2640d65786ac70000000049454e44ae426082",
expectedOutput: "89504e470d0a1a0a0000000d4948445200000020000000200806000000737a7af4000007ed494441547801c5c17b5c0d8602c0f15f9de3d16425a113999296348f3c0b75ea4e2b5be7a05bd46a32c99b5496477266d494ac97508a0e494848c2525e87bc95ccb31145915e3abacb38f7b6cfdde7d3a74faafff6fdaa59c81254fc8384b42179b40501455ee84476617b920eeee33e6742d7c994d685d15c9ac31ff85f5c4386b13ada4b0268a2597c8dc7fa72da23e423ccfca67221fa32f29dfe1c59b08ef4c4459c7a5acc1e130396d5aee2f8d8092c105ee7f9a91a6e6db6a6c4d3893e96b318aa1b41b7aa0822cd156c1aa5c39b2e0f698b7097d36b5af2caec499cc29dd409bd389b578ea66f10569394fc229b89f7fd2f890bbdcbbbeb83c8511b8acbc67b6cad39c7c691f7e81ceb829eb12deb6de740247f912e1c465b84d285c368c92150c68f338e31784e11c3924e522281d50a0156fdf84bf27a1fa2c4de7cb3d79dbdd3ab916f90a2b4ec45e3e6159cb54fc6c8741fa3b48a703e654e0f872ada2230f216cb348cebd030ae43c3b80e0de33aca2a2c30cc37a5d7c89714780a11de84dda24914ae28a5617b209f0f4e22bba03bfd973930a1df22ece73ea1dbe30d8c9ee48455e925a2d39dd861fa968e1088c41219ad1873b89e5137bf66a465029b46f461aaebf79cad7c4e68f0262aabba503ec09123e3b7a319e6cbdefe12385e485d5d0fe4d21e7c2bb047d1e94b3a429d8fb0d64de39cff1172f213581aea8f32eb2ebaf23bc85f6be2e1b5859af4a5680c9d4df046299551c9ec58ed49935d3f9bf04a2d8b8e1288c41219ad383ebe3f771475dc30f88490e1f7e82c8c62f34007be8e53e026b5c4c3a11b03ae6f657abf4944e8fe4efef3293c689c8d87961e11db9da91beb4847084462898c76e48499b243438fead0183e645660133886d3ffaa65acc0971b0113c9add4a3583b1c9f05b5a46c352447bb2f5a867de908753ac03f478bb26b9f52e4f88642e712b47cb7b122f4097ee5d5788cc8e2e8e20a4c94cf5962fa03e9257339635d4e47a9d30195dade841c9273d5408731bdcbf139b983d8de57393d2f908c992ed49b6c6474a101f1c11928dc8ef066ed753a4a483b740f34703fd38c82ada58c7c358f17c77ee2c98aa7acf9598df57ebfd0b93a8dfc3333c82aafc0e1e518968f49e7495e2e6a411fe8ba5e417bd469c79463eef8c54f63d76173a24f9f40b955c989dcb7f867bee7b33c29fd97b8e09c771de5ae5a9c4bd7d15747cae8ea30065ebc4d47086987b6cd34eef4aca56be65bfcc3c6312fab37bb2ec5303c64177d621c18eb25e24ef71ea41e0c216250000d9e525ef7d065d0d628ca3a4da73d02915822a30d1a29c398ebf12be1a5f3d1093a42df9709bc4a6e60d07721945c3d84a47b118a803c0483aff02e3a9eb74356b2283688ec05f6bcf94d8ff6a8d38ebb353ac4fe618ac53d57ee5cbd8874f26d2e9d8ec3eebc2b8ee163f1591bc3a0e25282b639d14bc305a7c652f20b37a06bb8878e50a71d8eff598d4cef2056dd8cd896da8537aebe6cd3b4e3c1706b2a53f5315d1b448d5a363a669fa2f2d442392198f8fe539816ad4e47084462898c36dc2cb4e2d6dc2f181b5241cf47f1147c178db67b19911e4fd1ba3c9e9f728e7241ef393766ca091a974145891ca5d88751920cf21555b44720124b64b44112f135a9053739693e0a3dd3f1684b5c392f4a24cefb027aef0663be3190c64867ba769acc90f43ed8c4a450239b43f5aa069e7656d11e753e62ffd52c94b646f49b7b1fcb3001d6dfbe6375d5778cebfd16cbc453b8669dc66e71144b8dc55cb7fb8a4b71fa1cb55d4279843e36cb2d18aa32e2135b7f027cbc688b402496c868c1cd620259ba4370b9aacec0a06c1cbfe8c2b08614a2b5df5353e14db0db441efa2e4623f92835c92bf18df56464919440d52c56b113b7ec4d686fd1e6b31d6b5813b6946335c51ce86b426b0422b144460be10633a9bff56ff236dee7878bc94c0e7d48a3d10d82baf664f45e3f7627a868541c47f9bb883d665ff15a56c5a36c2f54f16e6cb8a0497d4d29c2a365ecdf2ec2eb81132b0627a0fa7322ad11d28a5986a94c038cc2d7121da5e026ffa380a4862c0c0fc552231f87fcad90facf0229f23ac9dcc2482aee66919462c1a188857caf914813a3f0f1c03e9e8913c8ea398bd6a85d7bd85fc5fff9a4ace19c7e236689d964e858e26d9946c172335ab2d9ff827a83e1bc5fe8c78cf70dbc59684373f1ebeaf009fe940d3eb67cf54087dfb65c2379ea3cfc2ebfa725350b59828a66242bed51793b53f5a29ea84e3d89f2ddc4a4158598e9c969ce35ad8cf9f9fdb8bf3a86dcd35389720ce66fa22d2202a507099b338078fd18cc3ba961305f972901beb424108925329a99b5e021eb96e570f4543051b955ec769dca3c074b164b8d78f4e3532eb9f720b1fb5224a5d6ccd73d4892e609726a63095ee9c39e705b94cf26e3f3a18eb2ea7378561af0f3950f6cb1abe151cc455e5dba474b02915822a319ffd9c188cec8499a2a20c4269ebbb9ae7c1b684556c40786767bc6fdd05b4c1c6a49491739f2dc13d8efb62661531acbc6ebb1ece57ee6ab7499257067e7f2e92cb1d267709f517c73db8d068fde3cb1bc474beab4b0d376274df68d9b89dedd3b0ccc48648fc93374970e42651c878be1af8cd83986cd7602940557386babe0855a19b5ef42e86df788b3227b4e2c7362f3a248a47f1612e1349f26e71f3ca6356a16b20415cd445d7984225d4c695d1887334d386f664f9c7d3ff282dc68f2a7cf019a180d5cc4df7e2f8ee56fc278179a1cb00e67e26fa798e2f48034873f280ed1447cd98596d42c64092afe41eafcc3fe0b9c67148a38c1a5620000000049454e44ae426082",
recipeConfig: [
{
op: "From Hex",
args: ["None"]
},
{
op: "Randomize Colour Palette",
args: ["myseed"]
},
{
op: "To Hex",
args: ["None"]
}
]
}
]);

View file

@ -0,0 +1,22 @@
/**
* Index of Coincidence tests.
*
* @author George O [georgeomnet+cyberchef@gmail.com]
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Index of Coincidence",
input: "Hello world, this is a test to determine the correct IC value.",
expectedMatch: /^Index of Coincidence: 0\.07142857142857142\nNormalized: 1\.857142857142857/,
recipeConfig: [
{
"op": "Index of Coincidence",
"args": []
},
],
},
]);

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,93 @@
/**
* JSON to CSV tests.
*
* @author mshwed [m@ttshwed.com]
*
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
const EXPECTED_CSV_SINGLE = "a,b,c\r\n1,2,3\r\n";
const EXPECTED_CSV_MULTIPLE = "a,b,c\r\n1,2,3\r\n1,2,3\r\n";
const EXPECTED_CSV_EMPTY = "\r\n\r\n";
TestRegister.addTests([
{
name: "JSON to CSV: strings as values",
input: JSON.stringify({a: "1", b: "2", c: "3"}),
expectedOutput: EXPECTED_CSV_SINGLE,
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
},
{
name: "JSON to CSV: numbers as values",
input: JSON.stringify({a: 1, b: 2, c: 3}),
expectedOutput: EXPECTED_CSV_SINGLE,
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
},
{
name: "JSON to CSV: numbers and strings as values",
input: JSON.stringify({a: 1, b: "2", c: 3}),
expectedOutput: EXPECTED_CSV_SINGLE,
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
},
{
name: "JSON to CSV: JSON as an array",
input: JSON.stringify([{a: 1, b: "2", c: 3}]),
expectedOutput: EXPECTED_CSV_SINGLE,
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
},
{
name: "JSON to CSV: multiple JSON values in an array",
input: JSON.stringify([{a: 1, b: "2", c: 3}, {a: 1, b: "2", c: 3}]),
expectedOutput: EXPECTED_CSV_MULTIPLE,
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
},
{
name: "JSON to CSV: empty JSON",
input: JSON.stringify({}),
expectedOutput: EXPECTED_CSV_EMPTY,
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
},
{
name: "JSON to CSV: empty JSON in array",
input: JSON.stringify([{}]),
expectedOutput: EXPECTED_CSV_EMPTY,
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
}
]);

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
const outputObject = JSON.stringify({
String: "SomeString",

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
const inputObject = JSON.stringify({
String: "SomeString",

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
const outputObject = JSON.stringify({
String: "SomeString",

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

File diff suppressed because one or more lines are too long

View file

@ -4,7 +4,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,49 @@
/**
* Bombe machine tests.
* @author s2224834
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Multi-Bombe: 3 rotor",
input: "BBYFLTHHYIJQAYBBYS",
expectedMatch: /<td>LGA<\/td> {2}<td>SS<\/td> {2}<td>VFISUSGTKSTMPSUNAK<\/td>/,
recipeConfig: [
{
"op": "Multiple Bombe",
"args": [
// I, II and III
"User defined",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R\nAJDKSIRUXBLHWTMCQGZNPYFVOE<F\nBDFHJLCPRTXVZNYEIWGAKMUSQO<W",
"",
"AY BR CU DH EQ FS GL IP JX KN MO TZ VW", // B
"THISISATESTMESSAGE", 0, false
]
}
]
},
/*
* This is too slow to run regularly
{
name: "Multi-Bombe: 4 rotor",
input: "LUOXGJSHGEDSRDOQQX",
expectedMatch: /<td>LHSC<\/td><td>SS<\/td><td>HHHSSSGQUUQPKSEKWK<\/td>/,
recipeConfig: [
{
"op": "Multiple Bombe",
"args": [
// I, II and III
"User defined",
"EKMFLGDQVZNTOWYHXUSPAIBRCJ<R\nAJDKSIRUXBLHWTMCQGZNPYFVOE<F\nBDFHJLCPRTXVZNYEIWGAKMUSQO<W",
"LEYJVCNIXWPBQMDRTAKZGFUHOS", // Beta
"AE BN CK DQ FU GY HW IJ LO MP RX SZ TV", // B thin
"THISISATESTMESSAGE", 0, false
]
}
]
},
*/
]);

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
const ASCII_TEXT = "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.";
@ -248,7 +248,8 @@ IOE1W/Zqmqzq+4frwnzWwYv9/U1RwIs/qlFVnzliREOzW+om8EncSSd7fQ==
=fEAT
-----END PGP MESSAGE-----
`,
expectedOutput: `Signed by PGP fingerprint: e94e06dd0b3744a0e970de9d84246548df98e485
expectedOutput: `Signed by PGP key ID: DF98E485
PGP fingerprint: e94e06dd0b3744a0e970de9d84246548df98e485
Signed on Tue, 29 May 2018 15:44:52 GMT
----------------------------------
${UTF8_TEXT}`,
@ -282,4 +283,30 @@ H2qMY1O7hezH3fp+EZzCAccJMtK7VPk13WAgMRH22HirG4aK1i75IVOtjBgObzDh
}
]
},
{
name: "PGP Verify: ASCII, Alice",
input: `-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-----BEGIN PGP SIGNATURE-----
iLMEAQEIAB0WIQRLbJy6MLpYOr9qojE+2VNAUiMLOgUCXRTsvwAKCRA+2VNAUiML
OuaHBADMMNtsuN92Fb+UrDimsv6TDQpbJhDkwp9kZdKYP5HAmSYAhXBG7N+YCMw+
v2FSpUu9jJiPBm1K1SEwLufQVexoRv6RsBNolRFB07sArau0s0DnIXUchCZWvyTP
1KsjBnDr84U2b11H58g4DlTT4gQrz30rFuHz9AGmPAtDHbSXIA==
=vnk/
-----END PGP SIGNATURE-----`,
expectedOutput: `Signed by PGP key ID: DF98E485
PGP fingerprint: e94e06dd0b3744a0e970de9d84246548df98e485
Signed on Thu, 27 Jun 2019 16:20:15 GMT
----------------------------------
A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.`,
recipeConfig: [
{
"op": "PGP Verify",
"args": [ALICE_PUBLIC]
}
]
}
]);

View file

@ -7,7 +7,7 @@
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,65 @@
/**
* Parse SSH Host Key tests
*
* @author j433866 [j433866@gmail.com]
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "SSH Host Key: RSA",
input: "AAAAB3NzaC1yc2EAAAADAQABAAABAQDiJZ/9W9Ix/Dk9b+K4E+RGCug1AtkGXaJ9vNIY0YHFHLpWsB8DAuh/cGEI9TLbL1gzR2wG+RJNQ2EAQVWe6ypkK63Jm4zw4re+vhEiszpnP889J0h5N9yzyTndesrl4d3cQtv861FcKDPxUJbRALdtl6gwOB7BCL8gsXJLLVLO4EesrbPXD454qpVt7CgJXEXByOFjcIm3XwkdOnXMPHHnMSD7EIN1SvQMD6PfIDrbDd6KQt5QXW/Rc/BsfX5cbUIV1QW5A/GbepXHHKmWRtLC2J/mH3hW2Zq/hITPEaJdG1CtIilQmJaZGXpfGIwFeb0Av9pSL926arZZ6vDi9ctF",
expectedOutput: `Key type: ssh-rsa
Exponent: 0x010001
Modulus: 0x00e2259ffd5bd231fc393d6fe2b813e4460ae83502d9065da27dbcd218d181c51cba56b01f0302e87f706108f532db2f5833476c06f9124d43610041559eeb2a642badc99b8cf0e2b7bebe1122b33a673fcf3d27487937dcb3c939dd7acae5e1dddc42dbfceb515c2833f15096d100b76d97a830381ec108bf20b1724b2d52cee047acadb3d70f8e78aa956dec28095c45c1c8e1637089b75f091d3a75cc3c71e73120fb1083754af40c0fa3df203adb0dde8a42de505d6fd173f06c7d7e5c6d4215d505b903f19b7a95c71ca99646d2c2d89fe61f7856d99abf8484cf11a25d1b50ad222950989699197a5f188c0579bd00bfda522fddba6ab659eaf0e2f5cb45`,
recipeConfig: [
{
op: "Parse SSH Host Key",
args: ["Base64"]
}
]
},
{
name: "SSH Host Key: DSA",
input: "AAAAB3NzaC1kc3MAAACBAMnoZCOzvaQqs//9mxK2USZvJBc7b1dFJiBcV80abN6maE+203pTRPIPCpPt0deQxv4YN3dSHoodEcArWxs1QRAIuRsQIvsUP7chovzGnxP84XWK5sbfrseD0vxZ7UR0NaAFPcSgeXcWC1SG9uvrAJQlyp4DBy+fKuqiYmwaz0bHAAAAFQCXNJ4yiE1V7LpCU2V1JKbqDvICMwAAAIB/5aR1iBOeyCVpj0dP3YZmoxd9R7FCC/0UuOf0lx4E6WHT6Z2QuPBhc2mpNDq2M0VF9oJfVWgcfG8r1rlXaCYODSacGcbnW5VKQ+LKkkALmg4h8jFCHReUC+Hmia/v8LyDwPO1wK6ETn7a3m80yM7gAU5ZNurVIVVP2lB65mjEsQAAAIA3ct9YRB6iUCvOD45sZM1C9oTC24Ttmaou0GcpWx3h0/iZ8mbil1cjaO9frRNZ/vSSVWEhEDNG8gwkjZWlvnJL3y1XUxbMll4WbmI/Q1kzKwopceaFwMbYTPKDg6L1RtCMUxSUyKsFk1c4SpEPlDS7DApZs5PgmWgMd/u6vwMXyg==",
expectedOutput: `Key type: ssh-dss
p: 0x00c9e86423b3bda42ab3fffd9b12b651266f24173b6f574526205c57cd1a6cdea6684fb6d37a5344f20f0a93edd1d790c6fe183777521e8a1d11c02b5b1b35411008b91b1022fb143fb721a2fcc69f13fce1758ae6c6dfaec783d2fc59ed447435a0053dc4a07977160b5486f6ebeb009425ca9e03072f9f2aeaa2626c1acf46c7
q: 0x0097349e32884d55ecba4253657524a6ea0ef20233
g: 0x7fe5a47588139ec825698f474fdd8666a3177d47b1420bfd14b8e7f4971e04e961d3e99d90b8f0617369a9343ab6334545f6825f55681c7c6f2bd6b95768260e0d269c19c6e75b954a43e2ca92400b9a0e21f231421d17940be1e689afeff0bc83c0f3b5c0ae844e7edade6f34c8cee0014e5936ead521554fda507ae668c4b1
y: 0x3772df58441ea2502bce0f8e6c64cd42f684c2db84ed99aa2ed067295b1de1d3f899f266e297572368ef5fad1359fef492556121103346f20c248d95a5be724bdf2d575316cc965e166e623f4359332b0a2971e685c0c6d84cf28383a2f546d08c531494c8ab059357384a910f9434bb0c0a59b393e099680c77fbbabf0317ca`,
recipeConfig: [
{
op: "Parse SSH Host Key",
args: ["Base64"]
}
]
},
{
name: "SSH Host Key: ECDSA",
input: "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGxZWSAGJyJQoVBwFCpr420eRUZDE/kw2YWm5vDro8050DZ1ZzqIuYaNl0BGzMcRTeasGtJuI8G84ZQQSgca3C4=",
expectedOutput: `Key type: ecdsa-sha2-nistp256
Curve: nistp256
Point: 0x046c59592006272250a15070142a6be36d1e45464313f930d985a6e6f0eba3cd39d03675673a88b9868d974046ccc7114de6ac1ad26e23c1bce194104a071adc2e`,
recipeConfig: [
{
op: "Parse SSH Host Key",
args: ["Base64"]
}
]
},
{
name: "SSH Host Key: Extract key",
input: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDiJZ/9W9Ix/Dk9b+K4E+RGCug1AtkGXaJ9vNIY0YHFHLpWsB8DAuh/cGEI9TLbL1gzR2wG+RJNQ2EAQVWe6ypkK63Jm4zw4re+vhEiszpnP889J0h5N9yzyTndesrl4d3cQtv861FcKDPxUJbRALdtl6gwOB7BCL8gsXJLLVLO4EesrbPXD454qpVt7CgJXEXByOFjcIm3XwkdOnXMPHHnMSD7EIN1SvQMD6PfIDrbDd6KQt5QXW/Rc/BsfX5cbUIV1QW5A/GbepXHHKmWRtLC2J/mH3hW2Zq/hITPEaJdG1CtIilQmJaZGXpfGIwFeb0Av9pSL926arZZ6vDi9ctF test@test",
expectedOutput: `Key type: ssh-rsa
Exponent: 0x010001
Modulus: 0x00e2259ffd5bd231fc393d6fe2b813e4460ae83502d9065da27dbcd218d181c51cba56b01f0302e87f706108f532db2f5833476c06f9124d43610041559eeb2a642badc99b8cf0e2b7bebe1122b33a673fcf3d27487937dcb3c939dd7acae5e1dddc42dbfceb515c2833f15096d100b76d97a830381ec108bf20b1724b2d52cee047acadb3d70f8e78aa956dec28095c45c1c8e1637089b75f091d3a75cc3c71e73120fb1083754af40c0fa3df203adb0dde8a42de505d6fd173f06c7d7e5c6d4215d505b903f19b7a95c71ca99646d2c2d89fe61f7856d99abf8484cf11a25d1b50ad222950989699197a5f188c0579bd00bfda522fddba6ab659eaf0e2f5cb45`,
recipeConfig: [
{
op: "Parse SSH Host Key",
args: ["Base64"]
}
]
}
]);

View file

@ -6,7 +6,7 @@
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,68 @@
/**
* Parse UDP tests.
*
* @author h345983745
*
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Parse UDP: No Data - JSON",
input: "04 89 00 35 00 2c 01 01",
expectedOutput: "{\"Source port\":1161,\"Destination port\":53,\"Length\":44,\"Checksum\":\"0101\"}",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"],
},
{
op: "Parse UDP",
args: [],
},
{
op: "JSON Minify",
args: [],
},
],
}, {
name: "Parse UDP: With Data - JSON",
input: "04 89 00 35 00 2c 01 01 02 02",
expectedOutput: "{\"Source port\":1161,\"Destination port\":53,\"Length\":44,\"Checksum\":\"0101\",\"Data\":\"0202\"}",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"],
},
{
op: "Parse UDP",
args: [],
},
{
op: "JSON Minify",
args: [],
},
],
},
{
name: "Parse UDP: Not Enough Bytes",
input: "04 89 00",
expectedOutput: "Need 8 bytes for a UDP Header",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"],
},
{
op: "Parse UDP",
args: [],
},
{
op: "JSON Minify",
args: [],
},
],
}
]);

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,36 @@
/**
* Protobuf tests.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Protobuf Decode",
input: "0d1c0000001203596f751a024d65202b2a0a0a066162633132331200",
expectedOutput: JSON.stringify({
"1": 469762048,
"2": "You",
"3": "Me",
"4": 43,
"5": {
"1": "abc123",
"2": {}
}
}, null, 4),
recipeConfig: [
{
"op": "From Hex",
"args": ["Auto"]
},
{
"op": "Protobuf Decode",
"args": []
}
]
},
]);

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([

View file

@ -5,7 +5,7 @@
* @copyright Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

File diff suppressed because one or more lines are too long

View file

@ -5,7 +5,7 @@
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,55 @@
/**
* To Geohash tests
*
* @author gchq77703
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "To Geohash",
input: "37.8324,112.5584",
expectedOutput: "ww8p1r4t8",
recipeConfig: [
{
op: "To Geohash",
args: [9],
},
],
},
{
name: "To Geohash",
input: "37.9324,-112.2584",
expectedOutput: "9w8pv3ruj",
recipeConfig: [
{
op: "To Geohash",
args: [9],
},
],
},
{
name: "To Geohash",
input: "37.8324,112.5584",
expectedOutput: "ww8",
recipeConfig: [
{
op: "To Geohash",
args: [3],
},
],
},
{
name: "To Geohash",
input: "37.9324,-112.2584",
expectedOutput: "9w8pv3rujxy5b99",
recipeConfig: [
{
op: "To Geohash",
args: [15],
},
],
},
]);

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,105 @@
/**
* Typex machine tests.
* @author s2224834
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
// Unlike Enigma we're not verifying against a real machine here, so this is just a test
// to catch inadvertent breakage.
name: "Typex: basic",
input: "hello world, this is a test message.",
expectedOutput: "VIXQQ VHLPN UCVLA QDZNZ EAYAT HWC",
recipeConfig: [
{
"op": "Typex",
"args": [
"MCYLPQUVRXGSAOWNBJEZDTFKHI<BFHNQUW",
false, "B", "C",
"KHWENRCBISXJQGOFMAPVYZDLTU<BFHNQUW",
false, "D", "E",
"BYPDZMGIKQCUSATREHOJNLFWXV<BFHNQUW",
false, "F", "G",
"ZANJCGDLVHIXOBRPMSWQUKFYET<BFHNQUW",
true, "H", "I",
"QXBGUTOVFCZPJIHSWERYNDAMLK<BFHNQUW",
true, "J", "K",
"AN BC FG IE KD LU MH OR TS VZ WQ XJ YP",
"EHZTLCVKFRPQSYANBUIWOJXGMD",
"None", true
]
}
]
},
{
name: "Typex: keyboard",
input: "hello world, this is a test message.",
expectedOutput: "VIXQQ FDJXT WKLDQ DFQOD CNCSK NULBG JKQDD MVGQ",
recipeConfig: [
{
"op": "Typex",
"args": [
"MCYLPQUVRXGSAOWNBJEZDTFKHI<BFHNQUW",
false, "B", "C",
"KHWENRCBISXJQGOFMAPVYZDLTU<BFHNQUW",
false, "D", "E",
"BYPDZMGIKQCUSATREHOJNLFWXV<BFHNQUW",
false, "F", "G",
"ZANJCGDLVHIXOBRPMSWQUKFYET<BFHNQUW",
true, "H", "I",
"QXBGUTOVFCZPJIHSWERYNDAMLK<BFHNQUW",
true, "J", "K",
"AN BC FG IE KD LU MH OR TS VZ WQ XJ YP",
"EHZTLCVKFRPQSYANBUIWOJXGMD",
"Encrypt", true
]
}
]
},
{
name: "Typex: self-decrypt",
input: "hello world, this is a test message.",
expectedOutput: "HELLO WORLD, THIS IS A TEST MESSAGE.",
recipeConfig: [
{
"op": "Typex",
"args": [
"MCYLPQUVRXGSAOWNBJEZDTFKHI<BFHNQUW",
false, "B", "C",
"KHWENRCBISXJQGOFMAPVYZDLTU<BFHNQUW",
false, "D", "E",
"BYPDZMGIKQCUSATREHOJNLFWXV<BFHNQUW",
false, "F", "G",
"ZANJCGDLVHIXOBRPMSWQUKFYET<BFHNQUW",
true, "H", "I",
"QXBGUTOVFCZPJIHSWERYNDAMLK<BFHNQUW",
true, "J", "K",
"AN BC FG IE KD LU MH OR TS VZ WQ XJ YP",
"EHZTLCVKFRPQSYANBUIWOJXGMD",
"Encrypt", true
]
},
{
"op": "Typex",
"args": [
"MCYLPQUVRXGSAOWNBJEZDTFKHI<BFHNQUW",
false, "B", "C",
"KHWENRCBISXJQGOFMAPVYZDLTU<BFHNQUW",
false, "D", "E",
"BYPDZMGIKQCUSATREHOJNLFWXV<BFHNQUW",
false, "F", "G",
"ZANJCGDLVHIXOBRPMSWQUKFYET<BFHNQUW",
true, "H", "I",
"QXBGUTOVFCZPJIHSWERYNDAMLK<BFHNQUW",
true, "J", "K",
"AN BC FG IE KD LU MH OR TS VZ WQ XJ YP",
"EHZTLCVKFRPQSYANBUIWOJXGMD",
"Decrypt", true
]
}
]
},
]);

View file

@ -6,7 +6,7 @@
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{