From d175aa958cf58ba8e2600cad83a78e6d55b62496 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Fri, 18 Oct 2019 11:09:12 +0100 Subject: [PATCH] DES no longer requires an IV in ECB mode --- src/core/operations/DESDecrypt.mjs | 2 +- src/core/operations/DESEncrypt.mjs | 2 +- src/core/operations/TripleDESDecrypt.mjs | 2 +- src/core/operations/TripleDESEncrypt.mjs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/operations/DESDecrypt.mjs b/src/core/operations/DESDecrypt.mjs index 92b9609f..42097cc2 100644 --- a/src/core/operations/DESDecrypt.mjs +++ b/src/core/operations/DESDecrypt.mjs @@ -73,7 +73,7 @@ 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) { + if (iv.length !== 8 && mode !== "ECB") { throw new OperationError(`Invalid IV length: ${iv.length} bytes DES uses an IV length of 8 bytes (64 bits). diff --git a/src/core/operations/DESEncrypt.mjs b/src/core/operations/DESEncrypt.mjs index ee845151..6f297d32 100644 --- a/src/core/operations/DESEncrypt.mjs +++ b/src/core/operations/DESEncrypt.mjs @@ -73,7 +73,7 @@ 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) { + if (iv.length !== 8 && mode !== "ECB") { throw new OperationError(`Invalid IV length: ${iv.length} bytes DES uses an IV length of 8 bytes (64 bits). diff --git a/src/core/operations/TripleDESDecrypt.mjs b/src/core/operations/TripleDESDecrypt.mjs index f1aa02c8..70376a5f 100644 --- a/src/core/operations/TripleDESDecrypt.mjs +++ b/src/core/operations/TripleDESDecrypt.mjs @@ -75,7 +75,7 @@ class TripleDESDecrypt extends Operation { Triple DES uses a key length of 24 bytes (192 bits). DES uses a key length of 8 bytes (64 bits).`); } - if (iv.length !== 8) { + if (iv.length !== 8 && mode !== "ECB") { throw new OperationError(`Invalid IV length: ${iv.length} bytes Triple DES uses an IV length of 8 bytes (64 bits). diff --git a/src/core/operations/TripleDESEncrypt.mjs b/src/core/operations/TripleDESEncrypt.mjs index 9f767ab9..bcd77d2e 100644 --- a/src/core/operations/TripleDESEncrypt.mjs +++ b/src/core/operations/TripleDESEncrypt.mjs @@ -75,7 +75,7 @@ class TripleDESEncrypt extends Operation { Triple DES uses a key length of 24 bytes (192 bits). DES uses a key length of 8 bytes (64 bits).`); } - if (iv.length !== 8) { + if (iv.length !== 8 && mode !== "ECB") { throw new OperationError(`Invalid IV length: ${iv.length} bytes Triple DES uses an IV length of 8 bytes (64 bits).