diff --git a/src/core/operations/DESDecrypt.mjs b/src/core/operations/DESDecrypt.mjs index 6725160a..9ab694b8 100644 --- a/src/core/operations/DESDecrypt.mjs +++ b/src/core/operations/DESDecrypt.mjs @@ -73,6 +73,11 @@ class DESDecrypt extends Operation { DES uses a key length of 8 bytes (64 bits). Triple DES uses a key length of 24 bytes (192 bits).`); } + if (iv.length !== 8) { + throw new OperationError(`Invalid IV length: ${iv.length} bytes + +DES uses an IV length of 8 bytes (64 bits).`); + } input = Utils.convertToByteString(input, inputType); diff --git a/src/core/operations/DESEncrypt.mjs b/src/core/operations/DESEncrypt.mjs index 5ea5f5fc..9897a413 100644 --- a/src/core/operations/DESEncrypt.mjs +++ b/src/core/operations/DESEncrypt.mjs @@ -73,6 +73,11 @@ 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).`); } + if (iv.length !== 8) { + throw new OperationError(`Invalid IV length: ${iv.length} bytes + +DES uses an IV length of 8 bytes (64 bits).`); + } input = Utils.convertToByteString(input, inputType); diff --git a/tests/node/tests/operations.mjs b/tests/node/tests/operations.mjs index 81af9593..255d8dc1 100644 --- a/tests/node/tests/operations.mjs +++ b/tests/node/tests/operations.mjs @@ -400,7 +400,7 @@ color: white; }, iv: { string: "threetwo", - option: "Hex", + option: "utf8", }, mode: "ECB", }); @@ -415,7 +415,7 @@ color: white; }, iv: { string: "threetwo", - option: "Hex", + option: "utf8", }, mode: "ECB", });