From 2270145a4a69efcea343c6bd287b73f9065b1b31 Mon Sep 17 00:00:00 2001 From: Macide Celik Date: Mon, 28 Oct 2019 01:02:46 +0300 Subject: [PATCH] Delete BLAKE2b.mjs --- src/core/operations/BLAKE2b.mjs | 79 --------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 src/core/operations/BLAKE2b.mjs diff --git a/src/core/operations/BLAKE2b.mjs b/src/core/operations/BLAKE2b.mjs deleted file mode 100644 index 6218f7f0..00000000 --- a/src/core/operations/BLAKE2b.mjs +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @author h345983745 - * @copyright Crown Copyright 2019 - * @license Apache-2.0 - */ - -import Operation from "../Operation.mjs"; -import blakejs from "blakejs"; -import OperationError from "../errors/OperationError.mjs"; -import Utils from "../Utils.mjs"; -import { toBase64 } from "../lib/Base64.mjs"; - -/** - * BLAKE2b operation - */ -class BLAKE2b extends Operation { - - /** - * BLAKE2b constructor - */ - constructor() { - super(); - - this.name = "BLAKE2b"; - this.module = "Hashing"; - this.description = `Performs BLAKE2b hashing on the input. -

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. -

Supports the use of an optional key.`; - this.infoURL = "https://wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2b_algorithm"; - this.inputType = "ArrayBuffer"; - this.outputType = "string"; - this.args = [ - { - "name": "Size", - "type": "option", - "value": ["512", "384", "256", "160", "128"] - }, { - "name": "Output Encoding", - "type": "option", - "value": ["Hex", "Base64", "Raw"] - }, { - "name": "Key", - "type": "toggleString", - "value": "", - "toggleValues": ["UTF8", "Decimal", "Base64", "Hex", "Latin1"] - } - ]; - } - - /** - * @param {ArrayBuffer} input - * @param {Object[]} args - * @returns {string} The input having been hashed with BLAKE2b in the encoding format specified. - */ - run(input, args) { - const [outSize, outFormat] = args; - let key = Utils.convertToByteArray(args[2].string || "", args[2].option); - if (key.length === 0) { - key = null; - } else if (key.length > 64) { - throw new OperationError(["Key cannot be greater than 64 bytes", "It is currently " + key.length + " bytes."].join("\n")); - } - - input = new Uint8Array(input); - switch (outFormat) { - case "Hex": - return blakejs.blake2bHex(input, key, outSize / 8); - case "Base64": - return toBase64(blakejs.blake2b(input, key, outSize / 8)); - case "Raw": - return Utils.arrayBufferToStr(blakejs.blake2b(input, key, outSize / 8).buffer); - default: - return new OperationError("Unsupported Output Type"); - } - } - -} - -export default BLAKE2b;