cyberchef 9.50.12 → 9.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -13,6 +13,12 @@ All major and minor version changes will be documented in this file. Details of
13
13
 
14
14
  ## Details
15
15
 
16
+ ### [9.52.0] - 2022-11-25
17
+ - Added 'ChaCha' operation [@joostrijneveld] | [#1466]
18
+
19
+ ### [9.51.0] - 2022-11-25
20
+ - Added 'CMAC' operation [@mikecat] | [#1457]
21
+
16
22
  ### [9.50.0] - 2022-11-25
17
23
  - Added 'Shuffle' operation [@mikecat] | [#1472]
18
24
 
@@ -327,6 +333,8 @@ All major and minor version changes will be documented in this file. Details of
327
333
 
328
334
 
329
335
 
336
+ [9.52.0]: https://github.com/gchq/CyberChef/releases/tag/v9.52.0
337
+ [9.51.0]: https://github.com/gchq/CyberChef/releases/tag/v9.51.0
330
338
  [9.50.0]: https://github.com/gchq/CyberChef/releases/tag/v9.50.0
331
339
  [9.49.0]: https://github.com/gchq/CyberChef/releases/tag/v9.49.0
332
340
  [9.48.0]: https://github.com/gchq/CyberChef/releases/tag/v9.48.0
@@ -467,6 +475,7 @@ All major and minor version changes will be documented in this file. Details of
467
475
  [@thomasleplus]: https://github.com/thomasleplus
468
476
  [@valdelaseras]: https://github.com/valdelaseras
469
477
  [@brun0ne]: https://github.com/brun0ne
478
+ [@joostrijneveld]: https://github.com/joostrijneveld
470
479
 
471
480
  [8ad18b]: https://github.com/gchq/CyberChef/commit/8ad18bc7db6d9ff184ba3518686293a7685bf7b7
472
481
  [9a33498]: https://github.com/gchq/CyberChef/commit/9a33498fed26a8df9c9f35f39a78a174bf50a513
@@ -573,4 +582,6 @@ All major and minor version changes will be documented in this file. Details of
573
582
  [#1421]: https://github.com/gchq/CyberChef/pull/1421
574
583
  [#1427]: https://github.com/gchq/CyberChef/pull/1427
575
584
  [#1472]: https://github.com/gchq/CyberChef/pull/1472
585
+ [#1457]: https://github.com/gchq/CyberChef/pull/1457
586
+ [#1466]: https://github.com/gchq/CyberChef/pull/1466
576
587
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cyberchef",
3
- "version": "9.50.12",
3
+ "version": "9.52.0",
4
4
  "description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
5
5
  "author": "n1474335 <n1474335@gmail.com>",
6
6
  "homepage": "https://gchq.github.io/CyberChef",
@@ -382,6 +382,70 @@ class Utils {
382
382
  }
383
383
 
384
384
 
385
+ /**
386
+ * Converts a byte array to an integer.
387
+ *
388
+ * @param {byteArray} byteArray
389
+ * @param {string} byteorder - "little" or "big"
390
+ * @returns {integer}
391
+ *
392
+ * @example
393
+ * // returns 67305985
394
+ * Utils.byteArrayToInt([1, 2, 3, 4], "little");
395
+ *
396
+ * // returns 16909060
397
+ * Utils.byteArrayToInt([1, 2, 3, 4], "big");
398
+ */
399
+ static byteArrayToInt(byteArray, byteorder) {
400
+ let value = 0;
401
+ if (byteorder === "big") {
402
+ for (let i = 0; i < byteArray.length; i++) {
403
+ value = (value * 256) + byteArray[i];
404
+ }
405
+ } else {
406
+ for (let i = byteArray.length - 1; i >= 0; i--) {
407
+ value = (value * 256) + byteArray[i];
408
+ }
409
+ }
410
+ return value;
411
+ }
412
+
413
+
414
+ /**
415
+ * Converts an integer to a byte array of {length} bytes.
416
+ *
417
+ * @param {integer} value
418
+ * @param {integer} length
419
+ * @param {string} byteorder - "little" or "big"
420
+ * @returns {byteArray}
421
+ *
422
+ * @example
423
+ * // returns [5, 255, 109, 1]
424
+ * Utils.intToByteArray(23985925, 4, "little");
425
+ *
426
+ * // returns [1, 109, 255, 5]
427
+ * Utils.intToByteArray(23985925, 4, "big");
428
+ *
429
+ * // returns [0, 0, 0, 0, 1, 109, 255, 5]
430
+ * Utils.intToByteArray(23985925, 8, "big");
431
+ */
432
+ static intToByteArray(value, length, byteorder) {
433
+ const arr = new Array(length);
434
+ if (byteorder === "little") {
435
+ for (let i = 0; i < length; i++) {
436
+ arr[i] = value & 0xFF;
437
+ value = value >>> 8;
438
+ }
439
+ } else {
440
+ for (let i = length - 1; i >= 0; i--) {
441
+ arr[i] = value & 0xFF;
442
+ value = value >>> 8;
443
+ }
444
+ }
445
+ return arr;
446
+ }
447
+
448
+
385
449
  /**
386
450
  * Converts a string to an ArrayBuffer.
387
451
  * Treats the string as UTF-8 if any values are over 255.
@@ -75,6 +75,7 @@
75
75
  "AES Decrypt",
76
76
  "Blowfish Encrypt",
77
77
  "Blowfish Decrypt",
78
+ "ChaCha",
78
79
  "DES Encrypt",
79
80
  "DES Decrypt",
80
81
  "Triple DES Encrypt",
@@ -368,6 +369,7 @@
368
369
  "Compare SSDEEP hashes",
369
370
  "Compare CTPH hashes",
370
371
  "HMAC",
372
+ "CMAC",
371
373
  "Bcrypt",
372
374
  "Bcrypt compare",
373
375
  "Bcrypt parse",
@@ -1330,6 +1330,36 @@
1330
1330
  "manualBake": false,
1331
1331
  "args": []
1332
1332
  },
1333
+ "CMAC": {
1334
+ "module": "Crypto",
1335
+ "description": "CMAC is a block-cipher based message authentication code algorithm.<br><br>RFC4493 defines AES-CMAC that uses AES encryption with a 128-bit key.<br>NIST SP 800-38B suggests usages of AES with other key lengths and Triple DES.",
1336
+ "infoURL": "https://wikipedia.org/wiki/CMAC",
1337
+ "inputType": "ArrayBuffer",
1338
+ "outputType": "string",
1339
+ "flowControl": false,
1340
+ "manualBake": false,
1341
+ "args": [
1342
+ {
1343
+ "name": "Key",
1344
+ "type": "toggleString",
1345
+ "value": "",
1346
+ "toggleValues": [
1347
+ "Hex",
1348
+ "UTF8",
1349
+ "Latin1",
1350
+ "Base64"
1351
+ ]
1352
+ },
1353
+ {
1354
+ "name": "Encryption algorithm",
1355
+ "type": "option",
1356
+ "value": [
1357
+ "AES",
1358
+ "Triple DES"
1359
+ ]
1360
+ }
1361
+ ]
1362
+ },
1333
1363
  "CRC-16 Checksum": {
1334
1364
  "module": "Crypto",
1335
1365
  "description": "A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data.<br><br>The CRC was invented by W. Wesley Peterson in 1961.",
@@ -1533,6 +1563,71 @@
1533
1563
  "manualBake": false,
1534
1564
  "args": []
1535
1565
  },
1566
+ "ChaCha": {
1567
+ "module": "Default",
1568
+ "description": "ChaCha is a stream cipher designed by Daniel J. Bernstein. It is a variant of the Salsa stream cipher. Several parameterizations exist; 'ChaCha' may refer to the original construction, or to the variant as described in RFC-8439. ChaCha is often used with Poly1305, in the ChaCha20-Poly1305 AEAD construction.<br><br><b>Key:</b> ChaCha uses a key of 16 or 32 bytes (128 or 256 bits).<br><br><b>Nonce:</b> ChaCha uses a nonce of 8 or 12 bytes (64 or 96 bits).<br><br><b>Counter:</b> ChaCha uses a counter of 4 or 8 bytes (32 or 64 bits); together, the nonce and counter must add up to 16 bytes. The counter starts at zero at the start of the keystream, and is incremented at every 64 bytes.",
1569
+ "infoURL": "https://wikipedia.org/wiki/Salsa20#ChaCha_variant",
1570
+ "inputType": "string",
1571
+ "outputType": "string",
1572
+ "flowControl": false,
1573
+ "manualBake": false,
1574
+ "args": [
1575
+ {
1576
+ "name": "Key",
1577
+ "type": "toggleString",
1578
+ "value": "",
1579
+ "toggleValues": [
1580
+ "Hex",
1581
+ "UTF8",
1582
+ "Latin1",
1583
+ "Base64"
1584
+ ]
1585
+ },
1586
+ {
1587
+ "name": "Nonce",
1588
+ "type": "toggleString",
1589
+ "value": "",
1590
+ "toggleValues": [
1591
+ "Hex",
1592
+ "UTF8",
1593
+ "Latin1",
1594
+ "Base64",
1595
+ "Integer"
1596
+ ]
1597
+ },
1598
+ {
1599
+ "name": "Counter",
1600
+ "type": "number",
1601
+ "value": 0,
1602
+ "min": 0
1603
+ },
1604
+ {
1605
+ "name": "Rounds",
1606
+ "type": "option",
1607
+ "value": [
1608
+ "20",
1609
+ "12",
1610
+ "8"
1611
+ ]
1612
+ },
1613
+ {
1614
+ "name": "Input",
1615
+ "type": "option",
1616
+ "value": [
1617
+ "Hex",
1618
+ "Raw"
1619
+ ]
1620
+ },
1621
+ {
1622
+ "name": "Output",
1623
+ "type": "option",
1624
+ "value": [
1625
+ "Raw",
1626
+ "Hex"
1627
+ ]
1628
+ }
1629
+ ]
1630
+ },
1536
1631
  "Change IP format": {
1537
1632
  "module": "Default",
1538
1633
  "description": "Convert an IP address from one format to another, e.g. <code>172.20.23.54</code> to <code>ac141736</code>",
@@ -10,6 +10,7 @@ import AnalyseHash from "../../operations/AnalyseHash.mjs";
10
10
  import Bcrypt from "../../operations/Bcrypt.mjs";
11
11
  import BcryptCompare from "../../operations/BcryptCompare.mjs";
12
12
  import BcryptParse from "../../operations/BcryptParse.mjs";
13
+ import CMAC from "../../operations/CMAC.mjs";
13
14
  import CRC16Checksum from "../../operations/CRC16Checksum.mjs";
14
15
  import CRC32Checksum from "../../operations/CRC32Checksum.mjs";
15
16
  import CRC8Checksum from "../../operations/CRC8Checksum.mjs";
@@ -63,6 +64,7 @@ OpModules.Crypto = {
63
64
  "Bcrypt": Bcrypt,
64
65
  "Bcrypt compare": BcryptCompare,
65
66
  "Bcrypt parse": BcryptParse,
67
+ "CMAC": CMAC,
66
68
  "CRC-16 Checksum": CRC16Checksum,
67
69
  "CRC-32 Checksum": CRC32Checksum,
68
70
  "CRC-8 Checksum": CRC8Checksum,
@@ -14,6 +14,7 @@ import BitShiftLeft from "../../operations/BitShiftLeft.mjs";
14
14
  import BitShiftRight from "../../operations/BitShiftRight.mjs";
15
15
  import CSVToJSON from "../../operations/CSVToJSON.mjs";
16
16
  import CartesianProduct from "../../operations/CartesianProduct.mjs";
17
+ import ChaCha from "../../operations/ChaCha.mjs";
17
18
  import ChangeIPFormat from "../../operations/ChangeIPFormat.mjs";
18
19
  import ChiSquare from "../../operations/ChiSquare.mjs";
19
20
  import Comment from "../../operations/Comment.mjs";
@@ -188,6 +189,7 @@ OpModules.Default = {
188
189
  "Bit shift right": BitShiftRight,
189
190
  "CSV to JSON": CSVToJSON,
190
191
  "Cartesian Product": CartesianProduct,
192
+ "ChaCha": ChaCha,
191
193
  "Change IP format": ChangeIPFormat,
192
194
  "Chi Square": ChiSquare,
193
195
  "Comment": Comment,
@@ -0,0 +1,149 @@
1
+ /**
2
+ * @author mikecat
3
+ * @copyright Crown Copyright 2022
4
+ * @license Apache-2.0
5
+ */
6
+
7
+ import Operation from "../Operation.mjs";
8
+ import Utils from "../Utils.mjs";
9
+ import forge from "node-forge";
10
+ import { toHexFast } from "../lib/Hex.mjs";
11
+ import OperationError from "../errors/OperationError.mjs";
12
+
13
+ /**
14
+ * CMAC operation
15
+ */
16
+ class CMAC extends Operation {
17
+
18
+ /**
19
+ * CMAC constructor
20
+ */
21
+ constructor() {
22
+ super();
23
+
24
+ this.name = "CMAC";
25
+ this.module = "Crypto";
26
+ this.description = "CMAC is a block-cipher based message authentication code algorithm.<br><br>RFC4493 defines AES-CMAC that uses AES encryption with a 128-bit key.<br>NIST SP 800-38B suggests usages of AES with other key lengths and Triple DES.";
27
+ this.infoURL = "https://wikipedia.org/wiki/CMAC";
28
+ this.inputType = "ArrayBuffer";
29
+ this.outputType = "string";
30
+ this.args = [
31
+ {
32
+ "name": "Key",
33
+ "type": "toggleString",
34
+ "value": "",
35
+ "toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
36
+ },
37
+ {
38
+ "name": "Encryption algorithm",
39
+ "type": "option",
40
+ "value": ["AES", "Triple DES"]
41
+ }
42
+ ];
43
+ }
44
+
45
+ /**
46
+ * @param {ArrayBuffer} input
47
+ * @param {Object[]} args
48
+ * @returns {string}
49
+ */
50
+ run(input, args) {
51
+ const key = Utils.convertToByteString(args[0].string, args[0].option);
52
+ const algo = args[1];
53
+
54
+ const info = (function() {
55
+ switch (algo) {
56
+ case "AES":
57
+ if (key.length !== 16 && key.length !== 24 && key.length !== 32) {
58
+ throw new OperationError("The key for AES must be either 16, 24, or 32 bytes (currently " + key.length + " bytes)");
59
+ }
60
+ return {
61
+ "algorithm": "AES-ECB",
62
+ "key": key,
63
+ "blockSize": 16,
64
+ "Rb": new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x87]),
65
+ };
66
+ case "Triple DES":
67
+ if (key.length !== 16 && key.length !== 24) {
68
+ throw new OperationError("The key for Triple DES must be 16 or 24 bytes (currently " + key.length + " bytes)");
69
+ }
70
+ return {
71
+ "algorithm": "3DES-ECB",
72
+ "key": key.length === 16 ? key + key.substring(0, 8) : key,
73
+ "blockSize": 8,
74
+ "Rb": new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0x1b]),
75
+ };
76
+ default:
77
+ throw new OperationError("Undefined encryption algorithm");
78
+ }
79
+ })();
80
+
81
+ const xor = function(a, b, out) {
82
+ if (!out) out = new Uint8Array(a.length);
83
+ for (let i = 0; i < a.length; i++) {
84
+ out[i] = a[i] ^ b[i];
85
+ }
86
+ return out;
87
+ };
88
+
89
+ const leftShift1 = function(a) {
90
+ const out = new Uint8Array(a.length);
91
+ let carry = 0;
92
+ for (let i = a.length - 1; i >= 0; i--) {
93
+ out[i] = (a[i] << 1) | carry;
94
+ carry = a[i] >> 7;
95
+ }
96
+ return out;
97
+ };
98
+
99
+ const cipher = forge.cipher.createCipher(info.algorithm, info.key);
100
+ const encrypt = function(a, out) {
101
+ if (!out) out = new Uint8Array(a.length);
102
+ cipher.start();
103
+ cipher.update(forge.util.createBuffer(a));
104
+ cipher.finish();
105
+ const cipherText = cipher.output.getBytes();
106
+ for (let i = 0; i < a.length; i++) {
107
+ out[i] = cipherText.charCodeAt(i);
108
+ }
109
+ return out;
110
+ };
111
+
112
+ const L = encrypt(new Uint8Array(info.blockSize));
113
+ const K1 = leftShift1(L);
114
+ if (L[0] & 0x80) xor(K1, info.Rb, K1);
115
+ const K2 = leftShift1(K1);
116
+ if (K1[0] & 0x80) xor(K2, info.Rb, K2);
117
+
118
+ const n = Math.ceil(input.byteLength / info.blockSize);
119
+ const lastBlock = (function() {
120
+ if (n === 0) {
121
+ const data = new Uint8Array(K2);
122
+ data[0] ^= 0x80;
123
+ return data;
124
+ }
125
+ const inputLast = new Uint8Array(input, info.blockSize * (n - 1));
126
+ if (inputLast.length === info.blockSize) {
127
+ return xor(inputLast, K1, inputLast);
128
+ } else {
129
+ const data = new Uint8Array(info.blockSize);
130
+ data.set(inputLast, 0);
131
+ data[inputLast.length] = 0x80;
132
+ return xor(data, K2, data);
133
+ }
134
+ })();
135
+
136
+ const X = new Uint8Array(info.blockSize);
137
+ const Y = new Uint8Array(info.blockSize);
138
+ for (let i = 0; i < n - 1; i++) {
139
+ xor(X, new Uint8Array(input, info.blockSize * i, info.blockSize), Y);
140
+ encrypt(Y, X);
141
+ }
142
+ xor(lastBlock, X, Y);
143
+ const T = encrypt(Y);
144
+ return toHexFast(T);
145
+ }
146
+
147
+ }
148
+
149
+ export default CMAC;
@@ -0,0 +1,234 @@
1
+ /**
2
+ * @author joostrijneveld [joost@joostrijneveld.nl]
3
+ * @copyright Crown Copyright 2022
4
+ * @license Apache-2.0
5
+ */
6
+
7
+ import Operation from "../Operation.mjs";
8
+ import OperationError from "../errors/OperationError.mjs";
9
+ import Utils from "../Utils.mjs";
10
+ import { toHex } from "../lib/Hex.mjs";
11
+
12
+ /**
13
+ * Computes the ChaCha block function
14
+ *
15
+ * @param {byteArray} key
16
+ * @param {byteArray} nonce
17
+ * @param {byteArray} counter
18
+ * @param {integer} rounds
19
+ * @returns {byteArray}
20
+ */
21
+ function chacha(key, nonce, counter, rounds) {
22
+ const tau = "expand 16-byte k";
23
+ const sigma = "expand 32-byte k";
24
+
25
+ let state, c;
26
+ if (key.length === 16) {
27
+ c = Utils.strToByteArray(tau);
28
+ state = c.concat(key).concat(key);
29
+ } else {
30
+ c = Utils.strToByteArray(sigma);
31
+ state = c.concat(key);
32
+ }
33
+ state = state.concat(counter).concat(nonce);
34
+
35
+ const x = Array();
36
+ for (let i = 0; i < 64; i += 4) {
37
+ x.push(Utils.byteArrayToInt(state.slice(i, i + 4), "little"));
38
+ }
39
+ const a = [...x];
40
+
41
+ /**
42
+ * Macro to compute a 32-bit rotate-left operation
43
+ *
44
+ * @param {integer} x
45
+ * @param {integer} n
46
+ * @returns {integer}
47
+ */
48
+ function ROL32(x, n) {
49
+ return ((x << n) & 0xFFFFFFFF) | (x >>> (32 - n));
50
+ }
51
+
52
+ /**
53
+ * Macro to compute a single ChaCha quarterround operation
54
+ *
55
+ * @param {integer} x
56
+ * @param {integer} a
57
+ * @param {integer} b
58
+ * @param {integer} c
59
+ * @param {integer} d
60
+ * @returns {integer}
61
+ */
62
+ function quarterround(x, a, b, c, d) {
63
+ x[a] = ((x[a] + x[b]) & 0xFFFFFFFF); x[d] = ROL32(x[d] ^ x[a], 16);
64
+ x[c] = ((x[c] + x[d]) & 0xFFFFFFFF); x[b] = ROL32(x[b] ^ x[c], 12);
65
+ x[a] = ((x[a] + x[b]) & 0xFFFFFFFF); x[d] = ROL32(x[d] ^ x[a], 8);
66
+ x[c] = ((x[c] + x[d]) & 0xFFFFFFFF); x[b] = ROL32(x[b] ^ x[c], 7);
67
+ }
68
+
69
+ for (let i = 0; i < rounds / 2; i++) {
70
+ quarterround(x, 0, 4, 8, 12);
71
+ quarterround(x, 1, 5, 9, 13);
72
+ quarterround(x, 2, 6, 10, 14);
73
+ quarterround(x, 3, 7, 11, 15);
74
+ quarterround(x, 0, 5, 10, 15);
75
+ quarterround(x, 1, 6, 11, 12);
76
+ quarterround(x, 2, 7, 8, 13);
77
+ quarterround(x, 3, 4, 9, 14);
78
+ }
79
+
80
+ for (let i = 0; i < 16; i++) {
81
+ x[i] = (x[i] + a[i]) & 0xFFFFFFFF;
82
+ }
83
+
84
+ let output = Array();
85
+ for (let i = 0; i < 16; i++) {
86
+ output = output.concat(Utils.intToByteArray(x[i], 4, "little"));
87
+ }
88
+ return output;
89
+ }
90
+
91
+ /**
92
+ * ChaCha operation
93
+ */
94
+ class ChaCha extends Operation {
95
+
96
+ /**
97
+ * ChaCha constructor
98
+ */
99
+ constructor() {
100
+ super();
101
+
102
+ this.name = "ChaCha";
103
+ this.module = "Default";
104
+ this.description = "ChaCha is a stream cipher designed by Daniel J. Bernstein. It is a variant of the Salsa stream cipher. Several parameterizations exist; 'ChaCha' may refer to the original construction, or to the variant as described in RFC-8439. ChaCha is often used with Poly1305, in the ChaCha20-Poly1305 AEAD construction.<br><br><b>Key:</b> ChaCha uses a key of 16 or 32 bytes (128 or 256 bits).<br><br><b>Nonce:</b> ChaCha uses a nonce of 8 or 12 bytes (64 or 96 bits).<br><br><b>Counter:</b> ChaCha uses a counter of 4 or 8 bytes (32 or 64 bits); together, the nonce and counter must add up to 16 bytes. The counter starts at zero at the start of the keystream, and is incremented at every 64 bytes.";
105
+ this.infoURL = "https://wikipedia.org/wiki/Salsa20#ChaCha_variant";
106
+ this.inputType = "string";
107
+ this.outputType = "string";
108
+ this.args = [
109
+ {
110
+ "name": "Key",
111
+ "type": "toggleString",
112
+ "value": "",
113
+ "toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
114
+ },
115
+ {
116
+ "name": "Nonce",
117
+ "type": "toggleString",
118
+ "value": "",
119
+ "toggleValues": ["Hex", "UTF8", "Latin1", "Base64", "Integer"]
120
+ },
121
+ {
122
+ "name": "Counter",
123
+ "type": "number",
124
+ "value": 0,
125
+ "min": 0
126
+ },
127
+ {
128
+ "name": "Rounds",
129
+ "type": "option",
130
+ "value": ["20", "12", "8"]
131
+ },
132
+ {
133
+ "name": "Input",
134
+ "type": "option",
135
+ "value": ["Hex", "Raw"]
136
+ },
137
+ {
138
+ "name": "Output",
139
+ "type": "option",
140
+ "value": ["Raw", "Hex"]
141
+ }
142
+ ];
143
+ }
144
+
145
+ /**
146
+ * @param {string} input
147
+ * @param {Object[]} args
148
+ * @returns {string}
149
+ */
150
+ run(input, args) {
151
+ const key = Utils.convertToByteArray(args[0].string, args[0].option),
152
+ nonceType = args[1].option,
153
+ rounds = parseInt(args[3], 10),
154
+ inputType = args[4],
155
+ outputType = args[5];
156
+
157
+ if (key.length !== 16 && key.length !== 32) {
158
+ throw new OperationError(`Invalid key length: ${key.length} bytes.
159
+
160
+ ChaCha uses a key of 16 or 32 bytes (128 or 256 bits).`);
161
+ }
162
+
163
+ let counter, nonce, counterLength;
164
+ if (nonceType === "Integer") {
165
+ nonce = Utils.intToByteArray(parseInt(args[1].string, 10), 12, "little");
166
+ counterLength = 4;
167
+ } else {
168
+ nonce = Utils.convertToByteArray(args[1].string, args[1].option);
169
+ if (!(nonce.length === 12 || nonce.length === 8)) {
170
+ throw new OperationError(`Invalid nonce length: ${nonce.length} bytes.
171
+
172
+ ChaCha uses a nonce of 8 or 12 bytes (64 or 96 bits).`);
173
+ }
174
+ counterLength = 16 - nonce.length;
175
+ }
176
+ counter = Utils.intToByteArray(args[2], counterLength, "little");
177
+
178
+ const output = [];
179
+ input = Utils.convertToByteArray(input, inputType);
180
+
181
+ let counterAsInt = Utils.byteArrayToInt(counter, "little");
182
+ for (let i = 0; i < input.length; i += 64) {
183
+ counter = Utils.intToByteArray(counterAsInt, counterLength, "little");
184
+ const stream = chacha(key, nonce, counter, rounds);
185
+ for (let j = 0; j < 64 && i + j < input.length; j++) {
186
+ output.push(input[i + j] ^ stream[j]);
187
+ }
188
+ counterAsInt++;
189
+ }
190
+
191
+ if (outputType === "Hex") {
192
+ return toHex(output);
193
+ } else {
194
+ return Utils.arrayBufferToStr(output);
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Highlight ChaCha
200
+ *
201
+ * @param {Object[]} pos
202
+ * @param {number} pos[].start
203
+ * @param {number} pos[].end
204
+ * @param {Object[]} args
205
+ * @returns {Object[]} pos
206
+ */
207
+ highlight(pos, args) {
208
+ const inputType = args[4],
209
+ outputType = args[5];
210
+ if (inputType === "Raw" && outputType === "Raw") {
211
+ return pos;
212
+ }
213
+ }
214
+
215
+ /**
216
+ * Highlight ChaCha in reverse
217
+ *
218
+ * @param {Object[]} pos
219
+ * @param {number} pos[].start
220
+ * @param {number} pos[].end
221
+ * @param {Object[]} args
222
+ * @returns {Object[]} pos
223
+ */
224
+ highlightReverse(pos, args) {
225
+ const inputType = args[4],
226
+ outputType = args[5];
227
+ if (inputType === "Raw" && outputType === "Raw") {
228
+ return pos;
229
+ }
230
+ }
231
+
232
+ }
233
+
234
+ export default ChaCha;
@@ -40,6 +40,7 @@ import Bzip2Compress from "./Bzip2Compress.mjs";
40
40
  import Bzip2Decompress from "./Bzip2Decompress.mjs";
41
41
  import CBORDecode from "./CBORDecode.mjs";
42
42
  import CBOREncode from "./CBOREncode.mjs";
43
+ import CMAC from "./CMAC.mjs";
43
44
  import CRC16Checksum from "./CRC16Checksum.mjs";
44
45
  import CRC32Checksum from "./CRC32Checksum.mjs";
45
46
  import CRC8Checksum from "./CRC8Checksum.mjs";
@@ -52,6 +53,7 @@ import CaesarBoxCipher from "./CaesarBoxCipher.mjs";
52
53
  import CartesianProduct from "./CartesianProduct.mjs";
53
54
  import CetaceanCipherDecode from "./CetaceanCipherDecode.mjs";
54
55
  import CetaceanCipherEncode from "./CetaceanCipherEncode.mjs";
56
+ import ChaCha from "./ChaCha.mjs";
55
57
  import ChangeIPFormat from "./ChangeIPFormat.mjs";
56
58
  import ChiSquare from "./ChiSquare.mjs";
57
59
  import CipherSaber2Decrypt from "./CipherSaber2Decrypt.mjs";
@@ -432,6 +434,7 @@ export {
432
434
  Bzip2Decompress,
433
435
  CBORDecode,
434
436
  CBOREncode,
437
+ CMAC,
435
438
  CRC16Checksum,
436
439
  CRC32Checksum,
437
440
  CRC8Checksum,
@@ -444,6 +447,7 @@ export {
444
447
  CartesianProduct,
445
448
  CetaceanCipherDecode,
446
449
  CetaceanCipherEncode,
450
+ ChaCha,
447
451
  ChangeIPFormat,
448
452
  ChiSquare,
449
453
  CipherSaber2Decrypt,
@@ -50,6 +50,7 @@ import {
50
50
  Bzip2Decompress as core_Bzip2Decompress,
51
51
  CBORDecode as core_CBORDecode,
52
52
  CBOREncode as core_CBOREncode,
53
+ CMAC as core_CMAC,
53
54
  CRC16Checksum as core_CRC16Checksum,
54
55
  CRC32Checksum as core_CRC32Checksum,
55
56
  CRC8Checksum as core_CRC8Checksum,
@@ -62,6 +63,7 @@ import {
62
63
  CartesianProduct as core_CartesianProduct,
63
64
  CetaceanCipherDecode as core_CetaceanCipherDecode,
64
65
  CetaceanCipherEncode as core_CetaceanCipherEncode,
66
+ ChaCha as core_ChaCha,
65
67
  ChangeIPFormat as core_ChangeIPFormat,
66
68
  ChiSquare as core_ChiSquare,
67
69
  CipherSaber2Decrypt as core_CipherSaber2Decrypt,
@@ -442,6 +444,7 @@ function generateChef() {
442
444
  "bzip2Decompress": _wrap(core_Bzip2Decompress),
443
445
  "CBORDecode": _wrap(core_CBORDecode),
444
446
  "CBOREncode": _wrap(core_CBOREncode),
447
+ "CMAC": _wrap(core_CMAC),
445
448
  "CRC16Checksum": _wrap(core_CRC16Checksum),
446
449
  "CRC32Checksum": _wrap(core_CRC32Checksum),
447
450
  "CRC8Checksum": _wrap(core_CRC8Checksum),
@@ -454,6 +457,7 @@ function generateChef() {
454
457
  "cartesianProduct": _wrap(core_CartesianProduct),
455
458
  "cetaceanCipherDecode": _wrap(core_CetaceanCipherDecode),
456
459
  "cetaceanCipherEncode": _wrap(core_CetaceanCipherEncode),
460
+ "chaCha": _wrap(core_ChaCha),
457
461
  "changeIPFormat": _wrap(core_ChangeIPFormat),
458
462
  "chiSquare": _wrap(core_ChiSquare),
459
463
  "cipherSaber2Decrypt": _wrap(core_CipherSaber2Decrypt),
@@ -842,6 +846,7 @@ const bzip2Compress = chef.bzip2Compress;
842
846
  const bzip2Decompress = chef.bzip2Decompress;
843
847
  const CBORDecode = chef.CBORDecode;
844
848
  const CBOREncode = chef.CBOREncode;
849
+ const CMAC = chef.CMAC;
845
850
  const CRC16Checksum = chef.CRC16Checksum;
846
851
  const CRC32Checksum = chef.CRC32Checksum;
847
852
  const CRC8Checksum = chef.CRC8Checksum;
@@ -854,6 +859,7 @@ const caesarBoxCipher = chef.caesarBoxCipher;
854
859
  const cartesianProduct = chef.cartesianProduct;
855
860
  const cetaceanCipherDecode = chef.cetaceanCipherDecode;
856
861
  const cetaceanCipherEncode = chef.cetaceanCipherEncode;
862
+ const chaCha = chef.chaCha;
857
863
  const changeIPFormat = chef.changeIPFormat;
858
864
  const chiSquare = chef.chiSquare;
859
865
  const cipherSaber2Decrypt = chef.cipherSaber2Decrypt;
@@ -1236,6 +1242,7 @@ const operations = [
1236
1242
  bzip2Decompress,
1237
1243
  CBORDecode,
1238
1244
  CBOREncode,
1245
+ CMAC,
1239
1246
  CRC16Checksum,
1240
1247
  CRC32Checksum,
1241
1248
  CRC8Checksum,
@@ -1248,6 +1255,7 @@ const operations = [
1248
1255
  cartesianProduct,
1249
1256
  cetaceanCipherDecode,
1250
1257
  cetaceanCipherEncode,
1258
+ chaCha,
1251
1259
  changeIPFormat,
1252
1260
  chiSquare,
1253
1261
  cipherSaber2Decrypt,
@@ -1634,6 +1642,7 @@ export {
1634
1642
  bzip2Decompress,
1635
1643
  CBORDecode,
1636
1644
  CBOREncode,
1645
+ CMAC,
1637
1646
  CRC16Checksum,
1638
1647
  CRC32Checksum,
1639
1648
  CRC8Checksum,
@@ -1646,6 +1655,7 @@ export {
1646
1655
  cartesianProduct,
1647
1656
  cetaceanCipherDecode,
1648
1657
  cetaceanCipherEncode,
1658
+ chaCha,
1649
1659
  changeIPFormat,
1650
1660
  chiSquare,
1651
1661
  cipherSaber2Decrypt,
@@ -30,6 +30,7 @@ import "./tests/ByteRepr.mjs";
30
30
  import "./tests/CartesianProduct.mjs";
31
31
  import "./tests/CetaceanCipherEncode.mjs";
32
32
  import "./tests/CetaceanCipherDecode.mjs";
33
+ import "./tests/ChaCha.mjs";
33
34
  import "./tests/CharEnc.mjs";
34
35
  import "./tests/ChangeIPFormat.mjs";
35
36
  import "./tests/Charts.mjs";
@@ -126,6 +127,7 @@ import "./tests/LZString.mjs";
126
127
  import "./tests/NTLM.mjs";
127
128
  import "./tests/Shuffle.mjs";
128
129
  import "./tests/FletcherChecksum.mjs";
130
+ import "./tests/CMAC.mjs";
129
131
 
130
132
  // Cannot test operations that use the File type yet
131
133
  // import "./tests/SplitColourChannels.mjs";
@@ -0,0 +1,314 @@
1
+ /**
2
+ * @author mikecat
3
+ * @copyright Crown Copyright 2022
4
+ * @license Apache-2.0
5
+ */
6
+ import TestRegister from "../../lib/TestRegister.mjs";
7
+
8
+ // values in "NIST's CSRC" testcases are taken from here:
9
+ // https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
10
+
11
+ TestRegister.addTests([
12
+ {
13
+ "name": "CMAC-AES128 NIST's CSRC Example #1",
14
+ "input": "",
15
+ "expectedOutput": "bb1d6929e95937287fa37d129b756746",
16
+ "recipeConfig": [
17
+ {
18
+ "op": "CMAC",
19
+ "args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
20
+ },
21
+ ]
22
+ },
23
+ {
24
+ "name": "CMAC-AES128 NIST's CSRC Example #2",
25
+ "input": "6bc1bee22e409f96e93d7e117393172a",
26
+ "expectedOutput": "070a16b46b4d4144f79bdd9dd04a287c",
27
+ "recipeConfig": [
28
+ {
29
+ "op": "From Hex",
30
+ "args": ["None"]
31
+ },
32
+ {
33
+ "op": "CMAC",
34
+ "args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
35
+ },
36
+ ]
37
+ },
38
+ {
39
+ "name": "CMAC-AES128 NIST's CSRC Example #3",
40
+ "input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
41
+ "expectedOutput": "7d85449ea6ea19c823a7bf78837dfade",
42
+ "recipeConfig": [
43
+ {
44
+ "op": "From Hex",
45
+ "args": ["None"]
46
+ },
47
+ {
48
+ "op": "CMAC",
49
+ "args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
50
+ },
51
+ ]
52
+ },
53
+ {
54
+ "name": "CMAC-AES128 NIST's CSRC Example #4",
55
+ "input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
56
+ "expectedOutput": "51f0bebf7e3b9d92fc49741779363cfe",
57
+ "recipeConfig": [
58
+ {
59
+ "op": "From Hex",
60
+ "args": ["None"]
61
+ },
62
+ {
63
+ "op": "CMAC",
64
+ "args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
65
+ },
66
+ ]
67
+ },
68
+ {
69
+ "name": "CMAC-AES192 NIST's CSRC Example #1",
70
+ "input": "",
71
+ "expectedOutput": "d17ddf46adaacde531cac483de7a9367",
72
+ "recipeConfig": [
73
+ {
74
+ "op": "CMAC",
75
+ "args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
76
+ },
77
+ ]
78
+ },
79
+ {
80
+ "name": "CMAC-AES192 NIST's CSRC Example #2",
81
+ "input": "6bc1bee22e409f96e93d7e117393172a",
82
+ "expectedOutput": "9e99a7bf31e710900662f65e617c5184",
83
+ "recipeConfig": [
84
+ {
85
+ "op": "From Hex",
86
+ "args": ["None"]
87
+ },
88
+ {
89
+ "op": "CMAC",
90
+ "args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
91
+ },
92
+ ]
93
+ },
94
+ {
95
+ "name": "CMAC-AES192 NIST's CSRC Example #3",
96
+ "input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
97
+ "expectedOutput": "3d75c194ed96070444a9fa7ec740ecf8",
98
+ "recipeConfig": [
99
+ {
100
+ "op": "From Hex",
101
+ "args": ["None"]
102
+ },
103
+ {
104
+ "op": "CMAC",
105
+ "args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
106
+ },
107
+ ]
108
+ },
109
+ {
110
+ "name": "CMAC-AES192 NIST's CSRC Example #4",
111
+ "input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
112
+ "expectedOutput": "a1d5df0eed790f794d77589659f39a11",
113
+ "recipeConfig": [
114
+ {
115
+ "op": "From Hex",
116
+ "args": ["None"]
117
+ },
118
+ {
119
+ "op": "CMAC",
120
+ "args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
121
+ },
122
+ ]
123
+ },
124
+ {
125
+ "name": "CMAC-AES256 NIST's CSRC Example #1",
126
+ "input": "",
127
+ "expectedOutput": "028962f61b7bf89efc6b551f4667d983",
128
+ "recipeConfig": [
129
+ {
130
+ "op": "CMAC",
131
+ "args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
132
+ },
133
+ ]
134
+ },
135
+ {
136
+ "name": "CMAC-AES256 NIST's CSRC Example #2",
137
+ "input": "6bc1bee22e409f96e93d7e117393172a",
138
+ "expectedOutput": "28a7023f452e8f82bd4bf28d8c37c35c",
139
+ "recipeConfig": [
140
+ {
141
+ "op": "From Hex",
142
+ "args": ["None"]
143
+ },
144
+ {
145
+ "op": "CMAC",
146
+ "args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
147
+ },
148
+ ]
149
+ },
150
+ {
151
+ "name": "CMAC-AES256 NIST's CSRC Example #3",
152
+ "input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
153
+ "expectedOutput": "156727dc0878944a023c1fe03bad6d93",
154
+ "recipeConfig": [
155
+ {
156
+ "op": "From Hex",
157
+ "args": ["None"]
158
+ },
159
+ {
160
+ "op": "CMAC",
161
+ "args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
162
+ },
163
+ ]
164
+ },
165
+ {
166
+ "name": "CMAC-AES256 NIST's CSRC Example #4",
167
+ "input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
168
+ "expectedOutput": "e1992190549f6ed5696a2c056c315410",
169
+ "recipeConfig": [
170
+ {
171
+ "op": "From Hex",
172
+ "args": ["None"]
173
+ },
174
+ {
175
+ "op": "CMAC",
176
+ "args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
177
+ },
178
+ ]
179
+ },
180
+ {
181
+ "name": "CMAC-TDES (1) NIST's CSRC Sample #1",
182
+ "input": "",
183
+ "expectedOutput": "7db0d37df936c550",
184
+ "recipeConfig": [
185
+ {
186
+ "op": "CMAC",
187
+ "args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
188
+ },
189
+ ]
190
+ },
191
+ {
192
+ "name": "CMAC-TDES (1) NIST's CSRC Sample #2",
193
+ "input": "6bc1bee22e409f96e93d7e117393172a",
194
+ "expectedOutput": "30239cf1f52e6609",
195
+ "recipeConfig": [
196
+ {
197
+ "op": "From Hex",
198
+ "args": ["None"]
199
+ },
200
+ {
201
+ "op": "CMAC",
202
+ "args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
203
+ },
204
+ ]
205
+ },
206
+ {
207
+ "name": "CMAC-TDES (1) NIST's CSRC Sample #3",
208
+ "input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
209
+ "expectedOutput": "6c9f3ee4923f6be2",
210
+ "recipeConfig": [
211
+ {
212
+ "op": "From Hex",
213
+ "args": ["None"]
214
+ },
215
+ {
216
+ "op": "CMAC",
217
+ "args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
218
+ },
219
+ ]
220
+ },
221
+ {
222
+ "name": "CMAC-TDES (1) NIST's CSRC Sample #4",
223
+ "input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51",
224
+ "expectedOutput": "99429bd0bf7904e5",
225
+ "recipeConfig": [
226
+ {
227
+ "op": "From Hex",
228
+ "args": ["None"]
229
+ },
230
+ {
231
+ "op": "CMAC",
232
+ "args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
233
+ },
234
+ ]
235
+ },
236
+ {
237
+ "name": "CMAC-TDES (2) NIST's CSRC Sample #1",
238
+ "input": "",
239
+ "expectedOutput": "79ce52a7f786a960",
240
+ "recipeConfig": [
241
+ {
242
+ "op": "CMAC",
243
+ "args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
244
+ },
245
+ ]
246
+ },
247
+ {
248
+ "name": "CMAC-TDES (2) NIST's CSRC Sample #2",
249
+ "input": "6bc1bee22e409f96e93d7e117393172a",
250
+ "expectedOutput": "cc18a0b79af2413b",
251
+ "recipeConfig": [
252
+ {
253
+ "op": "From Hex",
254
+ "args": ["None"]
255
+ },
256
+ {
257
+ "op": "CMAC",
258
+ "args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
259
+ },
260
+ ]
261
+ },
262
+ {
263
+ "name": "CMAC-TDES (2) NIST's CSRC Sample #3",
264
+ "input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
265
+ "expectedOutput": "c06d377ecd101969",
266
+ "recipeConfig": [
267
+ {
268
+ "op": "From Hex",
269
+ "args": ["None"]
270
+ },
271
+ {
272
+ "op": "CMAC",
273
+ "args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
274
+ },
275
+ ]
276
+ },
277
+ {
278
+ "name": "CMAC-TDES (2) NIST's CSRC Sample #4",
279
+ "input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51",
280
+ "expectedOutput": "9cd33580f9b64dfb",
281
+ "recipeConfig": [
282
+ {
283
+ "op": "From Hex",
284
+ "args": ["None"]
285
+ },
286
+ {
287
+ "op": "CMAC",
288
+ "args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
289
+ },
290
+ ]
291
+ },
292
+ {
293
+ "name": "CMAC-AES: invalid key length",
294
+ "input": "",
295
+ "expectedOutput": "The key for AES must be either 16, 24, or 32 bytes (currently 20 bytes)",
296
+ "recipeConfig": [
297
+ {
298
+ "op": "CMAC",
299
+ "args": [{"option": "Hex", "string": "00112233445566778899aabbccddeeff01234567"}, "AES"]
300
+ },
301
+ ]
302
+ },
303
+ {
304
+ "name": "CMAC-TDES: invalid key length",
305
+ "input": "",
306
+ "expectedOutput": "The key for Triple DES must be 16 or 24 bytes (currently 20 bytes)",
307
+ "recipeConfig": [
308
+ {
309
+ "op": "CMAC",
310
+ "args": [{"option": "Hex", "string": "00112233445566778899aabbccddeeff01234567"}, "Triple DES"]
311
+ },
312
+ ]
313
+ },
314
+ ]);
@@ -0,0 +1,151 @@
1
+ /**
2
+ * ChaCha tests.
3
+ *
4
+ * @author joostrijneveld [joost@joostrijneveld.nl]
5
+ * @copyright Crown Copyright 2022
6
+ * @license Apache-2.0
7
+ */
8
+
9
+ import TestRegister from "../../lib/TestRegister.mjs";
10
+
11
+ TestRegister.addTests([
12
+ {
13
+ name: "ChaCha: no key",
14
+ input: "",
15
+ expectedOutput: `Invalid key length: 0 bytes.
16
+
17
+ ChaCha uses a key of 16 or 32 bytes (128 or 256 bits).`,
18
+ recipeConfig: [
19
+ {
20
+ "op": "ChaCha",
21
+ "args": [
22
+ {"option": "Hex", "string": ""},
23
+ {"option": "Hex", "string": ""},
24
+ 0, "20", "Hex", "Hex",
25
+ ]
26
+ }
27
+ ],
28
+ },
29
+ {
30
+ name: "ChaCha: no nonce",
31
+ input: "",
32
+ expectedOutput: `Invalid nonce length: 0 bytes.
33
+
34
+ ChaCha uses a nonce of 8 or 12 bytes (64 or 96 bits).`,
35
+ recipeConfig: [
36
+ {
37
+ "op": "ChaCha",
38
+ "args": [
39
+ {"option": "Hex", "string": "00000000000000000000000000000000"},
40
+ {"option": "Hex", "string": ""},
41
+ 0, "20", "Hex", "Hex",
42
+ ]
43
+ }
44
+ ],
45
+ },
46
+ {
47
+ name: "ChaCha: RFC8439",
48
+ input: "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.",
49
+ 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",
50
+ recipeConfig: [
51
+ {
52
+ "op": "ChaCha",
53
+ "args": [
54
+ {"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"},
55
+ {"option": "Hex", "string": "00:00:00:00:00:00:00:4a:00:00:00:00"},
56
+ 1, "20", "Raw", "Hex",
57
+ ]
58
+ }
59
+ ],
60
+ },
61
+ {
62
+ name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.1",
63
+ 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",
64
+ 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",
65
+ recipeConfig: [
66
+ {
67
+ "op": "ChaCha",
68
+ "args": [
69
+ {"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"},
70
+ {"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
71
+ 0, "8", "Hex", "Hex",
72
+ ]
73
+ }
74
+ ],
75
+ },
76
+ {
77
+ name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.2",
78
+ 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",
79
+ 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",
80
+ recipeConfig: [
81
+ {
82
+ "op": "ChaCha",
83
+ "args": [
84
+ {"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"},
85
+ {"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
86
+ 0, "12", "Hex", "Hex",
87
+ ]
88
+ }
89
+ ],
90
+ },
91
+ {
92
+ name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.3",
93
+ 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",
94
+ 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",
95
+ recipeConfig: [
96
+ {
97
+ "op": "ChaCha",
98
+ "args": [
99
+ {"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"},
100
+ {"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
101
+ 0, "20", "Hex", "Hex",
102
+ ]
103
+ }
104
+ ],
105
+ },
106
+ {
107
+ name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.4",
108
+ 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",
109
+ 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",
110
+ recipeConfig: [
111
+ {
112
+ "op": "ChaCha",
113
+ "args": [
114
+ {"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"},
115
+ {"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
116
+ 0, "8", "Hex", "Hex",
117
+ ]
118
+ }
119
+ ],
120
+ },
121
+ {
122
+ name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.5",
123
+ 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",
124
+ 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",
125
+ recipeConfig: [
126
+ {
127
+ "op": "ChaCha",
128
+ "args": [
129
+ {"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"},
130
+ {"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
131
+ 0, "12", "Hex", "Hex",
132
+ ]
133
+ }
134
+ ],
135
+ },
136
+ {
137
+ name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.6",
138
+ 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",
139
+ 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",
140
+ recipeConfig: [
141
+ {
142
+ "op": "ChaCha",
143
+ "args": [
144
+ {"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"},
145
+ {"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
146
+ 0, "20", "Hex", "Hex",
147
+ ]
148
+ }
149
+ ],
150
+ },
151
+ ]);