Fix BLAKE3 size validation
This commit is contained in:
parent
d735496641
commit
2672b1dfad
@ -47,6 +47,11 @@ class BLAKE3 extends Operation {
|
||||
run(input, args) {
|
||||
const key = args[1];
|
||||
const size = args[0];
|
||||
|
||||
if (!Number.isInteger(size) || size < 0) {
|
||||
throw new OperationError("Size must be a non-negative integer");
|
||||
}
|
||||
|
||||
const opts = { dkLen: size };
|
||||
const inputBytes = new Uint8Array(Utils.strToArrayBuffer(input));
|
||||
if (key !== "") {
|
||||
|
||||
@ -34,6 +34,24 @@ TestRegister.addTests([
|
||||
"args": [32, ""] }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "BLAKE3: negative size",
|
||||
input: "hello",
|
||||
expectedOutput: "Size must be a non-negative integer",
|
||||
recipeConfig: [
|
||||
{ "op": "BLAKE3",
|
||||
"args": [-6, ""] }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "BLAKE3: fractional size",
|
||||
input: "hello",
|
||||
expectedOutput: "Size must be a non-negative integer",
|
||||
recipeConfig: [
|
||||
{ "op": "BLAKE3",
|
||||
"args": [1.2, ""] }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "BLAKE3: Key Test",
|
||||
input: "Hello world",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user