Fix BLAKE2 output encoding validation
This commit is contained in:
parent
d735496641
commit
309e0932db
@ -70,7 +70,7 @@ class BLAKE2b extends Operation {
|
||||
case "Raw":
|
||||
return Utils.arrayBufferToStr(blakejs.blake2b(input, key, outSize / 8).buffer);
|
||||
default:
|
||||
return new OperationError("Unsupported Output Type");
|
||||
throw new OperationError("Unsupported Output Type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ class BLAKE2s extends Operation {
|
||||
case "Raw":
|
||||
return Utils.arrayBufferToStr(blakejs.blake2s(input, key, outSize / 8).buffer);
|
||||
default:
|
||||
return new OperationError("Unsupported Output Type");
|
||||
throw new OperationError("Unsupported Output Type");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -52,5 +52,14 @@ TestRegister.addTests([
|
||||
{ "op": "BLAKE2b",
|
||||
"args": ["128", "Hex", {string: "pseudorandom key", option: "UTF8"}] }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "BLAKE2b: missing output encoding",
|
||||
input: "hello",
|
||||
expectedOutput: "Unsupported Output Type",
|
||||
recipeConfig: [
|
||||
{ "op": "BLAKE2b",
|
||||
"args": ["512", "", {string: "", option: "UTF8"}] }
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
||||
@ -43,5 +43,14 @@ TestRegister.addTests([
|
||||
{ "op": "BLAKE2s",
|
||||
"args": ["128", "Hex", {string: "", option: "UTF8"}] }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "BLAKE2s: missing output encoding",
|
||||
input: "hello",
|
||||
expectedOutput: "Unsupported Output Type",
|
||||
recipeConfig: [
|
||||
{ "op": "BLAKE2s",
|
||||
"args": ["256", "", {string: "", option: "UTF8"}] }
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user