From 9ddb20784531bd84afdba3bb24b1b65cf19e0814 Mon Sep 17 00:00:00 2001 From: Storms-Engineering Date: Thu, 31 Oct 2019 08:42:23 -0800 Subject: [PATCH] Revert "DES Encryption: Check Length of IV" This reverts commit b785f4482a89a8c304fc03449d796ce036a5f85b. --- src/core/lib/Hex.mjs | 2 +- src/core/operations/DESEncrypt.mjs | 7 ++----- tests/node/tests/operations.mjs | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/core/lib/Hex.mjs b/src/core/lib/Hex.mjs index 1c9c7eca..5ae06a7e 100644 --- a/src/core/lib/Hex.mjs +++ b/src/core/lib/Hex.mjs @@ -90,7 +90,7 @@ export function fromHex(data, delim="Auto", byteLen=2) { const delimRegex = delim === "Auto" ? /[^a-f\d]/gi : Utils.regexRep(delim); data = data.replace(delimRegex, ""); } - + const output = []; for (let i = 0; i < data.length; i += byteLen) { output.push(parseInt(data.substr(i, byteLen), 16)); diff --git a/src/core/operations/DESEncrypt.mjs b/src/core/operations/DESEncrypt.mjs index 19ef452e..5ea5f5fc 100644 --- a/src/core/operations/DESEncrypt.mjs +++ b/src/core/operations/DESEncrypt.mjs @@ -19,6 +19,7 @@ class DESEncrypt extends Operation { */ constructor() { super(); + this.name = "DES Encrypt"; this.module = "Ciphers"; this.description = "DES is a previously dominant algorithm for encryption, and was published as an official U.S. Federal Information Processing Standard (FIPS). It is now considered to be insecure due to its small key size.

Key: DES uses a key length of 8 bytes (64 bits).
Triple DES uses a key length of 24 bytes (192 bits).

You can generate a password-based key using one of the KDF operations.

IV: The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.

Padding: In CBC and ECB mode, PKCS#7 padding will be used."; @@ -72,13 +73,9 @@ class DESEncrypt extends Operation { DES uses a key length of 8 bytes (64 bits). Triple DES uses a key length of 24 bytes (192 bits).`); } - else if(iv.length !== 8) { - throw new OperationError(`Invalid IV length: ${iv.length} bytes -DES uses a iv length of 8 bytes (64 bits).`); - - } input = Utils.convertToByteString(input, inputType); + const cipher = forge.cipher.createCipher("DES-" + mode, key); cipher.start({iv: iv}); cipher.update(forge.util.createBuffer(input)); diff --git a/tests/node/tests/operations.mjs b/tests/node/tests/operations.mjs index b8bc2500..42ba74c9 100644 --- a/tests/node/tests/operations.mjs +++ b/tests/node/tests/operations.mjs @@ -415,7 +415,7 @@ color: white; }, iv: { string: "threetwo", - option: "utf8", + option: "Hex", }, mode: "ECB", });