mirror of
https://github.com/gchq/CyberChef
synced 2024-12-28 13:33:20 +00:00
Changed input type for BLAKE hashing ops to ArrayBuffer and tidied
This commit is contained in:
parent
342e11f83e
commit
3dc5b5c31a
5 changed files with 32 additions and 21 deletions
|
@ -1,6 +1,10 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
All major and minor version changes will be documented in this file. Details of patch-level version changes can be found in [commit messages](https://github.com/gchq/CyberChef/commits/master).
|
All major and minor version changes will be documented in this file. Details of patch-level version changes can be found in [commit messages](https://github.com/gchq/CyberChef/commits/master).
|
||||||
|
|
||||||
|
|
||||||
|
### [8.29.0] - 2019-03-31
|
||||||
|
- 'BLAKE2s' and 'BLAKE2b' hashing operations added [@h345983745] | [#525]
|
||||||
|
|
||||||
### [8.28.0] - 2019-03-31
|
### [8.28.0] - 2019-03-31
|
||||||
- 'Heatmap Chart', 'Hex Density Chart', 'Scatter Chart' and 'Series Chart' operation added [@artemisbot] [@tlwr] | [#496] [#143]
|
- 'Heatmap Chart', 'Hex Density Chart', 'Scatter Chart' and 'Series Chart' operation added [@artemisbot] [@tlwr] | [#496] [#143]
|
||||||
|
|
||||||
|
@ -120,6 +124,7 @@ All major and minor version changes will be documented in this file. Details of
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[8.29.0]: https://github.com/gchq/CyberChef/releases/tag/v8.29.0
|
||||||
[8.28.0]: https://github.com/gchq/CyberChef/releases/tag/v8.28.0
|
[8.28.0]: https://github.com/gchq/CyberChef/releases/tag/v8.28.0
|
||||||
[8.27.0]: https://github.com/gchq/CyberChef/releases/tag/v8.27.0
|
[8.27.0]: https://github.com/gchq/CyberChef/releases/tag/v8.27.0
|
||||||
[8.26.0]: https://github.com/gchq/CyberChef/releases/tag/v8.26.0
|
[8.26.0]: https://github.com/gchq/CyberChef/releases/tag/v8.26.0
|
||||||
|
@ -217,3 +222,4 @@ All major and minor version changes will be documented in this file. Details of
|
||||||
[#496]: https://github.com/gchq/CyberChef/pull/496
|
[#496]: https://github.com/gchq/CyberChef/pull/496
|
||||||
[#506]: https://github.com/gchq/CyberChef/pull/506
|
[#506]: https://github.com/gchq/CyberChef/pull/506
|
||||||
[#516]: https://github.com/gchq/CyberChef/pull/516
|
[#516]: https://github.com/gchq/CyberChef/pull/516
|
||||||
|
[#525]: https://github.com/gchq/CyberChef/pull/525
|
||||||
|
|
|
@ -297,6 +297,8 @@
|
||||||
"HAS-160",
|
"HAS-160",
|
||||||
"Whirlpool",
|
"Whirlpool",
|
||||||
"Snefru",
|
"Snefru",
|
||||||
|
"BLAKE2b",
|
||||||
|
"BLAKE2s",
|
||||||
"SSDEEP",
|
"SSDEEP",
|
||||||
"CTPH",
|
"CTPH",
|
||||||
"Compare SSDEEP hashes",
|
"Compare SSDEEP hashes",
|
||||||
|
@ -313,9 +315,7 @@
|
||||||
"Adler-32 Checksum",
|
"Adler-32 Checksum",
|
||||||
"CRC-16 Checksum",
|
"CRC-16 Checksum",
|
||||||
"CRC-32 Checksum",
|
"CRC-32 Checksum",
|
||||||
"TCP/IP Checksum",
|
"TCP/IP Checksum"
|
||||||
"BLAKE2b",
|
|
||||||
"BLAKE2s"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@ class BLAKE2b extends Operation {
|
||||||
<br><br> BLAKE2b is a flavour of the BLAKE cryptographic hash function that is optimized for 64-bit platforms and produces digests of any size between 1 and 64 bytes.
|
<br><br> BLAKE2b is a flavour of the BLAKE cryptographic hash function that is optimized for 64-bit platforms and produces digests of any size between 1 and 64 bytes.
|
||||||
<br><br> Supports the use of an optional key.`;
|
<br><br> Supports the use of an optional key.`;
|
||||||
this.infoURL = "https://wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2b_algorithm";
|
this.infoURL = "https://wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2b_algorithm";
|
||||||
this.inputType = "string";
|
this.inputType = "ArrayBuffer";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
this.args = [
|
this.args = [
|
||||||
{
|
{
|
||||||
|
@ -48,18 +48,20 @@ class BLAKE2b extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} input
|
* @param {ArrayBuffer} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string} The input having been hashed with BLAKE2b in the encoding format speicifed.
|
* @returns {string} The input having been hashed with BLAKE2b in the encoding format speicifed.
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const [outSize, outFormat] = args;
|
const [outSize, outFormat] = args;
|
||||||
let key = Utils.convertToByteArray(args[2].string || "", args[2].option);
|
let key = Utils.convertToByteArray(args[2].string || "", args[2].option);
|
||||||
if (key.length === 0){
|
if (key.length === 0) {
|
||||||
key = null;
|
key = null;
|
||||||
} else if (key.length > 64){
|
} else if (key.length > 64) {
|
||||||
throw new OperationError(["Key cannot be greater than 64 bytes", "It is currently " + key.length + " bytes."].join("\n"));
|
throw new OperationError(["Key cannot be greater than 64 bytes", "It is currently " + key.length + " bytes."].join("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input = new Uint8Array(input);
|
||||||
switch (outFormat) {
|
switch (outFormat) {
|
||||||
case "Hex":
|
case "Hex":
|
||||||
return blakejs.blake2bHex(input, key, outSize / 8);
|
return blakejs.blake2bHex(input, key, outSize / 8);
|
||||||
|
|
|
@ -9,6 +9,7 @@ import blakejs from "blakejs";
|
||||||
import OperationError from "../errors/OperationError";
|
import OperationError from "../errors/OperationError";
|
||||||
import Utils from "../Utils";
|
import Utils from "../Utils";
|
||||||
import { toBase64 } from "../lib/Base64";
|
import { toBase64 } from "../lib/Base64";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BLAKE2s Operation
|
* BLAKE2s Operation
|
||||||
*/
|
*/
|
||||||
|
@ -23,10 +24,10 @@ class BLAKE2s extends Operation {
|
||||||
this.name = "BLAKE2s";
|
this.name = "BLAKE2s";
|
||||||
this.module = "Hashing";
|
this.module = "Hashing";
|
||||||
this.description = `Performs BLAKE2s hashing on the input.
|
this.description = `Performs BLAKE2s hashing on the input.
|
||||||
<br><br> BLAKE2s is a flavour of the BLAKE cryptographic hash function that is optimized for 8 to 32-bit platforms and produces digests of any size between 1 and 32 bytes.
|
<br><br>BLAKE2s is a flavour of the BLAKE cryptographic hash function that is optimized for 8- to 32-bit platforms and produces digests of any size between 1 and 32 bytes.
|
||||||
<br><br> Supports the use of an optional key.`;
|
<br><br>Supports the use of an optional key.`;
|
||||||
this.infoURL = "https://wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2";
|
this.infoURL = "https://wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2";
|
||||||
this.inputType = "string";
|
this.inputType = "ArrayBuffer";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
this.args = [
|
this.args = [
|
||||||
{
|
{
|
||||||
|
@ -48,18 +49,20 @@ class BLAKE2s extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} input
|
* @param {ArrayBuffer} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string} The input having been hashed with BLAKE2s in the encoding format speicifed.
|
* @returns {string} The input having been hashed with BLAKE2s in the encoding format speicifed.
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const [outSize, outFormat] = args;
|
const [outSize, outFormat] = args;
|
||||||
let key = Utils.convertToByteArray(args[2].string || "", args[2].option);
|
let key = Utils.convertToByteArray(args[2].string || "", args[2].option);
|
||||||
if (key.length === 0){
|
if (key.length === 0) {
|
||||||
key = null;
|
key = null;
|
||||||
} else if (key.length > 32){
|
} else if (key.length > 32) {
|
||||||
throw new OperationError(["Key cannot be greater than 32 bytes", "It is currently " + key.length + " bytes."].join("\n"));
|
throw new OperationError(["Key cannot be greater than 32 bytes", "It is currently " + key.length + " bytes."].join("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input = new Uint8Array(input);
|
||||||
switch (outFormat) {
|
switch (outFormat) {
|
||||||
case "Hex":
|
case "Hex":
|
||||||
return blakejs.blake2sHex(input, key, outSize / 8);
|
return blakejs.blake2sHex(input, key, outSize / 8);
|
||||||
|
|
|
@ -88,16 +88,16 @@ class GenerateAllHashes extends Operation {
|
||||||
"\nWhirlpool-0: " + (new Whirlpool()).run(arrayBuffer, ["Whirlpool-0"]) +
|
"\nWhirlpool-0: " + (new Whirlpool()).run(arrayBuffer, ["Whirlpool-0"]) +
|
||||||
"\nWhirlpool-T: " + (new Whirlpool()).run(arrayBuffer, ["Whirlpool-T"]) +
|
"\nWhirlpool-T: " + (new Whirlpool()).run(arrayBuffer, ["Whirlpool-T"]) +
|
||||||
"\nWhirlpool: " + (new Whirlpool()).run(arrayBuffer, ["Whirlpool"]) +
|
"\nWhirlpool: " + (new Whirlpool()).run(arrayBuffer, ["Whirlpool"]) +
|
||||||
|
"\nBLAKE2b-128: " + (new BLAKE2b).run(arrayBuffer, ["128", "Hex", {string: "", option: "UTF8"}]) +
|
||||||
|
"\nBLAKE2b-160: " + (new BLAKE2b).run(arrayBuffer, ["160", "Hex", {string: "", option: "UTF8"}]) +
|
||||||
|
"\nBLAKE2b-256: " + (new BLAKE2b).run(arrayBuffer, ["256", "Hex", {string: "", option: "UTF8"}]) +
|
||||||
|
"\nBLAKE2b-384: " + (new BLAKE2b).run(arrayBuffer, ["384", "Hex", {string: "", option: "UTF8"}]) +
|
||||||
|
"\nBLAKE2b-512: " + (new BLAKE2b).run(arrayBuffer, ["512", "Hex", {string: "", option: "UTF8"}]) +
|
||||||
|
"\nBLAKE2s-128: " + (new BLAKE2s).run(arrayBuffer, ["128", "Hex", {string: "", option: "UTF8"}]) +
|
||||||
|
"\nBLAKE2s-160: " + (new BLAKE2s).run(arrayBuffer, ["160", "Hex", {string: "", option: "UTF8"}]) +
|
||||||
|
"\nBLAKE2s-256: " + (new BLAKE2s).run(arrayBuffer, ["256", "Hex", {string: "", option: "UTF8"}]) +
|
||||||
"\nSSDEEP: " + (new SSDEEP()).run(str) +
|
"\nSSDEEP: " + (new SSDEEP()).run(str) +
|
||||||
"\nCTPH: " + (new CTPH()).run(str) +
|
"\nCTPH: " + (new CTPH()).run(str) +
|
||||||
"\nBLAKE2b-512: " + (new BLAKE2b).run(str, ["512", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2b-384: " + (new BLAKE2b).run(str, ["384", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2b-256: " + (new BLAKE2b).run(str, ["256", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2b-160: " + (new BLAKE2b).run(str, ["160", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2b-128: " + (new BLAKE2b).run(str, ["128", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2s-256: " + (new BLAKE2s).run(str, ["256", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2s-160: " + (new BLAKE2s).run(str, ["160", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\nBLAKE2s-128: " + (new BLAKE2s).run(str, ["128", "Hex", {string: "", option: "UTF8"}]) +
|
|
||||||
"\n\nChecksums:" +
|
"\n\nChecksums:" +
|
||||||
"\nFletcher-8: " + (new Fletcher8Checksum).run(byteArray, []) +
|
"\nFletcher-8: " + (new Fletcher8Checksum).run(byteArray, []) +
|
||||||
"\nFletcher-16: " + (new Fletcher16Checksum).run(byteArray, []) +
|
"\nFletcher-16: " + (new Fletcher16Checksum).run(byteArray, []) +
|
||||||
|
|
Loading…
Reference in a new issue