diff --git a/src/core/operations/BLAKE2b.mjs b/src/core/operations/BLAKE2b.mjs index 6218f7f0..22b7f06c 100644 --- a/src/core/operations/BLAKE2b.mjs +++ b/src/core/operations/BLAKE2b.mjs @@ -32,8 +32,10 @@ class BLAKE2b extends Operation { this.args = [ { "name": "Size", - "type": "option", - "value": ["512", "384", "256", "160", "128"] + "type": "number", + "value": 256, + "min": 8, + "max": 512 }, { "name": "Output Encoding", "type": "option", @@ -61,6 +63,10 @@ class BLAKE2b extends Operation { throw new OperationError(["Key cannot be greater than 64 bytes", "It is currently " + key.length + " bytes."].join("\n")); } + if (outSize % 8 !== 0 || outSize < 8 || outSize > 512) { + throw new OperationError("Size has to be between 8 to 512 and multiple of 8."); + } + input = new Uint8Array(input); switch (outFormat) { case "Hex": diff --git a/src/core/operations/BLAKE2s.mjs b/src/core/operations/BLAKE2s.mjs index 8f84e041..48c41a6c 100644 --- a/src/core/operations/BLAKE2s.mjs +++ b/src/core/operations/BLAKE2s.mjs @@ -32,8 +32,10 @@ class BLAKE2s extends Operation { this.args = [ { "name": "Size", - "type": "option", - "value": ["256", "160", "128"] + "type": "number", + "value": 256, + "min": 8, + "max": 256 }, { "name": "Output Encoding", "type": "option", @@ -62,6 +64,10 @@ class BLAKE2s extends Operation { throw new OperationError(["Key cannot be greater than 32 bytes", "It is currently " + key.length + " bytes."].join("\n")); } + if (outSize % 8 !== 0 || outSize < 8 || outSize > 256) { + throw new OperationError("Size has to be between 8 to 256 and multiple of 8."); + } + input = new Uint8Array(input); switch (outFormat) { case "Hex":