Merge 2672b1dfad1f85b342691be370d671ab370e2414 into 002ed911b1a39f303b70246ac0ebf455a91c6d0f

This commit is contained in:
Петушков А. 2026-07-06 12:37:34 +01:00 committed by GitHub
commit cd6630d6b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 0 deletions

View File

@ -51,6 +51,11 @@ class BLAKE3 extends Operation {
run(input, args) { run(input, args) {
const key = args[1]; const key = args[1];
const size = args[0]; 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 opts = { dkLen: size };
const inputBytes = new Uint8Array(Utils.strToArrayBuffer(input)); const inputBytes = new Uint8Array(Utils.strToArrayBuffer(input));
if (key !== "") { if (key !== "") {

View File

@ -34,6 +34,24 @@ TestRegister.addTests([
"args": [32, ""] } "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", name: "BLAKE3: Key Test",
input: "Hello world", input: "Hello world",