Skip to content

Commit 004ef7f

Browse files
authoredFeb 16, 2025··
Merge pull request #1904 from FranciscoPombal/des_triple_des_error_message
fix: DES/Triple DES - misleading error messages
2 parents 9ab990f + 784b263 commit 004ef7f

File tree

6 files changed

+13
-21
lines changed

6 files changed

+13
-21
lines changed
 

‎src/core/operations/DESDecrypt.mjs

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class DESDecrypt extends Operation {
2222

2323
this.name = "DES Decrypt";
2424
this.module = "Ciphers";
25-
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><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 as a default.";
25+
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><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 as a default.";
2626
this.infoURL = "https://wikipedia.org/wiki/Data_Encryption_Standard";
2727
this.inputType = "string";
2828
this.outputType = "string";
@@ -72,8 +72,7 @@ class DESDecrypt extends Operation {
7272
if (key.length !== 8) {
7373
throw new OperationError(`Invalid key length: ${key.length} bytes
7474
75-
DES uses a key length of 8 bytes (64 bits).
76-
Triple DES uses a key length of 24 bytes (192 bits).`);
75+
DES uses a key length of 8 bytes (64 bits).`);
7776
}
7877
if (iv.length !== 8 && mode !== "ECB") {
7978
throw new OperationError(`Invalid IV length: ${iv.length} bytes

‎src/core/operations/DESEncrypt.mjs

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class DESEncrypt extends Operation {
2222

2323
this.name = "DES Encrypt";
2424
this.module = "Ciphers";
25-
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.";
25+
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><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.";
2626
this.infoURL = "https://wikipedia.org/wiki/Data_Encryption_Standard";
2727
this.inputType = "string";
2828
this.outputType = "string";
@@ -70,8 +70,7 @@ class DESEncrypt extends Operation {
7070
if (key.length !== 8) {
7171
throw new OperationError(`Invalid key length: ${key.length} bytes
7272
73-
DES uses a key length of 8 bytes (64 bits).
74-
Triple DES uses a key length of 24 bytes (192 bits).`);
73+
DES uses a key length of 8 bytes (64 bits).`);
7574
}
7675
if (iv.length !== 8 && mode !== "ECB") {
7776
throw new OperationError(`Invalid IV length: ${iv.length} bytes

‎src/core/operations/TripleDESDecrypt.mjs

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class TripleDESDecrypt extends Operation {
2222

2323
this.name = "Triple DES Decrypt";
2424
this.module = "Ciphers";
25-
this.description = "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<br>DES uses a key length of 8 bytes (64 bits).<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 as a default.";
25+
this.description = "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<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 as a default.";
2626
this.infoURL = "https://wikipedia.org/wiki/Triple_DES";
2727
this.inputType = "string";
2828
this.outputType = "string";
@@ -73,8 +73,7 @@ class TripleDESDecrypt extends Operation {
7373
if (key.length !== 24 && key.length !== 16) {
7474
throw new OperationError(`Invalid key length: ${key.length} bytes
7575
76-
Triple DES uses a key length of 24 bytes (192 bits).
77-
DES uses a key length of 8 bytes (64 bits).`);
76+
Triple DES uses a key length of 24 bytes (192 bits).`);
7877
}
7978
if (iv.length !== 8 && mode !== "ECB") {
8079
throw new OperationError(`Invalid IV length: ${iv.length} bytes

‎src/core/operations/TripleDESEncrypt.mjs

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class TripleDESEncrypt extends Operation {
2222

2323
this.name = "Triple DES Encrypt";
2424
this.module = "Ciphers";
25-
this.description = "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<br>DES uses a key length of 8 bytes (64 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.";
25+
this.description = "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> 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.";
2626
this.infoURL = "https://wikipedia.org/wiki/Triple_DES";
2727
this.inputType = "string";
2828
this.outputType = "string";
@@ -72,8 +72,7 @@ class TripleDESEncrypt extends Operation {
7272
if (key.length !== 24 && key.length !== 16) {
7373
throw new OperationError(`Invalid key length: ${key.length} bytes
7474
75-
Triple DES uses a key length of 24 bytes (192 bits).
76-
DES uses a key length of 8 bytes (64 bits).`);
75+
Triple DES uses a key length of 24 bytes (192 bits).`);
7776
}
7877
if (iv.length !== 8 && mode !== "ECB") {
7978
throw new OperationError(`Invalid IV length: ${iv.length} bytes

‎tests/node/tests/nodeApi.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ TestRegister.addApiTests([
119119
assert.strictEqual(result[0].module, "Ciphers");
120120
assert.strictEqual(result[0].inputType, "string");
121121
assert.strictEqual(result[0].outputType, "string");
122-
assert.strictEqual(result[0].description, "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<br>DES uses a key length of 8 bytes (64 bits).<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 as a default.");
122+
assert.strictEqual(result[0].description, "Triple DES applies DES three times to each block to increase key size.<br><br><b>Key:</b> Triple DES uses a key length of 24 bytes (192 bits).<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 as a default.");
123123
assert.strictEqual(result[0].args.length, 5);
124124
}),
125125

‎tests/operations/tests/Crypt.mjs

+4-8
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,7 @@ Tag: a8f04c4d93bbef82bef61a103371aef9`,
580580
input: "",
581581
expectedOutput: `Invalid key length: 0 bytes
582582
583-
DES uses a key length of 8 bytes (64 bits).
584-
Triple DES uses a key length of 24 bytes (192 bits).`,
583+
DES uses a key length of 8 bytes (64 bits).`,
585584
recipeConfig: [
586585
{
587586
"op": "DES Encrypt",
@@ -674,8 +673,7 @@ Triple DES uses a key length of 24 bytes (192 bits).`,
674673
input: "",
675674
expectedOutput: `Invalid key length: 0 bytes
676675
677-
Triple DES uses a key length of 24 bytes (192 bits).
678-
DES uses a key length of 8 bytes (64 bits).`,
676+
Triple DES uses a key length of 24 bytes (192 bits).`,
679677
recipeConfig: [
680678
{
681679
"op": "Triple DES Encrypt",
@@ -1300,8 +1298,7 @@ The following algorithms will be used based on the size of the key:
13001298
input: "",
13011299
expectedOutput: `Invalid key length: 0 bytes
13021300
1303-
DES uses a key length of 8 bytes (64 bits).
1304-
Triple DES uses a key length of 24 bytes (192 bits).`,
1301+
DES uses a key length of 8 bytes (64 bits).`,
13051302
recipeConfig: [
13061303
{
13071304
"op": "DES Decrypt",
@@ -1394,8 +1391,7 @@ Triple DES uses a key length of 24 bytes (192 bits).`,
13941391
input: "",
13951392
expectedOutput: `Invalid key length: 0 bytes
13961393
1397-
Triple DES uses a key length of 24 bytes (192 bits).
1398-
DES uses a key length of 8 bytes (64 bits).`,
1394+
Triple DES uses a key length of 24 bytes (192 bits).`,
13991395
recipeConfig: [
14001396
{
14011397
"op": "Triple DES Decrypt",

0 commit comments

Comments
 (0)
Please sign in to comment.