CyberChef/src/core/operations/Snefru.mjs

56 lines
1.6 KiB
JavaScript

/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*/
import Operation from "../Operation";
import {runHash} from "../lib/Hash";
/**
* Snefru operation
*/
class Snefru extends Operation {
/**
* Snefru constructor
*/
constructor() {
super();
this.name = "Snefru";
this.module = "Crypto";
this.description = "Snefru is a cryptographic hash function invented by Ralph Merkle in 1990 while working at Xerox PARC. The function supports 128-bit and 256-bit output. It was named after the Egyptian Pharaoh Sneferu, continuing the tradition of the Khufu and Khafre block ciphers.<br><br>The original design of Snefru was shown to be insecure by Eli Biham and Adi Shamir who were able to use differential cryptanalysis to find hash collisions. The design was then modified by increasing the number of iterations of the main pass of the algorithm from two to eight.";
this.infoURL = "https://wikipedia.org/wiki/Snefru";
this.inputType = "ArrayBuffer";
this.outputType = "string";
this.args = [
{
"name": "Rounds",
"type": "option",
"value": ["8", "4", "2"]
},
{
"name": "Size",
"type": "option",
"value": ["256", "128"]
}
];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
return runHash("snefru", input, {
rounds: args[0],
length: args[1]
});
}
}
export default Snefru;