mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-10 08:15:00 -04:00
DES Encryption: Check Length of IV
Encryption operation now checks the length of the IV. Also changed test to use utf8 instead of HEX because the hex string wasn't valid.
This commit is contained in:
parent
7a3ca027bb
commit
b785f4482a
3 changed files with 7 additions and 4 deletions
|
@ -19,7 +19,6 @@ 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.<br><br><b>Key:</b> DES uses a key length of 8 bytes (64 bits).<br>Triple DES uses a key length of 24 bytes (192 bits).<br><br>You can generate a password-based key using one of the KDF operations.<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used.";
|
||||
|
@ -73,9 +72,13 @@ 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));
|
||||
|
|
|
@ -415,7 +415,7 @@ color: white;
|
|||
},
|
||||
iv: {
|
||||
string: "threetwo",
|
||||
option: "Hex",
|
||||
option: "utf8",
|
||||
},
|
||||
mode: "ECB",
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue