mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
Added 'GOST Hash' operation
This commit is contained in:
parent
99f4091c1a
commit
09bea6e231
1 changed files with 71 additions and 0 deletions
71
src/core/operations/GOSTHash.mjs
Normal file
71
src/core/operations/GOSTHash.mjs
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/**
|
||||||
|
* @author n1474335 [n1474335@gmail.com]
|
||||||
|
* @copyright Crown Copyright 2019
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation";
|
||||||
|
import OperationError from "../errors/OperationError";
|
||||||
|
import GostDigest from "../vendor/gost/gostDigest";
|
||||||
|
import {toHexFast} from "../lib/Hex";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GOST hash operation
|
||||||
|
*/
|
||||||
|
class GOSTHash extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GOSTHash constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "GOST hash";
|
||||||
|
this.module = "Hashing";
|
||||||
|
this.description = "The GOST hash function, defined in the standards GOST R 34.11-94 and GOST 34.311-95 is a 256-bit cryptographic hash function. It was initially defined in the Russian national standard GOST R 34.11-94 <i>Information Technology – Cryptographic Information Security – Hash Function</i>. The equivalent standard used by other member-states of the CIS is GOST 34.311-95.<br><br>This function must not be confused with a different Streebog hash function, which is defined in the new revision of the standard GOST R 34.11-2012.<br><br>The GOST hash function is based on the GOST block cipher.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/GOST_(hash_function)";
|
||||||
|
this.inputType = "ArrayBuffer";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [
|
||||||
|
{
|
||||||
|
"name": "S-Box",
|
||||||
|
"type": "option",
|
||||||
|
"value": [
|
||||||
|
"D-A",
|
||||||
|
"D-SC",
|
||||||
|
"E-TEST",
|
||||||
|
"E-A",
|
||||||
|
"E-B",
|
||||||
|
"E-C",
|
||||||
|
"E-D",
|
||||||
|
"E-SC",
|
||||||
|
"E-Z",
|
||||||
|
"D-TEST"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ArrayBuffer} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
try {
|
||||||
|
const sBox = args[1];
|
||||||
|
const gostDigest = new GostDigest({
|
||||||
|
name: "GOST R 34.11",
|
||||||
|
version: 1994,
|
||||||
|
sBox: sBox
|
||||||
|
});
|
||||||
|
|
||||||
|
return toHexFast(gostDigest.digest(input));
|
||||||
|
} catch (err) {
|
||||||
|
throw new OperationError(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GOSTHash;
|
Loading…
Add table
Add a link
Reference in a new issue