Merge branch 'master' into bugfix-api-sanitise

This commit is contained in:
a3957273 2024-03-30 19:49:33 +00:00 committed by GitHub
commit bea1b7dc58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
430 changed files with 41278 additions and 17234 deletions

View file

@ -5,6 +5,9 @@
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/
const utils = require("./browserUtils.js");
module.exports = {
before: browser => {
browser
@ -70,7 +73,7 @@ module.exports = {
.moveToElement(toHex, 10, 10)
.useCss()
.waitForElementVisible(".popover-body", 1000)
.doubleClick();
.doubleClick("xpath", toHex);
// Confirm that it has been added to the recipe
browser
@ -81,7 +84,7 @@ module.exports = {
// Enter input
browser
.useCss()
.setValue("#input-text", "Don't Panic.")
.sendKeys("#input-text .cm-content", "Don't Panic.")
.pause(1000)
.click("#bake");
@ -89,7 +92,7 @@ module.exports = {
browser
.useCss()
.waitForElementNotVisible("#stale-indicator", 1000)
.expect.element("#output-text").to.have.value.that.equals("44 6f 6e 27 74 20 50 61 6e 69 63 2e");
.expect.element("#output-text .cm-content").text.that.equals("44 6f 6e 27 74 20 50 61 6e 69 63 2e");
// Clear recipe
browser
@ -191,6 +194,9 @@ module.exports = {
// Open category
browser
.useCss()
.waitForElementNotVisible("#snackbar-container", 10000)
.useXpath()
.click(otherCat)
.expect.element(genUUID).to.be.visible;
@ -201,11 +207,11 @@ module.exports = {
browser
.getLocationInView(genUUID)
.moveToElement(genUUID, 10, 10)
.doubleClick()
.doubleClick("xpath", genUUID)
.useCss()
.waitForElementVisible(".operation .op-title", 1000)
.waitForElementNotVisible("#stale-indicator", 1000)
.expect.element("#output-text").to.have.value.which.matches(/[\da-f-]{36}/);
.expect.element("#output-text .cm-content").text.which.matches(/[\da-f-]{36}/);
browser.click("#clr-recipe");
},
@ -217,7 +223,26 @@ module.exports = {
.clearValue("#search")
.setValue("#search", "md5")
.useXpath()
.waitForElementVisible("//ul[@id='search-results']//u[text()='MD5']", 1000);
.waitForElementVisible("//ul[@id='search-results']//b[text()='MD5']", 1000);
},
"Alert bar": browser => {
// Bake nothing to create an empty output which can be copied
utils.clear(browser);
utils.bake(browser);
// Alert bar shows and contains correct content
browser
.waitForElementNotVisible("#snackbar-container")
.click("#copy-output")
.waitForElementVisible("#snackbar-container .snackbar-content")
.expect.element("#snackbar-container .snackbar-content").text.to.equal("Copied raw output successfully.");
// Alert bar disappears after the correct amount of time
// Should disappear after 2000ms
browser
.waitForElementNotPresent("#snackbar-container .snackbar-content", 2500)
.waitForElementNotVisible("#snackbar-container");
},
after: browser => {

704
tests/browser/01_io.js Normal file
View file

@ -0,0 +1,704 @@
/**
* Tests for input and output of various types to ensure the editors work as expected
* and retain data integrity, especially when it comes to special characters.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2023
* @license Apache-2.0
*/
// import {
// clear,
// utils.setInput,
// bake,
// setChrEnc,
// setEOLSeq,
// copy,
// paste,
// loadRecipe,
// expectOutput,
// uploadFile,
// uploadFolder
// } from "./browserUtils.js";
const utils = require("./browserUtils.js");
const SPECIAL_CHARS = [
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000a\u000b\u000c\u000d\u000e\u000f",
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f",
"\u007f",
"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008a\u008b\u008c\u008d\u008e\u008f",
"\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009a\u009b\u009c\u009d\u009e\u009f",
"\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9\ufffa\ufffb\ufffc"
].join("");
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f",
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f",
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f",
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
].join("");
const PUA_CHARS = "\ue000\ue001\uf8fe\uf8ff";
const MULTI_LINE_STRING =`"You know," said Arthur, "it's at times like this, when I'm trapped in a Vogon airlock with a man from Betelgeuse, and about to die of asphyxiation in deep space that I really wish I'd listened to what my mother told me when I was young."
"Why, what did she tell you?"
"I don't know, I didn't listen."`;
const SELECTABLE_STRING = `ONE
two
ONE
three
ONE
four
ONE`;
// Descriptions for named control characters
const CONTROL_CHAR_NAMES = {
0: "null",
7: "bell",
8: "backspace",
10: "line feed",
11: "vertical tab",
13: "carriage return",
27: "escape",
8203: "zero width space",
8204: "zero width non-joiner",
8205: "zero width joiner",
8206: "left-to-right mark",
8207: "right-to-left mark",
8232: "line separator",
8237: "left-to-right override",
8238: "right-to-left override",
8294: "left-to-right isolate",
8295: "right-to-left isolate",
8297: "pop directional isolate",
8233: "paragraph separator",
65279: "zero width no-break space",
65532: "object replacement"
};
module.exports = {
before: browser => {
browser
.resizeWindow(1280, 800)
.url(browser.launchUrl)
.useCss()
.waitForElementNotPresent("#preloader", 10000)
.click("#auto-bake-label");
},
"CodeMirror has loaded correctly": browser => {
/* Editor has initialised */
browser
.useCss()
// Input
.waitForElementVisible("#input-text")
.waitForElementVisible("#input-text .cm-editor")
.waitForElementVisible("#input-text .cm-editor .cm-scroller")
.waitForElementVisible("#input-text .cm-editor .cm-scroller .cm-content")
.waitForElementVisible("#input-text .cm-editor .cm-scroller .cm-content .cm-line")
// Output
.waitForElementVisible("#output-text")
.waitForElementVisible("#output-text .cm-editor")
.waitForElementVisible("#output-text .cm-editor .cm-scroller")
.waitForElementVisible("#output-text .cm-editor .cm-scroller .cm-content")
.waitForElementVisible("#output-text .cm-editor .cm-scroller .cm-content .cm-line");
/* Status bar is showing and has correct values */
browser // Input
.waitForElementVisible("#input-text .cm-status-bar")
.waitForElementVisible("#input-text .cm-status-bar .stats-length-value")
.expect.element("#input-text .cm-status-bar .stats-length-value").text.to.equal("0");
browser.waitForElementVisible("#input-text .cm-status-bar .stats-lines-value")
.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("1");
browser.waitForElementVisible("#input-text .cm-status-bar .chr-enc-value")
.expect.element("#input-text .cm-status-bar .chr-enc-value").text.to.equal("Raw Bytes");
browser.waitForElementVisible("#input-text .cm-status-bar .eol-value")
.expect.element("#input-text .cm-status-bar .eol-value").text.to.equal("LF");
browser // Output
.waitForElementVisible("#output-text .cm-status-bar")
.waitForElementVisible("#output-text .cm-status-bar .stats-length-value")
.expect.element("#output-text .cm-status-bar .stats-length-value").text.to.equal("0");
browser.waitForElementVisible("#output-text .cm-status-bar .stats-lines-value")
.expect.element("#output-text .cm-status-bar .stats-lines-value").text.to.equal("1");
browser.waitForElementVisible("#output-text .cm-status-bar .baking-time-info")
.expect.element("#output-text .cm-status-bar .baking-time-info").text.to.contain("ms");
browser.waitForElementVisible("#output-text .cm-status-bar .chr-enc-value")
.expect.element("#output-text .cm-status-bar .chr-enc-value").text.to.equal("Raw Bytes");
browser.waitForElementVisible("#output-text .cm-status-bar .eol-value")
.expect.element("#output-text .cm-status-bar .eol-value").text.to.equal("LF");
},
"Adding content": browser => {
/* Status bar updates correctly */
utils.setInput(browser, MULTI_LINE_STRING);
browser.expect.element("#input-text .cm-status-bar .stats-length-value").text.to.equal("301");
browser.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("3");
browser.expect.element("#input-text .cm-status-bar .chr-enc-value").text.to.equal("Raw Bytes");
browser.expect.element("#input-text .cm-status-bar .eol-value").text.to.equal("LF");
browser.expect.element("#output-text .cm-status-bar .stats-length-value").text.to.equal("0");
browser.expect.element("#output-text .cm-status-bar .stats-lines-value").text.to.equal("1");
browser.expect.element("#output-text .cm-status-bar .baking-time-info").text.to.contain("ms");
browser.expect.element("#output-text .cm-status-bar .chr-enc-value").text.to.equal("Raw Bytes");
browser.expect.element("#output-text .cm-status-bar .eol-value").text.to.equal("LF");
/* Output updates correctly */
utils.bake(browser);
browser.expect.element("#output-text .cm-status-bar .stats-length-value").text.to.equal("301");
browser.expect.element("#output-text .cm-status-bar .stats-lines-value").text.to.equal("3");
browser.expect.element("#output-text .cm-status-bar .baking-time-info").text.to.contain("ms");
browser.expect.element("#output-text .cm-status-bar .chr-enc-value").text.to.equal("Raw Bytes");
browser.expect.element("#output-text .cm-status-bar .eol-value").text.to.equal("LF");
},
"Special content": browser => {
/* Special characters are rendered correctly */
utils.setInput(browser, SPECIAL_CHARS, false);
// First line
for (let i = 0x0; i <= 0x8; i++) {
browser.expect.element(`#input-text .cm-line:nth-of-type(1) .cm-specialChar:nth-of-type(${i+1})`)
.to.have.property("title").equals(`Control character ${CONTROL_CHAR_NAMES[i] || "0x" + i.toString(16)}`);
browser.expect.element(`#input-text .cm-line:nth-of-type(1) .cm-specialChar:nth-of-type(${i+1})`)
.text.to.equal(String.fromCharCode(0x2400 + i));
}
// Tab \u0009
browser.expect.element(`#input-text .cm-line:nth-of-type(1)`).to.have.property("textContent").match(/\u0009$/);
// Line feed \u000a
browser.expect.element(`#input-text .cm-line:nth-of-type(1)`).to.have.property("textContent").match(/^.{10}$/);
browser.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("2");
// Second line
for (let i = 0x0b; i < SPECIAL_CHARS.length; i++) {
const index = SPECIAL_CHARS.charCodeAt(i);
const name = CONTROL_CHAR_NAMES[index] || "0x" + index.toString(16);
const value = index >= 32 ? "\u2022" : String.fromCharCode(0x2400 + index);
browser.expect.element(`#input-text .cm-line:nth-of-type(2) .cm-specialChar:nth-of-type(${i-10})`)
.to.have.property("title").equals(`Control character ${name}`);
browser.expect.element(`#input-text .cm-line:nth-of-type(2) .cm-specialChar:nth-of-type(${i-10})`)
.text.to.equal(value);
}
/* Output renders correctly */
utils.setChrEnc(browser, "output", "UTF-8");
utils.bake(browser);
// First line
for (let i = 0x0; i <= 0x8; i++) {
browser.expect.element(`#output-text .cm-line:nth-of-type(1) .cm-specialChar:nth-of-type(${i+1})`)
.to.have.property("title").equals(`Control character ${CONTROL_CHAR_NAMES[i] || "0x" + i.toString(16)}`);
browser.expect.element(`#output-text .cm-line:nth-of-type(1) .cm-specialChar:nth-of-type(${i+1})`)
.text.to.equal(String.fromCharCode(0x2400 + i));
}
// Tab \u0009
browser.expect.element(`#output-text .cm-line:nth-of-type(1)`).to.have.property("textContent").match(/\u0009$/);
// Line feed \u000a
browser.expect.element(`#output-text .cm-line:nth-of-type(1)`).to.have.property("textContent").match(/^.{10}$/);
browser.expect.element("#output-text .cm-status-bar .stats-lines-value").text.to.equal("2");
// Second line
for (let i = 0x0b; i < SPECIAL_CHARS.length; i++) {
const index = SPECIAL_CHARS.charCodeAt(i);
const name = CONTROL_CHAR_NAMES[index] || "0x" + index.toString(16);
const value = index >= 32 ? "\u2022" : String.fromCharCode(0x2400 + index);
browser.expect.element(`#output-text .cm-content .cm-line:nth-of-type(2) .cm-specialChar:nth-of-type(${i-10})`)
.to.have.property("title").equals(`Control character ${name}`);
browser.expect.element(`#output-text .cm-content .cm-line:nth-of-type(2) .cm-specialChar:nth-of-type(${i-10})`)
.text.to.equal(value);
}
/* Bytes are rendered correctly */
utils.setInput(browser, ALL_BYTES, false);
// Expect length to be 255, since one character is creating a newline
browser.expect.element(`#input-text .cm-content`).to.have.property("textContent").match(/^.{255}$/);
browser.expect.element("#input-text .cm-status-bar .stats-length-value").text.to.equal("256");
browser.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("2");
/* PUA \ue000-\uf8ff */
utils.setInput(browser, PUA_CHARS, false);
utils.setChrEnc(browser, "output", "UTF-8");
utils.bake(browser);
// Confirm input and output as expected
/* In order to render whitespace characters as control character pictures in the output, even
when they are the designated line separator, CyberChef sometimes chooses to represent them
internally using the Unicode Private Use Area (https://en.wikipedia.org/wiki/Private_Use_Areas).
See `Utils.escapeWhitespace()` for an example of this.
Therefore, PUA characters should be rendered normally in the Input but as control character
pictures in the output.
*/
browser.expect.element(`#input-text .cm-content`).to.have.property("textContent").match(/^\ue000\ue001\uf8fe\uf8ff$/);
browser.expect.element(`#output-text .cm-content`).to.have.property("textContent").match(/^\u2400\u2401\u3cfe\u3cff$/);
/* Can be copied */
utils.setInput(browser, SPECIAL_CHARS, false);
utils.setChrEnc(browser, "output", "UTF-8");
utils.bake(browser);
// Manual copy
browser
.doubleClick("#output-text .cm-content .cm-line:nth-of-type(1) .cm-specialChar:nth-of-type(1)")
.waitForElementVisible("#output-text .cm-selectionBackground");
utils.copy(browser);
utils.paste(browser, "#search"); // Paste into search box as this won't mess with the values
// Ensure that the values are as expected
browser.expect.element("#search").to.have.value.that.equals("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008");
browser.clearValue("#search");
// Raw copy
browser
.click("#copy-output")
.pause(100);
utils.paste(browser, "#search"); // Paste into search box as this won't mess with the values
// Ensure that the values are as expected
browser.expect.element("#search").to.have.value.that.matches(/^\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009/);
browser.clearValue("#search");
},
"HTML output": browser => {
/* Displays correctly */
utils.loadRecipe(browser, "Entropy", ALL_BYTES);
utils.bake(browser);
browser
.waitForElementVisible("#output-html")
.waitForElementVisible("#output-html #chart-area");
/* Status bar widgets are disabled */
browser.expect.element("#output-text .cm-status-bar .disabled .stats-length-value").to.be.visible;
browser.expect.element("#output-text .cm-status-bar .disabled .stats-lines-value").to.be.visible;
browser.expect.element("#output-text .cm-status-bar .disabled .chr-enc-value").to.be.visible;
browser.expect.element("#output-text .cm-status-bar .disabled .eol-value").to.be.visible;
/* Displays special chars correctly */
utils.loadRecipe(browser, "To Table", ",\u0000\u0001\u0002\u0003\u0004", [",", "\\r\\n", false, "HTML"]);
utils.bake(browser);
for (let i = 0x0; i <= 0x4; i++) {
browser.expect.element(`#output-html .cm-specialChar:nth-of-type(${i+1})`)
.to.have.property("title").equals(`Control character ${CONTROL_CHAR_NAMES[i] || "0x" + i.toString(16)}`);
browser.expect.element(`#output-html .cm-specialChar:nth-of-type(${i+1})`)
.text.to.equal(String.fromCharCode(0x2400 + i));
}
/* Can be copied */
// Raw copy
browser
.click("#copy-output")
.pause(100);
utils.paste(browser, "#search"); // Paste into search box as this won't mess with the values
// Ensure that the values are as expected
browser.expect.element("#search").to.have.value.that.matches(/\u0000\u0001\u0002\u0003\u0004/);
browser.clearValue("#search");
},
"Highlighting": browser => {
utils.setInput(browser, SELECTABLE_STRING);
utils.bake(browser);
/* Selecting input text also selects other instances in input and output */
browser // Input
.click("#auto-bake-label")
.doubleClick("#input-text .cm-content .cm-line:nth-of-type(1)")
.waitForElementVisible("#input-text .cm-selectionLayer .cm-selectionBackground")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(1) .cm-selectionMatch")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(2) .cm-selectionMatch")
.waitForElementVisible("#input-text .cm-content .cm-line:nth-of-type(3) .cm-selectionMatch")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(4) .cm-selectionMatch")
.waitForElementVisible("#input-text .cm-content .cm-line:nth-of-type(5) .cm-selectionMatch")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(6) .cm-selectionMatch")
.waitForElementVisible("#input-text .cm-content .cm-line:nth-of-type(7) .cm-selectionMatch");
browser // Output
.waitForElementVisible("#output-text .cm-selectionLayer .cm-selectionBackground")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(1) .cm-selectionMatch")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(2) .cm-selectionMatch")
.waitForElementVisible("#output-text .cm-content .cm-line:nth-of-type(3) .cm-selectionMatch")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(4) .cm-selectionMatch")
.waitForElementVisible("#output-text .cm-content .cm-line:nth-of-type(5) .cm-selectionMatch")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(6) .cm-selectionMatch")
.waitForElementVisible("#output-text .cm-content .cm-line:nth-of-type(7) .cm-selectionMatch");
/* Selecting output text highlights in input */
browser // Output
.click("#output-text")
.waitForElementNotPresent("#input-text .cm-selectionLayer .cm-selectionBackground")
.waitForElementNotPresent("#output-text .cm-selectionLayer .cm-selectionBackground")
.waitForElementNotPresent("#input-text .cm-content .cm-line .cm-selectionMatch")
.waitForElementNotPresent("#output-text .cm-content .cm-line .cm-selectionMatch")
.doubleClick("#output-text .cm-content .cm-line:nth-of-type(7)")
.waitForElementVisible("#output-text .cm-selectionLayer .cm-selectionBackground")
.waitForElementVisible("#output-text .cm-content .cm-line:nth-of-type(1) .cm-selectionMatch")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(2) .cm-selectionMatch")
.waitForElementVisible("#output-text .cm-content .cm-line:nth-of-type(3) .cm-selectionMatch")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(4) .cm-selectionMatch")
.waitForElementVisible("#output-text .cm-content .cm-line:nth-of-type(5) .cm-selectionMatch")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(6) .cm-selectionMatch")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(7) .cm-selectionMatch");
browser // Input
.waitForElementVisible("#input-text .cm-selectionLayer .cm-selectionBackground")
.waitForElementVisible("#input-text .cm-content .cm-line:nth-of-type(1) .cm-selectionMatch")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(2) .cm-selectionMatch")
.waitForElementVisible("#input-text .cm-content .cm-line:nth-of-type(3) .cm-selectionMatch")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(4) .cm-selectionMatch")
.waitForElementVisible("#input-text .cm-content .cm-line:nth-of-type(5) .cm-selectionMatch")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(6) .cm-selectionMatch")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(7) .cm-selectionMatch");
// Turn autobake off again
browser.click("#auto-bake-label");
},
"Character encoding": browser => {
const CHINESE_CHARS = "不要恐慌。";
/* Dropup works */
/* Selecting changes output correctly */
utils.setInput(browser, CHINESE_CHARS, false);
utils.setChrEnc(browser, "input", "UTF-8");
utils.bake(browser);
utils.expectOutput(browser, "\u00E4\u00B8\u008D\u00E8\u00A6\u0081\u00E6\u0081\u0090\u00E6\u0085\u008C\u00E3\u0080\u0082");
/* Changing output to match input works as expected */
utils.setChrEnc(browser, "output", "UTF-8");
utils.bake(browser);
utils.expectOutput(browser, CHINESE_CHARS);
/* Encodings appear in the URL */
browser.assert.urlContains("ienc=65001");
browser.assert.urlContains("oenc=65001");
/* Preserved when changing tabs */
browser
.click("#btn-new-tab")
.waitForElementVisible("#input-tabs li:nth-of-type(2).active-input-tab");
browser.expect.element("#input-text .chr-enc-value").text.that.equals("Raw Bytes");
browser.expect.element("#output-text .chr-enc-value").text.that.equals("Raw Bytes");
utils.setChrEnc(browser, "input", "UTF-7");
utils.setChrEnc(browser, "output", "UTF-7");
browser
.click("#input-tabs li:nth-of-type(1)")
.waitForElementVisible("#input-tabs li:nth-of-type(1).active-input-tab");
browser.expect.element("#input-text .chr-enc-value").text.that.equals("UTF-8");
browser.expect.element("#output-text .chr-enc-value").text.that.equals("UTF-8");
/* Try various encodings */
// These are not meant to be realistic encodings for this data
utils.setInput(browser, CHINESE_CHARS, false);
utils.setChrEnc(browser, "input", "UTF-8");
utils.setChrEnc(browser, "output", "UTF-16LE");
utils.bake(browser);
utils.expectOutput(browser, "\uB8E4\uE88D\u81A6\u81E6\uE690\u8C85\u80E3");
utils.setChrEnc(browser, "output", "Simplified Chinese GBK");
utils.bake(browser);
utils.expectOutput(browser, "\u6D93\u5D88\uFDFF\u93AD\u612D\u53A1\u9286\u0000");
utils.setChrEnc(browser, "input", "UTF-7");
utils.bake(browser);
utils.expectOutput(browser, "+Tg0-+iYE-+YFA-+YUw-");
utils.setChrEnc(browser, "input", "Traditional Chinese Big5");
utils.bake(browser);
utils.expectOutput(browser, "\u3043\u74B6\uFDFF\u7A3A\uFDFF");
utils.setChrEnc(browser, "output", "Windows-1251 Cyrillic");
utils.bake(browser);
utils.expectOutput(browser, "\u00A4\u0408\u00ADn\u00AE\u0408\u00B7W\u040EC");
},
"Line endings": browser => {
/* Dropup works */
/* Selecting changes view in input */
utils.setInput(browser, MULTI_LINE_STRING);
// Line endings: LF
// Input
browser
.waitForElementPresent("#input-text .cm-content .cm-line:nth-of-type(3)")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(4)")
.waitForElementNotPresent("#input-text .cm-content .cm-specialChar");
browser.expect.element("#input-text .cm-status-bar .stats-length-value").text.to.equal("301");
browser.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("3");
// Output
utils.bake(browser);
browser
.waitForElementPresent("#output-text .cm-content .cm-line:nth-of-type(3)")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(4)")
.waitForElementNotPresent("#output-text .cm-content .cm-specialChar");
browser.expect.element("#output-text .cm-status-bar .stats-length-value").text.to.equal("301");
browser.expect.element("#output-text .cm-status-bar .stats-lines-value").text.to.equal("3");
// Input EOL: VT
utils.setEOLSeq(browser, "input", "VT");
// Input
browser
.waitForElementPresent("#input-text .cm-content .cm-line:nth-of-type(1)")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(2)")
.waitForElementPresent("#input-text .cm-content .cm-specialChar");
browser.expect.element("#input-text .cm-content .cm-specialChar").text.to.equal("␊");
browser.expect.element("#input-text .cm-status-bar .stats-length-value").text.to.equal("301");
browser.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("1");
// Output
utils.bake(browser);
browser
.waitForElementPresent("#output-text .cm-content .cm-line:nth-of-type(3)")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(4)")
.waitForElementNotPresent("#output-text .cm-content .cm-specialChar");
browser.expect.element("#output-text .cm-status-bar .stats-length-value").text.to.equal("301");
browser.expect.element("#output-text .cm-status-bar .stats-lines-value").text.to.equal("3");
// Output EOL: VT
utils.setEOLSeq(browser, "output", "VT");
// Input
browser
.waitForElementPresent("#input-text .cm-content .cm-line:nth-of-type(1)")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(2)")
.waitForElementPresent("#input-text .cm-content .cm-specialChar");
browser.expect.element("#input-text .cm-content .cm-specialChar").text.to.equal("␊");
browser.expect.element("#input-text .cm-status-bar .stats-length-value").text.to.equal("301");
browser.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("1");
// Output
browser
.waitForElementPresent("#output-text .cm-content .cm-line:nth-of-type(1)")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(2)")
.waitForElementPresent("#output-text .cm-content .cm-specialChar");
browser.expect.element("#output-text .cm-content .cm-specialChar").text.to.equal("␊");
browser.expect.element("#output-text .cm-status-bar .stats-length-value").text.to.equal("301");
browser.expect.element("#output-text .cm-status-bar .stats-lines-value").text.to.equal("1");
/* Adding new line ending changes output correctly */
browser.sendKeys("#input-text .cm-content", browser.Keys.RETURN);
// Input
browser
.waitForElementPresent("#input-text .cm-content .cm-line:nth-of-type(2)")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(3)");
browser.expect.element("#input-text .cm-status-bar .stats-length-value").text.to.equal("302");
browser.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("2");
// Output
utils.bake(browser);
browser
.waitForElementPresent("#output-text .cm-content .cm-line:nth-of-type(2)")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(3)");
browser.expect.element("#output-text .cm-status-bar .stats-length-value").text.to.equal("302");
browser.expect.element("#output-text .cm-status-bar .stats-lines-value").text.to.equal("2");
// Input EOL: CRLF
utils.setEOLSeq(browser, "input", "CRLF");
// Output EOL: CR
utils.setEOLSeq(browser, "output", "CR");
browser.sendKeys("#input-text .cm-content", browser.Keys.RETURN);
// Input
browser
.waitForElementPresent("#input-text .cm-content .cm-line:nth-of-type(2)")
.waitForElementNotPresent("#input-text .cm-content .cm-line:nth-of-type(3)")
.waitForElementPresent("#input-text .cm-content .cm-line:nth-of-type(1) .cm-specialChar:nth-of-type(3)");
browser.expect.element("#input-text .cm-content .cm-line:nth-of-type(1) .cm-specialChar:nth-of-type(3)").text.to.equal("␋");
browser.expect.element("#input-text .cm-status-bar .stats-length-value").text.to.equal("304");
browser.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("2");
// Output
utils.bake(browser);
browser
.waitForElementPresent("#output-text .cm-content .cm-line:nth-of-type(2)")
.waitForElementNotPresent("#output-text .cm-content .cm-line:nth-of-type(3)")
.waitForElementPresent("#output-text .cm-content .cm-line:nth-of-type(2) .cm-specialChar");
browser.expect.element("#output-text .cm-content .cm-line:nth-of-type(2) .cm-specialChar").text.to.equal("␊");
browser.expect.element("#output-text .cm-status-bar .stats-length-value").text.to.equal("304");
browser.expect.element("#output-text .cm-status-bar .stats-lines-value").text.to.equal("2");
/* Line endings appear in the URL */
browser.assert.urlContains("ieol=CRLF");
browser.assert.urlContains("oeol=CR");
/* Preserved when changing tabs */
browser
.click("#btn-new-tab")
.waitForElementVisible("#input-tabs li:nth-of-type(2).active-input-tab");
browser.expect.element("#input-text .eol-value").text.that.equals("LF");
browser.expect.element("#output-text .eol-value").text.that.equals("LF");
utils.setEOLSeq(browser, "input", "FF");
utils.setEOLSeq(browser, "output", "LS");
browser
.click("#input-tabs li:nth-of-type(1)")
.waitForElementVisible("#input-tabs li:nth-of-type(1).active-input-tab");
browser.expect.element("#input-text .eol-value").text.that.equals("CRLF");
browser.expect.element("#output-text .eol-value").text.that.equals("CR");
},
"File inputs": browser => {
utils.clear(browser);
/* Side panel displays correct info */
utils.uploadFile(browser, "files/TowelDay.jpeg");
browser
.waitForElementVisible("#input-text .cm-file-details")
.waitForElementVisible("#input-text .cm-file-details .file-details-toggle-shown")
.waitForElementVisible("#input-text .cm-file-details .file-details-thumbnail")
.waitForElementVisible("#input-text .cm-file-details .file-details-name")
.waitForElementVisible("#input-text .cm-file-details .file-details-size")
.waitForElementVisible("#input-text .cm-file-details .file-details-type")
.waitForElementVisible("#input-text .cm-file-details .file-details-loaded");
browser.expect.element("#input-text .cm-file-details .file-details-name").text.that.equals("TowelDay.jpeg");
browser.expect.element("#input-text .cm-file-details .file-details-size").text.that.equals("61,379 bytes");
browser.expect.element("#input-text .cm-file-details .file-details-type").text.that.equals("image/jpeg");
browser.expect.element("#input-text .cm-file-details .file-details-loaded").text.that.equals("100%");
/* Side panel can be hidden */
browser
.click("#input-text .cm-file-details .file-details-toggle-shown")
.waitForElementNotPresent("#input-text .cm-file-details .file-details-toggle-shown")
.waitForElementVisible("#input-text .cm-file-details .file-details-toggle-hidden")
.expect.element("#input-text .cm-file-details").to.have.css("width").which.equals("1px");
browser
.click("#input-text .cm-file-details .file-details-toggle-hidden")
.waitForElementNotPresent("#input-text .cm-file-details .file-details-toggle-hidden")
.waitForElementVisible("#input-text .cm-file-details .file-details-toggle-shown")
.expect.element("#input-text .cm-file-details").to.have.css("width").which.equals("200px");
},
"Folder inputs": browser => {
utils.clear(browser);
/* Side panel displays correct info */
utils.uploadFolder(browser, "files");
// Loop through tabs
for (let i = 1; i < 3; i++) {
browser
.click(`#input-tabs li:nth-of-type(${i})`)
.waitForElementVisible(`#input-tabs li:nth-of-type(${i}).active-input-tab`);
browser
.waitForElementVisible("#input-text .cm-file-details")
.waitForElementVisible("#input-text .cm-file-details .file-details-toggle-shown")
.waitForElementVisible("#input-text .cm-file-details .file-details-thumbnail")
.waitForElementVisible("#input-text .cm-file-details .file-details-name")
.waitForElementVisible("#input-text .cm-file-details .file-details-size")
.waitForElementVisible("#input-text .cm-file-details .file-details-type")
.waitForElementVisible("#input-text .cm-file-details .file-details-loaded");
browser.getText("#input-text .cm-file-details .file-details-name", function(result) {
switch (result.value) {
case "TowelDay.jpeg":
browser.expect.element("#input-text .cm-file-details .file-details-name").text.that.equals("TowelDay.jpeg");
browser.expect.element("#input-text .cm-file-details .file-details-size").text.that.equals("61,379 bytes");
browser.expect.element("#input-text .cm-file-details .file-details-type").text.that.equals("image/jpeg");
browser.expect.element("#input-text .cm-file-details .file-details-loaded").text.that.equals("100%");
break;
case "Hitchhikers_Guide.jpeg":
browser.expect.element("#input-text .cm-file-details .file-details-name").text.that.equals("Hitchhikers_Guide.jpeg");
browser.expect.element("#input-text .cm-file-details .file-details-size").text.that.equals("36,595 bytes");
browser.expect.element("#input-text .cm-file-details .file-details-type").text.that.equals("image/jpeg");
browser.expect.element("#input-text .cm-file-details .file-details-loaded").text.that.equals("100%");
break;
default:
break;
}
});
}
},
"Loading from URL": browser => {
/* Complex deep link populates the input correctly (encoding, eol, input) */
browser
.urlHash("recipe=To_Base64('A-Za-z0-9%2B/%3D')&input=VGhlIHNoaXBzIGh1bmcgaW4gdGhlIHNreSBpbiBtdWNoIHRoZSBzYW1lIHdheSB0aGF0IGJyaWNrcyBkb24ndC4M&ienc=21866&oenc=1201&ieol=FF&oeol=PS")
.waitForElementVisible("#rec-list li.operation");
browser.expect.element(`#input-text .cm-content`).to.have.property("textContent").match(/^.{65}$/);
browser.expect.element("#input-text .cm-status-bar .stats-length-value").text.to.equal("66");
browser.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("2");
browser.expect.element("#input-text .chr-enc-value").text.that.equals("KOI8-U Ukrainian Cyrillic");
browser.expect.element("#output-text .chr-enc-value").text.that.equals("UTF-16BE");
browser.expect.element("#input-text .eol-value").text.that.equals("FF");
browser.expect.element("#output-text .eol-value").text.that.equals("PS");
utils.bake(browser);
browser.expect.element(`#output-text .cm-content`).to.have.property("textContent").match(/^.{44}$/);
browser.expect.element("#output-text .cm-status-bar .stats-length-value").text.to.equal("44");
browser.expect.element("#output-text .cm-status-bar .stats-lines-value").text.to.equal("1");
},
"Replace input with output": browser => {
/* Input is correctly populated */
utils.loadRecipe(browser, "XOR", "The ships hung in the sky in much the same way that bricks don't.", [{ "option": "Hex", "string": "65" }, "Standard", false]);
utils.setChrEnc(browser, "input", "UTF-32LE");
utils.setChrEnc(browser, "output", "UTF-7");
utils.setEOLSeq(browser, "input", "CRLF");
utils.setEOLSeq(browser, "output", "LS");
browser
.sendKeys("#input-text .cm-content", browser.Keys.RETURN)
.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("2");
utils.bake(browser);
browser.expect.element("#input-text .cm-status-bar .stats-length-value").text.to.equal("67");
browser.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("2");
browser.expect.element("#input-text .chr-enc-value").text.that.equals("UTF-32LE");
browser.expect.element("#input-text .eol-value").text.that.equals("CRLF");
browser.expect.element("#output-text .cm-status-bar .stats-length-value").text.to.equal("268");
browser
.click("#switch")
.waitForElementVisible("#stale-indicator");
browser.expect.element("#input-text .cm-status-bar .stats-length-value").text.to.equal("268");
/* Special characters, encodings and line endings all as expected */
browser.expect.element("#input-text .cm-status-bar .stats-lines-value").text.to.equal("1");
browser.expect.element("#input-text .chr-enc-value").text.that.equals("UTF-7");
browser.expect.element("#input-text .eol-value").text.that.equals("LS");
browser.expect.element("#input-text .cm-line:nth-of-type(1) .cm-specialChar:nth-of-type(1)").text.to.equal("␍");
browser.expect.element("#input-text .cm-line:nth-of-type(1) .cm-specialChar:nth-of-type(49)").text.to.equal("␑");
browser.waitForElementNotPresent("#input-text .cm-line:nth-of-type(1) .cm-specialChar:nth-of-type(50)");
},
after: browser => {
browser.end();
}
};

502
tests/browser/02_ops.js Normal file
View file

@ -0,0 +1,502 @@
/**
* Tests for operations.
* The primary purpose for these test is to ensure that the operations
* output something vaguely expected (i.e. they aren't completely broken
* after a dependency update or changes to the UI), rather than to confirm
* that this output is actually accurate. Accuracy of output and testing
* of edge cases should be carried out in the operations test suite found
* in /tests/operations as this is much faster and easier to configure
* than the UI tests found here.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2021
* @license Apache-2.0
*/
const utils = require("./browserUtils.js");
module.exports = {
before: browser => {
browser
.resizeWindow(1280, 800)
.url(browser.launchUrl)
.useCss()
.waitForElementNotPresent("#preloader", 10000)
.click("#auto-bake-label");
},
"Sanity check operations": async browser => {
const Images = await import("../samples/Images.mjs");
testOp(browser, "A1Z26 Cipher Decode", "20 5 19 20 15 21 20 16 21 20", "testoutput");
testOp(browser, "A1Z26 Cipher Encode", "test input", "20 5 19 20 9 14 16 21 20");
testOp(browser, "ADD", "test input", "Ê»ÉÊv¿ÄÆËÊ", [{ "option": "Hex", "string": "56" }]);
testOp(browser, "AES Decrypt", "b443f7f7c16ac5396a34273f6f639caa", "test output", [{ "option": "Hex", "string": "00112233445566778899aabbccddeeff" }, { "option": "Hex", "string": "00000000000000000000000000000000" }, "CBC", "Hex", "Raw", { "option": "Hex", "string": "" }]);
testOp(browser, "AES Encrypt", "test input", "e42eb8fbfb7a98fff061cd2c1a794d92", [{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00000000000000000000000000000000"}, "CBC", "Raw", "Hex"]);
testOp(browser, "AND", "test input", "4$04 $044", [{ "option": "Hex", "string": "34" }]);
testOp(browser, "Add line numbers", "test input", "1 test input");
testOp(browser, ["From Hex", "Add Text To Image", "To Base64"], Images.PNG_HEX, Images.PNG_CHEF_B64, [[], ["Chef", "Center", "Middle", 0, 0, 16], []]);
testOp(browser, "Adler-32 Checksum", "test input", "16160411");
testOp(browser, "Affine Cipher Decode", "test input", "rcqr glnsr", [1, 2]);
testOp(browser, "Affine Cipher Encode", "test input", "njln rbfpn", [2, 1]);
testOp(browser, "AMF Decode", "\u000A\u0013\u0001\u0003a\u0006\u0009test", /"\$value": "test"/);
testOp(browser, "AMF Encode", '{"a": "test"}', "\u000A\u0013\u0001\u0003a\u0006\u0009test");
testOp(browser, "Analyse hash", "0123456789abcdef", /CRC-64/);
testOp(browser, "Atbash Cipher", "test input", "gvhg rmkfg");
// testOp(browser, "Avro to JSON", "test input", "test_output");
testOp(browser, "BLAKE2b", "test input", "33ebdc8f38177f3f3f334eeb117a84e11f061bbca4db6b8923e5cec85103f59f415551a5d5a933fdb6305dc7bf84671c2540b463dbfa08ee1895cfaa5bd780b5", ["512", "Hex", { "option": "UTF8", "string": "pass" }]);
testOp(browser, "BLAKE2s", "test input", "defe73d61dfa6e5807e4f9643e159a09ccda6be3c26dcd65f8a9bb38bfc973a7", ["256", "Hex", { "option": "UTF8", "string": "pass" }]);
testOp(browser, "BSON deserialise", "\u0011\u0000\u0000\u0000\u0002a\u0000\u0005\u0000\u0000\u0000test\u0000\u0000", '{\u000A "a": "test"\u000A}');
testOp(browser, "BSON serialise", '{"a":"test"}', "\u0011\u0000\u0000\u0000\u0002a\u0000\u0005\u0000\u0000\u0000test\u0000\u0000");
// testOp(browser, "Bacon Cipher Decode", "test input", "test_output");
// testOp(browser, "Bacon Cipher Encode", "test input", "test_output");
testOp(browser, "Bcrypt", "test input", /^\$2a\$06\$.{53}$/, [6]);
testOp(browser, "Bcrypt compare", "test input", "Match: test input", ["$2a$05$FCfBSVX7OeRkK.9kQVFCiOYu9XtwtIbePqUiroD1lkASW9q5QClzG"]);
testOp(browser, "Bcrypt parse", "$2a$05$kXWtAIGB/R8VEzInoM5ocOTBtyc0m2YTIwFiBU/0XoW032f9QrkWW", /Rounds: 5/);
testOp(browser, "Bifid Cipher Decode", "qblb tfovy", "test input", ["pass"]);
testOp(browser, "Bifid Cipher Encode", "test input", "qblb tfovy", ["pass"]);
testOp(browser, "Bit shift left", "test input", "\u00E8\u00CA\u00E6\u00E8@\u00D2\u00DC\u00E0\u00EA\u00E8");
testOp(browser, "Bit shift right", "test input", ":29:\u0010478::");
testOp(browser, "Blowfish Decrypt", "10884e15427dd84ec35204e9c8e921ae", "test_output", [{"option": "Hex", "string": "1234567801234567"}, {"option": "Hex", "string": "0011223344556677"}, "CBC", "Hex", "Raw"]);
testOp(browser, "Blowfish Encrypt", "test input", "f0fadbd1d90d774f714248cf26b96410", [{"option": "Hex", "string": "1234567801234567"}, {"option": "Hex", "string": "0011223344556677"}, "CBC", "Raw", "Hex"]);
testOp(browser, ["From Hex", "Blur Image", "To Base64"], Images.PNG_HEX, Images.PNG_BLUR_B64);
testOpHtml(browser, "Bombe", "XTSYN WAEUG EZALY NRQIM AMLZX MFUOD AWXLY LZCUZ QOQBQ JLCPK NDDRW F", "table tr:last-child td:first-child", "ECG", ["3-rotor", "LEYJVCNIXWPBQMDRTAKZGFUHOS", "BDFHJLCPRTXVZNYEIWGAKMUSQO<W", "AJDKSIRUXBLHWTMCQGZNPYFVOE<F", "ESOVPZJAYQUIRHXLNFTGKDCMWB<K", "AY BR CU DH EQ FS GL IP JX KN MO TZ VW", "HELLO CYBER CHEFU SER", 0, true]);
testOp(browser, ["Bzip2 Compress", "To Hex"], "test input", "42 5a 68 39 31 41 59 26 53 59 cf 96 82 1d 00 00 03 91 80 40 00 02 21 4e 00 20 00 21 90 c2 10 c0 88 33 92 8e df 17 72 45 38 50 90 cf 96 82 1d");
testOp(browser, ["From Hex", "Bzip2 Decompress"], "425a68393141592653597b0884b7000003038000008200ce00200021a647a4218013709517c5dc914e14241ec2212dc0", "test_output", [[], [true]]);
// testOp(browser, "CBOR Decode", "test input", "test output");
// testOp(browser, "CBOR Encode", "test input", "test output");
testOp(browser, "CRC-16 Checksum", "test input", "77c7");
testOp(browser, "CRC-32 Checksum", "test input", "29822bc8");
testOp(browser, "CRC-8 Checksum", "test input", "9d");
// testOp(browser, "CSS Beautify", "test input", "test_output");
// testOp(browser, "CSS Minify", "test input", "test_output");
// testOp(browser, "CSS selector", "test input", "test_output");
// testOp(browser, "CSV to JSON", "test input", "test_output");
// testOp(browser, "CTPH", "test input", "test_output");
// testOp(browser, "Cartesian Product", "test input", "test_output");
// testOp(browser, "Change IP format", "test input", "test_output");
// testOp(browser, "Chi Square", "test input", "test_output");
// testOp(browser, "CipherSaber2 Decrypt", "test input", "test_output");
// testOp(browser, "CipherSaber2 Encrypt", "test input", "test_output");
// testOp(browser, "Citrix CTX1 Decode", "test input", "test_output");
// testOp(browser, "Citrix CTX1 Encode", "test input", "test_output");
testOpHtml(browser, "Colossus", "CTBKJUVXHZ-H3L4QV+YEZUK+SXOZ/N", "table tr:last-child td:first-child", "30", ["", "KH Pattern", "Z", "", "", "None", "Select Program", "Letter Count", "", "", "", "", "", "", false, "", "", "", "", "", "", false, "", "", "", "", "", "", false, "", false, "", false, false, false, false, false, "", false, false, "", "", 0, "", "", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]);
// testOp(browser, "Comment", "test input", "test_output");
// testOp(browser, "Compare CTPH hashes", "test input", "test_output");
// testOp(browser, "Compare SSDEEP hashes", "test input", "test_output");
// testOp(browser, "Conditional Jump", "test input", "test_output");
testOpImage(browser, "Contain Image", "files/Hitchhikers_Guide.jpeg");
// testOp(browser, "Convert area", "test input", "test_output");
// testOp(browser, "Convert co-ordinate format", "test input", "test_output");
// testOp(browser, "Convert data units", "test input", "test_output");
// testOp(browser, "Convert distance", "test input", "test_output");
testOpImage(browser, "Convert Image Format", "files/Hitchhikers_Guide.jpeg");
// testOp(browser, "Convert mass", "test input", "test_output");
// testOp(browser, "Convert speed", "test input", "test_output");
// testOp(browser, "Convert to NATO alphabet", "test input", "test_output");
// testOp(browser, "Count occurrences", "test input", "test_output");
testOpImage(browser, "Cover Image", "files/Hitchhikers_Guide.jpeg");
testOpImage(browser, "Crop Image", "files/Hitchhikers_Guide.jpeg");
// testOp(browser, "CSS Selector", "test input", "test output");
// testOp(browser, "DES Decrypt", "test input", "test_output");
// testOp(browser, "DES Encrypt", "test input", "test_output");
// testOp(browser, "DNS over HTTPS", "test input", "test_output");
// testOp(browser, "Dechunk HTTP response", "test input", "test_output");
// testOp(browser, "Decode NetBIOS Name", "test input", "test_output");
// testOp(browser, "Decode text", "test input", "test_output");
// testOp(browser, "Defang IP Addresses", "test input", "test_output");
// testOp(browser, "Defang URL", "test input", "test_output");
// testOp(browser, "Derive EVP key", "test input", "test_output");
// testOp(browser, "Derive PBKDF2 key", "test input", "test_output");
// testOp(browser, "Detect File Type", "test input", "test_output");
testOpHtml(browser, "Diff", "The cat sat on the mat\n\nThe mat cat on the sat", "ins:first-child", "mat", ["\\n\\n", "Word", true, true, false, false]);
// testOp(browser, "Disassemble x86", "test input", "test_output");
testOpImage(browser, "Dither Image", "files/Hitchhikers_Guide.jpeg");
// testOp(browser, "Divide", "test input", "test_output");
// testOp(browser, "Drop bytes", "test input", "test_output");
// testOp(browser, "Encode NetBIOS Name", "test input", "test_output");
// testOp(browser, "Encode text", "test input", "test_output");
// testOp(browser, "Enigma", "test input", "test_output");
testOpHtml(browser, "Entropy", "test input", "", /Shannon entropy: 2.8464393446710154/);
// testOp(browser, "Escape string", "test input", "test_output");
// testOp(browser, "Escape Unicode Characters", "test input", "test_output");
// testOp(browser, "Expand alphabet range", "test input", "test_output");
// testOp(browser, "Extract dates", "test input", "test_output");
// testOp(browser, "Extract domains", "test input", "test_output");
// testOp(browser, "Extract EXIF", "test input", "test_output");
// testOp(browser, "Extract email addresses", "test input", "test_output");
// testOp(browser, "Extract file paths", "test input", "test_output");
testOpFile(browser, "Extract Files", "files/Hitchhikers_Guide.jpeg", ".card:last-child .collapsed", "extracted_at_0x3d38.zlib");
testOpFile(browser, "Extract ID3", "files/mp3example.mp3", "tr:last-child td:last-child", "Kevin MacLeod");
// testOp(browser, "Extract IP addresses", "test input", "test_output");
// testOp(browser, "Extract LSB", "test input", "test_output");
// testOp(browser, "Extract MAC addresses", "test input", "test_output");
// testOp(browser, "Extract RGBA", "test input", "test_output");
// testOp(browser, "Extract URLs", "test input", "test_output");
// testOp(browser, "Filter", "test input", "test_output");
// testOp(browser, "Find / Replace", "test input", "test_output");
// testOp(browser, "Fletcher-16 Checksum", "test input", "test_output");
// testOp(browser, "Fletcher-32 Checksum", "test input", "test_output");
// testOp(browser, "Fletcher-64 Checksum", "test input", "test_output");
// testOp(browser, "Fletcher-8 Checksum", "test input", "test_output");
testOpImage(browser, "Flip Image", "files/Hitchhikers_Guide.jpeg");
// testOp(browser, "Fork", "test input", "test_output");
// testOp(browser, "Format MAC addresses", "test input", "test_output");
testOpHtml(browser, "Frequency distribution", "test input", "", /Number of bytes not represented: 248/);
// testOp(browser, "From BCD", "test input", "test_output");
// testOp(browser, "From Base", "test input", "test_output");
// testOp(browser, "From Base32", "test input", "test_output");
// testOp(browser, "From Base58", "test input", "test_output");
// testOp(browser, "From Base62", "test input", "test_output");
// testOp(browser, "From Base64", "test input", "test_output");
// testOp(browser, "From Base85", "test input", "test_output");
// testOp(browser, "From Binary", "test input", "test_output");
// testOp(browser, "From Braille", "test input", "test_output");
// testOp(browser, "From Case Insensitive Regex", "test input", "test_output");
// testOp(browser, "From Charcode", "test input", "test_output");
// testOp(browser, "From Decimal", "test input", "test_output");
// testOp(browser, "From HTML Entity", "test input", "test_output");
// testOp(browser, "From Hex", "test input", "test_output");
// testOp(browser, "From Hex Content", "test input", "test_output");
// testOp(browser, "From Hexdump", "test input", "test_output");
// testOp(browser, "From MessagePack", "test input", "test_output");
// testOp(browser, "From Morse Code", "test input", "test_output");
// testOp(browser, "From Octal", "test input", "test_output");
// testOp(browser, "From Punycode", "test input", "test_output");
// testOp(browser, "From Quoted Printable", "test input", "test_output");
// testOp(browser, "From UNIX Timestamp", "test input", "test_output");
testOpHtml(browser, "Fuzzy Match", "test input", "b:last-child", "in", ["tein", 15, 30, 30, 15, -5, -15, -1]);
// testOp(browser, "GOST hash", "test input", "test_output");
// testOp(browser, "Generate all hashes", "test input", "test_output");
// testOp(browser, "Generate HOTP", "test input", "test_output");
testOpHtml(browser, "Generate Image", "test input", "img", "");
// testOp(browser, "Generate Lorem Ipsum", "test input", "test_output");
// testOp(browser, "Generate PGP Key Pair", "test input", "test_output");
testOpHtml(browser, "Generate QR Code", "test input", "img", "");
// testOp(browser, "Generate TOTP", "test input", "test_output");
// testOp(browser, "Generate UUID", "test input", "test_output");
// testOp(browser, "Generic Code Beautify", "test input", "test_output");
// testOp(browser, "Group IP addresses", "test input", "test_output");
// testOp(browser, "Gunzip", "test input", "test_output");
// testOp(browser, "Gzip", "test input", "test_output");
// testOp(browser, "HAS-160", "test input", "test_output");
// testOp(browser, "HMAC", "test input", "test_output");
// testOp(browser, "HTML To Text", "test input", "test_output");
// testOp(browser, "HTTP request", "test input", "test_output");
// testOp(browser, "Hamming Distance", "test input", "test_output");
// testOp(browser, "Haversine distance", "test input", "test_output");
// testOp(browser, "Head", "test input", "test_output");
testOpHtml(browser, "Heatmap chart", "X Y\n0 1\n1 2", "svg", /X/);
testOpHtml(browser, "Hex Density chart", "X Y\n0 1\n1 2", "svg", /X/);
// testOp(browser, "Hex to Object Identifier", "test input", "test_output");
// testOp(browser, "Hex to PEM", "test input", "test_output");
testOpImage(browser, "Image Brightness / Contrast", "files/Hitchhikers_Guide.jpeg");
testOpImage(browser, "Image Filter", "files/Hitchhikers_Guide.jpeg");
testOpImage(browser, "Image Hue/Saturation/Lightness", "files/Hitchhikers_Guide.jpeg");
testOpImage(browser, "Image Opacity", "files/Hitchhikers_Guide.jpeg");
testOpHtml(browser, "Index of Coincidence", "test input", "", /Index of Coincidence: 0.08333333333333333/);
testOpImage(browser, "Invert Image", "files/Hitchhikers_Guide.jpeg");
// testOp(browser, "JPath expression", "test input", "test_output");
testOpHtml(browser, "JSON Beautify", "{a:1}", ".json-dict .json-literal", "1");
// testOp(browser, "JSON Minify", "test input", "test_output");
// testOp(browser, "JSON to CSV", "test input", "test_output");
// testOp(browser, "JWT Decode", "test input", "test_output");
// testOp(browser, "JWT Sign", "test input", "test_output");
// testOp(browser, "JWT Verify", "test input", "test_output");
// testOp(browser, "JavaScript Beautify", "test input", "test_output");
// testOp(browser, "JavaScript Minify", "test input", "test_output");
// testOp(browser, "JavaScript Parser", "test input", "test_output");
// testOp(browser, "Jump", "test input", "test_output");
// testOp(browser, "Keccak", "test input", "test_output");
// testOp(browser, "Label", "test input", "test_output");
// testOp(browser, "LM Hash", "test input", "test output");
// testOp(browser, "Lorenz", "test input", "test_output");
// testOp(browser, "Luhn Checksum", "test input", "test_output");
// testOp(browser, "LZ String", "test input", "test output");
// testOp(browser, "LZ4 Compress", "test input", "test output");
// testOp(browser, "LZ4 Decompress", "test input", "test output");
// testOp(browser, "LZMA Compress", "test input", "test output");
// testOp(browser, "LZMA Decompress", "test input", "test output");
// testOp(browser, "MD2", "test input", "test_output");
// testOp(browser, "MD4", "test input", "test_output");
// testOp(browser, "MD5", "test input", "test_output");
// testOp(browser, "MD6", "test input", "test_output");
testOpHtml(browser, "Magic", "dGVzdF9vdXRwdXQ=", "tr:nth-of-type(1) th:nth-of-type(2)", "Result snippet");
testOpHtml(browser, "Magic", "dGVzdF9vdXRwdXQ=", "tr:nth-of-type(2) td:nth-of-type(2)", "test_output");
testOpHtml(browser, "Magic", "dGVzdF9vdXRwdXQ=", "tr:nth-of-type(2) td:nth-of-type(1)", /Base64/);
// testOp(browser, "Mean", "test input", "test_output");
// testOp(browser, "Median", "test input", "test_output");`
// testOp(browser, "Merge", "test input", "test_output");`
// testOp(browser, "Microsoft Script Decoder", "test input", "test_output");
// testOp(browser, "Multiple Bombe", "test input", "test_output");
// testOp(browser, "Multiply", "test input", "test_output");
// testOp(browser, "NOT", "test input", "test_output");
// testOp(browser, "Normalise Image", "test input", "test_output");
// testOp(browser, "Normalise Unicode", "test input", "test_output");
// testOp(browser, "Numberwang", "test input", "test_output");
// testOp(browser, "OR", "test input", "test_output");
// testOp(browser, "Object Identifier to Hex", "test input", "test_output");
testOpHtml(browser, "Offset checker", "test input\n\nbest input", ".hl5", "est input");
// testOp(browser, "Optical Character Recognition", "test input", "test_output");
// testOp(browser, "PEM to Hex", "test input", "test_output");
// testOp(browser, "PGP Decrypt", "test input", "test_output");
// testOp(browser, "PGP Decrypt and Verify", "test input", "test_output");
// testOp(browser, "PGP Encrypt", "test input", "test_output");
// testOp(browser, "PGP Encrypt and Sign", "test input", "test_output");
// testOp(browser, "PGP Verify", "test input", "test_output");
// testOp(browser, "PHP Deserialize", "test input", "test_output");
// testOp(browser, "Pad lines", "test input", "test_output");
// testOp(browser, "Parse ASN.1 hex string", "test input", "test_output");
testOpHtml(browser, "Parse colour code", "#000", ".colorpicker-preview", "rgb(0, 0, 0)");
testOpHtml(browser, "Parse DateTime", "01/12/2000 13:00:00", "", /Date: Friday 1st December 2000/);
// testOp(browser, "Parse IP range", "test input", "test_output");
testOpHtml(browser, "Parse IPv4 header", "45 c0 00 c4 02 89 00 00 ff 11 1e 8c c0 a8 0c 01 c0 a8 0c 02", "tr:last-child td:last-child", "192.168.12.2");
// testOp(browser, "Parse IPv6 address", "test input", "test_output");
// testOp(browser, "Parse ObjectID timestamp", "test input", "test_output");
// testOp(browser, "Parse QR Code", "test input", "test_output");
// testOp(browser, "Parse SSH Host Key", "test input", "test_output");
testOpHtml(browser, "Parse TCP", "c2eb0050a138132e70dc9fb9501804025ea70000", "tr:nth-of-type(2) td:last-child", "49899");
// testOp(browser, "Parse TLV", "test input", "test_output");
testOpHtml(browser, "Parse UDP", "04 89 00 35 00 2c 01 01", "tr:last-child td:last-child", "0x0101");
// testOp(browser, "Parse UNIX file permissions", "test input", "test_output");
// testOp(browser, "Parse URI", "test input", "test_output");
// testOp(browser, "Parse User Agent", "test input", "test_output");
// testOp(browser, "Parse X.509 certificate", "test input", "test_output");
testOpFile(browser, "Play Media", "files/mp3example.mp3", "audio", "");
// testOp(browser, "Power Set", "test input", "test_output");
// testOp(browser, "Protobuf Decode", "test input", "test_output");
// testOp(browser, "Pseudo-Random Number Generator", "test input", "test_output");
// testOp(browser, "RC2 Decrypt", "test input", "test_output");
// testOp(browser, "RC2 Encrypt", "test input", "test_output");
// testOp(browser, "RC4", "test input", "test_output");
// testOp(browser, "RC4 Drop", "test input", "test_output");
// testOp(browser, "RIPEMD", "test input", "test_output");
// testOp(browser, "ROT13", "test input", "test_output");
// testOp(browser, "ROT47", "test input", "test_output");
// testOp(browser, "ROT8000", "test input", "test_output");
// testOp(browser, "Rail Fence Cipher Decode", "test input", "test_output");
// testOp(browser, "Rail Fence Cipher Encode", "test input", "test_output");
testOpImage(browser, "Randomize Colour Palette", "files/Hitchhikers_Guide.jpeg");
// testOp(browser, "Raw Deflate", "test input", "test_output");
// testOp(browser, "Raw Inflate", "test input", "test_output");
// testOp(browser, "Register", "test input", "test_output");
testOpHtml(browser, "Regular expression", "The cat sat on the mat", ".hl2:last-child", "mat", ["User defined", ".at", true, true, false, false, false, false, "Highlight matches"]);
// testOp(browser, "Remove Diacritics", "test input", "test_output");
// testOp(browser, "Remove EXIF", "test input", "test_output");
// testOp(browser, "Remove line numbers", "test input", "test_output");
// testOp(browser, "Remove null bytes", "test input", "test_output");
// testOp(browser, "Remove whitespace", "test input", "test_output");
testOpImage(browser, "Render Image", "files/Hitchhikers_Guide.jpeg");
testOpHtml(browser, "Render Markdown", "# test input", "h1", "test input");
testOpImage(browser, "Resize Image", "files/Hitchhikers_Guide.jpeg");
// testOp(browser, "Return", "test input", "test_output");
// testOp(browser, "Reverse", "test input", "test_output");
testOpImage(browser, "Rotate Image", "files/Hitchhikers_Guide.jpeg");
// testOp(browser, "Rotate left", "test input", "test_output");
// testOp(browser, "Rotate right", "test input", "test_output");
// testOp(browser, "Scrypt", "test input", "test output");
// testOp(browser, "SHA0", "test input", "test_output");
// testOp(browser, "SHA1", "test input", "test_output");
// testOp(browser, "SHA2", "test input", "test_output");
// testOp(browser, "SHA3", "test input", "test_output");
// testOp(browser, "SQL Beautify", "test input", "test_output");
// testOp(browser, "SQL Minify", "test input", "test_output");
// testOp(browser, "SSDEEP", "test input", "test_output");
// testOp(browser, "SUB", "test input", "test_output");
// testOp(browser, "Scan for Embedded Files", "test input", "test_output");
testOpHtml(browser, "Scatter chart", "a b\n1 2", "svg", /a/);
// testOp(browser, "Scrypt", "test input", "test_output");
testOpHtml(browser, "Series chart", "1 2 3\n4 5 6", "svg", /3/);
// testOp(browser, "Set Difference", "test input", "test_output");
// testOp(browser, "Set Intersection", "test input", "test_output");
// testOp(browser, "Set Union", "test input", "test_output");
// testOp(browser, "Shake", "test input", "test_output");
testOpImage(browser, "Sharpen Image", "files/Hitchhikers_Guide.jpeg");
testOpHtml(browser, "Show Base64 offsets", "test input", "span:nth-last-of-type(2)", "B");
testOpHtml(browser, "Show on map", "51.5007° N, 0.1246° W", "#presentedMap .leaflet-popup-content", "51.5007,-0.1246");
// testOp(browser, "Sleep", "test input", "test_output");
// testOp(browser, "SM3", "test input", "test output");
// testOp(browser, "Snefru", "test input", "test_output");
// testOp(browser, "Sort", "test input", "test_output");
// testOp(browser, "Split", "test input", "test_output");
// testOpImage(browser, "Split Colour Channels", "files/Hitchhikers_Guide.jpeg");
// testOp(browser, "Standard Deviation", "test input", "test_output");
// testOp(browser, "Streebog", "test input", "test_output");
// testOp(browser, "Strings", "test input", "test_output");
// testOp(browser, "Strip HTML tags", "test input", "test_output");
// testOp(browser, "Strip HTTP headers", "test input", "test_output");
// testOp(browser, "Subsection", "test input", "test_output");
// testOp(browser, "Substitute", "test input", "test_output");
// testOp(browser, "Subtract", "test input", "test_output");
// testOp(browser, "Sum", "test input", "test_output");
// testOp(browser, "Swap endianness", "test input", "test_output");
// testOp(browser, "Symmetric Difference", "test input", "test_output");
testOpHtml(browser, "Syntax highlighter", "var a = [4,5,6]", ".hljs-selector-attr", "[4,5,6]");
// testOp(browser, "TCP/IP Checksum", "test input", "test_output");
// testOp(browser, "Tail", "test input", "test_output");
// testOp(browser, "Take bytes", "test input", "test_output");
testOp(browser, "Tar", "test input", /^file\.txt\x00{92}/);
testOpHtml(browser, "Text Encoding Brute Force", "test input", "tr:nth-of-type(4) td:last-child", /t\u2400e\u2400s\u2400t\u2400/);
// testOp(browser, "To BCD", "test input", "test_output");
// testOp(browser, "To Base", "test input", "test_output");
// testOp(browser, "To Base32", "test input", "test_output");
// testOp(browser, "To Base58", "test input", "test_output");
// testOp(browser, "To Base62", "test input", "test_output");
// testOp(browser, "To Base64", "test input", "test_output");
// testOp(browser, "To Base85", "test input", "test_output");
// testOp(browser, "To Binary", "test input", "test_output");
// testOp(browser, "To Braille", "test input", "test_output");
// testOp(browser, "To Camel case", "test input", "test_output");
// testOp(browser, "To Case Insensitive Regex", "test input", "test_output");
// testOp(browser, "To Charcode", "test input", "test_output");
// testOp(browser, "To Decimal", "test input", "test_output");
// testOp(browser, "To HTML Entity", "test input", "test_output");
// testOp(browser, "To Hex", "test input", "test_output");
// testOp(browser, "To Hex Content", "test input", "test_output");
// testOp(browser, "To Hexdump", "test input", "test_output");
// testOp(browser, "To Kebab case", "test input", "test_output");
// testOp(browser, "To Lower case", "test input", "test_output");
// testOp(browser, "To MessagePack", "test input", "test_output");
// testOp(browser, "To Morse Code", "test input", "test_output");
// testOp(browser, "To Octal", "test input", "test_output");
// testOp(browser, "To Punycode", "test input", "test_output");
// testOp(browser, "To Quoted Printable", "test input", "test_output");
// testOp(browser, "To Snake case", "test input", "test_output");
testOpHtml(browser, "To Table", "a,b,c\n1,2,3", "", /| a | b | c |/);
// testOp(browser, "To UNIX Timestamp", "test input", "test_output");
// testOp(browser, "To Upper case", "test input", "test_output");
// testOp(browser, "Translate DateTime Format", "test input", "test_output");
// testOp(browser, "Triple DES Decrypt", "test input", "test_output");
// testOp(browser, "Triple DES Encrypt", "test input", "test_output");
// testOp(browser, "Typex", "test input", "test_output");
// testOp(browser, "UNIX Timestamp to Windows Filetime", "test input", "test_output");
// testOp(browser, "URL Decode", "test input", "test_output");
// testOp(browser, "URL Encode", "test input", "test_output");
// testOp(browser, "Unescape string", "test input", "test_output");
// testOp(browser, "Unescape Unicode Characters", "test input", "test_output");
// testOp(browser, "Unique", "test input", "test_output");
testOpHtml(browser, ["Tar", "Untar"], "test input", ".float-right", /10 bytes/);
testOpHtml(browser, ["Zip", "Unzip"], "test input", "#files span.float-right", /10 bytes/);
// testOp(browser, "VarInt Decode", "test input", "test_output");
// testOp(browser, "VarInt Encode", "test input", "test_output");
testOpImage(browser, "View Bit Plane", "files/Hitchhikers_Guide.jpeg");
// testOp(browser, "Vigenère Decode", "test input", "test_output");
// testOp(browser, "Vigenère Encode", "test input", "test_output");
testOp(browser, "Whirlpool", "test input", "8a0ee6885ba241353d17cbbe5f06538a7f04c8c955d376c20d6233fd4dd41aaffd13291447090ce781b5f940da266ed6d02cf8b79d4867065d10bdfc04166f38");
// testOp(browser, "Windows Filetime to UNIX Timestamp", "test input", "test_output");
testOp(browser, "XKCD Random Number", "test input", "4");
// testOp(browser, "XML Beautify", "test input", "test_output");
// testOp(browser, "XML Minify", "test input", "test_output");
// testOp(browser, "XOR", "test input", "test_output");
// testOp(browser, "XOR Brute Force", "test input", "test_output");
// testOp(browser, "XPath expression", "test input", "test_output");
// testOp(browser, "YARA Rules", "test input", "test_output");
testOp(browser, "Zip", "test input", /^PK\u0003\u0004\u0014\u0000{3}/);
// testOp(browser, "Zlib Deflate", "test input", "test_output");
// testOp(browser, "Zlib Inflate", "test input", "test_output");
},
after: browser => {
browser.end();
}
};
/** @function
* Clears the current recipe and bakes a new operation.
*
* @param {Browser} browser - Nightwatch client
* @param {string|Array<string>} opName - name of operation to be tested, array for multiple ops
* @param {string} input - input text for test
* @param {Array<string>|Array<Array<string>>} args - arguments, nested if multiple ops
*/
function bakeOp(browser, opName, input, args=[]) {
browser.perform(function() {
console.log(`Current test: ${opName}`);
});
utils.loadRecipe(browser, opName, input, args);
browser.waitForElementVisible("#stale-indicator", 5000);
utils.bake(browser);
}
/** @function
* Clears the current recipe and tests a new operation.
*
* @param {Browser} browser - Nightwatch client
* @param {string|Array<string>} opName - name of operation to be tested, array for multiple ops
* @param {string} input - input text
* @param {string} output - expected output
* @param {Array<string>|Array<Array<string>>} args - arguments, nested if multiple ops
*/
function testOp(browser, opName, input, output, args=[]) {
bakeOp(browser, opName, input, args);
utils.expectOutput(browser, output);
}
/** @function
* Clears the current recipe and tests a new operation with HTML output.
*
* @param {Browser} browser - Nightwatch client
* @param {string|Array<string>} opName - name of operation to be tested array for multiple ops
* @param {string} input - input text
* @param {string} cssSelector - CSS selector for HTML output
* @param {string} output - expected output
* @param {Array<string>|Array<Array<string>>} args - arguments, nested if multiple ops
*/
function testOpHtml(browser, opName, input, cssSelector, output, args=[]) {
bakeOp(browser, opName, input, args);
if (typeof output === "string") {
browser.expect.element("#output-html " + cssSelector).text.that.equals(output);
} else if (output instanceof RegExp) {
browser.expect.element("#output-html " + cssSelector).text.that.matches(output);
}
}
/** @function
* Clears the current recipe and tests a new Image-based operation.
*
* @param {Browser} browser - Nightwatch client
* @param {string|Array<string>} opName - name of operation to be tested array for multiple ops
* @param {string} filename - filename of image file from samples directory
* @param {Array<string>|Array<Array<string>>} args - arguments, nested if multiple ops
*/
function testOpImage(browser, opName, filename, args) {
browser.perform(function() {
console.log(`Current test: ${opName}`);
});
utils.loadRecipe(browser, opName, "", args);
utils.uploadFile(browser, filename);
browser.waitForElementVisible("#stale-indicator", 5000);
utils.bake(browser);
browser
.waitForElementVisible("#output-html img")
.expect.element("#output-html img").to.have.css("width").which.matches(/^[^0]\d*px/);
}
/** @function
* Clears the current recipe and tests a new File-based operation.
*
* @param {Browser} browser - Nightwatch client
* @param {string|Array<string>} opName - name of operation to be tested array for multiple ops
* @param {string} filename - filename of file from samples directory
* @param {string} cssSelector - CSS selector for HTML output
* @param {string} output - expected output
* @param {Array<string>|Array<Array<string>>} args - arguments, nested if multiple ops
*/
function testOpFile(browser, opName, filename, cssSelector, output, args) {
browser.perform(function() {
console.log(`Current test: ${opName}`);
});
utils.loadRecipe(browser, opName, "", args);
utils.uploadFile(browser, filename);
browser.pause(100).waitForElementVisible("#stale-indicator", 5000);
utils.bake(browser);
if (typeof output === "string") {
browser.expect.element("#output-html " + cssSelector).text.that.equals(output);
} else if (output instanceof RegExp) {
browser.expect.element("#output-html " + cssSelector).text.that.matches(output);
}
}

View file

@ -0,0 +1,249 @@
/**
* Utility functions for browser tests.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2023
* @license Apache-2.0
*/
/** @function
* Clears the recipe and input
*
* @param {Browser} browser - Nightwatch client
*/
function clear(browser) {
browser
.useCss()
.click("#clr-recipe")
.click("#clr-io")
.waitForElementNotPresent("#rec-list li.operation")
.expect.element("#input-text .cm-content").text.that.equals("");
}
/** @function
* Sets the input to the desired string
*
* @param {Browser} browser - Nightwatch client
* @param {string} input - The text to populate the input with
* @param {boolean} [type=true] - Whether to type the characters in by using sendKeys,
* or to set the value of the editor directly (useful for special characters)
*/
function setInput(browser, input, type=true) {
clear(browser);
if (type) {
browser
.useCss()
.sendKeys("#input-text .cm-content", input)
.pause(100);
} else {
browser.execute(text => {
window.app.setInput(text);
}, [input]);
}
}
/** @function
* Triggers a bake
*
* @param {Browser} browser - Nightwatch client
*/
function bake(browser) {
browser
.click("#bake")
.waitForElementNotVisible("#stale-indicator", 5000)
.waitForElementNotVisible("#output-loader", 5000);
}
/** @function
* Sets the character encoding in the input or output
*
* @param {Browser} browser - Nightwatch client
* @param {string} io - Either "input" or "output"
* @param {string} enc - The encoding to be set
*/
function setChrEnc(browser, io, enc) {
io = `#${io}-text`;
browser
.useCss()
.waitForElementNotVisible("#snackbar-container", 6000)
.click(io + " .chr-enc-value")
.waitForElementVisible(io + " .chr-enc-select .cm-status-bar-select-scroll")
.click("link text", enc)
.waitForElementNotVisible(io + " .chr-enc-select .cm-status-bar-select-scroll")
.expect.element(io + " .chr-enc-value").text.that.equals(enc);
}
/** @function
* Sets the end of line sequence in the input or output
*
* @param {Browser} browser - Nightwatch client
* @param {string} io - Either "input" or "output"
* @param {string} eol - The sequence to set
*/
function setEOLSeq(browser, io, eol) {
io = `#${io}-text`;
browser
.useCss()
.waitForElementNotVisible("#snackbar-container", 6000)
.click(io + " .eol-value")
.waitForElementVisible(io + " .eol-select .cm-status-bar-select-content")
.click(`${io} .cm-status-bar-select-content a[data-val=${eol}]`)
.waitForElementNotVisible(io + " .eol-select .cm-status-bar-select-content")
.expect.element(io + " .eol-value").text.that.equals(eol);
}
/** @function
* Copies whatever is currently selected
*
* @param {Browser} browser - Nightwatch client
*/
function copy(browser) {
browser.perform(function() {
const actions = this.actions({async: true});
// Ctrl + Ins used as this works on Windows, Linux and Mac
return actions
.keyDown(browser.Keys.CONTROL)
.keyDown(browser.Keys.INSERT)
.keyUp(browser.Keys.INSERT)
.keyUp(browser.Keys.CONTROL);
});
}
/** @function
* Pastes into the target element
*
* @param {Browser} browser - Nightwatch client
* @param {string} el - Target element selector
*/
function paste(browser, el) {
browser
.click(el)
.perform(function() {
const actions = this.actions({async: true});
// Shift + Ins used as this works on Windows, Linux and Mac
return actions
.keyDown(browser.Keys.SHIFT)
.keyDown(browser.Keys.INSERT)
.keyUp(browser.Keys.INSERT)
.keyUp(browser.Keys.SHIFT);
})
.pause(100);
}
/** @function
* Loads a recipe and input
*
* @param {Browser} browser - Nightwatch client
* @param {string|Array<string>} opName - name of operation to be loaded, array for multiple ops
* @param {string} input - input text for test
* @param {Array<string>|Array<Array<string>>} args - arguments, nested if multiple ops
*/
function loadRecipe(browser, opName, input, args) {
let recipeConfig;
if (typeof(opName) === "string") {
recipeConfig = JSON.stringify([{
"op": opName,
"args": args
}]);
} else if (opName instanceof Array) {
recipeConfig = JSON.stringify(
opName.map((op, i) => {
return {
op: op,
args: args.length ? args[i] : []
};
})
);
} else {
throw new Error("Invalid operation type. Must be string or array of strings. Received: " + typeof(opName));
}
clear(browser);
setInput(browser, input, false);
browser
.urlHash("recipe=" + recipeConfig)
.waitForElementPresent("#rec-list li.operation");
}
/** @function
* Tests whether the output matches a given value
*
* @param {Browser} browser - Nightwatch client
* @param {string|RegExp} expected - The expected output value
*/
function expectOutput(browser, expected) {
browser.execute(expected => {
const output = window.app.manager.output.outputEditorView.state.doc.toString();
if (expected instanceof RegExp) {
return expected.test(output);
} else {
return expected === output;
}
}, [expected]);
}
/** @function
* Uploads a file using the #open-file input
*
* @param {Browser} browser - Nightwatch client
* @param {string} filename - A path to a file in the samples directory
*/
function uploadFile(browser, filename) {
const filepath = require("path").resolve(__dirname + "/../samples/" + filename);
// The file input cannot be interacted with by nightwatch while it is hidden,
// so we temporarily expose it for the purposes of this test.
browser.execute(() => {
document.getElementById("open-file").style.display = "block";
});
browser
.pause(100)
.setValue("#open-file", filepath)
.pause(100);
browser.execute(() => {
document.getElementById("open-file").style.display = "none";
});
browser.waitForElementVisible("#input-text .cm-file-details");
}
/** @function
* Uploads a folder using the #open-folder input
*
* @param {Browser} browser - Nightwatch client
* @param {string} foldername - A path to a folder in the samples directory
*/
function uploadFolder(browser, foldername) {
const folderpath = require("path").resolve(__dirname + "/../samples/" + foldername);
// The folder input cannot be interacted with by nightwatch while it is hidden,
// so we temporarily expose it for the purposes of this test.
browser.execute(() => {
document.getElementById("open-folder").style.display = "block";
});
browser
.pause(100)
.setValue("#open-folder", folderpath)
.pause(500);
browser.execute(() => {
document.getElementById("open-folder").style.display = "none";
});
browser.waitForElementVisible("#input-text .cm-file-details");
}
module.exports = {
clear: clear,
setInput: setInput,
bake: bake,
setChrEnc: setChrEnc,
setEOLSeq: setEOLSeq,
copy: copy,
paste: paste,
loadRecipe: loadRecipe,
expectOutput: expectOutput,
uploadFile: uploadFile,
uploadFolder: uploadFolder
};

View file

@ -12,6 +12,7 @@
import Chef from "../../src/core/Chef.mjs";
import Utils from "../../src/core/Utils.mjs";
import cliProgress from "cli-progress";
import log from "loglevel";
/**
* Object to store and run the list of tests.
@ -50,6 +51,9 @@ class TestRegister {
* Runs all the tests in the register.
*/
async runTests () {
// Turn off logging to avoid messy errors
log.setLevel("silent", false);
const progBar = new cliProgress.SingleBar({
format: formatter,
stopOnComplete: true
@ -70,9 +74,7 @@ class TestRegister {
const result = await chef.bake(
test.input,
test.recipeConfig,
{},
0,
false
{ returnType: "string" }
);
const ret = {
@ -84,7 +86,17 @@ class TestRegister {
if (result.error) {
if (test.expectedError) {
ret.status = "passing";
if (result.error.displayStr === test.expectedOutput) {
ret.status = "passing";
} else {
ret.status = "failing";
ret.output = [
"Expected",
"\t" + test.expectedOutput.replace(/\n/g, "\n\t"),
"Received",
"\t" + result.error.displayStr.replace(/\n/g, "\n\t"),
].join("\n");
}
} else {
ret.status = "erroring";
ret.output = result.error.displayStr;
@ -118,6 +130,9 @@ class TestRegister {
progBar.increment();
}
// Turn logging back on
log.setLevel("info", false);
return testResults;
}
@ -152,7 +167,7 @@ class TestRegister {
result.status = "passing";
} catch (e) {
result.status = "erroring";
result.output = e.message;
result.output = `${e.message}\nError: ${e.stack}`;
}
testResults.push(result);

View file

@ -6,24 +6,27 @@
* @license Apache-2.0
*/
const chef = require("cyberchef");
const assert = require("assert");
const d = chef.bake("Testing, 1 2 3", [
chef.toHex,
chef.reverse,
{
op: chef.unique,
args: {
delimiter: "Space",
}
},
{
op: chef.multiply,
args: {
delimiter: "Space",
}
}
]);
require("cyberchef").then(chef => {
assert.equal(d.value, "630957449041920");
const d = chef.bake("Testing, 1 2 3", [
chef.toHex,
chef.reverse,
{
op: chef.unique,
args: {
delimiter: "Space",
}
},
{
op: chef.multiply,
args: {
delimiter: "Space",
}
}
]);
assert.equal(d.value, "630957449041920");
});

View file

@ -7,8 +7,28 @@
*/
import assert from "assert";
import chef from "cyberchef";
import { bake, toHex, reverse, unique, multiply } from "cyberchef";
const d = chef.bake("Testing, 1 2 3", [
const a = bake("Testing, 1 2 3", [
toHex,
reverse,
{
op: unique,
args: {
delimiter: "Space",
}
},
{
op: multiply,
args: {
delimiter: "Space",
}
}
]);
assert.equal(a.value, "630957449041920");
const b = chef.bake("Testing, 1 2 3", [
chef.toHex,
chef.reverse,
{
@ -25,4 +45,4 @@ const d = chef.bake("Testing, 1 2 3", [
}
]);
assert.equal(d.value, "630957449041920");
assert.equal(b.value, "630957449041920");

View file

@ -1,28 +0,0 @@
/**
* Tests to ensure that a consuming app can use named imports from deep import patch
*
* @author d98762625 [d98762625@gmail.com]
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import assert from "assert";
import { bake, toHex, reverse, unique, multiply } from "cyberchef/src/node/index.mjs";
const d = bake("Testing, 1 2 3", [
toHex,
reverse,
{
op: unique,
args: {
delimiter: "Space",
}
},
{
op: multiply,
args: {
delimiter: "Space",
}
}
]);
assert.equal(d.value, "630957449041920");

View file

@ -1,6 +1,6 @@
import TestRegister from "../../lib/TestRegister.mjs";
import Categories from "../../../src/core/config/Categories.json";
import OperationConfig from "../../../src/core/config/OperationConfig.json";
import Categories from "../../../src/core/config/Categories.json" assert {type: "json"};
import OperationConfig from "../../../src/core/config/OperationConfig.json" assert {type: "json"};
import it from "../assertionHandler.mjs";
import assert from "assert";

View file

@ -13,10 +13,10 @@
import assert from "assert";
import it from "../assertionHandler.mjs";
import chef from "../../../src/node/index.mjs";
import OperationError from "../../../src/core/errors/OperationError.mjs";
import { OperationError, ExcludedOperationError } from "../../../src/core/errors/index.mjs";
import NodeDish from "../../../src/node/NodeDish.mjs";
import { toBase32} from "../../../src/node/index.mjs";
import { toBase32, magic} from "../../../src/node/index.mjs";
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addApiTests([
@ -119,7 +119,7 @@ TestRegister.addApiTests([
assert.strictEqual(result[0].module, "Ciphers");
assert.strictEqual(result[0].inputType, "string");
assert.strictEqual(result[0].outputType, "string");
assert.strictEqual(result[0].description, "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<br>DES uses a key length of 8 bytes (64 bits).<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used.");
assert.strictEqual(result[0].description, "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<br>DES uses a key length of 8 bytes (64 bits).<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used as a default.");
assert.strictEqual(result[0].args.length, 5);
}),
@ -136,7 +136,7 @@ TestRegister.addApiTests([
it("chef.help: returns multiple results", () => {
const result = chef.help("base 64");
assert.strictEqual(result.length, 11);
assert.strictEqual(result.length, 13);
}),
it("chef.help: looks in description for matches too", () => {
@ -181,22 +181,17 @@ TestRegister.addApiTests([
}),
it("chef.bake: should complain if recipe isnt a valid object", () => {
try {
chef.bake("some input", 3264);
} catch (e) {
assert.strictEqual(e.name, "TypeError");
assert.strictEqual(e.message, "Recipe can only contain function names or functions");
}
assert.throws(() => chef.bake("some input", 3264), {
name: "TypeError",
message: "Recipe can only contain function names or functions"
});
}),
it("chef.bake: Should complain if string op is invalid", () => {
try {
chef.bake("some input", "not a valid operation");
assert.fail("Shouldn't be hit");
} catch (e) {
assert.strictEqual(e.name, "TypeError");
assert.strictEqual(e.message, "Couldn't find an operation with name 'not a valid operation'.");
}
assert.throws(() => chef.bake("some input", "not a valid operation"), {
name: "TypeError",
message: "Couldn't find an operation with name 'not a valid operation'."
});
}),
it("chef.bake: Should take an input and an operation and perform it", () => {
@ -205,13 +200,10 @@ TestRegister.addApiTests([
}),
it("chef.bake: Should complain if an invalid operation is inputted", () => {
try {
chef.bake("https://google.com/search?q=help", () => {});
assert.fail("Shouldn't be hit");
} catch (e) {
assert.strictEqual(e.name, "TypeError");
assert.strictEqual(e.message, "Inputted function not a Chef operation.");
}
assert.throws(() => chef.bake("https://google.com/search?q=help", () => {}), {
name: "TypeError",
message: "Inputted function not a Chef operation."
});
}),
it("chef.bake: accepts an array of operation names and performs them all in order", () => {
@ -241,12 +233,10 @@ TestRegister.addApiTests([
}),
it("should complain if an invalid operation is inputted as part of array", () => {
try {
chef.bake("something", [() => {}]);
} catch (e) {
assert.strictEqual(e.name, "TypeError");
assert.strictEqual(e.message, "Inputted function not a Chef operation.");
}
assert.throws(() => chef.bake("something", [() => {}]), {
name: "TypeError",
message: "Inputted function not a Chef operation."
});
}),
it("chef.bake: should take single JSON object describing op and args OBJ", () => {
@ -275,15 +265,13 @@ TestRegister.addApiTests([
}),
it("chef.bake: should error if op in JSON is not chef op", () => {
try {
chef.bake("some input", {
op: () => {},
args: ["Colon"],
});
} catch (e) {
assert.strictEqual(e.name, "TypeError");
assert.strictEqual(e.message, "Inputted function not a Chef operation.");
}
assert.throws(() => chef.bake("some input", {
op: () => {},
args: ["Colon"],
}), {
name: "TypeError",
message: "Inputted function not a Chef operation."
});
}),
it("chef.bake: should take multiple ops in JSON object form, some ops by string", () => {
@ -393,13 +381,38 @@ TestRegister.addApiTests([
}
}),
it("chef.bake: cannot accept flowControl operations in recipe", () => {
assert.throws(() => chef.bake("some input", "magic"), {
name: "TypeError",
message: "flowControl operations like Magic are not currently allowed in recipes for chef.bake in the Node API"
});
assert.throws(() => chef.bake("some input", magic), {
name: "TypeError",
message: "flowControl operations like Magic are not currently allowed in recipes for chef.bake in the Node API"
});
assert.throws(() => chef.bake("some input", ["to base 64", "magic"]), {
name: "TypeError",
message: "flowControl operations like Magic are not currently allowed in recipes for chef.bake in the Node API"
});
}),
it("Excluded operations: throw a sensible error when you try and call one", () => {
try {
chef.renderImage();
} catch (e) {
assert.strictEqual(e.type, "ExcludedOperationError");
assert.strictEqual(e.message, "Sorry, the RenderImage operation is not available in the Node.js version of CyberChef.");
}
assert.throws(chef.fork,
(err) => {
assert(err instanceof ExcludedOperationError);
assert.deepEqual(err.message, "Sorry, the Fork operation is not available in the Node.js version of CyberChef.");
return true;
},
"Unexpected error type"
);
assert.throws(chef.javaScriptBeautify,
(err) => {
assert(err instanceof ExcludedOperationError);
assert.deepEqual(err.message, "Sorry, the JavaScriptBeautify operation is not available in the Node.js version of CyberChef.");
return true;
},
"Unexpected error type"
);
}),
it("Operation arguments: should be accessible from operation object if op has array arg", () => {
@ -432,4 +445,5 @@ TestRegister.addApiTests([
assert.equal(chef.convertDistance.args.inputUnits.options[0], "Nanometres (nm)");
assert.equal(chef.defangURL.args.process.options[1], "Only full URLs");
}),
]);

View file

@ -32,7 +32,7 @@ import {
CSSMinify,
toBase64,
toHex
} from "../../../src/node/index";
} from "../../../src/node/index.mjs";
import chef from "../../../src/node/index.mjs";
import TestRegister from "../../lib/TestRegister.mjs";
import File from "../../../src/node/File.mjs";
@ -45,10 +45,10 @@ TestRegister.addApiTests([
const result = chef.ADD("sample input", {
key: {
string: "some key",
option: "Hex"
option: "utf8"
}
});
assert.equal(result.toString(), "aO[^ZS\u000eW\\^cb");
assert.equal(result.toString(), "\xe6\xd0\xda\xd5\x8c\xd0\x85\xe2\xe1\xdf\xe2\xd9");
}),
@ -121,10 +121,10 @@ Tiger-128`;
const result = chef.AND("Scot-free", {
key: {
string: "Raining Cats and Dogs",
option: "Hex",
option: "utf8",
}
});
assert.strictEqual(result.toString(), "\u0000\"M$(D E");
assert.strictEqual(result.toString(), "Raid)fb A");
}),
it("atBash Cipher", () => {
@ -371,10 +371,10 @@ color: white;
},
salt: {
string: "Market",
option: "Hex",
option: "utf8",
},
});
assert.strictEqual(result.toString(), "7c21a9f5063a4d62fb1050068245c181");
assert.strictEqual(result.toString(), "4930d5d200e80f18c96b5550d13c6af8");
}),
it("Derive PBKDF2 Key", () => {
@ -471,7 +471,7 @@ color: white;
}),
it("Extract dates", () => {
assert.strictEqual(chef.extractDates("Don't Look a Gift Horse In The Mouth 01/02/1992").toString(), "01/02/1992\n");
assert.strictEqual(chef.extractDates("Don't Look a Gift Horse In The Mouth 01/02/1992").toString(), "01/02/1992");
}),
it("Filter", () => {
@ -588,7 +588,7 @@ Password: 034148`;
const result = await chef.generatePGPKeyPair("Back To the Drawing Board", {
keyType: "ECC-256",
});
assert.strictEqual(result.toString().length, 2007);
assert.strictEqual(result.toString().substr(0, 37), "-----BEGIN PGP PRIVATE KEY BLOCK-----");
}),
it("Generate UUID", () => {
@ -635,12 +635,16 @@ WWFkYSBZYWRh\r
assert.strictEqual(chef.keccak("Flea Market").toString(), "c2a06880b19e453ee5440e8bd4c2024bedc15a6630096aa3f609acfd2b8f15f27cd293e1cc73933e81432269129ce954a6138889ce87831179d55dcff1cc7587");
}),
it("LZNT1 Decompress", () => {
assert.strictEqual(chef.LZNT1Decompress("\x1a\xb0\x00compress\x00edtestda\x04ta\x07\x88alot").toString(), "compressedtestdatacompressedalot");
}),
it("MD6", () => {
assert.strictEqual(chef.MD6("Head Over Heels", {key: "arty"}).toString(), "d8f7fe4931fbaa37316f76283d5f615f50ddd54afdc794b61da522556aee99ad");
}),
it("Parse ASN.1 Hex string", () => {
assert.strictEqual(chef.parseASN1HexString(chef.toHex("Mouth-watering")).toString(), "UNKNOWN(4d) 7574682d7761746572696e67\n");
assert.strictEqual(chef.parseASN1HexString(chef.toHex("Mouth-watering")).toString(), "UNKNOWN(77) 7574682d7761746572696e67\n");
}),
it("Parse DateTime", () => {
@ -656,7 +660,7 @@ Leap year: false
Days in this month: 31
Day of year: 187
Week number: 2001
Week number: 27
Quarter: 3`;
assert.strictEqual(result.toString(), expected);
}),
@ -685,8 +689,8 @@ Arguments:
it("Parse user agent", () => {
const result = chef.parseUserAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0 ");
const expected = `Browser
Name: Mozilla
Version: 5.0
Name: Firefox
Version: 47.0
Device
Model: unknown
Type: unknown
@ -816,7 +820,7 @@ pCGTErs=
it("RC4 Drop", () => {
assert.strictEqual(
chef.RC4Drop("Go Out On a Limb", {passphrase: {string: "Under Your Nose", option: "UTF8"}, inputFormat: "UTF8", outputFormat: "Hex"}).toString(),
"8fa5f2751d34476a0c857439f43816cf");
"b85cb1c4ed6bed8f260ab92829bba942");
}),
it("Regular Expression", () => {
@ -854,12 +858,12 @@ pCGTErs=
it("Snefru", () => {
assert.strictEqual(
chef.snefru("demeaning milestone").toString(),
chef.snefru("demeaning milestone", {size: 256, rounds: 8}).toString(),
"a671b48770fe073ce49e9259cc2f47d345a53712639f8ae23c5ad3fec19540a5");
}),
it("SQL Beautify", () => {
const result = chef.SQLBeautify(`SELECT MONTH, ID, RAIN_I, TEMP_F
const result = chef.SQLBeautify(`SELECT MONTH, ID, RAIN_I, TEMP_F
FROM STATS;`);
const expected = `SELECT MONTH,
ID,
@ -879,8 +883,7 @@ FROM STATS;`;
const result = chef.strings("smothering ampersand abreast", {displayTotal: true});
const expected = `Total found: 1
smothering ampersand abreast
`;
smothering ampersand abreast`;
assert.strictEqual(result.toString(), expected);
}),
@ -1075,6 +1078,60 @@ ExifImageHeight: 57`);
assert.equal(output, res.value);
}),
it("performs MAGIC", async () => {
const input = "WUagwsiae6mP8gNtCCLUFpCpCB26RmBDoDD8PacdAmzAzBVjkK2QstFXaKhpC6iUS7RHqXrJtFisoRSgoJ4whjm1arm864qaNq4RcfUmLHrcsAaZc5TXCYifNdgS83gDeejGX46gaiMyuBV6EskHt1scgJ88x2tNSotQDwbGY1mmCob2ARGFvCKYNqiN9ipMq1ZU1mgkdbNuGcb76aRtYWhCGUc8g93UJudhb8htsheZnwTpgqhx83SVJSZXMXUjJT2zmpC7uXWtumqokbdSi88YtkWDAc1Toouh2oH4D4ddmNKJWUDpMwmngUmK14xwmomccPQE9hM172APnSqwxdKQ172RkcAsysnmj5gGtRmVNNh2s359wr6mS2QRP";
const depth = 1;
const res = await chef.magic(input, {
depth,
});
// assert against the structure of the output, rather than the values.
assert.strictEqual(res.value.length, depth + 1);
res.value.forEach(row => {
assert.ok(row.recipe);
assert.ok(row.data);
assert.ok(row.languageScores);
assert.ok(Object.prototype.hasOwnProperty.call(row, "fileType")); // Can be null, so cannot just use ok
assert.ok(row.entropy);
assert.ok(row.matchingOps);
assert.ok(Object.prototype.hasOwnProperty.call(row, "useful"));
assert.ok(Object.prototype.hasOwnProperty.call(row, "matchesCrib"));
row.recipe.forEach(item => {
assert.ok(Object.prototype.hasOwnProperty.call(item, "op"), `No 'op' property in item ${item}`);
assert.strictEqual(typeof item.op, "string");
assert.ok(Object.prototype.hasOwnProperty.call(item, "args"), `No 'args' property in item ${item}`);
assert.ok(Array.isArray(item.args));
});
row.languageScores.forEach(score => {
assert.ok(Object.prototype.hasOwnProperty.call(score, "lang"), `No 'lang' property in languageScore ${score}`);
assert.strictEqual(typeof score.lang, "string");
assert.ok(Object.prototype.hasOwnProperty.call(score, "score"), `No 'score' property in languageScore ${score}`);
assert.strictEqual(typeof score.score, "number");
assert.ok(Object.prototype.hasOwnProperty.call(score, "probability"), `No 'probability' property in languageScore ${score}`);
assert.strictEqual(typeof score.probability, "number");
});
row.matchingOps.forEach(op => {
assert.ok(Object.prototype.hasOwnProperty.call(op, "op"), `No 'op' property in matchingOp ${JSON.stringify(op)}`);
assert.strictEqual(typeof op.op, "string");
assert.ok(Object.prototype.hasOwnProperty.call(op, "pattern"), `No 'pattern' property in matchingOp ${JSON.stringify(op)}`);
assert.ok(op.pattern instanceof RegExp);
assert.ok(Object.prototype.hasOwnProperty.call(op, "args"), `No 'args' property in matchingOp ${JSON.stringify(op)}`);
assert.ok(Array.isArray(op.args));
assert.ok(Object.prototype.hasOwnProperty.call(op, "useful"), `No 'useful' property in matchingOp ${JSON.stringify(op)}`);
assert.ifError(op.useful); // Expect this to be undefined
assert.ok(Object.prototype.hasOwnProperty.call(op, "entropyRange"), `No 'entropyRange' property in matchingOp ${JSON.stringify(op)}`);
assert.ifError(op.entropyRange); // Expect this to be undefined
assert.ok(Object.prototype.hasOwnProperty.call(op, "output"), `No 'output' property in matchingOp ${JSON.stringify(op)}`);
assert.ifError(op.output); // Expect this to be undefined
});
});
}),
]);

View file

@ -17,94 +17,136 @@ import {
} from "../lib/utils.mjs";
import TestRegister from "../lib/TestRegister.mjs";
import "./tests/BCD.mjs";
import "./tests/BSON.mjs";
import "./tests/AESKeyWrap.mjs";
import "./tests/AvroToJSON.mjs";
import "./tests/BaconCipher.mjs";
import "./tests/Base45.mjs";
import "./tests/Base58.mjs";
import "./tests/Base64.mjs";
import "./tests/Base62.mjs";
import "./tests/Base64.mjs";
import "./tests/Base85.mjs";
import "./tests/Base92.mjs";
import "./tests/BCD.mjs";
import "./tests/BitwiseOp.mjs";
import "./tests/BLAKE2b.mjs";
import "./tests/BLAKE2s.mjs";
import "./tests/Bombe.mjs";
import "./tests/BSON.mjs";
import "./tests/ByteRepr.mjs";
import "./tests/CaesarBoxCipher.mjs";
import "./tests/CaretMdecode.mjs";
import "./tests/CartesianProduct.mjs";
import "./tests/CharEnc.mjs";
import "./tests/CBORDecode.mjs";
import "./tests/CBOREncode.mjs";
import "./tests/CetaceanCipherDecode.mjs";
import "./tests/CetaceanCipherEncode.mjs";
import "./tests/ChaCha.mjs";
import "./tests/ChangeIPFormat.mjs";
import "./tests/CharEnc.mjs";
import "./tests/Charts.mjs";
import "./tests/Checksum.mjs";
import "./tests/Ciphers.mjs";
import "./tests/CipherSaber2.mjs";
import "./tests/CMAC.mjs";
import "./tests/Code.mjs";
import "./tests/Colossus.mjs";
import "./tests/Comment.mjs";
import "./tests/Compress.mjs";
import "./tests/ConditionalJump.mjs";
import "./tests/ConvertCoordinateFormat.mjs";
import "./tests/ConvertToNATOAlphabet.mjs";
import "./tests/Crypt.mjs";
import "./tests/CSV.mjs";
import "./tests/DateTime.mjs";
import "./tests/DefangIP.mjs";
import "./tests/ELFInfo.mjs";
import "./tests/Enigma.mjs";
import "./tests/ExtractEmailAddresses.mjs";
import "./tests/Float.mjs";
import "./tests/FileTree.mjs";
import "./tests/FletcherChecksum.mjs";
import "./tests/Fork.mjs";
import "./tests/FromDecimal.mjs";
import "./tests/Gzip.mjs";
import "./tests/GenerateAllHashes.mjs";
import "./tests/GenerateDeBruijnSequence.mjs";
import "./tests/GetAllCasings.mjs";
import "./tests/GOST.mjs";
import "./tests/Gunzip.mjs";
import "./tests/Gzip.mjs";
import "./tests/Hash.mjs";
import "./tests/HASSH.mjs";
import "./tests/HaversineDistance.mjs";
import "./tests/Hex.mjs";
import "./tests/Hexdump.mjs";
import "./tests/HKDF.mjs";
import "./tests/Image.mjs";
import "./tests/IndexOfCoincidence.mjs";
import "./tests/Jump.mjs";
import "./tests/JA3Fingerprint.mjs";
import "./tests/JA4Fingerprint.mjs";
import "./tests/JA3SFingerprint.mjs";
import "./tests/JSONBeautify.mjs";
import "./tests/JSONMinify.mjs";
import "./tests/JSONtoCSV.mjs";
import "./tests/Jump.mjs";
import "./tests/JWTDecode.mjs";
import "./tests/JWTSign.mjs";
import "./tests/JWTVerify.mjs";
import "./tests/MS.mjs";
import "./tests/LevenshteinDistance.mjs";
import "./tests/Lorenz.mjs";
import "./tests/LS47.mjs";
import "./tests/LuhnChecksum.mjs";
import "./tests/LZNT1Decompress.mjs";
import "./tests/LZString.mjs";
import "./tests/Magic.mjs";
import "./tests/Media.mjs";
import "./tests/MorseCode.mjs";
import "./tests/MS.mjs";
import "./tests/MultipleBombe.mjs";
import "./tests/MurmurHash3.mjs";
import "./tests/NetBIOS.mjs";
import "./tests/NormaliseUnicode.mjs";
import "./tests/NTLM.mjs";
import "./tests/OTP.mjs";
import "./tests/ParseIPRange.mjs";
import "./tests/ParseObjectIDTimestamp.mjs";
import "./tests/ParseQRCode.mjs";
import "./tests/ParseSSHHostKey.mjs";
import "./tests/ParseTCP.mjs";
import "./tests/ParseTLV.mjs";
import "./tests/ParseUDP.mjs";
import "./tests/PEMtoHex.mjs";
import "./tests/PGP.mjs";
import "./tests/PHP.mjs";
import "./tests/ParseIPRange.mjs";
import "./tests/ParseQRCode.mjs";
import "./tests/PowerSet.mjs";
import "./tests/Protobuf.mjs";
import "./tests/Rabbit.mjs";
import "./tests/RAKE.mjs";
import "./tests/Regex.mjs";
import "./tests/Register.mjs";
import "./tests/RemoveDiacritics.mjs";
import "./tests/RisonEncodeDecode.mjs";
import "./tests/Rotate.mjs";
import "./tests/RSA.mjs";
import "./tests/Salsa20.mjs";
import "./tests/XSalsa20.mjs";
import "./tests/SeqUtils.mjs";
import "./tests/SetDifference.mjs";
import "./tests/SetIntersection.mjs";
import "./tests/SetUnion.mjs";
import "./tests/Shuffle.mjs";
import "./tests/SIGABA.mjs";
import "./tests/SM4.mjs";
// import "./tests/SplitColourChannels.mjs"; // Cannot test operations that use the File type yet
import "./tests/StrUtils.mjs";
import "./tests/Subsection.mjs";
import "./tests/SwapCase.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.mjs";
import "./tests/Enigma.mjs";
import "./tests/Bombe.mjs";
import "./tests/MultipleBombe.mjs";
import "./tests/TranslateDateTimeFormat.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/AvroToJSON.mjs";
import "./tests/Lorenz.mjs";
import "./tests/LuhnChecksum.mjs";
import "./tests/CipherSaber2.mjs";
import "./tests/Colossus.mjs";
import "./tests/ParseObjectIDTimestamp.mjs";
// Cannot test operations that use the File type yet
// import "./tests/SplitColourChannels.mjs";
import "./tests/UnescapeString.mjs";
import "./tests/Unicode.mjs";
import "./tests/YARA.mjs";
const testStatus = {
allTestsPassing: true,

View file

@ -0,0 +1,324 @@
/**
* @author mikecat
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
"name": "AES Key Wrap: RFC Test Vector, 128-bit data, 128-bit KEK",
"input": "00112233445566778899aabbccddeeff",
"expectedOutput": "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5",
"recipeConfig": [
{
"op": "AES Key Wrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Wrap: RFC Test Vector, 128-bit data, 192-bit KEK",
"input": "00112233445566778899aabbccddeeff",
"expectedOutput": "96778b25ae6ca435f92b5b97c050aed2468ab8a17ad84e5d",
"recipeConfig": [
{
"op": "AES Key Wrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f1011121314151617"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Wrap: RFC Test Vector, 128-bit data, 256-bit KEK",
"input": "00112233445566778899aabbccddeeff",
"expectedOutput": "64e8c3f9ce0f5ba263e9777905818a2a93c8191e7d6e8ae7",
"recipeConfig": [
{
"op": "AES Key Wrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Wrap: RFC Test Vector, 192-bit data, 192-bit KEK",
"input": "00112233445566778899aabbccddeeff0001020304050607",
"expectedOutput": "031d33264e15d33268f24ec260743edce1c6c7ddee725a936ba814915c6762d2",
"recipeConfig": [
{
"op": "AES Key Wrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f1011121314151617"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Wrap: RFC Test Vector, 192-bit data, 256-bit KEK",
"input": "00112233445566778899aabbccddeeff0001020304050607",
"expectedOutput": "a8f9bc1612c68b3ff6e6f4fbe30e71e4769c8b80a32cb8958cd5d17d6b254da1",
"recipeConfig": [
{
"op": "AES Key Wrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Wrap: RFC Test Vector, 256-bit data, 256-bit KEK",
"input": "00112233445566778899aabbccddeeff000102030405060708090a0b0c0d0e0f",
"expectedOutput": "28c9f404c4b810f4cbccb35cfb87f8263f5786e2d80ed326cbc7f0e71a99f43bfb988b9b7a02dd21",
"recipeConfig": [
{
"op": "AES Key Wrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Unwrap: RFC Test Vector, 128-bit data, 128-bit KEK",
"input": "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5",
"expectedOutput": "00112233445566778899aabbccddeeff",
"recipeConfig": [
{
"op": "AES Key Unwrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Unwrap: RFC Test Vector, 128-bit data, 192-bit KEK",
"input": "96778b25ae6ca435f92b5b97c050aed2468ab8a17ad84e5d",
"expectedOutput": "00112233445566778899aabbccddeeff",
"recipeConfig": [
{
"op": "AES Key Unwrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f1011121314151617"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Unwrap: RFC Test Vector, 128-bit data, 256-bit KEK",
"input": "64e8c3f9ce0f5ba263e9777905818a2a93c8191e7d6e8ae7",
"expectedOutput": "00112233445566778899aabbccddeeff",
"recipeConfig": [
{
"op": "AES Key Unwrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Unwrap: RFC Test Vector, 192-bit data, 192-bit KEK",
"input": "031d33264e15d33268f24ec260743edce1c6c7ddee725a936ba814915c6762d2",
"expectedOutput": "00112233445566778899aabbccddeeff0001020304050607",
"recipeConfig": [
{
"op": "AES Key Unwrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f1011121314151617"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Unwrap: RFC Test Vector, 192-bit data, 256-bit KEK",
"input": "a8f9bc1612c68b3ff6e6f4fbe30e71e4769c8b80a32cb8958cd5d17d6b254da1",
"expectedOutput": "00112233445566778899aabbccddeeff0001020304050607",
"recipeConfig": [
{
"op": "AES Key Unwrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Unwrap: RFC Test Vector, 256-bit data, 256-bit KEK",
"input": "28c9f404c4b810f4cbccb35cfb87f8263f5786e2d80ed326cbc7f0e71a99f43bfb988b9b7a02dd21",
"expectedOutput": "00112233445566778899aabbccddeeff000102030405060708090a0b0c0d0e0f",
"recipeConfig": [
{
"op": "AES Key Unwrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Wrap: invalid KEK length",
"input": "00112233445566778899aabbccddeeff",
"expectedOutput": "KEK must be either 16, 24, or 32 bytes (currently 10 bytes)",
"recipeConfig": [
{
"op": "AES Key Wrap",
"args": [
{"option": "Hex", "string": "00010203040506070809"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Wrap: invalid IV length",
"input": "00112233445566778899aabbccddeeff",
"expectedOutput": "IV must be 8 bytes (currently 6 bytes)",
"recipeConfig": [
{
"op": "AES Key Wrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
{"option": "Hex", "string": "a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Wrap: input length not multiple of 8",
"input": "00112233445566778899aabbccddeeff0102",
"expectedOutput": "input must be 8n (n>=2) bytes (currently 18 bytes)",
"recipeConfig": [
{
"op": "AES Key Wrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Wrap: input too short",
"input": "0011223344556677",
"expectedOutput": "input must be 8n (n>=2) bytes (currently 8 bytes)",
"recipeConfig": [
{
"op": "AES Key Wrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Unwrap: invalid KEK length",
"input": "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5",
"expectedOutput": "KEK must be either 16, 24, or 32 bytes (currently 10 bytes)",
"recipeConfig": [
{
"op": "AES Key Unwrap",
"args": [
{"option": "Hex", "string": "00010203040506070809"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Unwrap: invalid IV length",
"input": "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5",
"expectedOutput": "IV must be 8 bytes (currently 6 bytes)",
"recipeConfig": [
{
"op": "AES Key Unwrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
{"option": "Hex", "string": "a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Unwrap: input length not multiple of 8",
"input": "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5e621",
"expectedOutput": "input must be 8n (n>=3) bytes (currently 26 bytes)",
"recipeConfig": [
{
"op": "AES Key Unwrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Unwrap: input too short",
"input": "1fa68b0a8112b447aef34bd8fb5a7b82",
"expectedOutput": "input must be 8n (n>=3) bytes (currently 16 bytes)",
"recipeConfig": [
{
"op": "AES Key Unwrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
{
"name": "AES Key Unwrap: corrupted input",
"input": "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe6",
"expectedOutput": "IV mismatch",
"recipeConfig": [
{
"op": "AES Key Unwrap",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
"Hex", "Hex"
],
},
],
},
]);

View file

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

View file

@ -5,8 +5,8 @@
* @copyright Karsten Silkenbäumer 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister";
import { BACON_ALPHABETS, BACON_TRANSLATIONS } from "../../../src/core/lib/Bacon";
import TestRegister from "../../lib/TestRegister.mjs";
import { BACON_ALPHABETS, BACON_TRANSLATIONS } from "../../../src/core/lib/Bacon.mjs";
const alphabets = Object.keys(BACON_ALPHABETS);
const translations = BACON_TRANSLATIONS;

View file

@ -0,0 +1,103 @@
/**
* Base45 tests.
*
* @author Thomas Weißschuh [thomas@t-8ch.de]
*
* @copyright Crown Copyright 2021
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
const defaultB45Alph = "0-9A-Z $%*+\\-./:";
TestRegister.addTests([
{
name: "To Base45: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "To Base45",
args: [defaultB45Alph],
},
],
},
{
name: "To Base45: Spec encoding example 1",
input: "AB",
expectedOutput: "BB8",
recipeConfig: [
{
op: "To Base45",
args: [defaultB45Alph],
},
],
},
{
name: "To Base45: Spec encoding example 2",
input: "Hello!!",
expectedOutput: "%69 VD92EX0",
recipeConfig: [
{
op: "To Base45",
args: [defaultB45Alph],
},
],
},
{
name: "To Base45: Spec encoding example 3",
input: "base-45",
expectedOutput: "UJCLQE7W581",
recipeConfig: [
{
op: "To Base45",
args: [defaultB45Alph],
},
],
},
{
name: "From Base45: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "From Base45",
args: [defaultB45Alph],
},
],
},
{
name: "From Base45: Spec decoding example 1",
input: "QED8WEX0",
expectedOutput: "ietf!",
recipeConfig: [
{
op: "From Base45",
args: [defaultB45Alph],
},
],
},
{
name: "From Base45: Invalid character",
input: "!",
expectedOutput: "Character not in alphabet: '!'",
recipeConfig: [
{
op: "From Base45",
args: [defaultB45Alph],
},
],
},
{
name: "From Base45: Invalid triplet value",
input: "ZZZ",
expectedOutput: "Triplet too large: 'ZZZ'",
recipeConfig: [
{
op: "From Base45",
args: [defaultB45Alph],
},
],
},
]);

View file

@ -0,0 +1,70 @@
/**
* Base85 tests
*
* @author john19696
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
// Example from Wikipedia
const wpExample = "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.";
// Escape newline, quote & backslash
const wpOutput = "9jqo^BlbD-BleB1DJ+*+F(f,q/0JhKF<GL>Cj@.4Gp$d7F!,L7@<6@)/0JDEF<G%<+EV:2F!,O<\
DJ+*.@<*K0@<6L(Df-\\0Ec5e;DffZ(EZee.Bl.9pF\"AGXBPCsi+DGm>@3BB/F*&OCAfu2/AKYi(\
DIb:@FD,*)+C]U=@3BN#EcYf8ATD3s@q?d$AftVqCh[NqF<G:8+EV:.+Cf>-FD5W8ARlolDIal(\
DId<j@<?3r@:F%a+D58'ATD4$Bl@l3De:,-DJs`8ARoFb/0JMK@qB4^F!,R<AKZ&-DfTqBG%G>u\
D.RTpAKYo'+CT/5+Cei#DII?(E,9)oF*2M7/c";
const allZeroExample = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
const allZeroOutput = "zz!!*-'\"9eu7#RLhG$k3[W&.oNg'GVB\"(`=52*$$(B+<_pR,UFcb-n-Vr/1iJ-0JP==1c70M3&s#]4?Ykm5X@_(6q'R884cEH9MJ8X:f1+h<)lt#=BSg3>[:ZC?t!MSA7]@cBPD3sCi+'.E,fo>FEMbNG^4U^I!pHnJ:W<)KS>/9Ll%\"IN/`jYOHG]iPa.Q$R$jD4S=Q7DTV8*TUnsrdW2ZetXKAY/Yd(L?['d?O\\@K2_]Y2%o^qmn*`5Ta:aN;TJbg\"GZd*^:jeCE.%f\\,!5gtgiEi8N\\UjQ5OekiqBum-X60nF?)@o_%qPq\"ad`r;HWp";
TestRegister.addTests([
{
name: "To Base85",
input: wpExample,
expectedOutput: wpOutput,
recipeConfig: [
{ "op": "To Base85",
"args": ["!-u"] }
]
},
{
name: "From Base85",
input: wpOutput + "\n",
expectedOutput: wpExample,
recipeConfig: [
{ "op": "From Base85",
"args": ["!-u", true] }
]
},
{
name: "From Base85",
input: wpOutput + "v",
expectedError: true,
expectedOutput: "From Base85 - Invalid character 'v' at index 337",
recipeConfig: [
{ "op": "From Base85",
"args": ["!-u", false] }
]
},
{
name: "To Base85",
input: allZeroExample,
expectedOutput: allZeroOutput,
recipeConfig: [
{ "op": "To Base85",
"args": ["!-u"] }
]
},
{
name: "From Base85",
input: allZeroOutput,
expectedOutput: allZeroExample,
recipeConfig: [
{ "op": "From Base85",
"args": ["!-u", true, "z"] }
]
},
]);

View file

@ -0,0 +1,89 @@
/**
* Base92 tests.
*
* @author sg5506844 [sg5506844@gmail.com]
* @copyright Crown Copyright 2021
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "To Base92: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "To Base92",
args: [],
},
],
},
{
name: "To Base92: Spec encoding example 1",
input: "AB",
expectedOutput: "8y2",
recipeConfig: [
{
op: "To Base92",
args: [],
},
],
},
{
name: "To Base92: Spec encoding example 2",
input: "Hello!!",
expectedOutput: ";K_$aOTo&",
recipeConfig: [
{
op: "To Base92",
args: [],
},
],
},
{
name: "To Base92: Spec encoding example 3",
input: "base-92",
expectedOutput: "DX2?V<Y(*",
recipeConfig: [
{
op: "To Base92",
args: [],
},
],
},
{
name: "From Base92: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "From Base92",
args: [],
},
],
},
{
name: "From Base92: Spec decoding example 1",
input: "G'_DW[B",
expectedOutput: "ietf!",
recipeConfig: [
{
op: "From Base92",
args: [],
},
],
},
{
name: "From Base92: Invalid character",
input: "~",
expectedOutput: "~ is not a base92 character",
recipeConfig: [
{
op: "From Base92",
args: [],
},
],
},
]);

View file

@ -104,26 +104,26 @@ TestRegister.addTests([
}
]
},
// 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
]
}
]
},
// Takes a while to run, so disabling for general purpose testing. Re-enable if modifying this operation.
// {
// 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",

View file

@ -0,0 +1,144 @@
/**
* CBOR Decode Tests
*
* @author Danh4 [dan.h4@ncsc.gov.uk]
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "CBOR Decode: Can decode integer",
input: "0f",
expectedOutput: "15",
recipeConfig: [
{
op: "From Hex",
args: []
},
{
op: "CBOR Decode",
args: []
}
]
},
{
name: "CBOR Decode: Can decode decimal",
input: "f9 3e 00",
expectedOutput: "1.5",
recipeConfig: [
{
op: "From Hex",
args: []
},
{
op: "CBOR Decode",
args: []
}
]
},
{
name: "From Hex: Can decode text",
input: "64 54 65 78 74",
expectedOutput: "\"Text\"",
recipeConfig: [
{
op: "From Hex",
args: []
},
{
op: "CBOR Decode",
args: []
}
]
},
{
name: "From Hex: Can decode boolean true",
input: "f5",
expectedOutput: "true",
recipeConfig: [
{
op: "From Hex",
args: []
},
{
op: "CBOR Decode",
args: []
}
]
},
{
name: "From Hex: Can decode boolean false",
input: "f4",
expectedOutput: "false",
recipeConfig: [
{
op: "From Hex",
args: []
},
{
op: "CBOR Decode",
args: []
}
]
},
{
name: "From Hex: Can decode map",
input: "a3 61 61 01 61 62 02 61 63 03",
expectedOutput: JSON.stringify({a: 1, b: 2, c: 3}),
recipeConfig: [
{
op: "From Hex",
args: []
},
{
op: "CBOR Decode",
args: []
},
{
op: "JSON Minify",
args: []
}
]
},
{
name: "From Hex: Can decode list",
input: "83 00 01 02",
expectedOutput: "[0,1,2]",
recipeConfig: [
{
op: "From Hex",
args: []
},
{
op: "CBOR Decode",
args: []
},
{
op: "JSON Minify",
args: []
}
]
},
{
name: "From Hex: Can round trip with encode",
input: JSON.stringify({a: 1, b: false, c: [1, 2, 3]}),
expectedOutput: JSON.stringify({a: 1, b: false, c: [1, 2, 3]}),
recipeConfig: [
{
op: "CBOR Encode",
args: []
},
{
op: "CBOR Decode",
args: []
},
{
op: "JSON Minify",
args: []
}
]
}
]);

View file

@ -0,0 +1,117 @@
/**
* CBOR Encode Tests.
*
* @author Danh4 [dan.h4@ncsc.gov.uk]
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "CBOR Encode: Can encode integer",
input: "15",
expectedOutput: "0f",
recipeConfig: [
{
op: "CBOR Encode",
args: []
},
{
op: "To Hex",
args: []
}
]
},
{
name: "CBOR Decode: Can encode decimal",
input: "1.5",
expectedOutput: "f9 3e 00",
recipeConfig: [
{
op: "CBOR Encode",
args: []
},
{
op: "To Hex",
args: []
}
]
},
{
name: "CBOR Encode: Can encode text",
input: "\"Text\"",
expectedOutput: "64 54 65 78 74",
recipeConfig: [
{
op: "CBOR Encode",
args: []
},
{
op: "To Hex",
args: []
}
]
},
{
name: "CBOR Encode: Can encode boolean true",
input: "true",
expectedOutput: "f5",
recipeConfig: [
{
op: "CBOR Encode",
args: []
},
{
op: "To Hex",
args: []
}
]
},
{
name: "CBOR Encode: Can encode boolean false",
input: "false",
expectedOutput: "f4",
recipeConfig: [
{
op: "CBOR Encode",
args: []
},
{
op: "To Hex",
args: []
}
]
},
{
name: "CBOR Encode: Can encode map",
input: JSON.stringify({a: 1, b: 2, c: 3}),
expectedOutput: "a3 61 61 01 61 62 02 61 63 03",
recipeConfig: [
{
op: "CBOR Encode",
args: []
},
{
op: "To Hex",
args: []
}
]
},
{
name: "CBOR Encode: Can encode list",
input: "[0,1,2]",
expectedOutput: "83 00 01 02",
recipeConfig: [
{
op: "CBOR Encode",
args: []
},
{
op: "To Hex",
args: []
}
]
}
]);

View file

@ -0,0 +1,314 @@
/**
* @author mikecat
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
// values in "NIST's CSRC" testcases are taken from here:
// https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
TestRegister.addTests([
{
"name": "CMAC-AES128 NIST's CSRC Example #1",
"input": "",
"expectedOutput": "bb1d6929e95937287fa37d129b756746",
"recipeConfig": [
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
},
]
},
{
"name": "CMAC-AES128 NIST's CSRC Example #2",
"input": "6bc1bee22e409f96e93d7e117393172a",
"expectedOutput": "070a16b46b4d4144f79bdd9dd04a287c",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
},
]
},
{
"name": "CMAC-AES128 NIST's CSRC Example #3",
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
"expectedOutput": "7d85449ea6ea19c823a7bf78837dfade",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
},
]
},
{
"name": "CMAC-AES128 NIST's CSRC Example #4",
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
"expectedOutput": "51f0bebf7e3b9d92fc49741779363cfe",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
},
]
},
{
"name": "CMAC-AES192 NIST's CSRC Example #1",
"input": "",
"expectedOutput": "d17ddf46adaacde531cac483de7a9367",
"recipeConfig": [
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
},
]
},
{
"name": "CMAC-AES192 NIST's CSRC Example #2",
"input": "6bc1bee22e409f96e93d7e117393172a",
"expectedOutput": "9e99a7bf31e710900662f65e617c5184",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
},
]
},
{
"name": "CMAC-AES192 NIST's CSRC Example #3",
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
"expectedOutput": "3d75c194ed96070444a9fa7ec740ecf8",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
},
]
},
{
"name": "CMAC-AES192 NIST's CSRC Example #4",
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
"expectedOutput": "a1d5df0eed790f794d77589659f39a11",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
},
]
},
{
"name": "CMAC-AES256 NIST's CSRC Example #1",
"input": "",
"expectedOutput": "028962f61b7bf89efc6b551f4667d983",
"recipeConfig": [
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
},
]
},
{
"name": "CMAC-AES256 NIST's CSRC Example #2",
"input": "6bc1bee22e409f96e93d7e117393172a",
"expectedOutput": "28a7023f452e8f82bd4bf28d8c37c35c",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
},
]
},
{
"name": "CMAC-AES256 NIST's CSRC Example #3",
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
"expectedOutput": "156727dc0878944a023c1fe03bad6d93",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
},
]
},
{
"name": "CMAC-AES256 NIST's CSRC Example #4",
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
"expectedOutput": "e1992190549f6ed5696a2c056c315410",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
},
]
},
{
"name": "CMAC-TDES (1) NIST's CSRC Sample #1",
"input": "",
"expectedOutput": "7db0d37df936c550",
"recipeConfig": [
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
},
]
},
{
"name": "CMAC-TDES (1) NIST's CSRC Sample #2",
"input": "6bc1bee22e409f96e93d7e117393172a",
"expectedOutput": "30239cf1f52e6609",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
},
]
},
{
"name": "CMAC-TDES (1) NIST's CSRC Sample #3",
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
"expectedOutput": "6c9f3ee4923f6be2",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
},
]
},
{
"name": "CMAC-TDES (1) NIST's CSRC Sample #4",
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51",
"expectedOutput": "99429bd0bf7904e5",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
},
]
},
{
"name": "CMAC-TDES (2) NIST's CSRC Sample #1",
"input": "",
"expectedOutput": "79ce52a7f786a960",
"recipeConfig": [
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
},
]
},
{
"name": "CMAC-TDES (2) NIST's CSRC Sample #2",
"input": "6bc1bee22e409f96e93d7e117393172a",
"expectedOutput": "cc18a0b79af2413b",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
},
]
},
{
"name": "CMAC-TDES (2) NIST's CSRC Sample #3",
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
"expectedOutput": "c06d377ecd101969",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
},
]
},
{
"name": "CMAC-TDES (2) NIST's CSRC Sample #4",
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51",
"expectedOutput": "9cd33580f9b64dfb",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
},
]
},
{
"name": "CMAC-AES: invalid key length",
"input": "",
"expectedOutput": "The key for AES must be either 16, 24, or 32 bytes (currently 20 bytes)",
"recipeConfig": [
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "00112233445566778899aabbccddeeff01234567"}, "AES"]
},
]
},
{
"name": "CMAC-TDES: invalid key length",
"input": "",
"expectedOutput": "The key for Triple DES must be 16 or 24 bytes (currently 20 bytes)",
"recipeConfig": [
{
"op": "CMAC",
"args": [{"option": "Hex", "string": "00112233445566778899aabbccddeeff01234567"}, "Triple DES"]
},
]
},
]);

View file

@ -0,0 +1,45 @@
/**
* Caesar Box Cipher tests.
*
* @author n1073645 [n1073645@gmail.com]
*
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Caesar Box Cipher: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "Caesar Box Cipher",
args: ["1"],
},
],
},
{
name: "Caesar Box Cipher: Hello World!",
input: "Hello World!",
expectedOutput: "Hlodeor!lWl",
recipeConfig: [
{
op: "Caesar Box Cipher",
args: ["3"],
},
],
},
{
name: "Caesar Box Cipher: Hello World!",
input: "Hlodeor!lWl",
expectedOutput: "HelloWorld!",
recipeConfig: [
{
op: "Caesar Box Cipher",
args: ["4"],
},
],
}
]);

View file

@ -0,0 +1,39 @@
/**
* Caesar Box Cipher tests.
*
* @author tedk [tedk@ted.do]
*
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Caret/M-decode: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "Caret/M-decode",
args: [],
},
],
},
{
/*
* Tests the full range.
* Everything except "^_" (\x5e\x5f) will decode correctly.
*/
name: "Caret/M-decode: Full set",
input: "^@^A^B^C^D^E^F^G^H^I^J^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\\^]^^^_ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^ZM-^[M-^\\M-^]M-^^M-^_M- M-!M-\"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9M-:M-;M-<M-=M->M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?",
expectedOutput: "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x1f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\x8d\x2d\x5f\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
recipeConfig: [
{
op: "Caret/M-decode",
args: [],
},
],
},
]);

View file

@ -0,0 +1,22 @@
/**
* CetaceanCipher Encode tests
*
* @author dolphinOnKeys
* @copyright Crown Copyright 2022
* @licence Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Cetacean Cipher Decode",
input: "EEEEEEEEEeeEEEEe EEEEEEEEEeeEEEeE EEEEEEEEEeeEEEee EEeeEEEEEeeEEeee",
expectedOutput: "a b c で",
recipeConfig: [
{
op: "Cetacean Cipher Decode",
args: []
},
],
}
]);

View file

@ -0,0 +1,22 @@
/**
* CetaceanCipher Encode tests
*
* @author dolphinOnKeys
* @copyright Crown Copyright 2022
* @licence Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Cetacean Cipher Encode",
input: "a b c で",
expectedOutput: "EEEEEEEEEeeEEEEe EEEEEEEEEeeEEEeE EEEEEEEEEeeEEEee EEeeEEEEEeeEEeee",
recipeConfig: [
{
op: "Cetacean Cipher Encode",
args: []
},
],
}
]);

View file

@ -0,0 +1,170 @@
/**
* ChaCha tests.
*
* @author joostrijneveld [joost@joostrijneveld.nl]
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "ChaCha: no key",
input: "",
expectedOutput: `Invalid key length: 0 bytes.
ChaCha uses a key of 16 or 32 bytes (128 or 256 bits).`,
recipeConfig: [
{
"op": "ChaCha",
"args": [
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
0, "20", "Hex", "Hex",
]
}
],
},
{
name: "ChaCha: no nonce",
input: "",
expectedOutput: `Invalid nonce length: 0 bytes.
ChaCha uses a nonce of 8 or 12 bytes (64 or 96 bits).`,
recipeConfig: [
{
"op": "ChaCha",
"args": [
{"option": "Hex", "string": "00000000000000000000000000000000"},
{"option": "Hex", "string": ""},
0, "20", "Hex", "Hex",
]
}
],
},
{
name: "ChaCha: RFC8439",
input: "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.",
expectedOutput: "6e 2e 35 9a 25 68 f9 80 41 ba 07 28 dd 0d 69 81 e9 7e 7a ec 1d 43 60 c2 0a 27 af cc fd 9f ae 0b f9 1b 65 c5 52 47 33 ab 8f 59 3d ab cd 62 b3 57 16 39 d6 24 e6 51 52 ab 8f 53 0c 35 9f 08 61 d8 07 ca 0d bf 50 0d 6a 61 56 a3 8e 08 8a 22 b6 5e 52 bc 51 4d 16 cc f8 06 81 8c e9 1a b7 79 37 36 5a f9 0b bf 74 a3 5b e6 b4 0b 8e ed f2 78 5e 42 87 4d",
recipeConfig: [
{
"op": "ChaCha",
"args": [
{"option": "Hex", "string": "00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f:10:11:12:13:14:15:16:17:18:19:1a:1b:1c:1d:1e:1f"},
{"option": "Hex", "string": "00:00:00:00:00:00:00:4a:00:00:00:00"},
1, "20", "Raw", "Hex",
]
}
],
},
{
name: "ChaCha: RFC8439 Raw output",
input: "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.",
expectedOutput: "6e 2e 35 9a 25 68 f9 80 41 ba 07 28 dd 0d 69 81 e9 7e 7a ec 1d 43 60 c2 0a 27 af cc fd 9f ae 0b f9 1b 65 c5 52 47 33 ab 8f 59 3d ab cd 62 b3 57 16 39 d6 24 e6 51 52 ab 8f 53 0c 35 9f 08 61 d8 07 ca 0d bf 50 0d 6a 61 56 a3 8e 08 8a 22 b6 5e 52 bc 51 4d 16 cc f8 06 81 8c e9 1a b7 79 37 36 5a f9 0b bf 74 a3 5b e6 b4 0b 8e ed f2 78 5e 42 87 4d",
recipeConfig: [
{
"op": "ChaCha",
"args": [
{"option": "Hex", "string": "00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f:10:11:12:13:14:15:16:17:18:19:1a:1b:1c:1d:1e:1f"},
{"option": "Hex", "string": "00:00:00:00:00:00:00:4a:00:00:00:00"},
1, "20", "Raw", "Raw",
]
},
{
"op": "To Hex",
"args": []
},
],
},
{
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.1",
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
expectedOutput: "29 56 0d 28 0b 45 28 40 0a 8f 4b 79 53 69 fb 3a 01 10 55 99 e9 f1 ed 58 27 9c fc 9e ce 2d c5 f9 9f 1c 2e 52 c9 82 38 f5 42 a5 c0 a8 81 d8 50 b6 15 d3 ac d9 fb db 02 6e 93 68 56 5d a5 0e 0d 49 dd 5b e8 ef 74 24 8b 3e 25 1d 96 5d 8f cb 21 e7 cf e2 04 d4 00 78 06 fb ee 3c e9 4c 74 bf ba d2 c1 1c 62 1b a0 48 14 7c 5c aa 94 d1 82 cc ff 6f d5 cf 44 ad f9 6e 3d 68 28 1b b4 96 76 af 87 e7",
recipeConfig: [
{
"op": "ChaCha",
"args": [
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"},
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
0, "8", "Hex", "Hex",
]
}
],
},
{
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.2",
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
expectedOutput: "5e dd c2 d9 42 8f ce ee c5 0a 52 a9 64 ea e0 ff b0 4b 2d e0 06 a9 b0 4c ff 36 8f fa 92 11 16 b2 e8 e2 64 ba bd 2e fa 0d e4 3e f2 e3 b6 d0 65 e8 f7 c0 a1 78 37 b0 a4 0e b0 e2 c7 a3 74 2c 87 53 ed e5 f3 f6 d1 9b e5 54 67 5e 50 6a 77 5c 63 f0 94 d4 96 5c 31 93 19 dc d7 50 6f 45 7b 11 7b 84 b1 0b 24 6e 95 6c 2d a8 89 8a 65 6c ee f3 f7 b7 16 45 b1 9f 70 1d b8 44 85 ce 51 21 f0 f6 17 ef",
recipeConfig: [
{
"op": "ChaCha",
"args": [
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"},
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
0, "12", "Hex", "Hex",
]
}
],
},
{
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.3",
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
expectedOutput: "d1 ab f6 30 46 7e b4 f6 7f 1c fb 47 cd 62 6a ae 8a fe db be 4f f8 fc 5f e9 cf ae 30 7e 74 ed 45 1f 14 04 42 5a d2 b5 45 69 d5 f1 81 48 93 99 71 ab b8 fa fc 88 ce 4a c7 fe 1c 3d 1f 7a 1e b7 ca e7 6c a8 7b 61 a9 71 35 41 49 77 60 dd 9a e0 59 35 0c ad 0d ce df aa 80 a8 83 11 9a 1a 6f 98 7f d1 ce 91 fd 8e e0 82 80 34 b4 11 20 0a 97 45 a2 85 55 44 75 d1 2a fc 04 88 7f ef 35 16 d1 2a 2c",
recipeConfig: [
{
"op": "ChaCha",
"args": [
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"},
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
0, "20", "Hex", "Hex",
]
}
],
},
{
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.4",
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
expectedOutput: "db 43 ad 9d 1e 84 2d 12 72 e4 53 0e 27 6b 3f 56 8f 88 59 b3 f7 cf 6d 9d 2c 74 fa 53 80 8c b5 15 7a 8e bf 46 ad 3d cc 4b 6c 7d ad de 13 17 84 b0 12 0e 0e 22 f6 d5 f9 ff a7 40 7d 4a 21 b6 95 d9 c5 dd 30 bf 55 61 2f ab 9b dd 11 89 20 c1 98 16 47 0c 7f 5d cd 42 32 5d bb ed 8c 57 a5 62 81 c1 44 cb 0f 03 e8 1b 30 04 62 4e 06 50 a1 ce 5a fa f9 a7 cd 81 63 f6 db d7 26 02 25 7d d9 6e 47 1e",
recipeConfig: [
{
"op": "ChaCha",
"args": [
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ff ee dd cc bb aa 99 88 77 66 55 44 33 22 11 00"},
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
0, "8", "Hex", "Hex",
]
}
],
},
{
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.5",
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
expectedOutput: "7e d1 2a 3a 63 91 2a e9 41 ba 6d 4c 0d 5e 86 2e 56 8b 0e 55 89 34 69 35 50 5f 06 4b 8c 26 98 db f7 d8 50 66 7d 8e 67 be 63 9f 3b 4f 6a 16 f9 2e 65 ea 80 f6 c7 42 94 45 da 1f c2 c1 b9 36 50 40 e3 2e 50 c4 10 6f 3b 3d a1 ce 7c cb 1e 71 40 b1 53 49 3c 0f 3a d9 a9 bc ff 07 7e c4 59 6f 1d 0f 29 bf 9c ba a5 02 82 0f 73 2a f5 a9 3c 49 ee e3 3d 1c 4f 12 af 3b 42 97 af 91 fe 41 ea 9e 94 a2",
recipeConfig: [
{
"op": "ChaCha",
"args": [
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ff ee dd cc bb aa 99 88 77 66 55 44 33 22 11 00"},
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
0, "12", "Hex", "Hex",
]
}
],
},
{
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.6",
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
expectedOutput: "9f ad f4 09 c0 08 11 d0 04 31 d6 7e fb d8 8f ba 59 21 8d 5d 67 08 b1 d6 85 86 3f ab bb 0e 96 1e ea 48 0f d6 fb 53 2b fd 49 4b 21 51 01 50 57 42 3a b6 0a 63 fe 4f 55 f7 a2 12 e2 16 7c ca b9 31 fb fd 29 cf 7b c1 d2 79 ed df 25 dd 31 6b b8 84 3d 6e de e0 bd 1e f1 21 d1 2f a1 7c bc 2c 57 4c cc ab 5e 27 51 67 b0 8b d6 86 f8 a0 9d f8 7e c3 ff b3 53 61 b9 4e bf a1 3f ec 0e 48 89 d1 8d a5",
recipeConfig: [
{
"op": "ChaCha",
"args": [
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ff ee dd cc bb aa 99 88 77 66 55 44 33 22 11 00"},
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
0, "20", "Hex", "Hex",
]
}
],
},
]);

View file

@ -185,11 +185,11 @@ TestRegister.addTests([
{
name: "JPath Expression: Empty expression",
input: JSON.stringify(JSON_TEST_DATA),
expectedOutput: "Invalid JPath expression: we need a path",
expectedOutput: "",
recipeConfig: [
{
"op": "JPath expression",
"args": ["", "\n"]
"args": ["", "\n", true]
}
],
},
@ -205,7 +205,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "JPath expression",
"args": ["$.store.book[*].author", "\n"]
"args": ["$.store.book[*].author", "\n", true]
}
],
},
@ -223,7 +223,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "JPath expression",
"args": ["$..title", "\n"]
"args": ["$..title", "\n", true]
}
],
},
@ -238,7 +238,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "JPath expression",
"args": ["$.store.*", "\n"]
"args": ["$.store.*", "\n", true]
}
],
},
@ -249,7 +249,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "JPath expression",
"args": ["$..book[-1:]", "\n"]
"args": ["$..book[-1:]", "\n", true]
}
],
},
@ -263,7 +263,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "JPath expression",
"args": ["$..book[:2]", "\n"]
"args": ["$..book[:2]", "\n", true]
}
],
},
@ -277,7 +277,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "JPath expression",
"args": ["$..book[?(@.isbn)]", "\n"]
"args": ["$..book[?(@.isbn)]", "\n", false]
}
],
},
@ -292,7 +292,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "JPath expression",
"args": ["$..book[?(@.price<30 && @.category==\"fiction\")]", "\n"]
"args": ["$..book[?(@.price<30 && @.category==\"fiction\")]", "\n", false]
}
],
},
@ -306,10 +306,25 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "JPath expression",
"args": ["$..book[?(@.price<10)]", "\n"]
"args": ["$..book[?(@.price<10)]", "\n", false]
}
],
},
{
name: "JPath Expression: Script-based expression",
input: "[{}]",
recipeConfig: [
{
"op": "JPath expression",
"args": [
"$..[?(({__proto__:[].constructor}).constructor(\"self.postMessage({action:'bakeComplete',data:{bakeId:1,dish:{type:1,value:''},duration:1,error:false,id:undefined,inputNum:2,progress:1,result:'<iframe/onload=debugger>',type: 'html'}});\")();)]",
"\n",
true
]
}
],
expectedOutput: "Invalid JPath expression: Eval [?(expr)] prevented in JSONPath expression."
},
{
name: "CSS selector",
input: '<div id="test">\n<p class="a">hello</p>\n<p>world</p>\n<p class="a">again</p>\n</div>',

File diff suppressed because one or more lines are too long

View file

@ -23,4 +23,86 @@ TestRegister.addTests([
}
],
},
{
name: "LZMA compress & decompress",
input: "The cat sat on the mat.",
// Generated using command `echo -n "The cat sat on the mat." | lzma -z -6 | xxd -p`
expectedOutput: "The cat sat on the mat.",
recipeConfig: [
{
"op": "LZMA Compress",
"args": ["6"]
},
{
"op": "LZMA Decompress",
"args": []
},
],
},
{
name: "LZMA decompress: binary",
// Generated using command `echo "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10" | xxd -r -p | lzma -z -6 | xxd -p`
input: "5d00008000ffffffffffffffff00000052500a84f99bb28021a969d627e03e8a922effffbd160000",
expectedOutput: "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10",
recipeConfig: [
{
"op": "From Hex",
"args": ["Space"]
},
{
"op": "LZMA Decompress",
"args": []
},
{
"op": "To Hex",
"args": ["Space", 0]
}
],
},
{
name: "LZMA decompress: string",
// Generated using command `echo -n "The cat sat on the mat." | lzma -z -6 | xxd -p`
input: "5d00008000ffffffffffffffff002a1a08a202b1a4b814b912c94c4152e1641907d3fd8cd903ffff4fec0000",
expectedOutput: "The cat sat on the mat.",
recipeConfig: [
{
"op": "From Hex",
"args": ["Space"]
},
{
"op": "LZMA Decompress",
"args": []
}
],
},
{
name: "LZ4 Compress",
input: "The cat sat on the mat.",
expectedOutput: "04224d184070df170000805468652063617420736174206f6e20746865206d61742e00000000",
recipeConfig: [
{
"op": "LZ4 Compress",
"args": []
},
{
"op": "To Hex",
"args": ["None", 0]
}
],
},
{
name: "LZ4 Decompress",
input: "04224d184070df170000805468652063617420736174206f6e20746865206d61742e00000000",
expectedOutput: "The cat sat on the mat.",
recipeConfig: [
{
"op": "From Hex",
"args": ["None"]
},
{
"op": "LZ4 Decompress",
"args": []
}
],
},
]);

View file

@ -25,15 +25,18 @@ TestRegister.addTests([
*
* from Crypto.Cipher import AES
* import binascii
*
* input_data = "0123456789ABCDEF"
* key = binascii.unhexlify("00112233445566778899aabbccddeeff")
* iv = binascii.unhexlify("ffeeddccbbaa99887766554433221100")
* aad = b'additional data'
*
* cipher = AES.new(key, AES.MODE_GCM, nonce=iv)
* cipher.update(aad)
* cipher_text, tag = cipher.encrypt_and_digest(binascii.unhexlify(input_data))
*
* cipher = AES.new(key, AES.MODE_GCM, nonce=iv)
* cipher.update(aad)
* decrypted = cipher.decrypt_and_verify(cipher_text, tag)
*
* key = binascii.hexlify(key).decode("UTF-8")
@ -42,7 +45,7 @@ TestRegister.addTests([
* 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))
* print("Key: {}\nIV : {}\nInput data: {}\nAAD: {}\n\nEncrypted ciphertext: {}\nGCM tag: {}\n\nDecrypted plaintext : {}".format(key, iv, input_data, aad, cipher_text, tag, decrypted))
*
*
* Outputs:
@ -70,7 +73,8 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
"CBC", "Raw", "Hex"
"CBC", "Raw", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -85,7 +89,8 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00000000000000000000000000000000"},
"CBC", "Raw", "Hex"
"CBC", "Raw", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -100,7 +105,8 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00000000000000000000000000000000"},
"CTR", "Raw", "Hex"
"CTR", "Raw", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -115,7 +121,8 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
"CBC", "Raw", "Hex"
"CBC", "Raw", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -130,7 +137,8 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
"CFB", "Raw", "Hex"
"CFB", "Raw", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -145,7 +153,8 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
"OFB", "Raw", "Hex"
"OFB", "Raw", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -160,7 +169,8 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
"CTR", "Raw", "Hex"
"CTR", "Raw", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -175,7 +185,8 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""},
"ECB", "Raw", "Hex"
"ECB", "Raw", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -192,7 +203,26 @@ Tag: 16a3e732a605cc9ca29108f742ca0743`,
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""},
"GCM", "Raw", "Hex"
"GCM", "Raw", "Hex",
{"option": "Hex", "string": ""}
]
}
],
},
{
name: "AES Encrypt: AES-128-GCM, ASCII, AAD",
input: "The quick brown fox jumps over the lazy dog.",
expectedOutput: `daa58faa056c52756aa488aeafbd265b6effcf4eca58220a97b0005b1a9b1e1c9e7a6725d35f5f79b9493de7
Tag: 3b5378917f67b0aade9891fc6c291646`,
recipeConfig: [
{
"op": "AES Encrypt",
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "ffeeddccbbaa99887766554433221100"},
"GCM", "Raw", "Hex",
{"option": "UTF8", "string": "additional data"}
]
}
],
@ -207,7 +237,8 @@ Tag: 16a3e732a605cc9ca29108f742ca0743`,
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CBC", "Hex", "Hex"
"CBC", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -222,7 +253,8 @@ Tag: 16a3e732a605cc9ca29108f742ca0743`,
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CFB", "Hex", "Hex"
"CFB", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -237,7 +269,8 @@ Tag: 16a3e732a605cc9ca29108f742ca0743`,
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"OFB", "Hex", "Hex"
"OFB", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -252,7 +285,8 @@ Tag: 16a3e732a605cc9ca29108f742ca0743`,
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CTR", "Hex", "Hex"
"CTR", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -269,7 +303,26 @@ Tag: 70fad2ca19412c20f40fd06918736e56`,
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex"
"GCM", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
},
{
name: "AES Encrypt: AES-128-GCM, Binary, AAD",
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
expectedOutput: `5a29debb5c5f38cdf8aee421bd94dbbf3399947faddf205f88b3ad8ecb0c51214ec0e28bf78942dfa212d7eb15259bbdcac677b4c05f473eeb9331d74f31d441d97d56eb5c73b586342d72128ca528813543dc0fc7eddb7477172cc9194c18b2e1383e4e
Tag: 61cc4b70809452b0b3e38f913fa0a109`,
recipeConfig: [
{
"op": "AES Encrypt",
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "UTF8", "string": "additional data"}
]
}
],
@ -284,7 +337,8 @@ Tag: 70fad2ca19412c20f40fd06918736e56`,
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"ECB", "Hex", "Hex"
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -299,7 +353,8 @@ Tag: 70fad2ca19412c20f40fd06918736e56`,
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CBC", "Hex", "Hex"
"CBC", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -314,7 +369,8 @@ Tag: 70fad2ca19412c20f40fd06918736e56`,
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CFB", "Hex", "Hex"
"CFB", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -329,7 +385,8 @@ Tag: 70fad2ca19412c20f40fd06918736e56`,
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"OFB", "Hex", "Hex"
"OFB", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -344,7 +401,8 @@ Tag: 70fad2ca19412c20f40fd06918736e56`,
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CTR", "Hex", "Hex"
"CTR", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -361,7 +419,26 @@ Tag: 86db597d5302595223cadbd990f1309b`,
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex"
"GCM", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
},
{
name: "AES Encrypt: AES-192-GCM, Binary, AAD",
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
expectedOutput: `318b479d919d506f0cd904f2676fab263a7921b6d7e0514f36e03ae2333b77fa66ef5600babcb2ee9718aeb71fc357412343c1f2cb351d8715bb0aedae4a6468124f9c4aaf6a721b306beddbe63a978bec8baeeba4b663be33ee5bc982746bd4aed1c38b
Tag: aeedf3e6ca4201577c0cf3e9ce58159d`,
recipeConfig: [
{
"op": "AES Encrypt",
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "UTF8", "string": "additional data"}
]
}
],
@ -376,7 +453,8 @@ Tag: 86db597d5302595223cadbd990f1309b`,
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"ECB", "Hex", "Hex"
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -391,7 +469,8 @@ Tag: 86db597d5302595223cadbd990f1309b`,
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CBC", "Hex", "Hex"
"CBC", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -406,7 +485,8 @@ Tag: 86db597d5302595223cadbd990f1309b`,
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CFB", "Hex", "Hex"
"CFB", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -421,7 +501,8 @@ Tag: 86db597d5302595223cadbd990f1309b`,
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"OFB", "Hex", "Hex"
"OFB", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -436,7 +517,8 @@ Tag: 86db597d5302595223cadbd990f1309b`,
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CTR", "Hex", "Hex"
"CTR", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -453,7 +535,26 @@ Tag: 821b1e5f32dad052e502775a523d957a`,
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex"
"GCM", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
},
{
name: "AES Encrypt: AES-256-GCM, Binary, AAD",
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
expectedOutput: `1287f188ad4d7ab0d9ff69b3c29cb11f861389532d8cb9337181da2e8cfc74a84927e8c0dd7a28a32fd485afe694259a63c199b199b95edd87c7aa95329feac340f2b78b72956a85f367044d821766b1b7135815571df44900695f1518cf3ae38ecb650f
Tag: a8f04c4d93bbef82bef61a103371aef9`,
recipeConfig: [
{
"op": "AES Encrypt",
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "UTF8", "string": "additional data"}
]
}
],
@ -468,7 +569,8 @@ Tag: 821b1e5f32dad052e502775a523d957a`,
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"ECB", "Hex", "Hex"
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""}
]
}
],
@ -677,6 +779,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
"CBC", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -693,6 +796,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00000000000000000000000000000000"},
"CBC", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -709,6 +813,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00000000000000000000000000000000"},
"CTR", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -725,6 +830,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
"CBC", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -741,6 +847,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
"CFB", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -757,6 +864,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
"OFB", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -773,6 +881,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
"CTR", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -789,6 +898,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""},
"ECB", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -805,7 +915,25 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""},
"GCM", "Hex", "Raw",
{"option": "Hex", "string": "16a3e732a605cc9ca29108f742ca0743"}
{"option": "Hex", "string": "16a3e732a605cc9ca29108f742ca0743"},
{"option": "Hex", "string": ""}
]
}
],
},
{
name: "AES Decrypt: AES-128-GCM, ASCII, AAD",
input: "daa58faa056c52756aa488aeafbd265b6effcf4eca58220a97b0005b1a9b1e1c9e7a6725d35f5f79b9493de7",
expectedOutput: "The quick brown fox jumps over the lazy dog.",
recipeConfig: [
{
"op": "AES Decrypt",
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "ffeeddccbbaa99887766554433221100"},
"GCM", "Hex", "Raw",
{"option": "Hex", "string": "3b5378917f67b0aade9891fc6c291646"},
{"option": "UTF8", "string": "additional data"}
]
}
],
@ -821,6 +949,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CBC", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -837,6 +966,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CFB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -853,6 +983,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"OFB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -869,6 +1000,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CTR", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -885,7 +1017,25 @@ 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": "70fad2ca19412c20f40fd06918736e56"}
{"option": "Hex", "string": "70fad2ca19412c20f40fd06918736e56"},
{"option": "Hex", "string": ""}
]
}
],
},
{
name: "AES Decrypt: AES-128-GCM, Binary, AAD",
input: "5a29debb5c5f38cdf8aee421bd94dbbf3399947faddf205f88b3ad8ecb0c51214ec0e28bf78942dfa212d7eb15259bbdcac677b4c05f473eeb9331d74f31d441d97d56eb5c73b586342d72128ca528813543dc0fc7eddb7477172cc9194c18b2e1383e4e",
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
recipeConfig: [
{
"op": "AES Decrypt",
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "61cc4b70809452b0b3e38f913fa0a109"},
{"option": "UTF8", "string": "additional data"}
]
}
],
@ -901,6 +1051,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -917,6 +1068,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CBC", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -933,6 +1085,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CFB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -949,6 +1102,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"OFB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -965,6 +1119,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CTR", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -981,7 +1136,25 @@ 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": "86db597d5302595223cadbd990f1309b"}
{"option": "Hex", "string": "86db597d5302595223cadbd990f1309b"},
{"option": "Hex", "string": ""}
]
}
],
},
{
name: "AES Decrypt: AES-192-GCM, Binary, AAD",
input: "318b479d919d506f0cd904f2676fab263a7921b6d7e0514f36e03ae2333b77fa66ef5600babcb2ee9718aeb71fc357412343c1f2cb351d8715bb0aedae4a6468124f9c4aaf6a721b306beddbe63a978bec8baeeba4b663be33ee5bc982746bd4aed1c38b",
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
recipeConfig: [
{
"op": "AES Decrypt",
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "aeedf3e6ca4201577c0cf3e9ce58159d"},
{"option": "UTF8", "string": "additional data"}
]
}
],
@ -997,6 +1170,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -1013,6 +1187,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CBC", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -1029,6 +1204,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CFB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -1045,6 +1221,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"OFB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -1061,6 +1238,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CTR", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}
@ -1077,7 +1255,25 @@ 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": "821b1e5f32dad052e502775a523d957a"}
{"option": "Hex", "string": "821b1e5f32dad052e502775a523d957a"},
{"option": "Hex", "string": ""}
]
}
],
},
{
name: "AES Decrypt: AES-256-GCM, Binary, AAD",
input: "1287f188ad4d7ab0d9ff69b3c29cb11f861389532d8cb9337181da2e8cfc74a84927e8c0dd7a28a32fd485afe694259a63c199b199b95edd87c7aa95329feac340f2b78b72956a85f367044d821766b1b7135815571df44900695f1518cf3ae38ecb650f",
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
recipeConfig: [
{
"op": "AES Decrypt",
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "a8f04c4d93bbef82bef61a103371aef9"},
{"option": "UTF8", "string": "additional data"}
]
}
],
@ -1093,6 +1289,7 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
]
}

View file

@ -0,0 +1,86 @@
/**
* @author n1073645 [n1073645@gmail.com]
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
import {ELF32_LE, ELF32_BE, ELF64_LE, ELF64_BE} from "../../samples/Executables.mjs";
const ELF32_LE_OUTPUT = "============================== ELF Header ==============================\nMagic: \x7fELF\nFormat: 32-bit\nEndianness: Little\nVersion: 1\nABI: System V\nABI Version: 0\nType: Executable File\nInstruction Set Architecture: x86\nELF Version: 1\nEntry Point: 0x8062150\nEntry PHOFF: 0x34\nEntry SHOFF: 0x54\nFlags: 00000000\nELF Header Size: 52 bytes\nProgram Header Size: 32 bytes\nProgram Header Entries: 1\nSection Header Size: 40 bytes\nSection Header Entries: 3\nSection Header Names: 0\n\n============================== Program Header ==============================\nProgram Header Type: Program Header Table\nOffset Of Segment: 52\nVirtual Address of Segment: 134512692\nPhysical Address of Segment: 134512692\nSize of Segment: 256 bytes\nSize of Segment in Memory: 256 bytes\nFlags: Execute,Read\n\n============================== Section Header ==============================\nType: String Table\nSection Name: .shstrab\nFlags: \nSection Vaddr in memory: 0\nOffset of the section: 204\nSection Size: 28\nAssociated Section: 0\nSection Extra Information: 0\n\nType: Symbol Table\nSection Name: .symtab\nFlags: \nSection Vaddr in memory: 0\nOffset of the section: 230\nSection Size: 16\nAssociated Section: 0\nSection Extra Information: 0\n\nType: String Table\nSection Name: .strtab\nFlags: \nSection Vaddr in memory: 0\nOffset of the section: 245\nSection Size: 4\nAssociated Section: 0\nSection Extra Information: 0\n\n============================== Symbol Table ==============================\nSymbol Name: test";
const ELF32_BE_OUTPUT = "============================== ELF Header ==============================\nMagic: \x7fELF\nFormat: 32-bit\nEndianness: Big\nVersion: 1\nABI: System V\nABI Version: 0\nType: Executable File\nInstruction Set Architecture: x86\nELF Version: 1\nEntry Point: 0x8062150\nEntry PHOFF: 0x34\nEntry SHOFF: 0x54\nFlags: 00000000\nELF Header Size: 52 bytes\nProgram Header Size: 32 bytes\nProgram Header Entries: 1\nSection Header Size: 40 bytes\nSection Header Entries: 3\nSection Header Names: 0\n\n============================== Program Header ==============================\nProgram Header Type: Program Header Table\nOffset Of Segment: 52\nVirtual Address of Segment: 134512692\nPhysical Address of Segment: 134512692\nSize of Segment: 256 bytes\nSize of Segment in Memory: 256 bytes\nFlags: Execute,Read\n\n============================== Section Header ==============================\nType: String Table\nSection Name: .shstrab\nFlags: \nSection Vaddr in memory: 0\nOffset of the section: 204\nSection Size: 28\nAssociated Section: 0\nSection Extra Information: 0\n\nType: Symbol Table\nSection Name: .symtab\nFlags: \nSection Vaddr in memory: 0\nOffset of the section: 230\nSection Size: 16\nAssociated Section: 0\nSection Extra Information: 0\n\nType: String Table\nSection Name: .strtab\nFlags: \nSection Vaddr in memory: 0\nOffset of the section: 245\nSection Size: 4\nAssociated Section: 0\nSection Extra Information: 0\n\n============================== Symbol Table ==============================\nSymbol Name: test";
const ELF64_LE_OUTPUT = "============================== ELF Header ==============================\nMagic: \x7fELF\nFormat: 64-bit\nEndianness: Little\nVersion: 1\nABI: System V\nABI Version: 0\nType: Executable File\nInstruction Set Architecture: AMD x86-64\nELF Version: 1\nEntry Point: 0x8062150\nEntry PHOFF: 0x40\nEntry SHOFF: 0x78\nFlags: 00000000\nELF Header Size: 64 bytes\nProgram Header Size: 56 bytes\nProgram Header Entries: 1\nSection Header Size: 64 bytes\nSection Header Entries: 3\nSection Header Names: 0\n\n============================== Program Header ==============================\nProgram Header Type: Program Header Table\nFlags: Execute,Read\nOffset Of Segment: 52\nVirtual Address of Segment: 134512692\nPhysical Address of Segment: 134512692\nSize of Segment: 256 bytes\nSize of Segment in Memory: 256 bytes\n\n============================== Section Header ==============================\nType: String Table\nSection Name: .shstrab\nFlags: \nSection Vaddr in memory: 0\nOffset of the section: 312\nSection Size: 28\nAssociated Section: 0\nSection Extra Information: 0\n\nType: Symbol Table\nSection Name: .symtab\nFlags: \nSection Vaddr in memory: 0\nOffset of the section: 336\nSection Size: 16\nAssociated Section: 0\nSection Extra Information: 0\n\nType: String Table\nSection Name: .strtab\nFlags: \nSection Vaddr in memory: 0\nOffset of the section: 361\nSection Size: 4\nAssociated Section: 0\nSection Extra Information: 0\n\n============================== Symbol Table ==============================\nSymbol Name: test";
const ELF64_BE_OUTPUT = "============================== ELF Header ==============================\nMagic: \x7fELF\nFormat: 64-bit\nEndianness: Big\nVersion: 1\nABI: System V\nABI Version: 0\nType: Executable File\nInstruction Set Architecture: AMD x86-64\nELF Version: 1\nEntry Point: 0x8062150\nEntry PHOFF: 0x40\nEntry SHOFF: 0x78\nFlags: 00000000\nELF Header Size: 64 bytes\nProgram Header Size: 56 bytes\nProgram Header Entries: 1\nSection Header Size: 64 bytes\nSection Header Entries: 3\nSection Header Names: 0\n\n============================== Program Header ==============================\nProgram Header Type: Program Header Table\nFlags: Execute,Read\nOffset Of Segment: 52\nVirtual Address of Segment: 134512692\nPhysical Address of Segment: 134512692\nSize of Segment: 256 bytes\nSize of Segment in Memory: 256 bytes\n\n============================== Section Header ==============================\nType: String Table\nSection Name: .shstrab\nFlags: \nSection Vaddr in memory: 0\nOffset of the section: 312\nSection Size: 28\nAssociated Section: 0\nSection Extra Information: 0\n\nType: Symbol Table\nSection Name: .symtab\nFlags: \nSection Vaddr in memory: 0\nOffset of the section: 336\nSection Size: 16\nAssociated Section: 0\nSection Extra Information: 0\n\nType: String Table\nSection Name: .strtab\nFlags: \nSection Vaddr in memory: 0\nOffset of the section: 361\nSection Size: 4\nAssociated Section: 0\nSection Extra Information: 0\n\n============================== Symbol Table ==============================\nSymbol Name: test";
TestRegister.addTests([
{
name: "ELF Info invalid ELF.",
input: "\x7f\x00\x00\x00",
expectedOutput: "Invalid ELF",
recipeConfig: [
{
op: "ELF Info",
args: [],
},
],
},
{
name: "ELF Info 32-bit ELF Little Endian.",
input: ELF32_LE,
expectedOutput: ELF32_LE_OUTPUT,
recipeConfig: [
{
op: "From Hex",
args: ["None"],
},
{
op: "ELF Info",
args: [],
},
],
},
{
name: "ELF Info 32-bit ELF Big Endian.",
input: ELF32_BE,
expectedOutput: ELF32_BE_OUTPUT,
recipeConfig: [
{
op: "From Hex",
args: ["None"],
},
{
op: "ELF Info",
args: [],
},
],
},
{
name: "ELF Info 64-bit ELF Little Endian.",
input: ELF64_LE,
expectedOutput: ELF64_LE_OUTPUT,
recipeConfig: [
{
op: "From Hex",
args: ["None"],
},
{
op: "ELF Info",
args: [],
},
],
},
{
name: "ELF Info 64-bit ELF Big Endian.",
input: ELF64_BE,
expectedOutput: ELF64_BE_OUTPUT,
recipeConfig: [
{
op: "From Hex",
args: ["None"],
},
{
op: "ELF Info",
args: [],
},
],
},
]);

View file

@ -11,7 +11,7 @@ TestRegister.addTests([
{
name: "Extract email address",
input: "email@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com email@example.name\nemail@example.museum email@example.co.jp firstname-lastname@example.com",
expectedOutput: "email@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com\nemail@example.name\nemail@example.museum\nemail@example.co.jp\nfirstname-lastname@example.com\n",
expectedOutput: "email@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com\nemail@example.name\nemail@example.museum\nemail@example.co.jp\nfirstname-lastname@example.com",
recipeConfig: [
{
"op": "Extract email addresses",
@ -22,7 +22,7 @@ TestRegister.addTests([
{
name: "Extract email address - Display total",
input: "email@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com email@example.name\nemail@example.museum email@example.co.jp firstname-lastname@example.com",
expectedOutput: "Total found: 11\n\nemail@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com\nemail@example.name\nemail@example.museum\nemail@example.co.jp\nfirstname-lastname@example.com\n",
expectedOutput: "Total found: 11\n\nemail@example.com\nfirstname.lastname@example.com\nemail@subdomain.example.com\nfirstname+lastname@example.com\n1234567890@example.com\nemail@example-one.com\n_______@example.com\nemail@example.name\nemail@example.museum\nemail@example.co.jp\nfirstname-lastname@example.com",
recipeConfig: [
{
"op": "Extract email addresses",
@ -33,7 +33,7 @@ TestRegister.addTests([
{
name: "Extract email address (Internationalized)",
input: "\u4f0a\u662d\u5091@\u90f5\u4ef6.\u5546\u52d9 \u093e\u092e@\u092e\u094b\u0939\u0928.\u0908\u0928\u094d\u092b\u094b\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c \u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc Jos\u1ec5Silv\u1ec5@googl\u1ec5.com\nJos\u1ec5Silv\u1ec5@google.com and Jos\u1ec5Silva@google.com\nFoO@BaR.CoM, john@192.168.10.100\ng\xf3mez@junk.br and Abc.123@example.com.\nuser+mailbox/department=shipping@example.com\n\u7528\u6237@\u4f8b\u5b50.\u5e7f\u544a\n\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e@\u0909\u0926\u093e\u0939\u0930\u0923.\u0915\u0949\u092e\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nD\xf6rte@S\xf6rensen.example.com\n\u0430\u0434\u0436\u0430\u0439@\u044d\u043a\u0437\u0430\u043c\u043f\u043b.\u0440\u0443\u0441\ntest@xn--bcher-kva.com",
expectedOutput: "\u4f0a\u662d\u5091@\u90f5\u4ef6.\u5546\u52d9\n\u093e\u092e@\u092e\u094b\u0939\u0928.\u0908\u0928\u094d\u092b\u094b\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nJos\u1ec5Silv\u1ec5@googl\u1ec5.com\nJos\u1ec5Silv\u1ec5@google.com\nJos\u1ec5Silva@google.com\nFoO@BaR.CoM\njohn@192.168.10.100\ng\xf3mez@junk.br\nAbc.123@example.com\nuser+mailbox/department=shipping@example.com\n\u7528\u6237@\u4f8b\u5b50.\u5e7f\u544a\n\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e@\u0909\u0926\u093e\u0939\u0930\u0923.\u0915\u0949\u092e\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nD\xf6rte@S\xf6rensen.example.com\n\u0430\u0434\u0436\u0430\u0439@\u044d\u043a\u0437\u0430\u043c\u043f\u043b.\u0440\u0443\u0441\ntest@xn--bcher-kva.com\n",
expectedOutput: "\u4f0a\u662d\u5091@\u90f5\u4ef6.\u5546\u52d9\n\u093e\u092e@\u092e\u094b\u0939\u0928.\u0908\u0928\u094d\u092b\u094b\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nJos\u1ec5Silv\u1ec5@googl\u1ec5.com\nJos\u1ec5Silv\u1ec5@google.com\nJos\u1ec5Silva@google.com\nFoO@BaR.CoM\njohn@192.168.10.100\ng\xf3mez@junk.br\nAbc.123@example.com\nuser+mailbox/department=shipping@example.com\n\u7528\u6237@\u4f8b\u5b50.\u5e7f\u544a\n\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e@\u0909\u0926\u093e\u0939\u0930\u0923.\u0915\u0949\u092e\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nD\xf6rte@S\xf6rensen.example.com\n\u0430\u0434\u0436\u0430\u0439@\u044d\u043a\u0437\u0430\u043c\u043f\u043b.\u0440\u0443\u0441\ntest@xn--bcher-kva.com",
recipeConfig: [
{
"op": "Extract email addresses",
@ -44,7 +44,7 @@ TestRegister.addTests([
{
name: "Extract email address - Display total (Internationalized)",
input: "\u4f0a\u662d\u5091@\u90f5\u4ef6.\u5546\u52d9 \u093e\u092e@\u092e\u094b\u0939\u0928.\u0908\u0928\u094d\u092b\u094b\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c \u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc Jos\u1ec5Silv\u1ec5@googl\u1ec5.com\nJos\u1ec5Silv\u1ec5@google.com and Jos\u1ec5Silva@google.com\nFoO@BaR.CoM, john@192.168.10.100\ng\xf3mez@junk.br and Abc.123@example.com.\nuser+mailbox/department=shipping@example.com\n\u7528\u6237@\u4f8b\u5b50.\u5e7f\u544a\n\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e@\u0909\u0926\u093e\u0939\u0930\u0923.\u0915\u0949\u092e\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nD\xf6rte@S\xf6rensen.example.com\n\u0430\u0434\u0436\u0430\u0439@\u044d\u043a\u0437\u0430\u043c\u043f\u043b.\u0440\u0443\u0441\ntest@xn--bcher-kva.com",
expectedOutput: "Total found: 19\n\n\u4f0a\u662d\u5091@\u90f5\u4ef6.\u5546\u52d9\n\u093e\u092e@\u092e\u094b\u0939\u0928.\u0908\u0928\u094d\u092b\u094b\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nJos\u1ec5Silv\u1ec5@googl\u1ec5.com\nJos\u1ec5Silv\u1ec5@google.com\nJos\u1ec5Silva@google.com\nFoO@BaR.CoM\njohn@192.168.10.100\ng\xf3mez@junk.br\nAbc.123@example.com\nuser+mailbox/department=shipping@example.com\n\u7528\u6237@\u4f8b\u5b50.\u5e7f\u544a\n\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e@\u0909\u0926\u093e\u0939\u0930\u0923.\u0915\u0949\u092e\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nD\xf6rte@S\xf6rensen.example.com\n\u0430\u0434\u0436\u0430\u0439@\u044d\u043a\u0437\u0430\u043c\u043f\u043b.\u0440\u0443\u0441\ntest@xn--bcher-kva.com\n",
expectedOutput: "Total found: 19\n\n\u4f0a\u662d\u5091@\u90f5\u4ef6.\u5546\u52d9\n\u093e\u092e@\u092e\u094b\u0939\u0928.\u0908\u0928\u094d\u092b\u094b\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nJos\u1ec5Silv\u1ec5@googl\u1ec5.com\nJos\u1ec5Silv\u1ec5@google.com\nJos\u1ec5Silva@google.com\nFoO@BaR.CoM\njohn@192.168.10.100\ng\xf3mez@junk.br\nAbc.123@example.com\nuser+mailbox/department=shipping@example.com\n\u7528\u6237@\u4f8b\u5b50.\u5e7f\u544a\n\u0909\u092a\u092f\u094b\u0917\u0915\u0930\u094d\u0924\u093e@\u0909\u0926\u093e\u0939\u0930\u0923.\u0915\u0949\u092e\n\u044e\u0437\u0435\u0440@\u0435\u043a\u0437\u0430\u043c\u043f\u043b.\u043a\u043e\u043c\n\u03b8\u03c3\u03b5\u03c1@\u03b5\u03c7\u03b1\u03bc\u03c0\u03bb\u03b5.\u03c8\u03bf\u03bc\nD\xf6rte@S\xf6rensen.example.com\n\u0430\u0434\u0436\u0430\u0439@\u044d\u043a\u0437\u0430\u043c\u043f\u043b.\u0440\u0443\u0441\ntest@xn--bcher-kva.com",
recipeConfig: [
{
"op": "Extract email addresses",

View file

@ -0,0 +1,80 @@
/**
* Fernet tests.
*
* @author Karsten Silkenbäumer [github.com/kassi]
* @copyright Karsten Silkenbäumer 2019
* @license Apache-2.0
*/
import TestRegister from "../TestRegister";
TestRegister.addTests([
{
name: "Fernet Decrypt: no input",
input: "",
expectedOutput: "Error: Invalid version",
recipeConfig: [
{
op: "Fernet Decrypt",
args: ["MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="]
}
],
},
{
name: "Fernet Decrypt: no secret",
input: "gAAAAABce-Tycae8klRxhDX2uenJ-uwV8-A1XZ2HRnfOXlNzkKKfRxviNLlgtemhT_fd1Fw5P_zFUAjd69zaJBQyWppAxVV00SExe77ql8c5n62HYJOnoIU=",
expectedOutput: "Error: Secret must be 32 url-safe base64-encoded bytes.",
recipeConfig: [
{
op: "Fernet Decrypt",
args: [""]
}
],
},
{
name: "Fernet Decrypt: valid arguments",
input: "gAAAAABce-Tycae8klRxhDX2uenJ-uwV8-A1XZ2HRnfOXlNzkKKfRxviNLlgtemhT_fd1Fw5P_zFUAjd69zaJBQyWppAxVV00SExe77ql8c5n62HYJOnoIU=",
expectedOutput: "This is a secret message.\n",
recipeConfig: [
{
op: "Fernet Decrypt",
args: ["VGhpc0lzVGhpcnR5VHdvQ2hhcmFjdGVyc0xvbmdLZXk="]
}
],
}
]);
TestRegister.addTests([
{
name: "Fernet Encrypt: no input",
input: "",
expectedMatch: /^gAAAAABce-[\w-]+={0,2}$/,
recipeConfig: [
{
op: "Fernet Encrypt",
args: ["MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="]
}
],
},
{
name: "Fernet Encrypt: no secret",
input: "This is a secret message.\n",
expectedOutput: "Error: Secret must be 32 url-safe base64-encoded bytes.",
recipeConfig: [
{
op: "Fernet Encrypt",
args: [""]
}
],
},
{
name: "Fernet Encrypt: valid arguments",
input: "This is a secret message.\n",
expectedMatch: /^gAAAAABce-[\w-]+={0,2}$/,
recipeConfig: [
{
op: "Fernet Encrypt",
args: ["MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="]
}
],
}
]);

View file

@ -0,0 +1,22 @@
/**
* File tree tests.
*
* @author sw5678
* @copyright Crown Copyright 2023
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
"name": "File Tree: basic example",
"input": "/test_dir1/test_file1.txt\n/test_dir1/test_file2.txt\n/test_dir2/test_file1.txt",
"expectedOutput": "test_dir1\n|---test_file1.txt\n|---test_file2.txt\ntest_dir2\n|---test_file1.txt",
"recipeConfig": [
{
"op": "File Tree",
"args": ["/", "Line feed"],
},
],
}
]);

View file

@ -0,0 +1,108 @@
/**
* @author mikecat
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Fletcher-16 Checksum: abcde",
input: "abcde",
expectedOutput: "c8f0",
recipeConfig: [
{
op: "Fletcher-16 Checksum",
args: [],
},
],
},
{
name: "Fletcher-16 Checksum: abcdef",
input: "abcdef",
expectedOutput: "2057",
recipeConfig: [
{
op: "Fletcher-16 Checksum",
args: [],
},
],
},
{
name: "Fletcher-16 Checksum: abcdefgh",
input: "abcdefgh",
expectedOutput: "0627",
recipeConfig: [
{
op: "Fletcher-16 Checksum",
args: [],
},
],
},
{
name: "Fletcher-32 Checksum: abcde",
input: "abcde",
expectedOutput: "f04fc729",
recipeConfig: [
{
op: "Fletcher-32 Checksum",
args: [],
},
],
},
{
name: "Fletcher-32 Checksum: abcdef",
input: "abcdef",
expectedOutput: "56502d2a",
recipeConfig: [
{
op: "Fletcher-32 Checksum",
args: [],
},
],
},
{
name: "Fletcher-32 Checksum: abcdefgh",
input: "abcdefgh",
expectedOutput: "ebe19591",
recipeConfig: [
{
op: "Fletcher-32 Checksum",
args: [],
},
],
},
{
name: "Fletcher-64 Checksum: abcde",
input: "abcde",
expectedOutput: "c8c6c527646362c6",
recipeConfig: [
{
op: "Fletcher-64 Checksum",
args: [],
},
],
},
{
name: "Fletcher-64 Checksum: abcdef",
input: "abcdef",
expectedOutput: "c8c72b276463c8c6",
recipeConfig: [
{
op: "Fletcher-64 Checksum",
args: [],
},
],
},
{
name: "Fletcher-64 Checksum: abcdefgh",
input: "abcdefgh",
expectedOutput: "312e2b28cccac8c6",
recipeConfig: [
{
op: "Fletcher-64 Checksum",
args: [],
},
],
},
]);

View file

@ -0,0 +1,164 @@
/**
* Float tests.
*
* @author tcode2k16 [tcode2k16@gmail.com]
*
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "To Float: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"]
},
{
op: "To Float",
args: ["Big Endian", "Float (4 bytes)", "Space"]
}
],
},
{
name: "To Float (Big Endian, 4 bytes): 0.5",
input: "3f0000003f000000",
expectedOutput: "0.5 0.5",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"]
},
{
op: "To Float",
args: ["Big Endian", "Float (4 bytes)", "Space"]
}
]
},
{
name: "To Float (Little Endian, 4 bytes): 0.5",
input: "0000003f0000003f",
expectedOutput: "0.5 0.5",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"]
},
{
op: "To Float",
args: ["Little Endian", "Float (4 bytes)", "Space"]
}
]
},
{
name: "To Float (Big Endian, 8 bytes): 0.5",
input: "3fe00000000000003fe0000000000000",
expectedOutput: "0.5 0.5",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"]
},
{
op: "To Float",
args: ["Big Endian", "Double (8 bytes)", "Space"]
}
]
},
{
name: "To Float (Little Endian, 8 bytes): 0.5",
input: "000000000000e03f000000000000e03f",
expectedOutput: "0.5 0.5",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"]
},
{
op: "To Float",
args: ["Little Endian", "Double (8 bytes)", "Space"]
}
]
},
{
name: "From Float: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "From Float",
args: ["Big Endian", "Float (4 bytes)", "Space"]
},
{
op: "To Hex",
args: ["None"]
}
]
},
{
name: "From Float (Big Endian, 4 bytes): 0.5",
input: "0.5 0.5",
expectedOutput: "3f0000003f000000",
recipeConfig: [
{
op: "From Float",
args: ["Big Endian", "Float (4 bytes)", "Space"]
},
{
op: "To Hex",
args: ["None"]
}
]
},
{
name: "From Float (Little Endian, 4 bytes): 0.5",
input: "0.5 0.5",
expectedOutput: "0000003f0000003f",
recipeConfig: [
{
op: "From Float",
args: ["Little Endian", "Float (4 bytes)", "Space"]
},
{
op: "To Hex",
args: ["None"]
}
]
},
{
name: "From Float (Big Endian, 8 bytes): 0.5",
input: "0.5 0.5",
expectedOutput: "3fe00000000000003fe0000000000000",
recipeConfig: [
{
op: "From Float",
args: ["Big Endian", "Double (8 bytes)", "Space"]
},
{
op: "To Hex",
args: ["None"]
}
]
},
{
name: "From Float (Little Endian, 8 bytes): 0.5",
input: "0.5 0.5",
expectedOutput: "000000000000e03f000000000000e03f",
recipeConfig: [
{
op: "From Float",
args: ["Little Endian", "Double (8 bytes)", "Space"]
},
{
op: "To Hex",
args: ["None"]
}
]
}
]);

View file

@ -31,7 +31,7 @@ TestRegister.addTests([
},
{
op: "Merge",
args: [],
args: [true],
},
],
},
@ -50,7 +50,7 @@ TestRegister.addTests([
},
{
op: "Merge",
args: [],
args: [true],
},
],
},
@ -66,5 +66,16 @@ TestRegister.addTests([
{"op": "Label", "args": ["skipReturn"]},
{"op": "To Base64", "args": ["A-Za-z0-9+/="]}
]
}
},
{
name: "Fork, Partial Merge",
input: "Hello World",
expectedOutput: "48656c6c6f 576f726c64",
recipeConfig: [
{ "op": "Fork", "args": [" ", " ", false] },
{ "op": "Fork", "args": ["l", "l", false] },
{ "op": "Merge", "args": [false] },
{ "op": "To Hex", "args": ["None", 0] },
]
},
]);

View file

@ -1,55 +0,0 @@
/**
* 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

@ -0,0 +1,183 @@
/**
* GOST tests.
*
* The GOST library already includes a range of tests for the correctness of
* the algorithms. These tests are intended only to confirm that the library
* has been correctly integrated into CyberChef.
*
* @author n1474335 [n1474335@gmail.com]
*
* @copyright Crown Copyright 2023
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "GOST Encrypt: Magma",
input: "Hello, World!",
expectedOutput: "f124ac5c0853870906dbaf9b56",
recipeConfig: [
{
op: "GOST Encrypt",
args: [
{ "option": "Hex", "string": "00112233" },
{ "option": "Hex", "string": "0011223344556677" },
"Raw",
"Hex",
"GOST 28147 (Magma, 1989)",
"64",
"E-SC",
"OFB",
"CP",
"ZERO"
]
}
],
},
{
name: "GOST Encrypt: Kuznyechik",
input: "Hello, World!",
expectedOutput: "8673d490dfa4a66d5e3ff00ba316724f",
recipeConfig: [
{
op: "GOST Encrypt",
args: [
{ "option": "Hex", "string": "00112233" },
{ "option": "Hex", "string": "00112233445566778899aabbccddeeff" },
"Raw",
"Hex",
"GOST R 34.12 (Kuznyechik, 2015)",
"128",
"E-SC",
"CBC",
"CP",
"PKCS5"
]
}
],
},
{
name: "GOST Decrypt: Magma",
input: "f124ac5c0853870906dbaf9b56",
expectedOutput: "Hello, World!",
recipeConfig: [
{
op: "GOST Decrypt",
args: [
{ "option": "Hex", "string": "00112233" },
{ "option": "Hex", "string": "0011223344556677" },
"Hex",
"Raw",
"GOST 28147 (Magma, 1989)",
"128",
"E-SC",
"OFB",
"CP",
"ZERO"
]
}
],
},
{
name: "GOST Decrypt: Kuznyechik",
input: "8673d490dfa4a66d5e3ff00ba316724f",
expectedOutput: "Hello, World!\0\0\0",
recipeConfig: [
{
op: "GOST Decrypt",
args: [
{ "option": "Hex", "string": "00112233" },
{ "option": "Hex", "string": "00112233445566778899aabbccddeeff" },
"Hex",
"Raw",
"GOST R 34.12 (Kuznyechik, 2015)",
"128",
"E-TEST",
"CBC",
"CP",
"PKCS5"
]
}
],
},
{
name: "GOST Sign",
input: "Hello, World!",
expectedOutput: "810d0c40e965",
recipeConfig: [
{
op: "GOST Sign",
args: [
{ "option": "Hex", "string": "00112233" },
{ "option": "Hex", "string": "0011223344556677" },
"Raw",
"Hex",
"GOST 28147 (Magma, 1989)",
"64",
"E-C",
48
]
}
],
},
{
name: "GOST Verify",
input: "Hello, World!",
expectedOutput: "The signature matches",
recipeConfig: [
{
op: "GOST Verify",
args: [
{ "option": "Hex", "string": "00112233" },
{ "option": "Hex", "string": "00112233445566778899aabbccddeeff" },
{ "option": "Hex", "string": "42b77fb3d6f6bf04" },
"Raw",
"GOST R 34.12 (Kuznyechik, 2015)",
"128",
"E-TEST"
]
}
],
},
{
name: "GOST Key Wrap",
input: "Hello, World!123",
expectedOutput: "0bb706e92487fceef97589911faeb28200000000000000000000000000000000\r\n6b7bfd16",
recipeConfig: [
{
op: "GOST Key Wrap",
args: [
{ "option": "Hex", "string": "00112233" },
{ "option": "Hex", "string": "0011223344556677" },
"Raw",
"Hex",
"GOST R 34.12 (Kuznyechik, 2015)",
"64",
"E-TEST",
"CP"
]
}
],
},
{
name: "GOST Key Unwrap",
input: "c8e58458a42d21974d50103d59b469f2c8e58458a42d21974d50103d59b469f2\r\na32a1575",
expectedOutput: "0123456789abcdef0123456789abcdef",
recipeConfig: [
{
op: "GOST Key Unwrap",
args: [
{ "option": "Hex", "string": "" },
{ "option": "Latin1", "string": "00112233" },
"Hex",
"Raw",
"GOST 28147 (Magma, 1989)",
"64",
"E-Z",
"CP"
]
}
],
},
]);

View file

@ -0,0 +1,115 @@
/**
* GenerateAllHashes tests.
*
* @author john19696 [john19696@protonmail.com]
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Full generate all hashes",
input: "test",
expectedOutput: `MD2: dd34716876364a02d0195e2fb9ae2d1b
MD4: db346d691d7acc4dc2625db19f9e3f52
MD5: 098f6bcd4621d373cade4e832627b4f6
MD6: 93c8a7d0ff132f325138a82b2baa98c12a7c9ac982feb6c5b310a1ca713615bd
SHA0: f8d3b312442a67706057aeb45b983221afb4f035
SHA1: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
SHA2 224: 90a3ed9e32b2aaf4c61c410eb925426119e1a9dc53d4286ade99a809
SHA2 256: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
SHA2 384: 768412320f7b0aa5812fce428dc4706b3cae50e02a64caa16a782249bfe8efc4b7ef1ccb126255d196047dfedf17a0a9
SHA2 512: ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff
SHA3 224: 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b
SHA3 256: 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
SHA3 384: e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7ff0f1b41eecb9db3ff219007c4e097260d58621bd
SHA3 512: 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14
Keccak 224: 3be30a9ff64f34a5861116c5198987ad780165f8366e67aff4760b5e
Keccak 256: 9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658
Keccak 384: 53d0ba137307d4c2f9b6674c83edbd58b70c0f4340133ed0adc6fba1d2478a6a03b7788229e775d2de8ae8c0759d0527
Keccak 512: 1e2e9fc2002b002d75198b7503210c05a1baac4560916a3c6d93bcce3a50d7f00fd395bf1647b9abb8d1afcc9c76c289b0c9383ba386a956da4b38934417789e
Shake 128: d3b0aa9cd8b7255622cebc631e867d4093d6f6010191a53973c45fec9b07c774
Shake 256: b54ff7255705a71ee2925e4a3e30e41aed489a579d5595e0df13e32e1e4dd202a7c7f68b31d6418d9845eb4d757adda6ab189e1bb340db818e5b3bc725d992fa
RIPEMD-128: f1abb5083c9ff8a9dbbca9cd2b11fead
RIPEMD-160: 5e52fee47e6b070565f74372468cdc699de89107
RIPEMD-256: fe0289110d07daeee9d9500e14c57787d9083f6ba10e6bcb256f86bb4fe7b981
RIPEMD-320: 3b0a2e841e589cf583634a5dd265d2b5d497c4cc44b241e34e0f62d03e98c1b9dc72970b9bc20eb5
HAS-160: cb15e491eec6e769771d1f811315139c93071084
Whirlpool-0: d50ff71342b521974bae166539871922669afcfc7181250ebbae015c317ebb797173a69e7a05afd11099a9f0918159cd5bc88434d3ca44513d7263caea9244fe
Whirlpool-T: e6b4aa087751b4428171777f1893ba585404c7e0171787720eba0d8bccd710dc2c42f874c572bfae4cedabf50f2c80bf923805d4e31c504b86ca3bc59265e7dd
Whirlpool: b913d5bbb8e461c2c5961cbe0edcdadfd29f068225ceb37da6defcf89849368f8c6c2eb6a4c4ac75775d032a0ecfdfe8550573062b653fe92fc7b8fb3b7be8d6
BLAKE2b-128: 44a8995dd50b6657a037a7839304535b
BLAKE2b-160: a34fc3b6d2cce8beb3216c2bbb5e55739e8121ed
BLAKE2b-256: 928b20366943e2afd11ebc0eae2e53a93bf177a4fcf35bcc64d503704e65e202
BLAKE2b-384: 8a84b8666c8fcfb69f2ec41f578d7c85fbdb504ea6510fb05b50fcbf7ed8153c77943bc2da73abb136834e1a0d4f22cb
BLAKE2b-512: a71079d42853dea26e453004338670a53814b78137ffbed07603a41d76a483aa9bc33b582f77d30a65e6f29a896c0411f38312e1d66e0bf16386c86a89bea572
BLAKE2s-128: e9ddd9926b9dcb382e09be39ba403d2c
BLAKE2s-160: d6197dabec2bd6f4ff303b8e519e8f15d42a453d
BLAKE2s-256: f308fc02ce9172ad02a7d75800ecfc027109bc67987ea32aba9b8dcc7b10150e
Streebog-256: 12a50838191b5504f1e5f2fd078714cf6b592b9d29af99d0b10d8d02881c3857
Streebog-512: 7200bf5dea560f0d7960d07fdc8874ad9f3b86ece2e45f5502ae2e176f2c928e0e581152281f5aee818318bed7cbe6aa69999589234723ceb33175598365b5c8
GOST: ee67303696d205ddd2b2363e8e01b4b7199a80957d94d7678eaad3fc834c5a27
LM Hash: 01FC5A6BE7BC6929AAD3B435B51404EE
NT Hash: 0CB6948805F797BF2A82807973B89537
SSDEEP: 3:Hn:Hn
CTPH: A:E:E
Checksums:
Fletcher-8: 3d
Fletcher-16: 5dc1
Fletcher-32: 3f5cd9e7
Fletcher-64: 7473657474736574
Adler-32: 045d01c1
CRC-8: b9
CRC-16: f82e
CRC-32: d87f7e0c
`,
recipeConfig: [
{
"op": "Generate all hashes",
"args": ["All", true]
}
]
},
{
name: "Hashes with length 32",
input: "test",
expectedOutput: `MD2: dd34716876364a02d0195e2fb9ae2d1b
MD4: db346d691d7acc4dc2625db19f9e3f52
MD5: 098f6bcd4621d373cade4e832627b4f6
RIPEMD-128: f1abb5083c9ff8a9dbbca9cd2b11fead
BLAKE2b-128: 44a8995dd50b6657a037a7839304535b
BLAKE2s-128: e9ddd9926b9dcb382e09be39ba403d2c
LM Hash: 01FC5A6BE7BC6929AAD3B435B51404EE
NT Hash: 0CB6948805F797BF2A82807973B89537
`,
recipeConfig: [
{
"op": "Generate all hashes",
"args": ["128", true]
}
]
},
{
name: "Hashes without names",
input: "test",
expectedOutput: `93c8a7d0ff132f325138a82b2baa98c12a7c9ac982feb6c5b310a1ca713615bd
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658
d3b0aa9cd8b7255622cebc631e867d4093d6f6010191a53973c45fec9b07c774
fe0289110d07daeee9d9500e14c57787d9083f6ba10e6bcb256f86bb4fe7b981
928b20366943e2afd11ebc0eae2e53a93bf177a4fcf35bcc64d503704e65e202
f308fc02ce9172ad02a7d75800ecfc027109bc67987ea32aba9b8dcc7b10150e
12a50838191b5504f1e5f2fd078714cf6b592b9d29af99d0b10d8d02881c3857
ee67303696d205ddd2b2363e8e01b4b7199a80957d94d7678eaad3fc834c5a27
`,
recipeConfig: [
{
"op": "Generate all hashes",
"args": ["256", false]
}
]
}
]);

View file

@ -0,0 +1,33 @@
/**
* De Brujin Sequence tests.
*
* @author gchq77703 [gchq77703@gchq.gov.uk]
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Generate De Bruijn Sequence: Small Sequence",
input: "",
expectedOutput: "00010111",
recipeConfig: [
{
"op": "Generate De Bruijn Sequence",
"args": [2, 3]
}
]
},
{
name: "Generate De Bruijn Sequence: Long Sequence",
input: "",
expectedOutput: "0000010000200003000110001200013000210002200023000310003200033001010010200103001110011200113001210012200123001310013200133002010020200203002110021200213002210022200223002310023200233003010030200303003110031200313003210032200323003310033200333010110101201013010210102201023010310103201033011020110301111011120111301121011220112301131011320113301202012030121101212012130122101222012230123101232012330130201303013110131201313013210132201323013310133201333020210202202023020310203202033021030211102112021130212102122021230213102132021330220302211022120221302221022220222302231022320223302303023110231202313023210232202323023310233202333030310303203033031110311203113031210312203123031310313203133032110321203213032210322203223032310323203233033110331203313033210332203323033310333203333111112111131112211123111321113311212112131122211223112321123311312113131132211323113321133312122121231213212133122131222212223122321223312313123221232312332123331313213133132221322313232132331332213323133321333322222322233223232233323233233333",
recipeConfig: [
{
"op": "Generate De Bruijn Sequence",
"args": [4, 5]
}
]
}
]);

View file

@ -0,0 +1,44 @@
/**
* GetAllCasings tests.
*
* @author n1073645 [n1073645@gmail.com]
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "All casings of test",
input: "test",
expectedOutput: "test\nTest\ntEst\nTEst\nteSt\nTeSt\ntESt\nTESt\ntesT\nTesT\ntEsT\nTEsT\nteST\nTeST\ntEST\nTEST",
recipeConfig: [
{
"op": "Get All Casings",
"args": []
}
]
},
{
name: "All casings of t",
input: "t",
expectedOutput: "t\nT",
recipeConfig: [
{
"op": "Get All Casings",
"args": []
}
]
},
{
name: "All casings of null",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "Get All Casings",
"args": []
}
]
}
]);

View file

@ -0,0 +1,33 @@
/**
* HASSH tests.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2021
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "HASSH Client Fingerprint",
input: "000003140814c639665f5425dcb80bf9f0a048380a410000007e6469666669652d68656c6c6d616e2d67726f75702d65786368616e67652d7368613235362c6469666669652d68656c6c6d616e2d67726f75702d65786368616e67652d736861312c6469666669652d68656c6c6d616e2d67726f757031342d736861312c6469666669652d68656c6c6d616e2d67726f7570312d736861310000000f7373682d7273612c7373682d6473730000009d6165733132382d6374722c6165733139322d6374722c6165733235362d6374722c617263666f75723235362c617263666f75723132382c6165733132382d6362632c336465732d6362632c626c6f77666973682d6362632c636173743132382d6362632c6165733139322d6362632c6165733235362d6362632c617263666f75722c72696a6e6461656c2d636263406c797361746f722e6c69752e73650000009d6165733132382d6374722c6165733139322d6374722c6165733235362d6374722c617263666f75723235362c617263666f75723132382c6165733132382d6362632c336465732d6362632c626c6f77666973682d6362632c636173743132382d6362632c6165733139322d6362632c6165733235362d6362632c617263666f75722c72696a6e6461656c2d636263406c797361746f722e6c69752e736500000069686d61632d6d64352c686d61632d736861312c756d61632d3634406f70656e7373682e636f6d2c686d61632d726970656d643136302c686d61632d726970656d64313630406f70656e7373682e636f6d2c686d61632d736861312d39362c686d61632d6d64352d393600000069686d61632d6d64352c686d61632d736861312c756d61632d3634406f70656e7373682e636f6d2c686d61632d726970656d643136302c686d61632d726970656d64313630406f70656e7373682e636f6d2c686d61632d736861312d39362c686d61632d6d64352d39360000001a6e6f6e652c7a6c6962406f70656e7373682e636f6d2c7a6c69620000001a6e6f6e652c7a6c6962406f70656e7373682e636f6d2c7a6c6962000000000000000000000000000000000000000000",
expectedOutput: "21b457a327ce7a2d4fce5ef2c42400bd",
recipeConfig: [
{
"op": "HASSH Client Fingerprint",
"args": ["Hex", "Hash digest"]
}
],
},
{
name: "HASSH Server Fingerprint",
input: "0000027c0b142c7bb93a1da21c9e54f5862e60a5597c000000596469666669652d68656c6c6d616e2d67726f75702d65786368616e67652d736861312c6469666669652d68656c6c6d616e2d67726f757031342d736861312c6469666669652d68656c6c6d616e2d67726f7570312d736861310000000f7373682d7273612c7373682d647373000000876165733132382d6362632c336465732d6362632c626c6f77666973682d6362632c636173743132382d6362632c617263666f75722c6165733139322d6362632c6165733235362d6362632c72696a6e6461656c2d636263406c797361746f722e6c69752e73652c6165733132382d6374722c6165733139322d6374722c6165733235362d637472000000876165733132382d6362632c336465732d6362632c626c6f77666973682d6362632c636173743132382d6362632c617263666f75722c6165733139322d6362632c6165733235362d6362632c72696a6e6461656c2d636263406c797361746f722e6c69752e73652c6165733132382d6374722c6165733139322d6374722c6165733235362d63747200000055686d61632d6d64352c686d61632d736861312c686d61632d726970656d643136302c686d61632d726970656d64313630406f70656e7373682e636f6d2c686d61632d736861312d39362c686d61632d6d64352d393600000055686d61632d6d64352c686d61632d736861312c686d61632d726970656d643136302c686d61632d726970656d64313630406f70656e7373682e636f6d2c686d61632d736861312d39362c686d61632d6d64352d3936000000096e6f6e652c7a6c6962000000096e6f6e652c7a6c6962000000000000000000000000000000000000000000000000",
expectedOutput: "f430cd6761697a6a658ee1d45ed22e49",
recipeConfig: [
{
"op": "HASSH Server Fingerprint",
"args": ["Hex", "Hash digest"]
}
],
}
]);

View file

@ -0,0 +1,180 @@
/**
* @author mikecat
* @copyright Crown Copyright 2023
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
"name": "HKDF: RFC5869 Test Case 1",
"input": "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
"expectedOutput": "3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"],
},
{
"op": "Derive HKDF key",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c"},
{"option": "Hex", "string": "f0f1f2f3f4f5f6f7f8f9"},
"SHA256", "with salt", 42,
],
},
],
},
{
"name": "HKDF: RFC5869 Test Case 2",
"input": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f",
"expectedOutput": "b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"],
},
{
"op": "Derive HKDF key",
"args": [
{"option": "Hex", "string": "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf"},
{"option": "Hex", "string": "b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"},
"SHA256", "with salt", 82,
],
},
],
},
{
"name": "HKDF: RFC5869 Test Case 3",
"input": "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
"expectedOutput": "8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"],
},
{
"op": "Derive HKDF key",
"args": [
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
"SHA256", "with salt", 42,
],
},
],
},
{
"name": "HKDF: RFC5869 Test Case 4",
"input": "0b0b0b0b0b0b0b0b0b0b0b",
"expectedOutput": "085a01ea1b10f36933068b56efa5ad81a4f14b822f5b091568a9cdd4f155fda2c22e422478d305f3f896",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"],
},
{
"op": "Derive HKDF key",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c"},
{"option": "Hex", "string": "f0f1f2f3f4f5f6f7f8f9"},
"SHA1", "with salt", 42,
],
},
],
},
{
"name": "HKDF: RFC5869 Test Case 5",
"input": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f",
"expectedOutput": "0bd770a74d1160f7c9f12cd5912a06ebff6adcae899d92191fe4305673ba2ffe8fa3f1a4e5ad79f3f334b3b202b2173c486ea37ce3d397ed034c7f9dfeb15c5e927336d0441f4c4300e2cff0d0900b52d3b4",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"],
},
{
"op": "Derive HKDF key",
"args": [
{"option": "Hex", "string": "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf"},
{"option": "Hex", "string": "b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"},
"SHA1", "with salt", 82,
],
},
],
},
{
"name": "HKDF: RFC5869 Test Case 6",
"input": "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
"expectedOutput": "0ac1af7002b3d761d1e55298da9d0506b9ae52057220a306e07b6b87e8df21d0ea00033de03984d34918",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"],
},
{
"op": "Derive HKDF key",
"args": [
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
"SHA1", "with salt", 42,
],
},
],
},
{
"name": "HKDF: RFC5869 Test Case 7",
"input": "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c",
"expectedOutput": "2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"],
},
{
"op": "Derive HKDF key",
"args": [
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
"SHA1", "no salt", 42,
],
},
],
},
{
"name": "HKDF: RFC5869 Test Case 1 with skip extract",
"input": "077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5",
"expectedOutput": "3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"],
},
{
"op": "Derive HKDF key",
"args": [
{"option": "Hex", "string": ""},
{"option": "Hex", "string": "f0f1f2f3f4f5f6f7f8f9"},
"SHA256", "skip", 42,
],
},
],
},
{
"name": "HKDF: too large L",
"input": "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
"expectedOutput": "L too large (maximum length for SHA256 is 8160)",
"recipeConfig": [
{
"op": "From Hex",
"args": ["None"],
},
{
"op": "Derive HKDF key",
"args": [
{"option": "Hex", "string": "000102030405060708090a0b0c"},
{"option": "Hex", "string": "f0f1f2f3f4f5f6f7f8f9"},
"SHA256", "with salt", 8161,
],
},
],
},
]);

View file

@ -345,7 +345,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "Snefru",
"args": ["2", "128"]
"args": ["128", "2"]
}
]
},
@ -356,7 +356,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "Snefru",
"args": ["4", "128"]
"args": ["128", "4"]
}
]
},
@ -367,7 +367,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "Snefru",
"args": ["8", "128"]
"args": ["128", "8"]
}
]
},
@ -378,7 +378,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "Snefru",
"args": ["2", "256"]
"args": ["256", "2"]
}
]
},
@ -389,7 +389,7 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "Snefru",
"args": ["4", "256"]
"args": ["256", "4"]
}
]
},
@ -400,7 +400,18 @@ TestRegister.addTests([
recipeConfig: [
{
"op": "Snefru",
"args": ["8", "256"]
"args": ["256", "8"]
}
]
},
{
name: "SM3 256 64",
input: "Hello, World!",
expectedOutput: "7ed26cbf0bee4ca7d55c1e64714c4aa7d1f163089ef5ceb603cd102c81fbcbc5",
recipeConfig: [
{
"op": "SM3",
"args": ["256", "64"]
}
]
},
@ -1083,8 +1094,8 @@ TestRegister.addTests([
expectedOutput: "981e5f3ca30c841487830f84fb433e13ac1101569b9c13584ac483234cd656c0",
recipeConfig: [
{
op: "GOST hash",
args: ["D-A"]
op: "GOST Hash",
args: ["GOST 28147 (1994)", "256", "D-A"]
}
]
},
@ -1094,11 +1105,11 @@ TestRegister.addTests([
expectedOutput: "2cefc2f7b7bdc514e18ea57fa74ff357e7fa17d652c75f69cb1be7893ede48eb",
recipeConfig: [
{
op: "GOST hash",
args: ["D-A"]
op: "GOST Hash",
args: ["GOST 28147 (1994)", "256", "D-A"]
}
]
}
},
/* { // This takes a LONG time to run (over a minute usually).
name: "Scrypt: RFC test vector 4",
input: "pleaseletmein",
@ -1116,4 +1127,36 @@ TestRegister.addTests([
}
]
}, */
{
name: "Argon2",
input: "argon2password",
expectedOutput: "$argon2i$v=19$m=4096,t=3,p=1$c29tZXNhbHQ$s43my9eBljQADuF/LWCG8vGqwAJzOorKQ0Yog8jFvbw",
recipeConfig: [
{
op: "Argon2",
args: [
{"option": "UTF8", "string": "somesalt"},
3,
4096,
1,
32,
"Argon2i",
"Encoded hash"
]
}
]
},
{
name: "Argon2 compare",
input: "argon2password",
expectedOutput: "Match: argon2password",
recipeConfig: [
{
op: "Argon2 compare",
args: [
"$argon2i$v=19$m=4096,t=3,p=1$c29tZXNhbHQ$s43my9eBljQADuF/LWCG8vGqwAJzOorKQ0Yog8jFvbw"
]
}
]
}
]);

View file

@ -11,7 +11,18 @@ TestRegister.addTests([
{
name: "Haversine distance",
input: "51.487263,-0.124323, 38.9517,-77.1467",
expectedOutput: "5619355.701829259",
expectedOutput: "5902542.836307819",
recipeConfig: [
{
"op": "Haversine distance",
"args": []
}
],
},
{
name: "Haversine distance, zero distance",
input: "51.487263,-0.124323, 51.487263,-0.124323",
expectedOutput: "0",
recipeConfig: [
{
"op": "Haversine distance",

View file

@ -9,7 +9,7 @@
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
import { GIF_ANIMATED_HEX, PNG_HEX, JPG_B64, EXIF_JPG_HEX, NO_EXIF_JPG_HEX } from "../samples/Images.mjs";
import { GIF_ANIMATED_HEX, PNG_HEX, JPG_B64, EXIF_JPG_HEX, NO_EXIF_JPG_HEX } from "../../samples/Images.mjs";
TestRegister.addTests([
{

View file

@ -0,0 +1,55 @@
/**
* JA3Fingerprint tests.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2021
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "JA3 Fingerprint: TLS 1.0",
input: "16030100a4010000a00301543dd2dd48f517ca9a93b1e599f019fdece704a23e86c1dcac588427abbaddf200005cc014c00a0039003800880087c00fc00500350084c012c00800160013c00dc003000ac013c00900330032009a009900450044c00ec004002f009600410007c011c007c00cc002000500040015001200090014001100080006000300ff0100001b000b000403000102000a000600040018001700230000000f000101",
expectedOutput: "503053a0c5b2bd9b9334bf7f3d3b8852",
recipeConfig: [
{
"op": "JA3 Fingerprint",
"args": ["Hex", "Hash digest"]
}
],
},
{
name: "JA3 Fingerprint: TLS 1.1",
input: "16030100a4010000a00302543dd2ed907e47d0086f34bee2c52dd6ccd8de63ba9387f5e810b09d9d49b38000005cc014c00a0039003800880087c00fc00500350084c012c00800160013c00dc003000ac013c00900330032009a009900450044c00ec004002f009600410007c011c007c00cc002000500040015001200090014001100080006000300ff0100001b000b000403000102000a000600040018001700230000000f000101",
expectedOutput: "a314eb64cee6cb832aaaa372c8295bab",
recipeConfig: [
{
"op": "JA3 Fingerprint",
"args": ["Hex", "Hash digest"]
}
],
},
{
name: "JA3 Fingerprint: TLS 1.2",
input: "1603010102010000fe0303543dd3283283692d85f9416b5ccc65d2aafca45c6530b3c6eafbf6d371b6a015000094c030c02cc028c024c014c00a00a3009f006b006a0039003800880087c032c02ec02ac026c00fc005009d003d00350084c012c00800160013c00dc003000ac02fc02bc027c023c013c00900a2009e0067004000330032009a009900450044c031c02dc029c025c00ec004009c003c002f009600410007c011c007c00cc002000500040015001200090014001100080006000300ff01000041000b000403000102000a000600040018001700230000000d002200200601060206030501050205030401040204030301030203030201020202030101000f000101",
expectedOutput: "c1a36e1a870786cc75edddc0009eaf3a",
recipeConfig: [
{
"op": "JA3 Fingerprint",
"args": ["Hex", "Hash digest"]
}
],
},
{
name: "JA3 Fingerprint: TLS 1.3",
input: "1603010200010001fc03034355d402c132771a9386b6e9994ae37069e0621af504c26673b1343843c21d8d0000264a4a130113021303c02bc02fc02cc030cca9cca8cc14cc13c013c014009c009d002f0035000a010001addada0000ff01000100000000180016000013626c6f672e636c6f7564666c6172652e636f6d0017000000230000000d00140012040308040401050308050501080606010201000500050100000000001200000010000e000c02683208687474702f312e3175500000000b000201000028002b00295a5a000100001d0020cf78b9167af054b922a96752b43973107b2a57766357dd288b2b42ab5df30e08002d00020101002b000b0acaca7f12030303020301000a000a00085a5a001d001700180a0a000100001500e4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
expectedOutput: "4826a90ec2daf4f7b4b64cc1c8bd343b",
recipeConfig: [
{
"op": "JA3 Fingerprint",
"args": ["Hex", "Hash digest"]
}
],
},
]);

View file

@ -0,0 +1,57 @@
/**
* JA3SFingerprint tests.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2021
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "JA3S Fingerprint: TLS 1.0",
input: "160301003d020000390301543dd2ddedbfe33895bd6bc676a3fa6b9fe5773a6e04d5476d1af3bcbc1dcbbb00c011000011ff01000100000b00040300010200230000",
expectedOutput: "bed95e1b525d2f41db3a6d68fac5b566",
recipeConfig: [
{
"op": "JA3S Fingerprint",
"args": ["Hex", "Hash digest"]
}
],
},
{
name: "JA3S Fingerprint: TLS 1.1",
input: "160302003d020000390302543dd2ed88131999a0120d36c14a4139671d75aae3d7d7779081d3cf7dd7725a00c013000011ff01000100000b00040300010200230000",
expectedOutput: "130fac2dc19b142500acb0abc63b6379",
recipeConfig: [
{
"op": "JA3S Fingerprint",
"args": ["Hex", "Hash digest"]
}
],
},
{
name: "JA3S Fingerprint: TLS 1.2",
input: "160303003d020000390303543dd328b38b445686739d58fab733fa23838f575e0e5ad9a1b9baace6cc3b4100c02f000011ff01000100000b00040300010200230000",
expectedOutput: "ccc514751b175866924439bdbb5bba34",
recipeConfig: [
{
"op": "JA3S Fingerprint",
"args": ["Hex", "Hash digest"]
}
],
},
// This Server Hello was based on draft 18 of the TLS1.3 spec which does not include a Session ID field, leading it to fail.
// The published version of TLS1.3 does require a legacy Session ID field (even if it is empty).
// {
// name: "JA3S Fingerprint: TLS 1.3",
// input: "16030100520200004e7f123ef1609fd3f4fa8668aac5822d500fb0639b22671d0fb7258597355795511bf61301002800280024001d0020ae0e282a3b7a463e71064ecbaf671586e979b0edbebf7a4735c31678c70f660c",
// expectedOutput: "986ae432c402479fe7a0c6fbe02164c1",
// recipeConfig: [
// {
// "op": "JA3S Fingerprint",
// "args": ["Hex", "Hash digest"]
// }
// ],
// },
]);

View file

@ -0,0 +1,55 @@
/**
* JA4Fingerprint tests.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "JA4 Fingerprint: TLS 1.3",
input: "1603010200010001fc0303b2c03e7ba990ef540c316a665d4d925f8e9079ac4b15687e587dc99016e75a6c20d0b0099243c9296a0c84153ea4ada7d87ad017f4211c2ea1350b0b3cc5514d5f00205a5a130113021303c02bc02fc02cc030cca9cca8c013c014009c009d002f003501000193fafa000000000024002200001f636f6e74656e742d6175746f66696c6c2e676f6f676c65617069732e636f6d0033002b00293a3a000100001d0020fb2cd8ef3d605b96ab03119ec4f30a6e2088cb1af86c41a81feace8706068c50000d001200100403080404010503080505010806060100230000000b00020100ff01000100000a000a00083a3a001d00170018001b000302000244690005000302683200120000002d000201010010000e000c02683208687474702f312e31000500050100000000002b0007060a0a03040303001700001a1a000100001500b800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
expectedOutput: "t13d1516h2_8daaf6152771_e5627efa2ab1",
recipeConfig: [
{
"op": "JA4 Fingerprint",
"args": ["Hex", "JA4"]
}
],
},
{
name: "JA4 Fingerprint: TLS 1.3 Original Rendering",
input: "1603010200010001fc0303b2c03e7ba990ef540c316a665d4d925f8e9079ac4b15687e587dc99016e75a6c20d0b0099243c9296a0c84153ea4ada7d87ad017f4211c2ea1350b0b3cc5514d5f00205a5a130113021303c02bc02fc02cc030cca9cca8c013c014009c009d002f003501000193fafa000000000024002200001f636f6e74656e742d6175746f66696c6c2e676f6f676c65617069732e636f6d0033002b00293a3a000100001d0020fb2cd8ef3d605b96ab03119ec4f30a6e2088cb1af86c41a81feace8706068c50000d001200100403080404010503080505010806060100230000000b00020100ff01000100000a000a00083a3a001d00170018001b000302000244690005000302683200120000002d000201010010000e000c02683208687474702f312e31000500050100000000002b0007060a0a03040303001700001a1a000100001500b800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
expectedOutput: "t13d1516h2_acb858a92679_5276cb03a33b",
recipeConfig: [
{
"op": "JA4 Fingerprint",
"args": ["Hex", "JA4 Original Rendering"]
}
],
},
{
name: "JA4 Fingerprint: TLS 1.2",
input: "1603010200010001fc0303ecb2691addb2bf6c599c7aaae23de5f42561cc04eb41029acc6fc050a16ac1d22046f8617b580ac9358e2aa44e306d52466bcc989c87c8ca64309f5faf50ba7b4d0022130113031302c02bc02fcca9cca8c02cc030c00ac009c013c014009c009d002f00350100019100000021001f00001c636f6e74696c652e73657276696365732e6d6f7a696c6c612e636f6d00170000ff01000100000a000e000c001d00170018001901000101000b00020100002300000010000e000c02683208687474702f312e310005000501000000000022000a000804030503060302030033006b0069001d00208909858fbeb6ed2f1248ba5b9e2978bead0e840110192c61daed0096798b184400170041044d183d91f5eed35791fa982464e3b0214aaa5f5d1b78616d9b9fbebc22d11f535b2f94c686143136aa795e6e5a875d6c08064ad5b76d44caad766e2483012748002b00050403040303000d0018001604030503060308040805080604010501060102030201002d00020101001c000240010015007a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
expectedOutput: "t13d1715h2_5b57614c22b0_3d5424432f57",
recipeConfig: [
{
"op": "JA4 Fingerprint",
"args": ["Hex", "JA4"]
}
],
},
{
name: "JA4 Fingerprint: TLS 1.2 Original Rendering",
input: "1603010200010001fc0303ecb2691addb2bf6c599c7aaae23de5f42561cc04eb41029acc6fc050a16ac1d22046f8617b580ac9358e2aa44e306d52466bcc989c87c8ca64309f5faf50ba7b4d0022130113031302c02bc02fcca9cca8c02cc030c00ac009c013c014009c009d002f00350100019100000021001f00001c636f6e74696c652e73657276696365732e6d6f7a696c6c612e636f6d00170000ff01000100000a000e000c001d00170018001901000101000b00020100002300000010000e000c02683208687474702f312e310005000501000000000022000a000804030503060302030033006b0069001d00208909858fbeb6ed2f1248ba5b9e2978bead0e840110192c61daed0096798b184400170041044d183d91f5eed35791fa982464e3b0214aaa5f5d1b78616d9b9fbebc22d11f535b2f94c686143136aa795e6e5a875d6c08064ad5b76d44caad766e2483012748002b00050403040303000d0018001604030503060308040805080604010501060102030201002d00020101001c000240010015007a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
expectedOutput: "t13d1715h2_5b234860e130_014157ec0da2",
recipeConfig: [
{
"op": "JA4 Fingerprint",
"args": ["Hex", "JA4 Original Rendering"]
}
],
},
]);

View file

@ -16,7 +16,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
args: [" ", false, false],
},
],
},
@ -27,7 +27,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
args: [" ", false, false],
},
],
},
@ -38,8 +38,12 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
args: [" ", false, false],
},
{
op: "HTML To Text",
args: []
}
],
},
{
@ -49,7 +53,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
args: [" ", false, false],
},
],
},
@ -60,7 +64,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
args: [" ", false, false],
},
],
},
@ -71,7 +75,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
args: [" ", false, false],
},
],
},
@ -82,7 +86,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JSON Beautify",
args: ["\t", false],
args: ["\t", false, false],
},
],
},
@ -93,8 +97,12 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JSON Beautify",
args: [" ", false],
args: [" ", false, false],
},
{
op: "HTML To Text",
args: []
}
],
},
{
@ -104,8 +112,12 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JSON Beautify",
args: ["\t", false],
args: ["\t", false, false],
},
{
op: "HTML To Text",
args: []
}
],
},
{
@ -115,8 +127,12 @@ TestRegister.addTests([
recipeConfig: [
{
op: "JSON Beautify",
args: ["\t", true],
args: ["\t", true, false],
},
{
op: "HTML To Text",
args: []
}
],
},
]);

View file

@ -46,6 +46,17 @@ TestRegister.addTests([
},
],
},
{
name: "JSON to CSV: boolean and null as values",
input: JSON.stringify({a: false, b: null, c: 3}),
expectedOutput: "a,b,c\r\nfalse,null,3\r\n",
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}]),
@ -89,5 +100,71 @@ TestRegister.addTests([
args: [",", "\\r\\n"]
},
],
},
{
name: "JSON to CSV: nested JSON",
input: JSON.stringify({a: 1, b: {c: 2, d: 3}}),
expectedOutput: "a,b.c,b.d\r\n1,2,3\r\n",
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
},
{
name: "JSON to CSV: nested array",
input: JSON.stringify({a: 1, b: [2, 3]}),
expectedOutput: "a,b.0,b.1\r\n1,2,3\r\n",
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
},
{
name: "JSON to CSV: nested JSON, nested array",
input: JSON.stringify({a: 1, b: {c: [2, 3], d: 4}}),
expectedOutput: "a,b.c.0,b.c.1,b.d\r\n1,2,3,4\r\n",
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
},
{
name: "JSON to CSV: nested array, nested JSON",
input: JSON.stringify({a: 1, b: [{c: 3, d: 4}]}),
expectedOutput: "a,b.0.c,b.0.d\r\n1,3,4\r\n",
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
},
{
name: "JSON to CSV: nested array, nested array",
input: JSON.stringify({a: 1, b: [[2, 3]]}),
expectedOutput: "a,b.0.0,b.0.1\r\n1,2,3\r\n",
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
},
{
name: "JSON to CSV: nested JSON, nested JSON",
input: JSON.stringify({a: 1, b: { c: { d: 2, e: 3}}}),
expectedOutput: "a,b.c.d,b.c.e\r\n1,2,3\r\n",
recipeConfig: [
{
op: "JSON to CSV",
args: [",", "\\r\\n"]
},
],
}
]);

View file

@ -14,10 +14,9 @@ const outputObject = JSON.stringify({
iat: 1
}, null, 4);
const invalidAlgorithm = "JsonWebTokenError: invalid algorithm";
const hsKey = "secret_cat";
const rsKey = `-----BEGIN RSA PRIVATE KEY-----
/* Retaining private key as a comment
const rsPriv = `-----BEGIN RSA PRIVATE KEY-----
MIICWwIBAAKBgQDdlatRjRjogo3WojgGHFHYLugdUWAY9iR3fy4arWNA1KoS8kVw
33cJibXr8bvwUAUparCwlvdbH6dvEOfou0/gCFQsHUfQrSDv+MuSUMAe8jzKE4qW
+jK+xQU9a03GUnKHkkle+Q0pX/g6jXZ7r1/xAK5Do2kQ+X5xK9cipRgEKwIDAQAB
@ -32,11 +31,24 @@ fSSjAkLRi54PKJ8TFUeOP15h9sQzydI8zJU+upvDEKZsZc/UhT/SySDOxQ4G/523
Y0sz/OZtSWcol/UMgQJALesy++GdvoIDLfJX5GBQpuFgFenRiRDabxrE9MNUZ2aP
FaFp+DyAe+b4nDwuJaW2LURbr8AEZga7oQj0uYxcYw==
-----END RSA PRIVATE KEY-----`;
const esKey = `-----BEGIN PRIVATE KEY-----
*/
const rsPub = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDdlatRjRjogo3WojgGHFHYLugd
UWAY9iR3fy4arWNA1KoS8kVw33cJibXr8bvwUAUparCwlvdbH6dvEOfou0/gCFQs
HUfQrSDv+MuSUMAe8jzKE4qW+jK+xQU9a03GUnKHkkle+Q0pX/g6jXZ7r1/xAK5D
o2kQ+X5xK9cipRgEKwIDAQAB
-----END PUBLIC KEY-----`;
/* Retaining private key as a comment
const esPriv = `-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgevZzL1gdAFr88hb2
OF/2NxApJCzGCEDdfSp6VQO30hyhRANCAAQRWz+jn65BtOMvdyHKcvjBeBSDZH2r
1RTwjmYSi9R/zpBnuQ4EiMnCqfMPWiZqB4QdbAd0E7oH50VpuZ1P087G
-----END PRIVATE KEY-----`;
*/
const esPub = `-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEVs/o5+uQbTjL3chynL4wXgUg2R9
q9UU8I5mEovUf86QZ7kOBIjJwqnzD1omageEHWwHdBO6B+dFabmdT9POxg==
-----END PUBLIC KEY-----`;
TestRegister.addTests([
{
@ -53,22 +65,22 @@ TestRegister.addTests([
{
name: "JWT Verify: RS",
input: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJTdHJpbmciOiJTb21lU3RyaW5nIiwiTnVtYmVyIjo0MiwiaWF0IjoxfQ.MjEJhtZk2nXzigi24piMzANmrj3mILHJcDl0xOjl5a8EgdKVL1oaMEjTkMQp5RA8YrqeRBFaX-BGGCKOXn5zPY1DJwWsBUyN9C-wGR2Qye0eogH_3b4M9EW00TPCUPXm2rx8URFj7Wg9VlsmrGzLV2oKkPgkVxuFSxnpO3yjn1Y",
expectedOutput: invalidAlgorithm,
expectedOutput: outputObject,
recipeConfig: [
{
op: "JWT Verify",
args: [rsKey],
args: [rsPub],
}
],
},
{
name: "JWT Verify: ES",
input: "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJTdHJpbmciOiJTb21lU3RyaW5nIiwiTnVtYmVyIjo0MiwiaWF0IjoxfQ.WkECT51jSfpRkcpQ4x0h5Dwe7CFBI6u6Et2gWp91HC7mpN_qCFadRpsvJLtKubm6cJTLa68xtei0YrDD8fxIUA",
expectedOutput: invalidAlgorithm,
expectedOutput: outputObject,
recipeConfig: [
{
op: "JWT Verify",
args: [esKey],
args: [esPub],
}
],
}

View file

@ -0,0 +1,45 @@
/**
* LS47 tests.
*
* @author n1073645 [n1073645@gmail.com]
*
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "LS47 Encrypt",
input: "thequickbrownfoxjumped",
expectedOutput: "(,t74ci78cp/8trx*yesu:alp1wqy",
recipeConfig: [
{
op: "LS47 Encrypt",
args: ["helloworld", 0, "test"],
},
],
},
{
name: "LS47 Decrypt",
input: "(,t74ci78cp/8trx*yesu:alp1wqy",
expectedOutput: "thequickbrownfoxjumped---test",
recipeConfig: [
{
op: "LS47 Decrypt",
args: ["helloworld", 0],
},
],
},
{
name: "LS47 Encrypt",
input: "thequickbrownfoxjumped",
expectedOutput: "Letter H is not included in LS47",
recipeConfig: [
{
op: "LS47 Encrypt",
args: ["Helloworld", 0, "test"],
},
],
}
]);

View file

@ -0,0 +1,22 @@
/**
* LZNT1 Decompress tests.
*
* @author 0xThiebaut [thiebaut.dev]
* @copyright Crown Copyright 2023
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "LZNT1 Decompress",
input: "\x1a\xb0\x00compress\x00edtestda\x04ta\x07\x88alot",
expectedOutput: "compressedtestdatacompressedalot",
recipeConfig: [
{
op: "LZNT1 Decompress",
args: []
}
],
}
]);

View file

@ -0,0 +1,33 @@
/**
* LZString tests.
*
* @author crespyl [peter@crespyl.net]
* @copyright Peter Jacobs 2021
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "LZString Compress To Base64",
input: "hello world",
expectedOutput: "BYUwNmD2AEDukCcwBMg=",
recipeConfig: [
{
"op": "LZString Compress",
"args": ["Base64"]
}
],
},
{
name: "LZString Decompress From Base64",
input: "BYUwNmD2AEDukCcwBMg=",
expectedOutput: "hello world",
recipeConfig: [
{
"op": "LZString Decompress",
"args": ["Base64"]
}
],
}
]);

View file

@ -0,0 +1,165 @@
/**
* @author mikecat
* @copyright Crown Copyright 2023
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
"name": "Levenshtein Distance: Wikipedia example 1",
"input": "kitten\nsitting",
"expectedOutput": "3",
"recipeConfig": [
{
"op": "Levenshtein Distance",
"args": [
"\\n", 1, 1, 1,
],
},
],
},
{
"name": "Levenshtein Distance: Wikipedia example 2",
"input": "saturday\nsunday",
"expectedOutput": "3",
"recipeConfig": [
{
"op": "Levenshtein Distance",
"args": [
"\\n", 1, 1, 1,
],
},
],
},
{
"name": "Levenshtein Distance: Wikipedia example 1 with substitution cost 2",
"input": "kitten\nsitting",
"expectedOutput": "5",
"recipeConfig": [
{
"op": "Levenshtein Distance",
"args": [
"\\n", 1, 1, 2,
],
},
],
},
{
"name": "Levenshtein Distance: varied costs 1",
"input": "kitten\nsitting",
"expectedOutput": "230",
"recipeConfig": [
{
"op": "Levenshtein Distance",
"args": [
"\\n", 10, 100, 1000,
],
},
],
},
{
"name": "Levenshtein Distance: varied costs 2",
"input": "kitten\nsitting",
"expectedOutput": "1020",
"recipeConfig": [
{
"op": "Levenshtein Distance",
"args": [
"\\n", 1000, 100, 10,
],
},
],
},
{
"name": "Levenshtein Distance: another delimiter",
"input": "kitten sitting",
"expectedOutput": "3",
"recipeConfig": [
{
"op": "Levenshtein Distance",
"args": [
" ", 1, 1, 1,
],
},
],
},
{
"name": "Levenshtein Distance: too few samples",
"input": "kitten",
"expectedOutput": "Incorrect number of samples. Check your input and/or delimiter.",
"recipeConfig": [
{
"op": "Levenshtein Distance",
"args": [
"\\n", 1, 1, 1,
],
},
],
},
{
"name": "Levenshtein Distance: too many samples",
"input": "kitten\nsitting\nkitchen",
"expectedOutput": "Incorrect number of samples. Check your input and/or delimiter.",
"recipeConfig": [
{
"op": "Levenshtein Distance",
"args": [
"\\n", 1, 1, 1,
],
},
],
},
{
"name": "Levenshtein Distance: negative insertion cost",
"input": "kitten\nsitting",
"expectedOutput": "Negative costs are not allowed.",
"recipeConfig": [
{
"op": "Levenshtein Distance",
"args": [
"\\n", -1, 1, 1,
],
},
],
},
{
"name": "Levenshtein Distance: negative deletion cost",
"input": "kitten\nsitting",
"expectedOutput": "Negative costs are not allowed.",
"recipeConfig": [
{
"op": "Levenshtein Distance",
"args": [
"\\n", 1, -1, 1,
],
},
],
},
{
"name": "Levenshtein Distance: negative substitution cost",
"input": "kitten\nsitting",
"expectedOutput": "Negative costs are not allowed.",
"recipeConfig": [
{
"op": "Levenshtein Distance",
"args": [
"\\n", 1, 1, -1,
],
},
],
},
{
"name": "Levenshtein Distance: cost zero",
"input": "kitten\nsitting",
"expectedOutput": "0",
"recipeConfig": [
{
"op": "Levenshtein Distance",
"args": [
"\\n", 0, 0, 0,
],
},
],
},
]);

View file

@ -7,7 +7,7 @@
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
import { JPG_RAW } from "../samples/Images.mjs";
import { JPG_RAW } from "../../samples/Images.mjs";
TestRegister.addTests([
{
@ -68,7 +68,7 @@ TestRegister.addTests([
{
name: "Magic Chain: Base64",
input: "WkVkV2VtUkRRbnBrU0Vwd1ltMWpQUT09",
expectedMatch: /From_Base64\('A-Za-z0-9\+\/=',true\)\nFrom_Base64\('A-Za-z0-9\+\/=',true\)\nFrom_Base64\('A-Za-z0-9\+\/=',true\)/,
expectedMatch: /From_Base64\('A-Za-z0-9\+\/=',true,false\)\nFrom_Base64\('A-Za-z0-9\+\/=',true,false\)\nFrom_Base64\('A-Za-z0-9\+\/=',true,false\)/,
recipeConfig: [
{
op: "Magic",
@ -79,7 +79,7 @@ TestRegister.addTests([
{
name: "Magic Chain: Hex -> Hexdump -> Base64",
input: "MDAwMDAwMDAgIDM3IDM0IDIwIDM2IDM1IDIwIDM3IDMzIDIwIDM3IDM0IDIwIDMyIDMwIDIwIDM3ICB8NzQgNjUgNzMgNzQgMjAgN3wKMDAwMDAwMTAgIDMzIDIwIDM3IDM0IDIwIDM3IDMyIDIwIDM2IDM5IDIwIDM2IDY1IDIwIDM2IDM3ICB8MyA3NCA3MiA2OSA2ZSA2N3w=",
expectedMatch: /From_Base64\('A-Za-z0-9\+\/=',true\)\nFrom_Hexdump\(\)\nFrom_Hex\('Space'\)/,
expectedMatch: /From_Base64\('A-Za-z0-9\+\/=',true,false\)\nFrom_Hexdump\(\)\nFrom_Hex\('Space'\)/,
recipeConfig: [
{
op: "Magic",

View file

@ -0,0 +1,77 @@
/**
* MurmurHash3 tests
* @author AliceGrey [alice@grey.systems]
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "To MurmurHash3: nothing",
input: "",
expectedOutput: "0",
recipeConfig: [
{
op: "MurmurHash3",
args: [0],
},
],
},
{
name: "To MurmurHash3: 1",
input: "1",
expectedOutput: "2484513939",
recipeConfig: [
{
op: "MurmurHash3",
args: [0],
},
],
},
{
name: "To MurmurHash3: Hello World!",
input: "Hello World!",
expectedOutput: "3691591037",
recipeConfig: [
{
op: "MurmurHash3",
args: [0],
},
],
},
{
name: "To MurmurHash3: Hello World! with seed",
input: "Hello World!",
expectedOutput: "1148600031",
recipeConfig: [
{
op: "MurmurHash3",
args: [1337],
},
],
},
{
name: "To MurmurHash3: foo",
input: "foo",
expectedOutput: "4138058784",
recipeConfig: [
{
op: "MurmurHash3",
args: [0],
},
],
},
{
name: "To MurmurHash3: foo signed",
input: "foo",
expectedOutput: "-156908512",
recipeConfig: [
{
op: "MurmurHash3",
args: [0, true],
},
],
}
]);

View file

@ -0,0 +1,34 @@
/**
* NTLM test.
*
* @author brun0ne [brunonblok@gmail.com]
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "NT Hash",
input: "QWERTYUIOPASDFGHJKLZXCVBNM1234567890!@#$%^&*()_+.,?/",
expectedOutput: "C5FA1C40E55734A8E528DBFE21766D23",
recipeConfig: [
{
op: "NT Hash",
args: [],
},
],
},
{
name: "LM Hash",
input: "QWERTYUIOPASDFGHJKLZXCVBNM1234567890!@#$%^&*()_+.,?/",
expectedOutput: "6D9DF16655336CA75A3C13DD18BA8156",
recipeConfig: [
{
op: "LM Hash",
args: [],
},
],
},
]);

View file

@ -0,0 +1,294 @@
/**
* Test PEMtoHex with different inputs
*
* @author cplussharp
*
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
/** RSA 2048bit key pair as PKCS1 and PKCS8 and as certificate */
const PEMS_RSA_PRIVATE_KEY_PKCS1 = `-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEA5WykLKHiBAhmZh5WhocgpQQqZjdrApuRxRT21SJZx6Ce+Oz2
V17/heozu5LEz63jCxW1NrBckzl/Ys8p9LeqYTu6x/LbKloTjfEWxlzXnzUSqn9J
HIxmmJQzjXp9X1D99Tj+NWpRGEIiCFE7JfDhe2KnMGVDDg6kfCLokDdLo256LeQ4
CEkViwY6d+at4xDlIHwvZZmG4Smk56eHhvQE3I8sSAzgoLMBamQ5m3MbiULAYtxs
kCpCfjFxrL6Ziaaj7HZoneF40R30KCI9ygF8vkzxLwe3t5Y4XgHL9TYQm1+BDnin
upIB/zTeO1ygBGA66m6zpmkmuG7d8HXIducz+wIDAQABAoIBACQu3jWr0lmQeZXh
cwQEi8F6xrUYSGhA4NyUUdmLcV1ql6fqt29QLDySk1Yh76hRZF17LvlRF0ig6NZM
lfFihhyPrwWZ57bmPe9E9rKSMe+KD0eUi5NVEVk/BmJpzxwZSfRC6NTDz8Zjp7po
FUwGkYlEJdocHlc5N/fcCZG1Jti/Z1AsZIjO6r6S0O7neC7icECBKHUyWa8/yE1N
++TVyMV+z53Ad1PC+SHMGDlbqJAM3o4wAzD/FAIzyVo6GSnnC+bFdgMtIwtwgYTH
rbr8M8j5fqAHTqNJeblqt/5KHEj2VVsIsHIuQ6lv4llESEqmH+N5KE4O33U7/Wmj
y/+VGAECgYEA9ysROHXOx1ofh3tI/r2C2FUan6/AAe4dc+8E4jMGI5T4xeqYHTRV
l1yS+ZKIxqclIoAmd6SJ7Nx2GdQ55MmokZdZRqsFN1flFOZw2kFH/I0zQZXdOjF+
sf5Lu0FfcTw3VJhJ/YU3CVdlgdP4ekHbaJVFW5i/pTUf5vNs6AGBGxsCgYEA7Z9D
0qnF6GhxA8lJfwnyuktYnwIQoXE6Xp26/NZD7t7HzxHDf43LQxmTk+mDP/yIQHwb
xIx2NE/ncNxlUMl/g1PkJbKVkB8tdIZrLyiT4lebeqgT72Q07IsxRl/GHOr7CfN0
61OBRCe44IlOtaNAZk4zWwuAwAYx+G8ifuOJ+KECgYBP5NvsJChyx+7pHDC8JwXk
Z53zgBvQg+eBUgGCHHwfhEflsa75wbDo/EOF6JfNnrmiLUpB4i2zIpAKSU9tZMHY
TdPNw/orqX2jA9n2sqNSP1ISIR8hcF5Dqq9QGBGByLUZ4yAHksf3fQiSrrHi0ubZ
J2cD9Jv+Cu4E+Sp61AGngQKBgHmuTPTbq1TP5s+hi9laJsnvO3pxfEKv0MwSyWYf
8rmnq3oGBq6S1buOpVvhAC0MDFm5NB76Lq2rHUFWGyu7g2ik1PfY823SCVzaWJjV
lqUZZ6zv1QWJsvBOdvUqpjC4w8TcvsqjAFb+YFXa+ktZRekdsn607UFn6r7laizA
KC8BAoGAZty7sIGMt1gDaoIjySgOox8x7AlY3QUyNQC5N8KW3MZ8KLC5UBtjhqLy
wYOJr+/1R/7ibiHrKkIE/dmg5QN1iS5tZmFvyLwJ+nHQZObFrlcKtpr+1lekQY/m
ly6YJFk3yj2nhYzt8eVXBX2lCoLG1gsrbpXvUfIGJ53L9m1mVAo=
-----END RSA PRIVATE KEY-----`;
const PEMS_RSA_PRIVATE_KEY_PKCS8 = `-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDlbKQsoeIECGZm
HlaGhyClBCpmN2sCm5HFFPbVIlnHoJ747PZXXv+F6jO7ksTPreMLFbU2sFyTOX9i
zyn0t6phO7rH8tsqWhON8RbGXNefNRKqf0kcjGaYlDONen1fUP31OP41alEYQiII
UTsl8OF7YqcwZUMODqR8IuiQN0ujbnot5DgISRWLBjp35q3jEOUgfC9lmYbhKaTn
p4eG9ATcjyxIDOCgswFqZDmbcxuJQsBi3GyQKkJ+MXGsvpmJpqPsdmid4XjRHfQo
Ij3KAXy+TPEvB7e3ljheAcv1NhCbX4EOeKe6kgH/NN47XKAEYDrqbrOmaSa4bt3w
dch25zP7AgMBAAECggEAJC7eNavSWZB5leFzBASLwXrGtRhIaEDg3JRR2YtxXWqX
p+q3b1AsPJKTViHvqFFkXXsu+VEXSKDo1kyV8WKGHI+vBZnntuY970T2spIx74oP
R5SLk1URWT8GYmnPHBlJ9ELo1MPPxmOnumgVTAaRiUQl2hweVzk399wJkbUm2L9n
UCxkiM7qvpLQ7ud4LuJwQIEodTJZrz/ITU375NXIxX7PncB3U8L5IcwYOVuokAze
jjADMP8UAjPJWjoZKecL5sV2Ay0jC3CBhMetuvwzyPl+oAdOo0l5uWq3/kocSPZV
Wwiwci5DqW/iWURISqYf43koTg7fdTv9aaPL/5UYAQKBgQD3KxE4dc7HWh+He0j+
vYLYVRqfr8AB7h1z7wTiMwYjlPjF6pgdNFWXXJL5kojGpyUigCZ3pIns3HYZ1Dnk
yaiRl1lGqwU3V+UU5nDaQUf8jTNBld06MX6x/ku7QV9xPDdUmEn9hTcJV2WB0/h6
QdtolUVbmL+lNR/m82zoAYEbGwKBgQDtn0PSqcXoaHEDyUl/CfK6S1ifAhChcTpe
nbr81kPu3sfPEcN/jctDGZOT6YM//IhAfBvEjHY0T+dw3GVQyX+DU+QlspWQHy10
hmsvKJPiV5t6qBPvZDTsizFGX8Yc6vsJ83TrU4FEJ7jgiU61o0BmTjNbC4DABjH4
byJ+44n4oQKBgE/k2+wkKHLH7ukcMLwnBeRnnfOAG9CD54FSAYIcfB+ER+WxrvnB
sOj8Q4Xol82euaItSkHiLbMikApJT21kwdhN083D+iupfaMD2fayo1I/UhIhHyFw
XkOqr1AYEYHItRnjIAeSx/d9CJKuseLS5tknZwP0m/4K7gT5KnrUAaeBAoGAea5M
9NurVM/mz6GL2Vomye87enF8Qq/QzBLJZh/yuaeregYGrpLVu46lW+EALQwMWbk0
HvourasdQVYbK7uDaKTU99jzbdIJXNpYmNWWpRlnrO/VBYmy8E529SqmMLjDxNy+
yqMAVv5gVdr6S1lF6R2yfrTtQWfqvuVqLMAoLwECgYBm3LuwgYy3WANqgiPJKA6j
HzHsCVjdBTI1ALk3wpbcxnwosLlQG2OGovLBg4mv7/VH/uJuIesqQgT92aDlA3WJ
Lm1mYW/IvAn6cdBk5sWuVwq2mv7WV6RBj+aXLpgkWTfKPaeFjO3x5VcFfaUKgsbW
Cytule9R8gYnncv2bWZUCg==
-----END PRIVATE KEY-----`;
const PEMS_RSA_PUBLIC_KEY_PKCS1 = `-----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEA5WykLKHiBAhmZh5WhocgpQQqZjdrApuRxRT21SJZx6Ce+Oz2V17/
heozu5LEz63jCxW1NrBckzl/Ys8p9LeqYTu6x/LbKloTjfEWxlzXnzUSqn9JHIxm
mJQzjXp9X1D99Tj+NWpRGEIiCFE7JfDhe2KnMGVDDg6kfCLokDdLo256LeQ4CEkV
iwY6d+at4xDlIHwvZZmG4Smk56eHhvQE3I8sSAzgoLMBamQ5m3MbiULAYtxskCpC
fjFxrL6Ziaaj7HZoneF40R30KCI9ygF8vkzxLwe3t5Y4XgHL9TYQm1+BDninupIB
/zTeO1ygBGA66m6zpmkmuG7d8HXIducz+wIDAQAB
-----END RSA PUBLIC KEY-----`;
const PEMS_RSA_PUBLIC_KEY_PKCS8 = `-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5WykLKHiBAhmZh5Whocg
pQQqZjdrApuRxRT21SJZx6Ce+Oz2V17/heozu5LEz63jCxW1NrBckzl/Ys8p9Leq
YTu6x/LbKloTjfEWxlzXnzUSqn9JHIxmmJQzjXp9X1D99Tj+NWpRGEIiCFE7JfDh
e2KnMGVDDg6kfCLokDdLo256LeQ4CEkViwY6d+at4xDlIHwvZZmG4Smk56eHhvQE
3I8sSAzgoLMBamQ5m3MbiULAYtxskCpCfjFxrL6Ziaaj7HZoneF40R30KCI9ygF8
vkzxLwe3t5Y4XgHL9TYQm1+BDninupIB/zTeO1ygBGA66m6zpmkmuG7d8HXIducz
+wIDAQAB
-----END PUBLIC KEY-----`;
const PEMS_RSA_CERT = `-----BEGIN CERTIFICATE-----
MIIDGzCCAgOgAwIBAgIUROs52CB3BsvEVLOCtALalnJG8tEwDQYJKoZIhvcNAQEL
BQAwHTEbMBkGA1UEAwwSUlNBIDIwNDggUHVibGljS2V5MB4XDTIxMDQxMzIxMDE0
OVoXDTMxMDQxMTIxMDE0OVowHTEbMBkGA1UEAwwSUlNBIDIwNDggUHVibGljS2V5
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5WykLKHiBAhmZh5Whocg
pQQqZjdrApuRxRT21SJZx6Ce+Oz2V17/heozu5LEz63jCxW1NrBckzl/Ys8p9Leq
YTu6x/LbKloTjfEWxlzXnzUSqn9JHIxmmJQzjXp9X1D99Tj+NWpRGEIiCFE7JfDh
e2KnMGVDDg6kfCLokDdLo256LeQ4CEkViwY6d+at4xDlIHwvZZmG4Smk56eHhvQE
3I8sSAzgoLMBamQ5m3MbiULAYtxskCpCfjFxrL6Ziaaj7HZoneF40R30KCI9ygF8
vkzxLwe3t5Y4XgHL9TYQm1+BDninupIB/zTeO1ygBGA66m6zpmkmuG7d8HXIducz
+wIDAQABo1MwUTAdBgNVHQ4EFgQUcRhRB6H5JqlDHbymwqydW2/EAt8wHwYDVR0j
BBgwFoAUcRhRB6H5JqlDHbymwqydW2/EAt8wDwYDVR0TAQH/BAUwAwEB/zANBgkq
hkiG9w0BAQsFAAOCAQEALXBmDizTp/Uz4M2A4nCl0AVclrXEk+YjAKqZnvtj44Gs
CUcpxtcXu64ppsSYCwawvzIm6B2Mdmib422aInH0e0oNrn8cRzC144Hjnzxguamj
LyZXnH/0wN9SAjqCKt++urH9wbRMIl0v+g4CWjGyY+eYkMmd1UMQvdCCCv6RVm56
7dBCijJIHg23JbgPJD72JCluXtTYWllv3duSwuWeYHo5EftU456pDcztkgn9XwFk
PFGnHLmbjpSzjE7u29qCjwHl3CiUsjfUlYFl/mf27oDXPqaWqPYv3fWH3H3ymiZQ
cqptUF4hDtPkaNkKWFmlljChN92o8g/jrv4DVDgJzQ==
-----END CERTIFICATE-----`;
/** EC P-256 key pair and certificate */
const PEMS_EC_P256_PRIVATE_KEY = `-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIIhdQxQIcMnCHD3X4WqNv+VgycWmFoEZpRl9X0+dT9uHoAoGCCqGSM49
AwEHoUQDQgAEFLQcBbzDweo6af4k3k0gKWMNWOZVn8+9hH2rv4DKKYZ7E1z64LBt
PnB1gMz++HDKySr2ozD3/46dIbQMXUZKpw==
-----END EC PRIVATE KEY-----`;
const PEMS_EC_P256_PRIVATE_KEY_PKCS8 = `-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgiF1DFAhwycIcPdfh
ao2/5WDJxaYWgRmlGX1fT51P24ehRANCAAQUtBwFvMPB6jpp/iTeTSApYw1Y5lWf
z72Efau/gMophnsTXPrgsG0+cHWAzP74cMrJKvajMPf/jp0htAxdRkqn
-----END PRIVATE KEY-----`;
const PEMS_EC_P256_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFLQcBbzDweo6af4k3k0gKWMNWOZV
n8+9hH2rv4DKKYZ7E1z64LBtPnB1gMz++HDKySr2ozD3/46dIbQMXUZKpw==
-----END PUBLIC KEY-----`;
const PEMS_FOO = `-----BEGIN FOO-----
Rk9P
-----END FOO-----`;
const PEMS_BAR = `-----BEGIN BAR-----
QkFS
-----END BAR-----`;
TestRegister.addTests([
{
name: "PEMtoHex: Nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "PEM to Hex",
"args": []
}
]
},
{
name: "PEMtoHex: No footer",
input: PEMS_RSA_PRIVATE_KEY_PKCS1.substring(0, 200),
expectedOutput: "PEM footer '-----END RSA PRIVATE KEY-----' not found",
recipeConfig: [
{
"op": "PEM to Hex",
"args": []
}
]
},
{
name: "PEMtoHex: Multiple PEMs",
input: PEMS_FOO + "\n" + PEMS_BAR,
expectedOutput: "FOOBAR",
recipeConfig: [
{
"op": "PEM to Hex",
"args": []
},
{
"op": "From Hex",
"args": ["Auto"]
}
]
},
{
name: "PEMtoHex: Single line PEM",
input: PEMS_FOO.replace(/(\n|\r)/gm, ""),
expectedOutput: "FOO",
recipeConfig: [
{
"op": "PEM to Hex",
"args": []
},
{
"op": "From Hex",
"args": ["None"]
}
]
},
{
name: "PEMtoHex: EC P-256 Private Key",
input: PEMS_EC_P256_PRIVATE_KEY,
expectedOutput: "30770201010420885d43140870c9c21c3dd7e16a8dbfe560c9c5a6168119a5197d5f4f9d4fdb87a00a06082a8648ce3d030107a1440342000414b41c05bcc3c1ea3a69fe24de4d2029630d58e6559fcfbd847dabbf80ca29867b135cfae0b06d3e707580ccfef870cac92af6a330f7ff8e9d21b40c5d464aa7",
recipeConfig: [
{
"op": "PEM to Hex",
"args": []
}
]
},
{
name: "PEMtoHex: EC P-256 Private Key PKCS8",
input: PEMS_EC_P256_PRIVATE_KEY_PKCS8,
expectedOutput: "308187020100301306072a8648ce3d020106082a8648ce3d030107046d306b0201010420885d43140870c9c21c3dd7e16a8dbfe560c9c5a6168119a5197d5f4f9d4fdb87a1440342000414b41c05bcc3c1ea3a69fe24de4d2029630d58e6559fcfbd847dabbf80ca29867b135cfae0b06d3e707580ccfef870cac92af6a330f7ff8e9d21b40c5d464aa7",
recipeConfig: [
{
"op": "PEM to Hex",
"args": []
}
]
},
{
name: "PEMtoHex: EC P-256 Public Key",
input: PEMS_EC_P256_PUBLIC_KEY,
expectedOutput: "3059301306072a8648ce3d020106082a8648ce3d0301070342000414b41c05bcc3c1ea3a69fe24de4d2029630d58e6559fcfbd847dabbf80ca29867b135cfae0b06d3e707580ccfef870cac92af6a330f7ff8e9d21b40c5d464aa7",
recipeConfig: [
{
"op": "PEM to Hex",
"args": []
}
]
},
{
name: "PEMtoHex: RSA Private Key PKCS1",
input: PEMS_RSA_PRIVATE_KEY_PKCS1,
expectedOutput: "fb49bd96ffc5d1351a35d773921fac03",
recipeConfig: [
{
"op": "PEM to Hex",
"args": []
},
{
"op": "MD5",
"args": []
}
]
},
{
name: "PEMtoHex: RSA Private Key PKCS8",
input: PEMS_RSA_PRIVATE_KEY_PKCS8,
expectedOutput: "23086d03633689fee64680c3c24409eb",
recipeConfig: [
{
"op": "PEM to Hex",
"args": []
},
{
"op": "MD5",
"args": []
}
]
},
{
name: "PEMtoHex: RSA Public Key PKCS1",
input: PEMS_RSA_PUBLIC_KEY_PKCS1,
expectedOutput: "5fc3f1f6c5d5806760b12eaad0c0292c",
recipeConfig: [
{
"op": "PEM to Hex",
"args": []
},
{
"op": "MD5",
"args": []
}
]
},
{
name: "PEMtoHex: RSA Public Key PKCS8",
input: PEMS_RSA_PUBLIC_KEY_PKCS8,
expectedOutput: "30fbe8e9495d591232affebdd6206ea6",
recipeConfig: [
{
"op": "PEM to Hex",
"args": []
},
{
"op": "MD5",
"args": []
}
]
},
{
name: "PEMtoHex: Certificate",
input: PEMS_RSA_CERT,
expectedOutput: "6694d8ca4a0ceb84c3951d25dc05ec6e",
recipeConfig: [
{
"op": "PEM to Hex",
"args": []
},
{
"op": "MD5",
"args": []
}
]
}
]);

View file

@ -6,30 +6,7 @@
* @license Apache-2.0
*/
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.";
const UTF8_TEXT = "Шанцы на высвятленне таго, што адбываецца на самай справе ў сусвеце настолькі выдаленыя, адзінае, што трэба зрабіць, гэта павесіць пачуццё яго і трымаць сябе занятымі.";
const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f",
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f",
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f",
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
].join("");
import {ASCII_TEXT, UTF8_TEXT, ALL_BYTES} from "../../samples/Ciphers.mjs";
// RSA-1024
const ALICE_PRIVATE = `-----BEGIN PGP PRIVATE KEY BLOCK-----

View file

@ -49,6 +49,18 @@ Point: 0x046c59592006272250a15070142a6be36d1e45464313f930d985a6e6f0eba3cd39d0367
}
]
},
{
name: "SSH Host Key: Ed25519",
input: "AAAAC3NzaC1lZDI1NTE5AAAAIBOF6r99IkvqGu1kwZrHHIqjpTB5w79bpv67B/Aw3+WJ",
expectedOutput: `Key type: ssh-ed25519
x: 0x1385eabf7d224bea1aed64c19ac71c8aa3a53079c3bf5ba6febb07f030dfe589`,
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",

View file

@ -0,0 +1,44 @@
/**
* Parse TCP tests.
*
* @author n1474335
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Parse TCP: No options",
input: "c2eb0050a138132e70dc9fb9501804025ea70000",
expectedMatch: /1026 \(Scaled: 1026\)/,
recipeConfig: [
{
op: "Parse TCP",
args: ["Hex"],
}
],
},
{
name: "Parse TCP: Options",
input: "c2eb0050a1380c1f000000008002faf080950000020405b40103030801010402",
expectedMatch: /1460/,
recipeConfig: [
{
op: "Parse TCP",
args: ["Hex"],
}
],
},
{
name: "Parse TCP: Timestamps",
input: "9e90e11574d57b2c00000000a002ffffe5740000020405b40402080aa4e8c8f50000000001030308",
expectedMatch: /2766719221/,
recipeConfig: [
{
op: "Parse TCP",
args: ["Hex"],
}
],
}
]);

View file

@ -2,7 +2,6 @@
* Parse UDP tests.
*
* @author h345983745
*
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
@ -12,15 +11,11 @@ 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\"}",
expectedOutput: "{\"Source port\":1161,\"Destination port\":53,\"Length\":44,\"Checksum\":\"0x0101\"}",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"],
},
{
op: "Parse UDP",
args: [],
args: ["Hex"],
},
{
op: "JSON Minify",
@ -30,15 +25,11 @@ TestRegister.addTests([
}, {
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\"}",
expectedOutput: "{\"Source port\":1161,\"Destination port\":53,\"Length\":44,\"Checksum\":\"0x0101\",\"Data\":\"0x0202\"}",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"],
},
{
op: "Parse UDP",
args: [],
args: ["Hex"],
},
{
op: "JSON Minify",
@ -51,13 +42,9 @@ TestRegister.addTests([
input: "04 89 00",
expectedOutput: "Need 8 bytes for a UDP Header",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"],
},
{
op: "Parse UDP",
args: [],
args: ["Hex"],
},
{
op: "JSON Minify",

View file

@ -10,10 +10,10 @@ import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Protobuf Decode",
name: "Protobuf Decode: no schema",
input: "0d1c0000001203596f751a024d65202b2a0a0a066162633132331200",
expectedOutput: JSON.stringify({
"1": 469762048,
"1": 28,
"2": "You",
"3": "Me",
"4": 43,
@ -29,7 +29,277 @@ TestRegister.addTests([
},
{
"op": "Protobuf Decode",
"args": []
"args": ["", false, false]
}
]
},
{
name: "Protobuf Decode: partial schema, no unknown fields",
input: "0d1c0000001203596f751a024d65202b2a0a0a066162633132331200",
expectedOutput: JSON.stringify({
"Apple": [
28
],
"Carrot": [
"Me"
],
"Banana": "You"
}, null, 4),
recipeConfig: [
{
"op": "From Hex",
"args": ["Auto"]
},
{
"op": "Protobuf Decode",
"args": [
`message Test {
repeated fixed32 Apple = 1;
optional string Banana = 2;
repeated string Carrot = 3;
}`,
false,
false
]
}
]
},
{
name: "Protobuf Decode: partial schema, show unknown fields",
input: "0d1c0000001203596f751a024d65202b2a0a0a066162633132331200",
expectedOutput: JSON.stringify({
"Test": {
"Apple": [
28
],
"Carrot": [
"Me"
],
"Banana": "You"
},
"Unknown Fields": {
"4": 43,
"5": {
"1": "abc123",
"2": {}
}
}
}, null, 4),
recipeConfig: [
{
"op": "From Hex",
"args": ["Auto"]
},
{
"op": "Protobuf Decode",
"args": [
`message Test {
repeated fixed32 Apple = 1;
optional string Banana = 2;
repeated string Carrot = 3;
}`,
true,
false
]
}
]
},
{
name: "Protobuf Decode: full schema, no unknown fields",
input: "0d1c0000001203596f751a024d65202b2a0a0a06616263313233120031ff00000000000000",
expectedOutput: JSON.stringify({
"Apple": [
28
],
"Carrot": [
"Me"
],
"Banana": "You",
"Date": 43,
"Elderberry": {
"Fig": "abc123",
"Grape": {}
},
"Huckleberry": 255
}, null, 4),
recipeConfig: [
{
"op": "From Hex",
"args": ["Auto"]
},
{
"op": "Protobuf Decode",
"args": [
`message Test {
repeated fixed32 Apple = 1;
optional string Banana = 2;
repeated string Carrot = 3;
optional int32 Date = 4;
optional subTest Elderberry = 5;
optional fixed64 Huckleberry = 6;
}
message subTest {
optional string Fig = 1;
optional subSubTest Grape = 2;
}
message subSubTest {}`,
false,
false
]
}
]
},
{
name: "Protobuf Decode: partial schema, show unknown fields, show types",
input: "0d1c0000001203596f751a024d65202b2a0a0a06616263313233120031ba32a96cc10200003801",
expectedOutput: JSON.stringify({
"Test": {
"Carrot (string)": [
"Me"
],
"Banana (string)": "You",
"Date (int32)": 43,
"Imbe (Options)": "Option1"
},
"Unknown Fields": {
"field #1: 32-Bit (e.g. fixed32, float)": 28,
"field #5: L-delim (e.g. string, message)": {
"field #1: L-delim (e.g. string, message)": "abc123",
"field #2: L-delim (e.g. string, message)": {}
},
"field #6: 64-Bit (e.g. fixed64, double)": 3029774971578
}
}, null, 4),
recipeConfig: [
{
"op": "From Hex",
"args": ["Auto"]
},
{
"op": "Protobuf Decode",
"args": [
`message Test {
optional string Banana = 2;
repeated string Carrot = 3;
optional int32 Date = 4;
optional Options Imbe = 7;
}
message subTest {
optional string Fig = 1;
optional subSubTest Grape = 2;
}
message subSubTest {}
enum Options {
Option0 = 0;
Option1 = 1;
Option2 = 2;
}`,
true,
true
]
}
]
},
{
name: "Protobuf Encode",
input: JSON.stringify({
"Apple": [
28
],
"Banana": "You",
"Carrot": [
"Me"
],
"Date": 43,
"Elderberry": {
"Fig": "abc123",
"Grape": {}
},
"Huckleberry": [3029774971578],
"Imbe": 1
}, null, 4),
expectedOutput: "0d1c0000001203596f751a024d65202b2a0a0a06616263313233120031ba32a96cc10200003801",
recipeConfig: [
{
"op": "Protobuf Encode",
"args": [
`message Test {
repeated fixed32 Apple = 1;
optional string Banana = 2;
repeated string Carrot = 3;
optional int32 Date = 4;
optional subTest Elderberry = 5;
repeated fixed64 Huckleberry = 6;
optional Options Imbe = 7;
}
message subTest {
optional string Fig = 1;
optional subSubTest Grape = 2;
}
message subSubTest {}
enum Options {
Option0 = 0;
Option1 = 1;
Option2 = 2;
}`
]
},
{
"op": "To Hex",
"args": [
"None",
0
]
}
]
},
{
name: "Protobuf Encode: incomplete schema",
input: JSON.stringify({
"Apple": [
28
],
"Banana": "You",
"Carrot": [
"Me"
],
"Date": 43,
"Elderberry": {
"Fig": "abc123",
"Grape": {}
},
"Huckleberry": [3029774971578],
"Imbe": 1
}, null, 4),
expectedOutput: "1203596f75202b2a0a0a06616263313233120031ba32a96cc1020000",
recipeConfig: [
{
"op": "Protobuf Encode",
"args": [
`message Test {
optional string Banana = 2;
optional int32 Date = 4;
optional subTest Elderberry = 5;
repeated fixed64 Huckleberry = 6;
}
message subTest {
optional string Fig = 1;
optional subSubTest Grape = 2;
}
message subSubTest {}
enum Options {
Option0 = 0;
Option1 = 1;
Option2 = 2;
}`
]
},
{
"op": "To Hex",
"args": [
"None",
0
]
}
]
},

View file

@ -0,0 +1,22 @@
/**
* RAKE, Rapid Automatic Keyword Extraction tests.
*
* @author sw5678
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
"name": "RAKE: Basic Example",
"input": "test1 test2. test2",
"expectedOutput": "Scores: , Keywords: \n3.5, test1 test2\n1.5, test2",
"recipeConfig": [
{
"op": "RAKE",
"args": ["\\s", "\\.\\s|\\n", "i,me,my,myself,we,our"]
},
],
}
]);

View file

@ -0,0 +1,350 @@
/**
* RSA tests.
*
* @author Matt C [me@mitt.dev]
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
import {ASCII_TEXT, UTF8_TEXT, ALL_BYTES} from "../../samples/Ciphers.mjs";
const PEM_PRIV_2048 = `-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAwfaUOpUEutKyU3wkCv6kYunz4MqxzSuTSckRz1IxwZtwIiqq
+ejkM6ioXPyGadfFNvG0JVOgr1q4KQglq0vXaYG57HZ8iinXnHgy1vr8i+fWYITB
RMrEDySaQh3sxVj8NudPDoTIxZwUcIUu/N53pUmI08ADxXPA+ZymPyZhZyxrj5Jq
2O2QuRu+R7K44NDweP/rETbGo5+QAPydm6UqBzTky/ohv6EGhjyqnaskTWwLWK6P
dKva8rEMb8nNJvhoTJDLYUfNjB7DFnWxgWuR/KVkXGAHX99J/wh6QTS+bsyJ2/Mw
Df6NWdh3iP7msLNl/GqL+HunhHjrthvvWlODDwIDAQABAoIBAApKwLvJC3q0UmUO
qcTxlRxwiJHNf5jA7qxUIH9NP7mju1P8ypy/KFi7Ys+oUKOOIPdU5Pe0E8sqN6pp
tcH8oL4G9awf72TPapLxZ9UzdTIhR6VQdgbl8XhSO2M1vkoMejmZlX7SOesOaKE9
1+vwDA43tCx0PF7+UOeN0d549WMphvw3VkSInO/MYpobCGra4YdrhYOhFMyLEGgA
zCyVUOxi538tyyFtK2EEQdcMtvVA6SECjF4xD/qrme0LelIj/L1Uhiu+SOzYt4y+
QLHL6zhJVfOejWxjeI7BhodkTV2D53n4svfizRgyYEb6iLPW3nlMYIlAksYaxxB9
nR3sMHECgYEA9RU+8J5A8RnBcwnlc2X1xEW2PN7+A1MeWPQwFqRwIokgvGbCtwjG
PwwNUYJCTBhfGhsISeCBOSYrDGTHsNH+tqFW2zlq61BolYl56jb1KgWzMOX8dak4
sgXIuBbvyuFNk08VMIzwcA76ka/Iuu/nN9ZOM2UYpdpGG+CTOoIFULECgYEAyppm
I+yAtrUn/BFmwmC8va4vqXlBFjvdkfX/71ywCpHIouLucMV7bILJu0nSCpmL1A7R
DT6qo0p5g+Dxl/+O2VyC5D89PBvcuT1+HtEZGLOoKZnojbSrwDApGbzQi57GoQR6
/SRjsdAmoelY8PFz2s2ZLJ4NkrZXYvkT1Tu8/78CgYEA4MAvC/HUlEWORbTZmk3y
Z5+WU5QbVWkv91tXjiwWOVWPk7aY8ck2JDMlM45ExgvDiuknXLhpSMNbzu3MwraQ
42JpiHjLOChxAFEmYEct5O99OGZwcmZQ+9CaFVfTZzXeMizfvbpB9EGIP3n4lpXS
cD4zUKZxSAc3K/FyksERpsECgYEAhQPXeVBltQ68oKaAE6/VWqcIjbiY/dLyBkk+
7dSpk1bhJefdadaN0NERRtARgXoLrn7Hy21QNILJwsaldwiGrbgqC1Zlipg0Ur3H
ls3rLyeMiTuNzbNHa5dy9H3dYT0t5Tr+0EHa3jvtkTGVfiLX0FhZb0yZVrA2MTmc
RsvAqxsCgYAgXy4qytgfzo5/bBt306NbtMEW3dWBWF77HAz4N1LynKZRUrAAK4rz
BVmXFUaNQOg0q8WJG+iFF79u2UnL8iZ5GoPMcpvifsZgef1OHnQnFrfyXSr0fXIm
xq8eZS0DpLvKGffCW03B9VDRHanE37Tng8lbgOtaufuVzFa1bCuLUA==
-----END RSA PRIVATE KEY-----`;
const PEM_PUB_2048 = `-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwfaUOpUEutKyU3wkCv6k
Yunz4MqxzSuTSckRz1IxwZtwIiqq+ejkM6ioXPyGadfFNvG0JVOgr1q4KQglq0vX
aYG57HZ8iinXnHgy1vr8i+fWYITBRMrEDySaQh3sxVj8NudPDoTIxZwUcIUu/N53
pUmI08ADxXPA+ZymPyZhZyxrj5Jq2O2QuRu+R7K44NDweP/rETbGo5+QAPydm6Uq
BzTky/ohv6EGhjyqnaskTWwLWK6PdKva8rEMb8nNJvhoTJDLYUfNjB7DFnWxgWuR
/KVkXGAHX99J/wh6QTS+bsyJ2/MwDf6NWdh3iP7msLNl/GqL+HunhHjrthvvWlOD
DwIDAQAB
-----END PUBLIC KEY-----`;
TestRegister.addTests([
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-1, nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-1"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-1"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-1, ASCII",
input: ASCII_TEXT,
expectedOutput: ASCII_TEXT,
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-1"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-1"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-1, UTF-8",
input: UTF8_TEXT.substr(0, 100),
expectedOutput: UTF8_TEXT.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-1"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-1"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-1, All bytes",
input: ALL_BYTES.substr(0, 100),
expectedOutput: ALL_BYTES.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-1"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-1"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/MD5, nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "MD5"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "MD5"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/MD5, ASCII",
input: ASCII_TEXT,
expectedOutput: ASCII_TEXT,
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "MD5"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "MD5"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/MD5, UTF-8",
input: UTF8_TEXT.substr(0, 100),
expectedOutput: UTF8_TEXT.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "MD5"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "MD5"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/MD5, All bytes",
input: ALL_BYTES.substr(0, 100),
expectedOutput: ALL_BYTES.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "MD5"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "MD5"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-256, nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-256"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-256"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-256, ASCII",
input: ASCII_TEXT,
expectedOutput: ASCII_TEXT,
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-256"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-256"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-256, UTF-8",
input: UTF8_TEXT.substr(0, 100),
expectedOutput: UTF8_TEXT.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-256"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-256"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-256, All bytes",
input: ALL_BYTES.substr(0, 100),
expectedOutput: ALL_BYTES.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-256"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-256"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-384, nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-384"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-384"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-384, ASCII",
input: ASCII_TEXT,
expectedOutput: ASCII_TEXT,
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-384"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-384"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-384, UTF-8",
input: UTF8_TEXT.substr(0, 80),
expectedOutput: UTF8_TEXT.substr(0, 80),
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-384"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-384"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-384, All bytes",
input: ALL_BYTES.substr(0, 100),
expectedOutput: ALL_BYTES.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-384"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-384"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-512, nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-512"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-512"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-512, ASCII",
input: ASCII_TEXT.substr(0, 100),
expectedOutput: ASCII_TEXT.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-512"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-512"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-512, UTF-8",
input: UTF8_TEXT.substr(0, 60),
expectedOutput: UTF8_TEXT.substr(0, 60),
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-512"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-512"]
}
]
},
{
name: "RSA Encrypt/Decrypt: RSA-OAEP/SHA-512, All bytes",
input: ALL_BYTES.substr(0, 100),
expectedOutput: ALL_BYTES.substr(0, 100),
recipeConfig: [
{
"op": "RSA Encrypt",
"args": [PEM_PUB_2048, "RSA-OAEP", "SHA-512"]
},
{
"op": "RSA Decrypt",
"args": [PEM_PRIV_2048, "", "RSA-OAEP", "SHA-512"]
}
]
},
]);

View file

@ -0,0 +1,177 @@
/**
* @author mikecat
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Rabbit: RFC Test vector, without IV 1",
input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
expectedOutput: "b15754f036a5d6ecf56b45261c4af70288e8d815c59c0c397b696c4789c68aa7f416a1c3700cd451da68d1881673d696",
recipeConfig: [
{
"op": "Rabbit",
"args": [
{"option": "Hex", "string": "00000000000000000000000000000000"},
{"option": "Hex", "string": ""},
"Big", "Hex", "Hex"
]
}
]
},
{
name: "Rabbit: RFC Test vector, without IV 2",
input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
expectedOutput: "3d2df3c83ef627a1e97fc38487e2519cf576cd61f4405b8896bf53aa8554fc19e5547473fbdb43508ae53b20204d4c5e",
recipeConfig: [
{
"op": "Rabbit",
"args": [
{"option": "Hex", "string": "912813292e3d36fe3bfc62f1dc51c3ac"},
{"option": "Hex", "string": ""},
"Big", "Hex", "Hex"
]
}
]
},
{
name: "Rabbit: RFC Test vector, without IV 3",
input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
expectedOutput: "0cb10dcda041cdac32eb5cfd02d0609b95fc9fca0f17015a7b7092114cff3ead9649e5de8bfc7f3f924147ad3a947428",
recipeConfig: [
{
"op": "Rabbit",
"args": [
{"option": "Hex", "string": "8395741587e0c733e9e9ab01c09b0043"},
{"option": "Hex", "string": ""},
"Big", "Hex", "Hex"
]
}
]
},
{
name: "Rabbit: RFC Test vector, with IV 1",
input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
expectedOutput: "c6a7275ef85495d87ccd5d376705b7ed5f29a6ac04f5efd47b8f293270dc4a8d2ade822b29de6c1ee52bdb8a47bf8f66",
recipeConfig: [
{
"op": "Rabbit",
"args": [
{"option": "Hex", "string": "00000000000000000000000000000000"},
{"option": "Hex", "string": "0000000000000000"},
"Big", "Hex", "Hex"
]
}
]
},
{
name: "Rabbit: RFC Test vector, with IV 2",
input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
expectedOutput: "1fcd4eb9580012e2e0dccc9222017d6da75f4e10d12125017b2499ffed936f2eebc112c393e738392356bdd012029ba7",
recipeConfig: [
{
"op": "Rabbit",
"args": [
{"option": "Hex", "string": "00000000000000000000000000000000"},
{"option": "Hex", "string": "c373f575c1267e59"},
"Big", "Hex", "Hex"
]
}
]
},
{
name: "Rabbit: RFC Test vector, with IV 3",
input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
expectedOutput: "445ad8c805858dbf70b6af23a151104d96c8f27947f42c5baeae67c6acc35b039fcbfc895fa71c17313df034f01551cb",
recipeConfig: [
{
"op": "Rabbit",
"args": [
{"option": "Hex", "string": "00000000000000000000000000000000"},
{"option": "Hex", "string": "a6eb561ad2f41727"},
"Big", "Hex", "Hex"
]
}
]
},
{
name: "Rabbit: generated stream should be XORed with the input",
input: "cedda96c054e3ddd93da7ed05e2a4b7bdb0c00fe214f03502e2708b2c2bfc77aa2311b0b9af8aa78d119f92b26db0a6b",
expectedOutput: "7f8afd9c33ebeb3166b13bf64260bc7953e4d8ebe4d30f69554e64f54b794ddd5627bac8eaf47e290b7128a330a8dcfd",
recipeConfig: [
{
"op": "Rabbit",
"args": [
{"option": "Hex", "string": "00000000000000000000000000000000"},
{"option": "Hex", "string": ""},
"Big", "Hex", "Hex"
]
}
]
},
{
name: "Rabbit: least significant bits should be used for the last block",
input: "0000000000000000",
expectedOutput: "f56b45261c4af702",
recipeConfig: [
{
"op": "Rabbit",
"args": [
{"option": "Hex", "string": "00000000000000000000000000000000"},
{"option": "Hex", "string": ""},
"Big", "Hex", "Hex"
]
}
]
},
{
name: "Rabbit: invalid key length",
input: "",
expectedOutput: "Invalid key length: 8 bytes (expected: 16)",
recipeConfig: [
{
"op": "Rabbit",
"args": [
{"option": "Hex", "string": "0000000000000000"},
{"option": "Hex", "string": ""},
"Big", "Hex", "Hex"
]
}
]
},
{
name: "Rabbit: invalid IV length",
input: "",
expectedOutput: "Invalid IV length: 4 bytes (expected: 0 or 8)",
recipeConfig: [
{
"op": "Rabbit",
"args": [
{"option": "Hex", "string": "00000000000000000000000000000000"},
{"option": "Hex", "string": "00000000"},
"Big", "Hex", "Hex"
]
}
]
},
{
// this testcase is taken from the first example on Crypto++ Wiki
// https://www.cryptopp.com/wiki/Rabbit
name: "Rabbit: little-endian mode (Crypto++ compatible)",
input: "Rabbit stream cipher test",
expectedOutput: "1ae2d4edcf9b6063b00fd6fda0b223aded157e77031cf0440b",
recipeConfig: [
{
"op": "Rabbit",
"args": [
{"option": "Hex", "string": "23c2731e8b5469fd8dabb5bc592a0f3a"},
{"option": "Hex", "string": "712906405ef03201"},
"Little", "Raw", "Hex"
]
}
]
},
]);

View file

@ -60,6 +60,10 @@ TestRegister.addTests([
"string": "$R0"
},
"CTR", "Hex", "Raw",
{
"option": "Hex",
"string": ""
},
{
"option": "Hex",
"string": ""

View file

@ -1,22 +0,0 @@
/**
* Remove Diacritics tests.
*
* @author Klaxon [klaxon@veyr.com]
* @copyright Crown Copyright 2017
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Remove Diacritics",
input: "\xe0, \xe8, \xec, \xf2, \xf9 \xc0, \xc8, \xcc, \xd2, \xd9\n\xe1, \xe9, \xed, \xf3, \xfa, \xfd \xc1, \xc9, \xcd, \xd3, \xda, \xdd\n\xe2, \xea, \xee, \xf4, \xfb \xc2, \xca, \xce, \xd4, \xdb\n\xe3, \xf1, \xf5 \xc3, \xd1, \xd5\n\xe4, \xeb, \xef, \xf6, \xfc, \xff \xc4, \xcb, \xcf, \xd6, \xdc, \u0178\n\xe5, \xc5",
expectedOutput: "a, e, i, o, u A, E, I, O, U\na, e, i, o, u, y A, E, I, O, U, Y\na, e, i, o, u A, E, I, O, U\na, n, o A, N, O\na, e, i, o, u, y A, E, I, O, U, Y\na, A",
recipeConfig: [
{
"op": "Remove Diacritics",
"args": []
},
],
},
]);

View file

@ -0,0 +1,66 @@
/**
* @author sg5506844 [sg5506844@gmail.com]
* @copyright Crown Copyright 2021
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Rison Encode: Encoding example 1",
input: JSON.stringify({ any: "json", yes: true }),
expectedOutput: "(any:json,yes:!t)",
recipeConfig: [
{
op: "Rison Encode",
args: ["Encode"]
}
]
},
{
name: "Rison Encode: Encoding example 2",
input: JSON.stringify({ supportsObjects: true, ints: 435 }),
expectedOutput: "ints:435,supportsObjects:!t",
recipeConfig: [
{
op: "Rison Encode",
args: ["Encode Object"]
}
]
},
{
name: "Rison Encode: Encoding example 3",
input: JSON.stringify(["A", "B", { supportsObjects: true }]),
expectedOutput: "A,B,(supportsObjects:!t)",
recipeConfig: [
{
op: "Rison Encode",
args: ["Encode Array"]
}
]
},
{
name: "Rison Encode: Object for an array",
input: JSON.stringify({ supportsObjects: true, ints: 435 }),
expectedOutput: "Rison Encode - rison.encode_array expects an array argument",
expectedError: "Rison Encode - rison.encode_array expects an array argument",
recipeConfig: [
{
op: "Rison Encode",
args: ["Encode Array"]
}
]
},
{
name: "Rison Decode: Decoding example 1",
input: "(any:json,yes:!t)",
expectedOutput: JSON.stringify({ any: "json", yes: true }, null, 4),
recipeConfig: [
{
op: "Rison Decode",
args: ["Decode"]
}
]
}
]);

View file

@ -131,7 +131,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "ROT13",
args: [true, true, 13]
args: [true, true, true, 13]
},
],
},
@ -142,7 +142,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "ROT13",
args: [true, true, 13]
args: [true, true, true, 13]
},
],
},
@ -153,7 +153,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "ROT13",
args: [true, true, 26]
args: [true, true, true, 26]
},
],
},
@ -164,7 +164,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "ROT13",
args: [true, false, 13]
args: [true, false, false, 13]
},
],
},
@ -175,7 +175,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "ROT13",
args: [false, true, 13]
args: [false, true, false, 13]
},
],
},
@ -212,4 +212,37 @@ TestRegister.addTests([
},
],
},
{
name: "ROT8000: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
op: "ROT8000",
args: []
},
],
},
{
name: "ROT8000: normal",
input: "The Quick Brown Fox Jumped Over The Lazy Dog.",
expectedOutput: "籝籱籮 籚籾籲籬籴 籋类籸粀籷 籏籸粁 籓籾籶籹籮籭 籘籿籮类 籝籱籮 籕籪粃粂 籍籸籰簷",
recipeConfig: [
{
op: "ROT8000",
args: []
},
],
},
{
name: "ROT8000: backward",
input: "籝籱籮 籚籾籲籬籴 籋类籸粀籷 籏籸粁 籓籾籶籹籮籭 籘籿籮类 籝籱籮 籕籪粃粂 籍籸籰簷",
expectedOutput: "The Quick Brown Fox Jumped Over The Lazy Dog.",
recipeConfig: [
{
op: "ROT8000",
args: []
},
],
},
]);

View file

@ -0,0 +1,91 @@
/**
* SIGABA machine tests
*
* @author hettysymes
* @copyright hettysymes 2020
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "SIGABA: encrypt test 1",
input: "HELLO WORLD TESTING THE SIGABA MACHINE",
expectedOutput: "ULBECJCZJBJFVUDWAVRGRBMPSQHOTTNVQEESKN",
recipeConfig: [
{
"op": "SIGABA",
"args": [
"BHKWECJDOVAYLFMITUGXRNSPZQ", true, "G",
"CDTAKGQOZXLVJYHSWMIBPRUNEF", false, "L",
"WAXHJZMBVDPOLTUYRCQFNSGKEI", false, "I",
"HUSCWIMJQXDALVGBFTOYZKRPNE", false, "T",
"RTLSMNKXFVWQUZGCHEJBYDAIPO", false, "B",
"GHAQBRJWDMNZTSKLOUXYPFIECV", false, "N",
"VFLGEMTCXZIQDYAKRPBONHWSUJ", true, "Q",
"ZQCAYHRJNXPFLKIOTBUSVWMGDE", false, "B",
"EZVSWPCTULGAOFDJNBIYMXKQHR", false, "J",
"ELKSGDXMVYJUZNCAROQBPWHITF", false, "R",
"3891625740", "3",
"6297135408", "1",
"2389715064", "8",
"9264351708", "6",
"9573086142", "6",
"Encrypt"
]
}
]
},
{
name: "SIGABA: encrypt test 2",
input: "PCRPJZWSPNOHMWANBFBEIVZOXDQESPYDEFBNTHXLSICIRPKUATJVDUQFLZOKGHHHDUDIBRKUHVCGAGLBWVGFFXNDHKPFSPSCIIPCXUFRRHNYWIJFEJWQSGMSNJHWSLPKVXHUQUWIURHDIHIUTWGQFIYLTKEZAUESWYEKIWXUSSXWXBEHCXCUDQWKCISVPKXJVPOIJZWTUGKAORBMKBAQUZOPTSUSYZRROWQUYKNCLHVIHEGWCCONGVHEKCEXVYIPNILIXTXDELNGLJGMEQKKQJWZLPNXPOGIOSVAEAJYKWYJXXGKKPLVYAZGDCMNHMPLCYWDQSRBEMVVVZVFYJMRYGHJOTDOEQVRQOVXOGOVYGTXETFHAYELRYVDGWOFVGAOWPMHQYRZMNXVTAHWSKZLJDFVQPZGMHZWFNOBHSZHEDAEXIFCEEJYZDOEFOQWCXTKPJRUEITKHVCITCLKBUFNAFBYXELAYPBRGGGOCCAGLXXJXTSWCJHMHQPVUIBAGBDKAGEEEPKRGGICJQXSYHBNNAKGYODRAUWAEYHWCKHEQIBAONWQJYQCIFKDTOCTJMBJULWKMSNNMPXINHZQWUMJQLQKIPVZVRGYPCJJZMENWTFTUSPCSPRXHMZPCHCNQTUDCOUJHRKYQIUWWVEVVRYFDIYRQISNGPMQLNMCNMVBEWHNCUODHAGEVEUMKVZLEIKYAMPGVVSBYNRJMFCATDXTQCYXIBCXXKYEYHHYERQGQWZTWCEJBFQLRFFCIVVSZUKGLOTLNGLQNTIKTBBWVFMONUFKRLCJASEKUEEDDQDIVQMFRSJRNHYZJODFHSCJSDAIRUXOSDNFUFUFMNZYQIEGRUXKUPCHENUEZHRKYHDRJYSHLZNYRBWVXORMJMJRIRNSAJQRUMPCXUDFYRGKEAXQXJHPEWNIYIDURDGWIFEMSOFYYCFRZGMZXJNTLTJBBSZIULQSOMEVGCTCVXUHTIEHSPOPQYCJLPAJAPQPAQXE",
expectedOutput: "GMEXPPCMFGKUVGXZHVTCKXRSTJUYWNOKFVELWAHHSJBXGOEXCMLOVSIMCDMGEYMWWTFDUMCDUJEZITNPVVBGQDJEVHJXSKJAAUZWBELMSPUTXCUYPDTJCQXEBGWPWRSQLSNFMASCTJZDSFNKDDTAXLRGUPKCBNXMZPADJSFGGNYKRPYBNTYPTGVPACBEINILNACWFVKMJPGCEZFROEYYKTGYSQYMFSGVDOJJONNYEYSCCIXWLKUSJZDRVAQSNUWHMDJVDNNMPGOYRGQRSBGSPQKGCTFZQWSOXBWSQZDCRQJQAWZDPQEILGMMABIMCDPNSKAFCLPQGIRJCMGQREBEUHBYREXFABFMVZTZBDUMASVNUMHIYRSZLGNZFMVAIABLCUZLJLKKZPWEXDHYZFVSNRLCLNDRKLKSWRHQVQJRTHCNFZXDEXSLAXXOGMFVSGCJGAWOLGDMTLWSFNTCUVCCEACINRZAZZOGLEHHXLPHVKILBBJDPOOCILQKKGODSXOBDPZZDXHJLLBOBVFCHJVMUBUZZIKGCWGCYGXVEHHIJGPEQERWEZLILQNHPHALFKFMGADNELGBKILKIUETGDCBQUEOECWVFNOXTJKUYPWBNEKYSIKMVSAMBZGLIKDAOELRSTKFASEKABTUCPSFEGXXQGDFPSPVOLBHGLZSLLWCABSRKZDQQRKVCKXDGTIHPDNMPDZEXYFYKXZTPJPLYOFNLWAGKJEOHOYLMZELXIDWWNXPKEPUCKNNNHJLFYHPQNHMMCGMUPHSUSYYIVWTIMFKKKTFPGFTLTWWSQBRBMGBTZXPVULKNZIIKVTYLJFISGPTLZFTCLGNZOMVKZOIMUDGXRDDSVFRHRYWBEWHYLCUISYMRWAZZAQPJYXZQQKZLILOSHXUTQJFPTXQSREKSUDZTLGUDLUGOJMQHJRJHXCHQTKJULTWWQOXIRFRQEYBPJPEKXFIRMNATWNFBADOSIJVZYRYDBHDAEDJUVDHLDAU",
recipeConfig: [
{ "op": "SIGABA",
"args": [
"YCHLQSUGBDIXNZKERPVJTAWFOM", true, "A",
"INPXBWETGUYSAOCHVLDMQKZJFR", false, "B",
"WNDRIOZPTAXHFJYQBMSVEKUCGL", false, "C",
"TZGHOBKRVUXLQDMPNFWCJYEIAS", false, "D",
"YWTAHRQJVLCEXUNGBIPZMSDFOK", true, "E",
"QSLRBTEKOGAICFWYVMHJNXZUDP", false, "F",
"CHJDQIGNBSAKVTUOXFWLEPRMZY", false, "G",
"CDFAJXTIMNBEQHSUGRYLWZKVPO", true, "H",
"XHFESZDNRBCGKQIJLTVMUOYAPW", false, "I",
"EZJQXMOGYTCSFRIUPVNADLHWBK", false, "J",
"7591482630", "0",
"3810592764", "1",
"4086153297", "2",
"3980526174", "3",
"6497135280", "4",
"Encrypt"]
}
]
},
{
name: "SIGABA: decrypt test",
input: "AKDHFWAYSLHJDKXEVMJJHGKFTQBZPJPJILOVHMBYOAGBZVLLTQUOIKXFPUFNILBDPCAELMAPSXTLMUEGSDTNUDWGZDADBFELWWHKVPRZNDATDPYEHIDMTGAGPDEZYXFSASVKSBMXVOJQXRMHDBWUNZDTIIIVKHJYPIEUHAJCNBXNLGVFADEWIKXDJZBUTGOQBCQZWYKRVEENWRWWRYDNOAPGMODTPTUJZCLUCRDILJABNTBTWUEIJSJRQBUVCOUJJDWFMNNUHXBDFYXLGUMXQEAWSVHBXQGEOOGPYRVOAJLAIYIOHHEXACDTAWWCBGQRNPERSIKHTXPXKBUNACZLFZTRBMBBDDGKNBIQMFHZROCZZBGNZSJKDRRWPEQHLCFADNPWPWSLPIFNKBWQPMARUERGWUUODXSCOJQECGHIZRFRNRSXWSFWKISHHTUFRVXLHCQWGBMRDHCYDSVNIDDRSTODCGJSSBLUYOBGEWFOVKOZBJTYCAKMZECUGLJGTSZJNBOLTMUZRRSIGGRQHLRPMGLINASSMZOBNACKUMSFNIZAUFCPFXXOOTJQWWLZOFLGZLHJCWZJCRJKVOUDLNMKQATGVTOFHACAEKFLRWRTTMVRXHYGOTYPNBMUSKDAKXFCICUOVSWXGPQOYUUWTWRPQMEQCSDJMMJKELIHGEDYKWOVHVPUAIBFGAODXODXVFIIZIGWRZSBTIGXVHFABMMOPGVMLGHQQXNOEJRDLOBGUOWSELBHERZFSBLUODMOGIBNVGVGQYDBTKLOPNKZZNGLTTGZYYXIBAHZJDCILZXKNSJDHXWTYQLFHTUINTYSBPIXOPLOQHSAHGQPYUWYNPKMRBBBYIICCBBJRKWVLBIDBBEKJCXHLPUBMIGBUFYDPOCSRUNZOKMKJHMYFJZWFNHQZOGGRTNNUVLMRLDSAJIECTYCJKBYVNAXGCMGNVFJEDSATZQDQTYRBPLZKHAXMOVJZEDKINXKBUVWXXHTYUFO",
expectedOutput: "KTSOYDGMLPMVXEAJIATXCNQFXHBNCBXIJOCQGCQBRQSBYFOOEVPVXACBMIUIRNVMJHREKRHBSXJFSMWCKTTCYXJOFSJCQECXXCHTEGPEYSMYDHCSMODUAVBNLILYUIBBIXJCXXNQPCERRSMJTPQLMOXSKTRPWOFUSWXOYRJLBIJGIOYTEAEJEGGYAGSXNHNQTETANPWEGATHSBFLHCVHVIJUAKDVGQCWUSIFFFVAJYPJAFUYDXSLGPGESOUAYXBQIIOXWTXNOXLNCGWSUKVIBMOUGNHORYLSNVNNJLKKFDUAEISOLBLCXYHMDGVBVVVIKDLTMTDVWWJBXWXROVTJBXXKXLEWTTISKIUMYSACVUGGNANMCGUMFNQUXDLTHJNYTFIQEPKQQQSSROYJOILJYQXICXACWGOHCSHENXJILOMIIFCIOUDXDCINIVKIRJCVHWXSFQXMNRBJJWTPXNJADEOPEJBLKHKXNTORIRVRLXUXXAMKMODBXNLQCVJXVOTBRHXBBVJHPFEQFCRXYRRXHXPTXXSUESUTHUGOWQYQPQFPXQPVGEIRPQNKXXMBHIPECRUWFEWJUTYIKSMJSRQIQAIAMXTGDXSJIABHIGKUPJBCHWMVYTMQNQYGDHCNMBSVTPXNFRELFXXQYIOLCDEXDXDVSINICOXRMNSPICPQMOBIDJCNBJKXFAVMUXOXHERJIBIXLMXXULDXKXXHAQDXEXIWXOEEUGKSUGCMRWJDPYCYKXTPCOXMURAJCPRXKFJAJALERWRHVMFHOGMFHXGSXQDPJCJNXRQFGHKRCYTEBJDHPCMYFEAPWSVVMMBVUJJMCAAYURHUPVQVJYDCSNMQEMNIFEXYXIIXBVRVILXAUCBDXRJHGPKPYXHPPPNVSBBCDRLVVIYPKAKYIXTJVYDGVPHXULWMADBEICNIFKWUOOHEFNANDKOXMCVBVORLQYNXLULOEGVGWNKNMOHYVRSYSOVYGAKCGAWKGAIAQNQR",
recipeConfig: [
{ "op": "SIGABA",
"args": [
"YCHLQSUGBDIXNZKERPVJTAWFOM", true, "A",
"INPXBWETGUYSAOCHVLDMQKZJFR", false, "B",
"WNDRIOZPTAXHFJYQBMSVEKUCGL", false, "C",
"TZGHOBKRVUXLQDMPNFWCJYEIAS", false, "D",
"YWTAHRQJVLCEXUNGBIPZMSDFOK", true, "E",
"QSLRBTEKOGAICFWYVMHJNXZUDP", false, "F",
"CHJDQIGNBSAKVTUOXFWLEPRMZY", false, "G",
"CDFAJXTIMNBEQHSUGRYLWZKVPO", true, "H",
"XHFESZDNRBCGKQIJLTVMUOYAPW", false, "I",
"EZJQXMOGYTCSFRIUPVNADLHWBK", false, "J",
"7591482630", "0",
"3810592764", "1",
"4086153297", "2",
"3980526174", "3",
"6497135280", "4",
"Decrypt"]
}
]
}
]);

View file

@ -0,0 +1,279 @@
/**
* SM4 crypto tests.
*
* Test data used from IETF draft-ribose-cfrg-sm4-09, see:
* https://tools.ietf.org/id/draft-ribose-cfrg-sm4-09.html
*
* @author swesven
* @copyright 2021
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
/* Cleartexts */
const TWO_BLOCK_PLAIN = "aa aa aa aa bb bb bb bb cc cc cc cc dd dd dd dd ee ee ee ee ff ff ff ff aa aa aa aa bb bb bb bb";
const FOUR_BLOCK_PLAIN = "aa aa aa aa aa aa aa aa bb bb bb bb bb bb bb bb cc cc cc cc cc cc cc cc dd dd dd dd dd dd dd dd ee ee ee ee ee ee ee ee ff ff ff ff ff ff ff ff aa aa aa aa aa aa aa aa bb bb bb bb bb bb bb bb";
/* Keys */
const KEY_1 = "01 23 45 67 89 ab cd ef fe dc ba 98 76 54 32 10";
const KEY_2 = "fe dc ba 98 76 54 32 10 01 23 45 67 89 ab cd ef";
/* IV */
const IV = "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f";
/* Ciphertexts */
const ECB_1 = "5e c8 14 3d e5 09 cf f7 b5 17 9f 8f 47 4b 86 19 2f 1d 30 5a 7f b1 7d f9 85 f8 1c 84 82 19 23 04";
const ECB_2 = "c5 87 68 97 e4 a5 9b bb a7 2a 10 c8 38 72 24 5b 12 dd 90 bc 2d 20 06 92 b5 29 a4 15 5a c9 e6 00";
/* With PKCS#7 padding */
const ECB_1P ="5e c8 14 3d e5 09 cf f7 b5 17 9f 8f 47 4b 86 19 2f 1d 30 5a 7f b1 7d f9 85 f8 1c 84 82 19 23 04 00 2a 8a 4e fa 86 3c ca d0 24 ac 03 00 bb 40 d2";
const ECB_2P= "c5 87 68 97 e4 a5 9b bb a7 2a 10 c8 38 72 24 5b 12 dd 90 bc 2d 20 06 92 b5 29 a4 15 5a c9 e6 00 a2 51 49 20 93 f8 f6 42 89 b7 8d 6e 8a 28 b1 c6";
const CBC_1 = "78 eb b1 1c c4 0b 0a 48 31 2a ae b2 04 02 44 cb 4c b7 01 69 51 90 92 26 97 9b 0d 15 dc 6a 8f 6d";
const CBC_2 = "0d 3a 6d dc 2d 21 c6 98 85 72 15 58 7b 7b b5 9a 91 f2 c1 47 91 1a 41 44 66 5e 1f a1 d4 0b ae 38";
const OFB_1 = "ac 32 36 cb 86 1d d3 16 e6 41 3b 4e 3c 75 24 b7 1d 01 ac a2 48 7c a5 82 cb f5 46 3e 66 98 53 9b";
const OFB_2 = "5d cc cd 25 a8 4b a1 65 60 d7 f2 65 88 70 68 49 33 fa 16 bd 5c d9 c8 56 ca ca a1 e1 01 89 7a 97";
const CFB_1 = "ac 32 36 cb 86 1d d3 16 e6 41 3b 4e 3c 75 24 b7 69 d4 c5 4e d4 33 b9 a0 34 60 09 be b3 7b 2b 3f";
const CFB_2 = "5d cc cd 25 a8 4b a1 65 60 d7 f2 65 88 70 68 49 0d 9b 86 ff 20 c3 bf e1 15 ff a0 2c a6 19 2c c5";
const CTR_1 = "ac 32 36 cb 97 0c c2 07 91 36 4c 39 5a 13 42 d1 a3 cb c1 87 8c 6f 30 cd 07 4c ce 38 5c dd 70 c7 f2 34 bc 0e 24 c1 19 80 fd 12 86 31 0c e3 7b 92 6e 02 fc d0 fa a0 ba f3 8b 29 33 85 1d 82 45 14";
const CTR_2 = "5d cc cd 25 b9 5a b0 74 17 a0 85 12 ee 16 0e 2f 8f 66 15 21 cb ba b4 4c c8 71 38 44 5b c2 9e 5c 0a e0 29 72 05 d6 27 04 17 3b 21 23 9b 88 7f 6c 8c b5 b8 00 91 7a 24 88 28 4b de 9e 16 ea 29 06";
TestRegister.addTests([
{
name: "SM4 Encrypt: ECB 1, No padding",
input: TWO_BLOCK_PLAIN,
expectedOutput: ECB_1,
recipeConfig: [
{
"op": "SM4 Encrypt",
"args": [{string: KEY_1, option: "Hex"}, {string: "", option: "Hex"}, "ECB/NoPadding", "Hex", "Hex"]
}
]
},
{
name: "SM4 Encrypt: ECB 2, No padding",
input: TWO_BLOCK_PLAIN,
expectedOutput: ECB_2,
recipeConfig: [
{
"op": "SM4 Encrypt",
"args": [{string: KEY_2, option: "Hex"}, {string: "", option: "Hex"}, "ECB/NoPadding", "Hex", "Hex"]
}
]
},
{
name: "SM4 Encrypt: ECB 1, With padding",
input: TWO_BLOCK_PLAIN,
expectedOutput: ECB_1P,
recipeConfig: [
{
"op": "SM4 Encrypt",
"args": [{string: KEY_1, option: "Hex"}, {string: "", option: "Hex"}, "ECB", "Hex", "Hex"]
}
]
},
{
name: "SM4 Encrypt: ECB 2, With padding",
input: TWO_BLOCK_PLAIN,
expectedOutput: ECB_2P,
recipeConfig: [
{
"op": "SM4 Encrypt",
"args": [{string: KEY_2, option: "Hex"}, {string: "", option: "Hex"}, "ECB", "Hex", "Hex"]
}
]
},
{
name: "SM4 Encrypt: CBC 1",
input: TWO_BLOCK_PLAIN,
expectedOutput: CBC_1,
recipeConfig: [
{
"op": "SM4 Encrypt",
"args": [{string: KEY_1, option: "Hex"}, {string: IV, option: "Hex"}, "CBC/NoPadding", "Hex", "Hex"]
}
]
},
{
name: "SM4 Encrypt: CBC 2",
input: TWO_BLOCK_PLAIN,
expectedOutput: CBC_2,
recipeConfig: [
{
"op": "SM4 Encrypt",
"args": [{string: KEY_2, option: "Hex"}, {string: IV, option: "Hex"}, "CBC/NoPadding", "Hex", "Hex"]
}
]
},
{
name: "SM4 Encrypt: OFB1",
input: TWO_BLOCK_PLAIN,
expectedOutput: OFB_1,
recipeConfig: [
{
"op": "SM4 Encrypt",
"args": [{string: KEY_1, option: "Hex"}, {string: IV, option: "Hex"}, "OFB", "Hex", "Hex"]
}
]
},
{
name: "SM4 Encrypt: OFB2",
input: TWO_BLOCK_PLAIN,
expectedOutput: OFB_2,
recipeConfig: [
{
"op": "SM4 Encrypt",
"args": [{string: KEY_2, option: "Hex"}, {string: IV, option: "Hex"}, "OFB", "Hex", "Hex"]
}
]
},
{
name: "SM4 Encrypt: CFB1",
input: TWO_BLOCK_PLAIN,
expectedOutput: CFB_1,
recipeConfig: [
{
"op": "SM4 Encrypt",
"args": [{string: KEY_1, option: "Hex"}, {string: IV, option: "Hex"}, "CFB", "Hex", "Hex"]
}
]
},
{
name: "SM4 Encrypt: CFB2",
input: TWO_BLOCK_PLAIN,
expectedOutput: CFB_2,
recipeConfig: [
{
"op": "SM4 Encrypt",
"args": [{string: KEY_2, option: "Hex"}, {string: IV, option: "Hex"}, "CFB", "Hex", "Hex"]
}
]
},
{
name: "SM4 Encrypt: CTR1",
input: FOUR_BLOCK_PLAIN,
expectedOutput: CTR_1,
recipeConfig: [
{
"op": "SM4 Encrypt",
"args": [{string: KEY_1, option: "Hex"}, {string: IV, option: "Hex"}, "CTR", "Hex", "Hex"]
}
]
},
{
name: "SM4 Encrypt: CTR1",
input: FOUR_BLOCK_PLAIN,
expectedOutput: CTR_2,
recipeConfig: [
{
"op": "SM4 Encrypt",
"args": [{string: KEY_2, option: "Hex"}, {string: IV, option: "Hex"}, "CTR", "Hex", "Hex"]
}
]
},
{
name: "SM4 Decrypt: ECB 1",
input: ECB_1,
expectedOutput: TWO_BLOCK_PLAIN,
recipeConfig: [
{
"op": "SM4 Decrypt",
"args": [{string: KEY_1, option: "Hex"}, {string: "", option: "Hex"}, "ECB/NoPadding", "Hex", "Hex"]
}
]
},
{
name: "SM4 Decrypt: ECB 2",
input: ECB_2,
expectedOutput: TWO_BLOCK_PLAIN,
recipeConfig: [
{
"op": "SM4 Decrypt",
"args": [{string: KEY_2, option: "Hex"}, {string: "", option: "Hex"}, "ECB/NoPadding", "Hex", "Hex"]
}
]
},
{
name: "SM4 Decrypt: CBC 1",
input: CBC_1,
expectedOutput: TWO_BLOCK_PLAIN,
recipeConfig: [
{
"op": "SM4 Decrypt",
"args": [{string: KEY_1, option: "Hex"}, {string: IV, option: "Hex"}, "CBC/NoPadding", "Hex", "Hex"]
}
]
},
{
name: "SM4 Decrypt: CBC 2",
input: CBC_2,
expectedOutput: TWO_BLOCK_PLAIN,
recipeConfig: [
{
"op": "SM4 Decrypt",
"args": [{string: KEY_2, option: "Hex"}, {string: IV, option: "Hex"}, "CBC/NoPadding", "Hex", "Hex"]
}
]
},
{
name: "SM4 Decrypt: OFB1",
input: TWO_BLOCK_PLAIN,
expectedOutput: OFB_1,
recipeConfig: [
{
"op": "SM4 Decrypt",
"args": [{string: KEY_1, option: "Hex"}, {string: IV, option: "Hex"}, "OFB", "Hex", "Hex"]
}
]
},
{
name: "SM4 Decrypt: OFB2",
input: OFB_2,
expectedOutput: TWO_BLOCK_PLAIN,
recipeConfig: [
{
"op": "SM4 Decrypt",
"args": [{string: KEY_2, option: "Hex"}, {string: IV, option: "Hex"}, "OFB", "Hex", "Hex"]
}
]
},
{
name: "SM4 Decrypt: CFB1",
input: CFB_1,
expectedOutput: TWO_BLOCK_PLAIN,
recipeConfig: [
{
"op": "SM4 Decrypt",
"args": [{string: KEY_1, option: "Hex"}, {string: IV, option: "Hex"}, "CFB", "Hex", "Hex"]
}
]
},
{
name: "SM4 Decrypt: CFB2",
input: CFB_2,
expectedOutput: TWO_BLOCK_PLAIN,
recipeConfig: [
{
"op": "SM4 Decrypt",
"args": [{string: KEY_2, option: "Hex"}, {string: IV, option: "Hex"}, "CFB", "Hex", "Hex"]
}
]
},
{
name: "SM4 Decrypt: CTR1",
input: CTR_1,
expectedOutput: FOUR_BLOCK_PLAIN,
recipeConfig: [
{
"op": "SM4 Decrypt",
"args": [{string: KEY_1, option: "Hex"}, {string: IV, option: "Hex"}, "CTR", "Hex", "Hex"]
}
]
},
{
name: "SM4 Decrypt: CTR1",
input: CTR_2,
expectedOutput: FOUR_BLOCK_PLAIN,
recipeConfig: [
{
"op": "SM4 Decrypt",
"args": [{string: KEY_2, option: "Hex"}, {string: IV, option: "Hex"}, "CTR", "Hex", "Hex"]
}
]
},
]);

View file

@ -0,0 +1,76 @@
/**
* Salsa20 tests.
*
* @author joostrijneveld [joost@joostrijneveld.nl]
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Salsa20: no key",
input: "",
expectedOutput: `Invalid key length: 0 bytes.
Salsa20 uses a key of 16 or 32 bytes (128 or 256 bits).`,
recipeConfig: [
{
"op": "Salsa20",
"args": [
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
0, "20", "Hex", "Hex",
]
}
],
},
{
name: "Salsa20: no nonce",
input: "",
expectedOutput: `Invalid nonce length: 0 bytes.
Salsa20 uses a nonce of 8 bytes (64 bits).`,
recipeConfig: [
{
"op": "Salsa20",
"args": [
{"option": "Hex", "string": "00000000000000000000000000000000"},
{"option": "Hex", "string": ""},
0, "20", "Hex", "Hex",
]
}
],
},
{
name: "Salsa20: ECRYPT Set 1 vector# 0",
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
expectedOutput: "e3 be 8f dd 8b ec a2 e3 ea 8e f9 47 5b 29 a6 e7 00 39 51 e1 09 7a 5c 38 d2 3b 7a 5f ad 9f 68 44 b2 2c 97 55 9e 27 23 c7 cb bd 3f e4 fc 8d 9a 07 44 65 2a 83 e7 2a 9c 46 18 76 af 4d 7e f1 a1 17 8d a2 b7 4e ef 1b 62 83 e7 e2 01 66 ab ca e5 38 e9 71 6e 46 69 e2 81 6b 6b 20 c5 c3 56 80 20 01 cc 14 03 a9 a1 17 d1 2a 26 69 f4 56 36 6d 6e bb 0f 12 46 f1 26 51 50 f7 93 cd b4 b2 53 e3 48 ae 20 3d 89 bc 02 5e 80 2a 7e 0e 00 62 1d 70 aa 36 b7 e0 7c b1 e7 d5 b3 8d 5e 22 2b 8b 0e 4b 84 07 01 42 b1 e2 95 04 76 7d 76 82 48 50 32 0b 53 68 12 9f dd 74 e8 61 b4 98 e3 be 8d 16 f2 d7 d1 69 57 be 81 f4 7b 17 d9 ae 7c 4f f1 54 29 a7 3e 10 ac f2 50 ed 3a 90 a9 3c 71 13 08 a7 4c 62 16 a9 ed 84 cd 12 6d a7 f2 8e 8a bf 8b b6 35 17 e1 ca 98 e7 12 f4 fb 2e 1a 6a ed 9f dc 73 29 1f aa 17 95 82 11 c4 ba 2e bd 58 38 c6 35 ed b8 1f 51 3a 91 a2 94 e1 94 f1 c0 39 ae ec 65 7d ce 40 aa 7e 7c 0a f5 7c ac ef a4 0c 9f 14 b7 1a 4b 34 56 a6 3e 16 2e c7 d8 d1 0b 8f fb 18 10 d7 10 01 b6 18 2f 9f 73 da 53 b8 54 05 c1 1f 7b 2d 89 0f a8 ae 0c 7f 2e 92 6d 8a 98 c7 ec 4e 91 b6 51 20 e9 88 34 96 31 a7 00 c6 fa ce c3 47 1c b0 41 36 56 e7 5e 30 94 56 58 40 84 d7 e1 2c 5b 43 a4 1c 43 ed 9a 04 8a bd 9b 88 0d a6 5f 6a 66 5a 20 fe 7b 77 cd 29 2f e6 2c ae 64 4b 7f 7d f6 9f 32 bd b3 31 90 3e 65 05 ce 44 fd c2 93 92 0c 6a 9e c7 05 7e 23 df 7d ad 29 8f 82 dd f4 ef b7 fd c7 bf c6 22 69 6a fc fd 0c dd cc 83 c7 e7 7f 11 a6 49 d7 9a cd c3 35 4e 96 35 ff 13 7e 92 99 33 a0 bd 6f 53 77 ef a1 05 a3 a4 26 6b 7c 0d 08 9d 08 f1 e8 55 cc 32 b1 5b 93 78 4a 36 e5 6a 76 cc 64 bc 84 77",
recipeConfig: [
{
"op": "Salsa20",
"args": [
{"option": "Hex", "string": "80:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"},
{"option": "Hex", "string": "00:00:00:00:00:00:00:00"},
0, "20", "Hex", "Hex",
]
}
],
},
{
name: "Salsa20: ECRYPT Set 6 vector# 3",
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
expectedOutput: "71 da ee 51 42 d0 72 8b 41 b6 59 79 33 eb f4 67 e4 32 79 e3 09 78 67 70 78 94 16 02 62 9c bf 68 b7 3d 6b d2 c9 5f 11 8d 2b 3e 6e c9 55 da bb 6d c6 1c 41 43 bc 9a 9b 32 b9 9d be 68 66 16 6d c0 86 31 b7 d6 55 30 50 30 3d 72 52 c2 64 d3 a9 0d 26 c8 53 63 48 13 e0 9a d7 54 5a 6c e7 e8 4a 5d fc 75 ec 43 43 12 07 d5 31 99 70 b0 fa ad b0 e1 51 06 25 bb 54 37 2c 85 15 e2 8e 2a cc f0 a9 93 0a d1 5f 43 18 74 92 3d 2a 59 e2 0d 9f 2a 53 67 db a6 05 15 64 f1 50 28 7d eb b1 db 53 6f f9 b0 9a d9 81 f2 5e 50 10 d8 5d 76 ee 0c 30 5f 75 5b 25 e6 f0 93 41 e0 81 2f 95 c9 4f 42 ee ad 34 6e 81 f3 9c 58 c5 fa a2 c8 89 53 dc 0c ac 90 46 9d b2 06 3c b5 cd b2 2c 9e ae 22 af bf 05 06 fc a4 1d c7 10 b8 46 fb df e3 c4 68 83 dd 11 8f 3a 5e 8b 11 b6 af d9 e7 16 80 d8 66 65 57 30 1a 2d aa fb 94 96 c5 59 78 4d 35 a0 35 36 08 85 f9 b1 7b d7 19 19 77 de ea 93 2b 98 1e bd b2 90 57 ae 3c 92 cf ef f5 e6 c5 d0 cb 62 f2 09 ce 34 2d 4e 35 c6 96 46 cc d1 4e 53 35 0e 48 8b b3 10 a3 2f 8b 02 48 e7 0a cc 5b 47 3d f5 37 ce d3 f8 1a 01 4d 40 83 93 2b ed d6 2e d0 e4 47 b6 76 6c d2 60 4b 70 6e 9b 34 6c 44 68 be b4 6a 34 ec f1 61 0e bd 38 33 1d 52 bf 33 34 6a fe c1 5e ef b2 a7 69 9e 87 59 db 5a 1f 63 6a 48 a0 39 68 8e 39 de 34 d9 95 df 9f 27 ed 9e dc 8d d7 95 e3 9e 53 d9 d9 25 b2 78 01 05 65 ff 66 52 69 04 2f 05 09 6d 94 da 34 33 d9 57 ec 13 d2 fd 82 a0 06 62 83 d0 d1 ee b8 1b f0 ef 13 3b 7f d9 02 48 b8 ff b4 99 b2 41 4c d4 fa 00 30 93 ff 08 64 57 5a 43 74 9b f5 96 02 f2 6c 71 7f a9 6b 1d 05 76 97 db 08 eb c3 fa 66 4a 01 6a 67 dc ef 88 07 57 7c c3 a0 93 85 d3",
recipeConfig: [
{
"op": "Salsa20",
"args": [
{"option": "Hex", "string": "0F:62:B5:08:5B:AE:01:54:A7:FA:4D:A0:F3:46:99:EC"},
{"option": "Hex", "string": "28:8F:F6:5D:C4:2B:92:F9"},
0, "20", "Hex", "Hex",
]
}
],
},
]);

View file

@ -0,0 +1,54 @@
/**
* @author mikecat
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
"name": "Shuffle empty",
"input": "",
"expectedOutput": "",
"recipeConfig": [
{
"op": "Shuffle",
"args": ["Comma"]
}
]
},
{
"name": "Shuffle bytes",
"input": "12345678",
"expectedOutput": "31 32 33 34 35 36 37 38",
"recipeConfig": [
{
"op": "Shuffle",
"args": ["Nothing (separate chars)"]
},
{
"op": "To Hex",
"args": ["Space", 0]
},
{
"op": "Sort",
"args": ["Space", false, "Alphabetical (case sensitive)"]
}
]
},
{
"name": "Shuffle lines",
"input": "1\n2\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\ne\nf\n",
"expectedOutput": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\ne\nf",
"recipeConfig": [
{
"op": "Shuffle",
"args": ["Line feed"]
},
{
"op": "Sort",
"args": ["Line feed", false, "Alphabetical (case sensitive)"]
}
]
}
]);

View file

@ -11,7 +11,7 @@ TestRegister.addTests([
{
name: "Diff, basic usage",
input: "testing23\n\ntesting123",
expectedOutput: "testing<span class='hl5'>1</span>23",
expectedOutput: "testing<ins>1</ins>23",
recipeConfig: [
{
"op": "Diff",
@ -22,7 +22,7 @@ TestRegister.addTests([
{
name: "Diff added with subtraction, basic usage",
input: "testing23\n\ntesting123",
expectedOutput: "<span class='hl5'>1</span>",
expectedOutput: "<ins>1</ins>",
recipeConfig: [
{
"op": "Diff",
@ -33,7 +33,7 @@ TestRegister.addTests([
{
name: "Diff removed with subtraction, basic usage",
input: "testing123\n\ntesting3",
expectedOutput: "<span class='hl3'>12</span>",
expectedOutput: "<del>12</del>",
recipeConfig: [
{
"op": "Diff",

View file

@ -0,0 +1,102 @@
/**
* Subsection Tests.
*
* @author n1073645 [n1073645@gmail.com]
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Subsection: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "Subsection",
"args": ["", true, true, false],
},
],
},
{
name: "Subsection, Full Merge: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "Subsection",
"args": ["", true, true, false],
},
{
"op": "Merge",
"args": [true],
},
],
},
{
name: "Subsection, Partial Merge: nothing",
input: "",
expectedOutput: "",
recipeConfig: [
{
"op": "Subsection",
"args": ["", true, true, false],
},
{
"op": "Merge",
"args": [false],
},
],
},
{
name: "Subsection, Full Merge: Base64 with Hex",
input: "SGVsbG38675629ybGQ=",
expectedOutput: "Hello World",
recipeConfig: [
{
"op": "Subsection",
"args": ["386756", true, true, false],
},
{
"op": "From Hex",
"args": ["Auto"],
},
{
"op": "Merge",
"args": [true],
},
{
"op": "From Base64",
"args": ["A-Za-z0-9+/=", true, false],
},
],
},
{
name: "Subsection, Partial Merge: Base64 with Hex surrounded by binary data.",
input: "000000000SGVsbG38675629ybGQ=0000000000",
expectedOutput: "000000000Hello World0000000000",
recipeConfig: [
{
"op": "Subsection",
"args": ["SGVsbG38675629ybGQ=", true, true, false],
},
{
"op": "Subsection",
"args": ["386756", true, true, false],
},
{
"op": "From Hex",
"args": ["Auto"],
},
{
"op": "Merge",
"args": [false],
},
{
"op": "From Base64",
"args": ["A-Za-z0-9+/=", true, false],
},
],
},
]);

View file

@ -0,0 +1,33 @@
/**
* @author mikecat
* @copyright Crown Copyright 2023
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
"name": "Swap Case: basic example",
"input": "Hello, World!",
"expectedOutput": "hELLO, wORLD!",
"recipeConfig": [
{
"op": "Swap case",
"args": [
],
},
],
},
{
"name": "Swap Case: empty input",
"input": "",
"expectedOutput": "",
"recipeConfig": [
{
"op": "Swap case",
"args": [
],
},
],
},
]);

View file

@ -1,55 +0,0 @@
/**
* 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

@ -0,0 +1,55 @@
/**
* UnescapeString tests.
*
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "UnescapeString: escape sequences",
input: "\\a\\b\\f\\n\\r\\t\\v\\'\\\"",
expectedOutput: String.fromCharCode(0x07, 0x08, 0x0c, 0x0a, 0x0d, 0x09,
0x0b, 0x27, 0x22),
recipeConfig: [
{
op: "Unescape string",
args: [],
},
],
},
{
name: "UnescapeString: octals",
input: "\\0\\01\\012\\1\\12",
expectedOutput: String.fromCharCode(0, 1, 10, 1, 10),
recipeConfig: [
{
op: "Unescape string",
args: [],
},
],
},
{
name: "UnescapeString: hexadecimals",
input: "\\x00\\xAA\\xaa",
expectedOutput: String.fromCharCode(0, 170, 170),
recipeConfig: [
{
op: "Unescape string",
args: [],
},
],
},
{
name: "UnescapeString: unicode",
input: "\\u0061\\u{0062}",
expectedOutput: "ab",
recipeConfig: [
{
op: "Unescape string",
args: [],
},
],
},
]);

View file

@ -0,0 +1,83 @@
/**
* Unicode operation tests.
*
* @author Matt C [me@mitt.dev]
* @author Klaxon [klaxon@veyr.com]
*
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Unicode Text Format: underline",
input: "a",
expectedOutput: "a\u0332",
recipeConfig: [
{
"op": "Unicode Text Format",
"args": [true, false],
}
],
},
{
name: "Unicode Text Format: strikethrough",
input: "a",
expectedOutput: "a\u0336",
recipeConfig: [
{
"op": "Unicode Text Format",
"args": [false, true],
}
],
},
{
name: "Unicode Text Format: both",
input: "a",
expectedOutput: "a\u0336\u0332",
recipeConfig: [
{
"op": "Unicode Text Format",
"args": [true, true],
}
],
},
{
name: "Remove Diacritics: text formatting",
input: "a",
expectedOutput: "a",
recipeConfig: [
{
"op": "Unicode Text Format",
"args": [true, true],
},
{
"op": "Remove Diacritics",
"args": []
}
],
},
{
name: "Remove Diacritics: all diacritical marks one char",
input: "à̴̵̶̷̸̡̢̧̨̛̖̗̘̙̜̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̱̲̳̹̺̻̼́̂̃̄̅̆̇̈̉̊̋̌̍̎̏̐̑̒̓̔̽̾̿̀́͂̓̈́̕̚͠͡ͅ", // sorry about this line lol
expectedOutput: "a",
recipeConfig: [
{
"op": "Remove Diacritics",
"args": []
}
],
},
{
name: "Remove Diacritics: default",
input: "\xe0, \xe8, \xec, \xf2, \xf9 \xc0, \xc8, \xcc, \xd2, \xd9\n\xe1, \xe9, \xed, \xf3, \xfa, \xfd \xc1, \xc9, \xcd, \xd3, \xda, \xdd\n\xe2, \xea, \xee, \xf4, \xfb \xc2, \xca, \xce, \xd4, \xdb\n\xe3, \xf1, \xf5 \xc3, \xd1, \xd5\n\xe4, \xeb, \xef, \xf6, \xfc, \xff \xc4, \xcb, \xcf, \xd6, \xdc, \u0178\n\xe5, \xc5",
expectedOutput: "a, e, i, o, u A, E, I, O, U\na, e, i, o, u, y A, E, I, O, U, Y\na, e, i, o, u A, E, I, O, U\na, n, o A, N, O\na, e, i, o, u, y A, E, I, O, U, Y\na, A",
recipeConfig: [
{
"op": "Remove Diacritics",
"args": []
},
],
},
]);

View file

@ -0,0 +1,61 @@
/**
* XSalsa20 tests.
*
* @author joostrijneveld [joost@joostrijneveld.nl]
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "XSalsa20: no key",
input: "",
expectedOutput: `Invalid key length: 0 bytes.
XSalsa20 uses a key of 16 or 32 bytes (128 or 256 bits).`,
recipeConfig: [
{
"op": "XSalsa20",
"args": [
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
0, "20", "Hex", "Hex",
]
}
],
},
{
name: "XSalsa20: no nonce",
input: "",
expectedOutput: `Invalid nonce length: 0 bytes.
XSalsa20 uses a nonce of 24 bytes (192 bits).`,
recipeConfig: [
{
"op": "XSalsa20",
"args": [
{"option": "Hex", "string": "00000000000000000000000000000000"},
{"option": "Hex", "string": ""},
0, "20", "Hex", "Hex",
]
}
],
},
{
name: "XSalsa20 custom vector",
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
expectedOutput: "7c b6 60 af dd 9e c6 46 8f 57 dd 6d 24 33 f9 34 28 fd 82 cd 73 86 c5 47 1a 24 d8 ad 2a 52 5b 6e 5e ff 38 4f c7 ca a2 10 bb 3c 8f 3e 68 8f 4a 97 52 a5 46 df 8c 25 3f ef 17 a2 67 94 55 c7 a1 e1 83 db f5 d5 45 b0 f5 02 b9 8d e0 99 7a 66 ab 43 23 41 68 9f f3 97 dc 4f bc 1f 27 bd 1a 61 97 f5 dc 80 ff 19 05 16 c9 ed 14 f2 81 d1 ca 73 88 82 f6 d3 d2 fb 92 1e 2e f8 99 38 9e 0a 22 3b e7 ae 81 5a 04 86 5f 82 52 68 2f 6a d1 4f 98 ff 5f 08 23 cc 22 9d d2 22 9e 69 9d c2 1a 81 7d c9 54 bb 9b c9 0d ec 3b 9b d3 bf 20 9b 82 da f7 89 34 8a 5e 14 ec 54 2b 6d ee 8b 60 1e 7e 6d e3 c2 8a 2d 57 b6 25 e7 ea b3 43 d8 eb 20 85 b6 f6 82 09 58 99 35 20 44 22 60 60 61 d2 8d e9 8b ea 58 af bf ba ad 70 03 98 19 a0 c3 9a a8 63 94 47 5c d0 61 94 b0 17 ab c4 bb 28 b7 56 6d 3c 66 1c 76 f4 8a d3 a3 a2 9e d3 36 df 1f c6 8b 4f 44 2f 06 a3 58 0b ae c8 06 e2 e6 5d 39 ab 18 28 fe 80 18 12 69 2c 60 34 b5 0b f5 f3 3c 51 fc 0c fb 43 82 1e 3e 92 d6 b8 06 cf 00 16 e3 49 a0 34 83 20 f9 b0 53 7e ad ac 4a c1 36 5f cc fb be e2 ba 5a ad 1d 29 74 07 19 34 61 0e 9d ce 84 60 24 6a e6 8d ed 50 e0 20 44 26 d8 76 6d f2 da 4b 12 72 5a 85 c2 b1 07 04 f5 10 2e 3c 67 1c 5a fc 5b 46 0e 4d fb 39 b6 10 73 22 47 84 10 93 df 5f c8 92 7e 87 c3 0d 24 3a 48 b2 ad c2 56 3d a2 22 e9 02 9c 58 64 c6 d5 a5 f8 c6 54 99 1c 0f 6b f3 db ed 81 16 85 28 17 b0 eb 11 c7 05 9f f9 d8 fc 4a 1c 36 db 16 fd 38 d8 32 34 5b 8c 80 c6 51 21 1d 91 01 c5 8a 60 ad a4 39 33 d5 32 9a c1 f5 b2 ab 20 46 75 db 63 e0 bd d2 97 c0 e9 fc 1c d9 17 4a d1 3a db ea c2 8c 46 22 21 c3 5a bf 6c 1e cf 28 9c 8c 2f b2 0f",
recipeConfig: [
{
"op": "XSalsa20",
"args": [
{"option": "Hex", "string": "00:01:02:03:04:05:06:07:08:09:0A:0B:0C:0D:0E:0F:10:11:12:13:14:15:16:17:18:19:1A:1B:1C:1D:1E:1F"},
{"option": "Hex", "string": "00:01:02:03:04:05:06:07:08:09:0A:0B:0C:0D:0E:0F:10:11:12:13:14:15:16:17"},
0, "20", "Hex", "Hex",
]
}
],
}
]);

View file

@ -8,6 +8,22 @@
*/
import TestRegister from "../../lib/TestRegister.mjs";
const CONSOLE_COMPILE_WARNING_RULE = `import "console"
rule a
{
strings:
$s=" "
condition:
$s and console.log("log rule a")
}
rule b
{
strings:
$s=" "
condition:
$s and console.hex("log rule b: int8(0)=", int8(0))
}`;
TestRegister.addTests([
{
name: "YARA Match: simple foobar",
@ -20,5 +36,56 @@ TestRegister.addTests([
}
],
},
{
name: "YARA Match: hashing rules",
input: "Hello World!",
expectedOutput: "Input matches rule \"HelloWorldMD5\".\nInput matches rule \"HelloWorldSHA256\".\n",
recipeConfig: [
{
"op": "YARA Rules",
"args": [
`import "hash"
rule HelloWorldMD5 {
condition:
hash.md5(0,filesize) == "ed076287532e86365e841e92bfc50d8c"
}
rule HelloWorldSHA256 {
condition:
hash.sha256(0,filesize) == "7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069"
}`,
true, true, true, true, false, false
],
}
],
},
{
name: "YARA Match: compile warnings",
input: "CyberChef Yara",
expectedOutput: "Warning on line 5: string \"$s\" may slow down scanning\n" +
"Warning on line 12: string \"$s\" may slow down scanning\n" +
"Input matches rule \"a\".\n" +
"Input matches rule \"b\".\n",
recipeConfig: [
{
"op": "YARA Rules",
"args": [CONSOLE_COMPILE_WARNING_RULE, false, false, false, false, true, false],
}
],
},
{
name: "YARA Match: console messages",
input: "CyberChef Yara",
expectedOutput: "log rule a\n" +
"log rule b: int8(0)=0x43\n" +
"Input matches rule \"a\".\n" +
"Input matches rule \"b\".\n",
recipeConfig: [
{
"op": "YARA Rules",
"args": [CONSOLE_COMPILE_WARNING_RULE, false, false, false, false, false, true],
}
],
},
]);

31
tests/samples/Ciphers.mjs Normal file
View file

@ -0,0 +1,31 @@
/**
* Various types of input data for use in tests
*
* @author n1474335 [n1474335@gmail.com]
* @author Matt C [me@mitt.dev]
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
export const ASCII_TEXT = "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.";
export const UTF8_TEXT = "Шанцы на высвятленне таго, што адбываецца на самай справе ў сусвеце настолькі выдаленыя, адзінае, што трэба зрабіць, гэта павесіць пачуццё яго і трымаць сябе занятымі.";
export const ALL_BYTES = [
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f",
"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f",
"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f",
"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f",
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f",
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf",
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
].join("");

View file

@ -0,0 +1,375 @@
/**
* Executables in various formats for use in tests.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2022
* @license Apache-2.0
*/
/**
* ---------------ELF Header---------------
* 7f454c46 - Magic: .ELF
* 01 - Format: 32 bit
* 01 - Endianness: Little
* 01 - ELF Version: 1
* 00 - Target ABI: System V
* 00 - ABI Version: 0
* 00000000000000 - Padding
* 0200 - File Type: Executable File
* 0300 - ISA: x86
* 01000000 - ELF Version: 1
* 50210608 - Entry Point: 0x8062150
* 34000000 - PH Offset: 0x34
* 54000000 - SH Offset: 0x54
* 00000000 - Flags: 0
* 3400 - ELF Header Size: 0x34
* 2000 - PH Header Size: 0x20
* 0100 - PH Entries: 1
* 2800 - SH Size: 0x28
* 0300 - SH Entries: 0x3
* 0000 - SH Names Offset: 0x0
*
* -------------Program Header-------------
* 06000000 - PH Type: Program Header Table
* 34000000 - Segment Offset: 0x34
* 34800408 - VAddr of segment: 134512692
* 34800408 - PAddr of segment: 134512692
* 00010000 - Size of segment: 256
* 00010000 - Size of segment: 256
* 05000000 - Flags: Execute,Read
* 04000000 - Alignment
*
* --------------SH .shstrtab--------------
* 00000000 - SH Name Offset: 0
* 03000000 - SH Type: String Table
* 00000000 - Flags:
* 00000000 - VAddr of section: 0
* cc000000 - Section offset: 204
* 1c000000 - Section size: 28
* 00000000 - Associated: 0
* 00000000 - Extra Info: 0
* 00000000 - Alignment
* 00000000 - Entry Size: 0
*
* ---------------SH .symtab---------------
* 09000000 - SH Name Offset: 9
* 02000000 - SH Type: Symbol Table
* 00000000 - Flags:
* 00000000 - VAddr of section: 0
* e6000000 - Section offset: 230
* 10000000 - Section size: 16
* 00000000 - Associated: 0
* 00000000 - Extra Info: 0
* 00000000 - Alignment
* 10000000 - Entry Size: 16
*
* ---------------SH .strtab---------------
* 11000000 - SH Name Offset: 17
* 03000000 - SH Type: String Table
* 00000000 - Flags:
* 00000000 - VAddr of section: 0
* f5000000 - Section offset: 245
* 04000000 - Section size: 4
* 00000000 - Associated: 0
* 00000000 - Extra Info: 0
* 00000000 - Alignment
* 00000000 - Entry Size: 0
*
* ---------------.shstrtab---------------
* 2e73687374726162002e73796d746162002e73747274616200 - .shstrab\0.symtab\0.strtab\0
*
* ----------------.symtab----------------
* 00000000 - Name Offset: 0
* 00000000 - Value: 0
* 00000000 - Size: 0
* 00 - Info
* 00 - other
* 0000 - shdx
*
* ----------------.strtab----------------
* 74657374 - test
*/
export const ELF32_LE = "7f454c46010101000000000000000000020003000100000050210608340000005400000000000000340020000100280003000000" +
"0600000034000000348004083480040800010000000100000500000004000000" +
"00000000030000000000000000000000cc0000001c00000000000000000000000000000000000000" +
"09000000020000000000000000000000e60000001000000000000000000000000000000010000000" +
"11000000030000000000000000000000f50000000400000000000000000000000000000000000000" +
"2e73687374726162002e73796d746162002e73747274616200" +
"00000000000000000000000000000000" +
"74657374";
/**
* ---------------ELF Header---------------
* 7f454c46 - Magic: .ELF
* 01 - Format: 32 bit
* 02 - Endianness: Big
* 01 - ELF Version: 1
* 00 - Target ABI: System V
* 00 - ABI Version: 0
* 00000000000000 - Padding
* 0002 - File Type: Executable File
* 0003 - ISA: x86
* 00000001 - ELF Version: 1
* 08062150 - Entry Point: 0x8062150
* 00000034 - PH Offset: 0x34
* 00000054 - SH Offset: 0x54
* 00000000 - Flags: 0
* 0034 - ELF Header Size: 0x34
* 0020 - PH Header Size: 0x20
* 0001 - PH Entries: 1
* 0028 - SH Size: 0x28
* 0003 - SH Entries: 0x3
* 0000 - SH Names Offset: 0x0
*
* -------------Program Header-------------
* 00000006 - PH Type: Program Header Table
* 00000034 - Segment Offset: 0x34
* 08048034 - VAddr of segment: 134512692
* 08048034 - PAddr of segment: 134512692
* 00000100 - Size of segment: 256
* 00000100 - Size of segment: 256
* 00000005 - Flags: Execute,Read
* 00000004 - Alignment
*
* --------------SH .shstrtab--------------
* 00000000 - SH Name Offset: 0
* 00000003 - SH Type: String Table
* 00000000 - Flags:
* 00000000 - VAddr of section: 0
* 000000cc - Section offset: 204
* 0000001c - Section size: 28
* 00000000 - Associated: 0
* 00000000 - Extra Info: 0
* 00000000 - Alignment
* 00000000 - Entry Size: 0
*
* ---------------SH .symtab---------------
* 00000009 - SH Name Offset: 9
* 00000002 - SH Type: Symbol Table
* 00000000 - Flags:
* 00000000 - VAddr of section: 0
* 000000e6 - Section offset: 230
* 00000010 - Section size: 16
* 00000000 - Associated: 0
* 00000000 - Extra Info: 0
* 00000000 - Alignment
* 00000010 - Entry Size: 16
*
* ---------------SH .strtab---------------
* 00000011 - SH Name Offset: 17
* 00000003 - SH Type: String Table
* 00000000 - Flags:
* 00000000 - VAddr of section: 0
* 000000f5 - Section offset: 245
* 00000004 - Section size: 4
* 00000000 - Associated: 0
* 00000000 - Extra Info: 0
* 00000000 - Alignment
* 00000000 - Entry Size: 0
*
* ---------------.shstrtab---------------
* 2e73687374726162002e73796d746162002e73747274616200 - .shstrab\0.symtab\0.strtab\0
*
* ----------------.symtab----------------
* 00000000 - Name Offset: 0
* 00000000 - Value: 0
* 00000000 - Size: 0
* 00 - Info
* 00 - other
* 0000 - shdx
*
* ----------------.strtab----------------
* 74657374 - test
*/
export const ELF32_BE = "7f454c46010201000000000000000000000200030000000108062150000000340000005400000000003400200001002800030000" +
"0000000600000034080480340804803400000100000001000000000500000004" +
"00000000000000030000000000000000000000cc0000001c00000000000000000000000000000000" +
"00000009000000020000000000000000000000e60000001000000000000000000000000000000010" +
"00000011000000030000000000000000000000f50000000400000000000000000000000000000000" +
"2e73687374726162002e73796d746162002e73747274616200" +
"00000000000000000000000000000000" +
"74657374";
/**
* ---------------ELF Header---------------
* 7f454c46 - Magic: .ELF
* 02 - Format: 64 bit
* 01 - Endianness: Little
* 01 - ELF Version: 1
* 00 - Target ABI: System V
* 00 - ABI Version: 0
* 00000000000000 - Padding
* 0200 - File Type: Executable File
* 3e00 - ISA: AMD x86-64
* 01000000 - ELF Version: 1
* 5021060800000000 - Entry Point: 0x8062150
* 4000000000000000 - PH Offset: 0x40
* 7800000000000000 - SH Offset: 0x78
* 00000000 - Flags: 0
* 4000 - ELF Header Size: 0x40
* 3800 - PH Header Size: 0x38
* 0100 - PH Entries: 1
* 4000 - SH Size: 0x40
* 0300 - SH Entries: 0x3
* 0000 - SH Names Offset: 0x0
*
* -------------Program Header-------------
* 06000000 - PH Type: Program Header Table
* 05000000 - Flags: Execute,Read
* 3400000000000000 - Segment Offset: 0x34
* 3480040800000000 - VAddr of segment: 134512692
* 3480040800000000 - PAddr of segment: 134512692
* 0001000000000000 - Size of segment: 256
* 0001000000000000 - Size of segment: 256
* 0400000000000000 - Alignment
*
* --------------SH .shstrtab--------------
* 00000000 - SH Name Offset: 0
* 03000000 - SH Type: String Table
* 0000000000000000 - Flags:
* 0000000000000000 - VAddr of section: 0
* 3801000000000000 - Section offset: 312
* 1c00000000000000 - Section size: 28
* 00000000 - Associated: 0
* 00000000 - Extra Info: 0
* 0000000000000000 - Alignment
* 0000000000000000 - Entry Size: 0
*
* ---------------SH .symtab---------------
* 09000000 - SH Name Offset: 9
* 02000000 - SH Type: Symbol Table
* 0000000000000000 - Flags:
* 0000000000000000 - VAddr of section: 0
* 5001000000000000 - Section offset: 336
* 1000000000000000 - Section size: 16
* 00000000 - Associated: 0
* 00000000 - Extra Info: 0
* 0000000000000000 - Alignment
* 1800000000000000 - Entry Size: 24
*
* ---------------SH .strtab---------------
* 11000000 - SH Name Offset: 17
* 03000000 - SH Type: String Table
* 0000000000000000 - Flags:
* 0000000000000000 - VAddr of section: 0
* 6901000000000000 - Section offset: 361
* 0400000000000000 - Section size: 4
* 00000000 - Associated: 0
* 00000000 - Extra Info: 0
* 0000000000000000 - Alignment
* 0000000000000000 - Entry Size: 0
*
* ---------------.shstrtab---------------
* 2e73687374726162002e73796d746162002e73747274616200 - .shstrab\0.symtab\0.strtab\0
*
* ----------------.symtab----------------
* 00000000 - Name Offset: 0
* 00 - Info
* 00 - other
* 0000 - shdx
* 0000000000000000 - Value: 0
* 0000000000000000 - Size: 0
*
* ----------------.strtab----------------
* 74657374 - test
*/
export const ELF64_LE = "7f454c4602010100000000000000000002003e000100000050210608000000004000000000000000780000000000000000000000400038000100400003000000" +
"0600000005000000340000000000000034800408000000003480040800000000000100000000000000010000000000000400000000000000" +
"00000000030000000000000000000000000000000000000038010000000000001c00000000000000000000000000000000000000000000000000000000000000" +
"09000000020000000000000000000000000000000000000050010000000000001000000000000000000000000000000000000000000000001800000000000000" +
"11000000030000000000000000000000000000000000000069010000000000000400000000000000000000000000000000000000000000000000000000000000" +
"2e73687374726162002e73796d746162002e73747274616200" +
"000000000000000000000000000000000000000000000000" +
"74657374";
/**
* ---------------ELF Header---------------
* 7f454c46 - Magic: .ELF
* 02 - Format: 64 bit
* 02 - Endianness: Big
* 01 - ELF Version: 1
* 00 - Target ABI: System V
* 00 - ABI Version: 0
* 00000000000000 - Padding
* 0002 - File Type: Executable File
* 003e - ISA: AMD x86-64
* 00000001 - ELF Version: 1
* 0000000008062150 - Entry Point: 0x8062150
* 0000000000000040 - PH Offset: 0x40
* 0000000000000078 - SH Offset: 0x78
* 00000000 - Flags: 0
* 0040 - ELF Header Size: 0x40
* 0038 - PH Header Size: 0x38
* 0001 - PH Entries: 1
* 0040 - SH Size: 0x40
* 0003 - SH Entries: 0x3
* 0000 - SH Names Offset: 0x0
*
* -------------Program Header-------------
* 00000006 - PH Type: Program Header Table
* 00000005 - Flags: Execute,Read
* 0000000000000034 - Segment Offset: 0x34
* 0000000008048034 - VAddr of segment: 134512692
* 0000000008048034 - PAddr of segment: 134512692
* 0000000000000100 - Size of segment: 256
* 0000000000000100 - Size of segment: 256
* 0400000000000000 - Alignment
*
* --------------SH .shstrtab--------------
* 00000000 - SH Name Offset: 0
* 00000003 - SH Type: String Table
* 0000000000000000 - Flags:
* 0000000000000000 - VAddr of section: 0
* 0000000000000138 - Section offset: 312
* 000000000000001c - Section size: 28
* 00000000 - Associated: 0
* 00000000 - Extra Info: 0
* 0000000000000000 - Alignment
* 0000000000000000 - Entry Size: 0
*
* ---------------SH .symtab---------------
* 00000009 - SH Name Offset: 9
* 00000002 - SH Type: Symbol Table
* 0000000000000000 - Flags:
* 0000000000000000 - VAddr of section: 0
* 0000000000000150 - Section offset: 336
* 0000000000000010 - Section size: 16
* 00000000 - Associated: 0
* 00000000 - Extra Info: 0
* 0000000000000000 - Alignment
* 0000000000000018 - Entry Size: 24
*
* ---------------SH .strtab---------------
* 00000011 - SH Name Offset: 17
* 00000003 - SH Type: String Table
* 0000000000000000 - Flags:
* 0000000000000000 - VAddr of section: 0
* 0000000000000169 - Section offset: 361
* 0000000000000004 - Section size: 4
* 00000000 - Associated: 0
* 00000000 - Extra Info: 0
* 0000000000000000 - Alignment
* 0000000000000000 - Entry Size: 0
*
* ---------------.shstrtab---------------
* 2e73687374726162002e73796d746162002e73747274616200 - .shstrab\0.symtab\0.strtab\0
*
* ----------------.symtab----------------
* 00000000 - Name Offset: 0
* 00 - Info
* 00 - other
* 0000 - shdx
* 0000000000000000 - Value: 0
* 0000000000000000 - Size: 0
*
* ----------------.strtab----------------
* 74657374 - test
*/
export const ELF64_BE = "7f454c460202010000000000000000000002003e0000000100000000080621500000000000000040000000000000007800000000004000380001004000030000" +
"0000000600000005000000000000003400000000080480340000000008048034000000000000010000000000000001000400000000000000" +
"0000000000000003000000000000000000000000000000000000000000000138000000000000001c000000000000000000000000000000000000000000000000" +
"00000009000000020000000000000000000000000000000000000000000001500000000000000010000000000000000000000000000000000000000000000018" +
"00000011000000030000000000000000000000000000000000000000000001690000000000000004000000000000000000000000000000000000000000000000" +
"2e73687374726162002e73796d746162002e73747274616200" +
"000000000000000000000000000000000000000000000000" +
"74657374";

View file

@ -18,6 +18,18 @@ export const GIF_ANIMATED_HEX = "4749463839610f000f00b30b00424242ffe700ffef00ffc
*/
export const PNG_HEX = "89504e470d0a1a0a0000000d4948445200000020000000200806000000737a7af400000006624b474400ff00ff00ffa0bda793000000097048597300000dd700000dd70142289b78000005184944415458c3c5575d6c145514feeeccecccacdbddb6e096a5dbcdb6d06d80d06090466d6953454ab52ad0a65589840ac1d02a313c989af062820fa66210130d9a68b0363c34610135690b188b7183c13f44506c8115ba535ab6ddd2617f667f66ae0fb41596ddee2eadf13c4de69e7bcf77cff9cecf25b83f613b3b3b975b2c96f25028c47a3c9e1f5a5a5a7e05a0016000d0c9ef9442d23448a60edeb973a769c78e1d077272721a65594620106000505996bf1a1f1f3f67369bebc2e1f0ef6bd7aedd0a409d2d00e2743a1f2929296915046199a66901007aa3d1580600131313da24000000a594124288aaaab72a2b2bed1d1d1d8f8ba2386fc3860d9f25f3c84c0088cbe56a2d2c2cdc4708d12552880770a7288a3228088215003c1ecfd68d1b377e9e488f4b66dde974aeb2dbed498da71251146d538ed1b4e4746092dddee170b4300ca3c32c251c0edfd8bc79f3d164de4e0680110461794a02119292c482202c387efcf86f3d3d3d7b13814816024a2955e62a8b4451b4abaafad8e485d5743ca005028153699c4dd30c83140a857e4c9409c900a0bbbbfbc368343a34a3754a693a1c58b76eddf2dadada5d89002705b07bf7eee13367ce3cab284aff6c482808425e6767e70bc9ea0033d3e6c6c6c65fd6ac5953a1695a3453c3a150c84d295529a59aa669914cd3705adc6eb7926eaca74455d5605555d5c3030303f59224bd525f5f7f30992e87ff40344d5328a5caa64d9bbe4ca5cbe07f1666ae522dae40a5dd8ed30941c8e5727d63341a9f8a5f181a1ac2f0f07022029e02109d2b00bae2e26207cbb2f72cf03c8f9c9c9c441c580c804dc70b330258b6c020beb87ac9abecb59f8b087377b4f4f30a68b6de482549a29224ddb5168bc51cd5d5d54ff6f5f575cfa69633edeb971c78e2d195db055e77cfb6a2eaadb816e5b59ffafb19a7d3095555e3ab64341a8d96f6f6f6fe755f247c69d542abd9c0bd3c70f90a628c30fd5f56542c5c550fc3837600406e6e2eca9e2e433837fcefc0c8b2e079fe7b9fcfe7aba9a9296613c52f55084acc864a027013b28c828a2d30e805bcbe670fac4b5740f5a9285b18c6a0db4da8c180fdc6fdb035d850c555a174a4148410b85cae7293c97442a7d395363434347775757d91b6075a2a6c45d66ce18369258685de644659d96af45ff80345f9f908c932821313c4eff7639b6d1b06838358242c82d96c86288abe582ce6e6797e052184701c9797910796e61976b10c991fff7f7b5313b6373541d5340426d36f747414e5c67294679503a1e90634e6f57adbac56ebb14020f0e9a14387decf84038c8e232b53b45888dc6dec63636389d290c9caca5a3d09a6a2a6a6a628130054d33092a2c52272bbe4515996113f16288ab2c86432bd01001cc72db5582caf651202eaf5473e7e80d7af270409d9cb320c0c66331ca5a5602c1624180d492412392bcbf2db46a3f1394992f665c481b77a2f9f78e719476b5e16ff2e00d31dae8524cb30e8f560390ee72e5e243d7d7d34168bc16030a87575752ccbb20400a2d1e8b7478e1c390ce0f0fd5442fae6d7039f343d643956345f5fcbf1fafd00b219868145afc78d4b97101a1b833a32426d361bcdcfcf87cd6663a7a6649ee70725497a6faede86e4c2c993cf171716eee5753aeb9d0b7f5ebfae5df67a99b86164e8e6cd9badcdcdcdc7d27ae5a6a3f45147c7794dd30e2e59bcf896c0f3851ccbe602c0a8df4fc783413269d8130c06f79d3e7d7a4b5b5bdbd9b45b77c60304c3f0df75752db31714acf8dbe7cbbee2f5fafd7efff9f6f6f6b357af5e8d647ade3fa1780bad734c65970000000049454e44ae426082";
/**
* The CyberChef logo with 'chef'
* 32x32
*/
export const PNG_CHEF_B64 = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAH40lEQVR4AaXBfVAU5wEH4N/77t7ufXAnHlwE5MuK1uApVo1ppNBxgpJKKyijaewYJzRj0eokjBpbp3HQ0VpN1fqHndCxNkW4UWf8KHZaa0yR1hPH04QGGwm9Ata7KN/c5m5v9+52t8tIp1QPJOnzEHw5TF1dnTMlJWVxOBxmfD7fjY0bN34EQAVAAWgAVEwAwcQQABSAtmXLFltlZeW7iYmJqwVBQCgUogA0QRAuDg4OfuxwOEpkWW5dunRpBQAFT8FifOTcuXPPz5w5cxPP87mqqoYAmKxW63N4RMUjxGazrbBard8hOp7ncziOe7O2tnaJ0Wi0l5WVnQCgIg6CsRG3270pOzv7CCHEgDgCgYAaCoUo4pAk6T7P81Oh8/l8FStXrvwt4mAxhnPnzi3Myso6Qggx4EswGo0ZeERTVRVjoYiPzJgxYyOl1ID/kyzLPevWrbsAgCAOBvExVVVVOzmOm4pxRCIRRCIRgnGwLJvwim7NmjUZdXV17+MxLOLTdBKejmACjEZjlqIoLwCgABSMQhGfGgqFmvB0GiZAlmV/OBz2AFDxGAZjyMzMvOt0OtcyDGPFiEgkAkVRwDAMhkmSpEWjUYJxyLLcU1xcnHvixIkGABpGEEIM6enpLxCMkpOT82JpaenLHMc9IwiCv6CgoG3RokWbjUbjTOh4nofX60VGRgaGBQIBNRQKUTyFz+fbWFZW9i5GmM3m9IaGhsb8/PxsihHbtm071traeikpKYnz+/2fLFiwILu8vPwXBw4cOK+qahQ6RVGgaRomIhwOd2qapmiapuoiGKWiomJbZmbm5OTk5K+y0BUUFHx33759P8jLy1vW1tb2Z+hqa2vR3Ny87/Dhwzs7OjrgcDgwUYqiiIWFhQvq6+sLzGazY9WqVe9hlPLy8rzTp097QqFQBwPd3r17a65evfo3l8u1H6O0tbW17t69e3t7ezvsdjsopRgcHITZbEYoFMLQ0BCRJAkcx2E0SZKI3+9/0NXVNd3j8fR1dna2K4oSYxjGuH79+h8WFxcXWSwWo8Fg4BldQk1NzaHjx4//+s6dOzcwSjQaFevr6z+orKys4DgOlFLwPA+bzQZVVWGz2TB37lx4vV5wHIdhQ0NDcDqddP78+Xmpqal07dq1r5WUlKw6pSOEsOvWrdvtdDqn2e1229DQUCLL83xCcnKy2e/3P0QcXq/3I5PJFAHAQWe329HV1YXk5GQEAgH19u3b1OFwQBRFaJoGq9WKvr4+LF68+NlYLCZYrdYUj8fTunz58sqGhoZ3qqqqlsybN6/x8uXLgf3795dRAAQ6RVFUxBd2u90ftLS0QBAEeDwe+Hw+tLS0wO12w+PxIC0tDZcuXcLFixexcOFCnDp1CoqiRAkhfDAYHLxy5cq1/Pz8ZRiFUkqgY1VVVaBLSkqyIj5DTk7ODIZhYDQaYTAYkJSUhGEcx6Gvrw8Mw2DWrFkQRRGUUlRXV6O6ulrEKC6X60PEwcqyPHD37t3eaTo8JneKxfjW1jdD/X9vplMmGQHL10Gkz0EG22Gyp2uTTFbtQTQKTdPQ3t6uASDQ7dq1C263u+rmzZt/xIhYLCYjDqppWuzChQt/WLFixcuUUh7/Rb//0iLP+u17qfbwLqj3ryChASAcAPVeQ5rZTCwMQ6BTVRXNzc3k+vXriMVi0DQNZrP5YH5+PoLB4KeiKHZIktSFOCh0R48e/emcOXNSt27desxoNCZC99o3Zy158fUfO1uuN8LORPAfiqohdeEqWJKzMMxkMoFSCnmyDEIIampqsGHDBjgcDjqgW758+WKXy3WpqKhoC+Jgoevu7m4vLCz81smTJ3+zZ8+eXlEUowkWs+nTm024VrMTqzcfgsXE48N+AYMw45MBBc+lyrjf2UlgMCBGYugv70chWwj+Mx49PT2oqalhJEnq4TgObrcbN27ceBVxEIxCCGHT09Odq/JSv+ZMZk8YIgKkmIrVb52A3ZGK42fP4tqtW9j7xhuwMAyabt2CYDKhK7MLxx4ew9uOt5EdzkYwGBxobGy0chxngG5gYGCby+U6hBFTpkyZJkmSEggE/sXgf6mCIDz83mxrhZlGn4cupmqYnV8Kk8WK+bm5KCsqgsVsRkwQ0NndjR5RRK4lF6VcKRJjiRhGCPE1NTW9brFYXhEE4bjL5foJAA0jQqHQkCzLAegonkQNLJmPcciyDCPLYlh/fz8ep6oqTUhI+AZ0PM/nL1u2bBrGQPEkTVXRjXHwPI8IdIRogiBA0zSMJknSV2w223boWJZ9NiUlZTPGwOJJWm8wUmPmTKWEgEEcDKWwOByYMWcOaEoKCCF4DIlEIi2CIOy1Wq0r/H7/EYyBRRzVf/rn+z/79oxNzyRw7wCwYYSqqvALAiwmExiWxcdtbeTS1ataLBaDxWJRSkpKGB2BLhqNNp4/f/4sgLMYB4v4tB/9/h+/WjMv5XfTkkwvsZzpKIBJlFKkmEzo8XoR7u+H0t2tZWRkaGlpacjIyGCIDjqO4+77/f5DmAAW4zjT8rAbQO2rPb1yjtnyc85gmGrgeUydPRvDog8eaIm9vRSjKIrymSiKW5qamvyYAAYT8Mva2juqqr43a/r0z3mOy2YZZjJ0fcGgNiiKBDpFUXyiKB5pbm5ev2PHjhZMEMEXRCnl/nLmTG5Wenpe18DApI7e3qDuzsGDB1vu3bsXwRf0bxUQXc2aUJWHAAAAAElFTkSuQmCC";
/**
* The CyberChef logo with blur
* 32x32
*/
export const PNG_BLUR_B64 = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAANT0lEQVR4AS3BC5CV1X0A8P8553s/7mMvyz5gWUFApEKpEtloSQdLDDDoREXMDK1Zx8dg4xjHqdWpQwgI29QoFrE6gyFJ6YhmoDNMapIBYhzHqgg1ZAvRdIVld5Vl9+597N17v+8779NNJ78fklL6GzdutJ955hnnrbfect98803vxIkTwccffxwdOnQoGhoaihuNRiilDKvValCr1XzGmNtqtdz29naru7sburq6dG9vr1i6dClbtWoV7evryzZv3pw8/PDDSX9/f+vIkSPN/fv3t86cOZMYY7KBgQFarVY5AAjr4MGD6KOPPsK1Wg0bY4ht25Y9q1gs2h0dHW6apm5PT4/HGPMrlYpv23aQJIk3y8nn85bneYgQopVSglJq1et1Mjk5iS5fvqzPnz+vzp49K44fP85uueUW++jRozalVDz77LOkUCjg/v5+hI8dO4YajQZSSuE0TYnW2rJneZ7nlEolt7293SuVSn5nZ6ff1tYWtrW1hcViMczn81EYhpHjOBFCKNJah5TSsNVqBZVKJRgdHQ0uXLjgnzt3znv77bfdo0ePOkeOHLEPHTpkHThwgKxbt46sWLECk4sXL3ozMzPWmTNnnEaj4QwPD3vbt2/3a7VaeOXKlVBKGRFCIsdxIilluGPHjnDXrl0BQsh3Xdf3PM8dGBiwXNe1fN/Hvu8jz/MgjmP98ssvq3379qkoiuTrr78ub731VvHhhx+qbdu2qf7+frV69WqNq9UqmpycxK7rYtu2ied5VhAEdj6ftwuFglssFr1SqeTncrkgn88HuVwuCMMwCsMw8jwvtCwrJISExpiQcx6maRq0Wi2/Uqn4X375pTcyMuIODg46586ds9977z373LlzZHx8HJ8+fRoXCgVEDh486D755JN2uVx2xsfH3eHhYf+JJ57wa7VaVC6XIyFERAiJACBijEWMscgYE+zcuTPYs2ePZ9u2Y9u25TgOdl0XeZ4HnufpKIpUHMfqtddeEwMDA2LZsmX85MmTYnx8XGit5djYmHznnXcUNsagKIqQbdvYsixSKBRIGIZWGIZ2oVBwCoWCm8vlvCiK/GBWGIbBrDAIgtBxnJAQEgJAqJQKpZQB59xPksRvNptuvV53JiYmnMuXL9vDw8PW+Pg4GRoaIrVaDc+dOxeVSiWE169fD3PnzkVdXV2oVCqhfD6P4zgm+Xye5PN5K45jO5fLObNcjLFHCPEAwEMIeUopXwjhc869LMu8VqvlzszMOI1Gw6nX6061WrUbjYY1PT1Nrl69SkZGRvDZs2fxBx98gF599VX0/vvvg3XvvffCyMgILFiwADzPQ/l8HsVBgKMowgBAQGsiGLNZltmcMZtS6lBKXZplLmXMUlIiTDC2bQdmScdx7DiOSZqmmDGG0zTFjDEkhEBSSlQqlaC3txd6e3vhtttuA7xo/U3w1W+uN/kFeQgLIfixBcR3QAFHQDQSWmHGKU7ThCRJy8rS1Mqy1KKUWlma2hmlVpZRizFGKKWEMYYZpVgIgYQQIIQwWmswsxhjptFomMnJSTMxMWFGR0cN/un3vmX65gLc3NtrlnTnTGQBBJYCDzT4WANIhjRniGUJZlmGGU0Jp5QwmhEhOBaMYc4Z5oxhKTkSgiMuBCiljBDCKKU0xlgbY7SUUgshtBBC53I5PTg4aPC2mwEe2txjruuYhqXzjJmf12ZOwE3B48ZDythGGC0YSEpB8AxxRpHgDEkhkOQcCcmRFAIJKUBKZaSURv8JIUTZtq3iOFBxHKv29nbl+77u7OzU9XrdvPTSSxofe+4ec20nwI2LPFOEFnQEyrR5yoRYGFdnAJKB4RQES0EyCkowkIKDksJIJY1S0mgltdZSKyW11koBAomQkRiDJDaRYZyTxWJRBkGg2tvblW3buqurS1+6dMngB5ZWIPnlHLN9QwPuukmba4t1mAMzUCDceIoZWzEDghkpqJGcghLCKMGNUsJoKYxWSisttVZaaa2UBiOVlkoDSESIAAAZBZG0bVs5gaOKxaJatmyZWrBggR4YGND4ujv/F368+HO4zxuBlfAFdMsyBGwSSFIFyJogswaIrAkqS0FxaiSnoJUwWnKjlDBKCaOU0lJJrZTUUkqt1Syp/h8QkEEcSMdxlOu6KteeU8YY3dHRoc+cOWPw/i9+jrak/42+VZiG7mQUdcsy5NIKqOkJBHQadNYEmTaBpy0ksxRpRkEwiiQXoIQwUgijpDBKcCOl1FJyLaVUUnOllFCUUi200MY1iraoHjo/ZJIk0fPnz9eHDx/W+HH/12gd/gA5w+/iztZFBONDmE2N4GxyDNPaBGb1Ck4bVcyTJhI0QYJlSHEKklOkBAfJOXDOQChhhOBGcGY4Zyaj1LSyluFZpgFAN5tNM1GdMIwxff78efPuu++aU6dOgfVt979QbvBXeKU8iMbGz2OYvIhVdQyLX43jrDpJ0ukqyWamMU9nMM+qmNMUS8aQ5BQJqZAEZLAhIAgBJhhwLkxKU6BZZrI0MzNJYrjgZmZmxkxVpsyJ/zwBr7zyCnz66adw3333GXz29ZfwzewjhC++jxuffkySkQskHf2cVL8Ytmh9ktDpCskadUJbM0RkCRY0xZJnWAqOpOBIco6E5CAEA8E4MMaAMgpZlkCz2YR6ow6N6QZUK1UYGx2Der1uyq2y4ZybO+64A/BN079GldO/wJfOvEPY+CCuj1wg5dE/WDMTo2RmatLKGjXCZupEZgmWNMWKUywZw5JzrKRASnKkhEBCCCQlBy4yxBmFJElQo9lA1WoVVWtlNDE5AZ999hkc/tlh9MjfPIKGhobQ7t27AV/+xXEMnw3i4MolTEcvEqt2FaNqGbNKhdBalfCZBmFZiwhKsRQcGyGRURIZJUEribRWoLQGrRVorUAqDZxzxIWAjGbQSmZQlmZQmaqgNE2h2WxCpVKBsbExGB8fB3wDrqP6l5/hrDqC82wa6Zk6pq0Gps0ZTFtNLFmGNOfIaIlAKQBjAAEYBAaQAYMAGYSMQQjMHwFoAwBGSA5SStAKIOMcwaxas4bK5TKCP7nzzjuR1YMFKhhAJZCo2qKYMIkMk0hQgUBrwNoAwdhYCBvHsnSVSG0RrW3LKI0MQoCUsSxlWZayLEtb2NKEEI3nYYPAzJJGKWVaSQsajQZUKhX4zUe/QfPa5qGTJ08CXpJJdG9vAW4qRtDrW9DmAoQA4CNsbGwZxyLGd2zl25byHVsFriN9x5G+6wrf9YTneSJwPRF4vgh8XwS+LwPPU0HgKdfxtesF2nd843u+ieLItOfazZL5S8ymTZsMzMLJvwHA+wA9dd8sJLF2pWdsJ9DY97Tju8oLA+n5vgziiHthyP0wYn4UMtcPeRCGLA5DFoUxi4KQ5+KYx1Ek4lxO5OKcbCsU5JxiUXV1zVVd87r00oVLdU9PjwmCAP7o2LFjhry3d2N4+O57rHXXbrceXFN12r7ZdNY8IJwNZeVeyoxzRex2ptCAXdu5x2ruskn6nIWetmwQjqvBcRXxfGEHAQtzuSzOFdK2A6WkY25H0tXdnSy8ZnFy3fLl6e8G/yfp+0pftmHDBlq+WmYHDhzg99xzj5yamlLk0Z9sCcJ3P7YW5bZbz94urTm/Z/aND0rnzjo4f5va9rhy7Wnjkgb+J9zAe3HzuQFI93haOp4CJxA4iJgd5TK/WMj2zfnXpK2jM5nX29vqXXRta8Wfr2itX7eudfHzS+mWLVvSx7/7OH3hn19gfX19or+/X65evVpZA3/do89vvVHNt1dKtuoTma4SYskKwntO+WxOo0Bj08hcXHeQk1nIaWLldxk6l0tFhUW0QTYQ5bou87u6szn5Qlrq6Uk7FvRmi66/Plu+chW7Zc0tfNfePeL2zbfLPd/fo3bs2KFaqKURQnrFihXGemP9Tfr03YPq9xNfqN1fvUGOfh+LNZditvgvYtZZLdO8PZ15uGwTr0mM30Ki0TKMSoEYt4hQiBBL2a7L/TkhzRXb0tKSpen8xQuzJStW0r6vraUbH3iQbd26lX9y7hOx43s7JG1QFcexPn78uFm7dq0h8Vs/cb+9Zht56FSAH97yPH7hoX3kuvJu646nI3L3EzEZsfJ4nNl4yg3RlBPCd93I1N1QGz9SVhALLy6yuNROCws6s+6enuSalSuT6//shuTmvjXJ3Z/8Lnnq0UfS3c/tyfYO7KXLFy9nzWaT7927V7744oty06ZNmtzK1zul+/4R/3uvwVu3tuOd93vkmseeJxv4D8iG7+wn255rw2MU4yt2iCZIgL7j5syUH2vsx8rLFbmfL/GX2jtp+7Xzsnm916SLb1ydrl79leT2D7+e3L/l3nTgqX/Ifvyjn2Zv/OwN+tsLv+Wff/q5LJfLIgxDjTHWZN8f9ts3tp5HT/3gGXz6/g789GNz8DWPReSvdkTk1OUfki279uPhp3bii8jDV6wAHvYiMxHntRXmlBvlZVTsYP/S3sU6li3IehYuypavXZv+5dfeSU5//RvZ3//do+nCMMiOHv0PeuKXJ9iVkSvirv67xOGfH5aPP/i4unr1qv4/bGwpHb1ZNmYAAAAASUVORK5CYII=";
/**
* Sunglasses smiley
* 32x32

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.