mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Merge pull request #933 from cbeuw/blowfish-keyfix
This commit is contained in:
commit
8647b50cca
3 changed files with 46 additions and 4 deletions
|
@ -70,10 +70,14 @@ class BlowfishDecrypt extends Operation {
|
||||||
inputType = args[3],
|
inputType = args[3],
|
||||||
outputType = args[4];
|
outputType = args[4];
|
||||||
|
|
||||||
if (key.length !== 8) {
|
if (key.length < 4 || key.length > 56) {
|
||||||
throw new OperationError(`Invalid key length: ${key.length} bytes
|
throw new OperationError(`Invalid key length: ${key.length} bytes
|
||||||
|
|
||||||
Blowfish uses a key length of 8 bytes (64 bits).`);
|
Blowfish's key length needs to be between 4 and 56 bytes (32-448 bits).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iv.length !== 8) {
|
||||||
|
throw new OperationError(`Invalid IV length: ${iv.length} bytes. Expected 8 bytes`);
|
||||||
}
|
}
|
||||||
|
|
||||||
input = Utils.convertToByteString(input, inputType);
|
input = Utils.convertToByteString(input, inputType);
|
||||||
|
|
|
@ -70,10 +70,14 @@ class BlowfishEncrypt extends Operation {
|
||||||
inputType = args[3],
|
inputType = args[3],
|
||||||
outputType = args[4];
|
outputType = args[4];
|
||||||
|
|
||||||
if (key.length !== 8) {
|
if (key.length < 4 || key.length > 56) {
|
||||||
throw new OperationError(`Invalid key length: ${key.length} bytes
|
throw new OperationError(`Invalid key length: ${key.length} bytes
|
||||||
|
|
||||||
Blowfish uses a key length of 8 bytes (64 bits).`);
|
Blowfish's key length needs to be between 4 and 56 bytes (32-448 bits).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iv.length !== 8) {
|
||||||
|
throw new OperationError(`Invalid IV length: ${iv.length} bytes. Expected 8 bytes`);
|
||||||
}
|
}
|
||||||
|
|
||||||
input = Utils.convertToByteString(input, inputType);
|
input = Utils.convertToByteString(input, inputType);
|
||||||
|
|
|
@ -1948,4 +1948,38 @@ DES uses a key length of 8 bytes (64 bits).`,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Blowfish Encrypt with variable key length: CBC, ASCII, 4 bytes",
|
||||||
|
input: "The quick brown fox jumps over the lazy dog.",
|
||||||
|
expectedOutput: "823f337a53ecf121aa9ec1b111bd5064d1d7586abbdaaa0c8fd0c6cc43c831c88bf088ee3e07287e3f36cf2e45f9c7e6",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Blowfish Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "00112233"}, // Key
|
||||||
|
{"option": "Hex", "string": "0000000000000000"}, // IV
|
||||||
|
"CBC", // Mode
|
||||||
|
"Raw", // Input
|
||||||
|
"Hex" // Output
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Blowfish Encrypt with variable key length: CBC, ASCII, 42 bytes",
|
||||||
|
input: "The quick brown fox jumps over the lazy dog.",
|
||||||
|
expectedOutput: "19f5a68145b34321cfba72226b0f33922ce44dd6e7869fe328db64faae156471216f12ed2a37fd0bdd7cebf867b3cff0",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Blowfish Encrypt",
|
||||||
|
"args": [
|
||||||
|
{"option": "Hex", "string": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdead"}, // Key
|
||||||
|
{"option": "Hex", "string": "0000000000000000"}, // IV
|
||||||
|
"CBC", // Mode
|
||||||
|
"Raw", // Input
|
||||||
|
"Hex" // Output
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue