Merge branch 'Storms-Engineering-IV-length-Error'

This commit is contained in:
n1474335 2019-10-16 15:50:51 +01:00
commit a02484c6cd
5 changed files with 28 additions and 4 deletions

View file

@ -73,6 +73,12 @@ class DESDecrypt extends Operation {
DES uses a key length of 8 bytes (64 bits). DES uses a key length of 8 bytes (64 bits).
Triple DES uses a key length of 24 bytes (192 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).
Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
}
input = Utils.convertToByteString(input, inputType); input = Utils.convertToByteString(input, inputType);

View file

@ -73,6 +73,12 @@ class DESEncrypt extends Operation {
DES uses a key length of 8 bytes (64 bits). DES uses a key length of 8 bytes (64 bits).
Triple DES uses a key length of 24 bytes (192 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).
Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
}
input = Utils.convertToByteString(input, inputType); input = Utils.convertToByteString(input, inputType);

View file

@ -75,6 +75,12 @@ class TripleDESDecrypt extends Operation {
Triple DES uses a key length of 24 bytes (192 bits). Triple DES uses a key length of 24 bytes (192 bits).
DES uses a key length of 8 bytes (64 bits).`); DES uses a key length of 8 bytes (64 bits).`);
} }
if (iv.length !== 8) {
throw new OperationError(`Invalid IV length: ${iv.length} bytes
Triple DES uses an IV length of 8 bytes (64 bits).
Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
}
input = Utils.convertToByteString(input, inputType); input = Utils.convertToByteString(input, inputType);

View file

@ -75,6 +75,12 @@ class TripleDESEncrypt extends Operation {
Triple DES uses a key length of 24 bytes (192 bits). Triple DES uses a key length of 24 bytes (192 bits).
DES uses a key length of 8 bytes (64 bits).`); DES uses a key length of 8 bytes (64 bits).`);
} }
if (iv.length !== 8) {
throw new OperationError(`Invalid IV length: ${iv.length} bytes
Triple DES uses an IV length of 8 bytes (64 bits).
Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
}
input = Utils.convertToByteString(input, inputType); input = Utils.convertToByteString(input, inputType);

View file

@ -400,7 +400,7 @@ color: white;
}, },
iv: { iv: {
string: "threetwo", string: "threetwo",
option: "Hex", option: "utf8",
}, },
mode: "ECB", mode: "ECB",
}); });
@ -415,7 +415,7 @@ color: white;
}, },
iv: { iv: {
string: "threetwo", string: "threetwo",
option: "Hex", option: "utf8",
}, },
mode: "ECB", mode: "ECB",
}); });
@ -943,10 +943,10 @@ smothering ampersand abreast
chef.tripleDESDecrypt( chef.tripleDESDecrypt(
chef.tripleDESEncrypt("Destroy Money", { chef.tripleDESEncrypt("Destroy Money", {
key: {string: "30 31 2f 30 34 2f 31 39 39 39 20 32 32 3a 33 33 3a 30 3130 31 2f 30 34", option: "Hex"}, key: {string: "30 31 2f 30 34 2f 31 39 39 39 20 32 32 3a 33 33 3a 30 3130 31 2f 30 34", option: "Hex"},
iv: {string: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00", option: "Hex"}}), iv: {string: "00 00 00 00 00 00 00 00", option: "Hex"}}),
{ {
key: {string: "30 31 2f 30 34 2f 31 39 39 39 20 32 32 3a 33 33 3a 30 3130 31 2f 30 34", option: "Hex"}, key: {string: "30 31 2f 30 34 2f 31 39 39 39 20 32 32 3a 33 33 3a 30 3130 31 2f 30 34", option: "Hex"},
iv: {string: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00", option: "Hex"} iv: {string: "00 00 00 00 00 00 00 00", option: "Hex"}
}).toString(), }).toString(),
"Destroy Money"); "Destroy Money");
}), }),