mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Lint
This commit is contained in:
parent
55809b2e87
commit
3f85c32c7c
2 changed files with 16 additions and 15 deletions
|
@ -381,6 +381,7 @@ class Utils {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts a byte array to an integer.
|
||||
*
|
||||
|
@ -409,6 +410,7 @@ class Utils {
|
|||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts an integer to a byte array of {length} bytes.
|
||||
*
|
||||
|
@ -443,6 +445,7 @@ class Utils {
|
|||
return arr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts a string to an ArrayBuffer.
|
||||
* Treats the string as UTF-8 if any values are over 255.
|
||||
|
|
|
@ -159,9 +159,12 @@ class ChaCha extends Operation {
|
|||
|
||||
ChaCha uses a key of 16 or 32 bytes (128 or 256 bits).`);
|
||||
}
|
||||
let counter, nonce;
|
||||
let counterLength;
|
||||
if (nonceType !== "Integer") {
|
||||
|
||||
let counter, nonce, counterLength;
|
||||
if (nonceType === "Integer") {
|
||||
nonce = Utils.intToByteArray(parseInt(args[1].string, 10), 12, "little");
|
||||
counterLength = 4;
|
||||
} else {
|
||||
nonce = Utils.convertToByteArray(args[1].string, args[1].option);
|
||||
if (!(nonce.length === 12 || nonce.length === 8)) {
|
||||
throw new OperationError(`Invalid nonce length: ${nonce.length} bytes.
|
||||
|
@ -169,15 +172,10 @@ ChaCha uses a key of 16 or 32 bytes (128 or 256 bits).`);
|
|||
ChaCha uses a nonce of 8 or 12 bytes (64 or 96 bits).`);
|
||||
}
|
||||
counterLength = 16 - nonce.length;
|
||||
counter = Utils.intToByteArray(args[2], counterLength, "little");
|
||||
}
|
||||
if (nonceType === "Integer") {
|
||||
nonce = Utils.intToByteArray(parseInt(args[1].string, 10), 12, "little");
|
||||
counterLength = 4;
|
||||
counter = Utils.intToByteArray(args[2], counterLength, "little");
|
||||
}
|
||||
|
||||
const output = new Array();
|
||||
const output = [];
|
||||
input = Utils.convertToByteArray(input, inputType);
|
||||
|
||||
let counterAsInt = Utils.byteArrayToInt(counter, "little");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue