mirror of
https://github.com/gchq/CyberChef
synced 2025-01-01 07:18:47 +00:00
allow 16-byte keys for Triple DES
This commit is contained in:
parent
ed8bd34915
commit
2255c5b360
2 changed files with 6 additions and 4 deletions
|
@ -70,7 +70,7 @@ class TripleDESDecrypt extends Operation {
|
|||
inputType = args[3],
|
||||
outputType = args[4];
|
||||
|
||||
if (key.length !== 24) {
|
||||
if (key.length !== 24 && key.length !== 16) {
|
||||
throw new OperationError(`Invalid key length: ${key.length} bytes
|
||||
|
||||
Triple DES uses a key length of 24 bytes (192 bits).
|
||||
|
@ -85,7 +85,8 @@ Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
|
|||
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
const decipher = forge.cipher.createDecipher("3DES-" + mode, key);
|
||||
const decipher = forge.cipher.createDecipher("3DES-" + mode,
|
||||
key.length === 16 ? key + key.substring(0, 8) : key);
|
||||
|
||||
/* Allow for a "no padding" mode */
|
||||
if (noPadding) {
|
||||
|
|
|
@ -69,7 +69,7 @@ class TripleDESEncrypt extends Operation {
|
|||
inputType = args[3],
|
||||
outputType = args[4];
|
||||
|
||||
if (key.length !== 24) {
|
||||
if (key.length !== 24 && key.length !== 16) {
|
||||
throw new OperationError(`Invalid key length: ${key.length} bytes
|
||||
|
||||
Triple DES uses a key length of 24 bytes (192 bits).
|
||||
|
@ -84,7 +84,8 @@ Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
|
|||
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
const cipher = forge.cipher.createCipher("3DES-" + mode, key);
|
||||
const cipher = forge.cipher.createCipher("3DES-" + mode,
|
||||
key.length === 16 ? key + key.substring(0, 8) : key);
|
||||
cipher.start({iv: iv});
|
||||
cipher.update(forge.util.createBuffer(input));
|
||||
cipher.finish();
|
||||
|
|
Loading…
Reference in a new issue