mirror of
https://github.com/gchq/CyberChef
synced 2025-01-01 07:18:47 +00:00
tests added and XXTEA not working correctly fixed
This commit is contained in:
parent
653af6a300
commit
c14098a27c
2 changed files with 65 additions and 3 deletions
|
@ -73,7 +73,7 @@ class XXTEAEncrypt extends Operation {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
toBinaryString(v, includeLENGTH) {
|
toBinaryString(v, includeLENGTH) {
|
||||||
const LENGTH = v.LENGTH;
|
const LENGTH = v.length;
|
||||||
let n = LENGTH << 2;
|
let n = LENGTH << 2;
|
||||||
if (includeLENGTH) {
|
if (includeLENGTH) {
|
||||||
const M = v[LENGTH - 1];
|
const M = v[LENGTH - 1];
|
||||||
|
@ -120,7 +120,7 @@ class XXTEAEncrypt extends Operation {
|
||||||
* @returns {Uint32Array}
|
* @returns {Uint32Array}
|
||||||
*/
|
*/
|
||||||
encryptUint32Array(v, k) {
|
encryptUint32Array(v, k) {
|
||||||
const LENGTH = v.LENGTH;
|
const LENGTH = v.length;
|
||||||
const N = LENGTH - 1;
|
const N = LENGTH - 1;
|
||||||
let y, z, sum, e, p, q;
|
let y, z, sum, e, p, q;
|
||||||
z = v[N];
|
z = v[N];
|
||||||
|
@ -159,7 +159,7 @@ class XXTEAEncrypt extends Operation {
|
||||||
* @returns {Uint32Array}
|
* @returns {Uint32Array}
|
||||||
*/
|
*/
|
||||||
convertToUint32Array(bs, includeLength) {
|
convertToUint32Array(bs, includeLength) {
|
||||||
const LENGTH = bs.LENGTH;
|
const LENGTH = bs.length;
|
||||||
let n = LENGTH >> 2;
|
let n = LENGTH >> 2;
|
||||||
if ((LENGTH & 3) !== 0) {
|
if ((LENGTH & 3) !== 0) {
|
||||||
++n;
|
++n;
|
||||||
|
|
62
tests/operations/tests/XXTEA.mjs
Normal file
62
tests/operations/tests/XXTEA.mjs
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/**
|
||||||
|
* Base64 tests.
|
||||||
|
*
|
||||||
|
* @author devcydo [devcydo@gmail.com]
|
||||||
|
*
|
||||||
|
* @copyright Crown Copyright 2022
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../lib/TestRegister.mjs";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "XXTEA",
|
||||||
|
input: "Hello World! 你好,中国!",
|
||||||
|
expectedOutput: "QncB1C0rHQoZ1eRiPM4dsZtRi9pNrp7sqvX76cFXvrrIHXL6",
|
||||||
|
reecipeConfig: [
|
||||||
|
{
|
||||||
|
args: "1234567890"
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "XXTEA",
|
||||||
|
input: "ნუ პანიკას",
|
||||||
|
expectedOutput: "PbWjnbFmP8Apu2MKOGNbjeW/72IZLlLMS/g82ozLxwE=",
|
||||||
|
reecipeConfig: [
|
||||||
|
{
|
||||||
|
args: "1234567890"
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "XXTEA",
|
||||||
|
input: "ნუ პანიკას",
|
||||||
|
expectedOutput: "dHrOJ4ClIx6gH33NPSafYR2GG7UqsazY6Xfb0iekBY4=",
|
||||||
|
reecipeConfig: [
|
||||||
|
{
|
||||||
|
args: "ll3kj209d2"
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "XXTEA",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "Invalid input length (0)",
|
||||||
|
reecipeConfig: [
|
||||||
|
{
|
||||||
|
args: "1234567890"
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "XXTEA",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "Invalid input length (0)",
|
||||||
|
reecipeConfig: [
|
||||||
|
{
|
||||||
|
args: ""
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
Loading…
Reference in a new issue