Add effective key bits option with 128 by default to RC2 operation

This commit is contained in:
r4mos 2025-09-25 13:13:33 +02:00
parent d7915b1a15
commit 663f7480ad
3 changed files with 24 additions and 7 deletions

View file

@ -32,6 +32,11 @@ class RC2Decrypt extends Operation {
"value": "",
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
},
{
name: "Effective key bits",
type: "number",
value: 128
},
{
"name": "IV",
"type": "toggleString",
@ -58,9 +63,10 @@ class RC2Decrypt extends Operation {
*/
run(input, args) {
const key = Utils.convertToByteString(args[0].string, args[0].option),
iv = Utils.convertToByteString(args[1].string, args[1].option),
[,, inputType, outputType] = args,
decipher = forge.rc2.createDecryptionCipher(key);
effective = args[1],
iv = Utils.convertToByteString(args[2].string, args[2].option),
[,,, inputType, outputType] = args,
decipher = forge.rc2.createDecryptionCipher(key, effective);
input = Utils.convertToByteString(input, inputType);

View file

@ -8,7 +8,6 @@ import Operation from "../Operation.mjs";
import Utils from "../Utils.mjs";
import forge from "node-forge";
/**
* RC2 Encrypt operation
*/
@ -33,6 +32,11 @@ class RC2Encrypt extends Operation {
"value": "",
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
},
{
name: "Effective key bits",
type: "number",
value: 128
},
{
"name": "IV",
"type": "toggleString",
@ -59,9 +63,10 @@ class RC2Encrypt extends Operation {
*/
run(input, args) {
const key = Utils.convertToByteString(args[0].string, args[0].option),
iv = Utils.convertToByteString(args[1].string, args[1].option),
[,, inputType, outputType] = args,
cipher = forge.rc2.createEncryptionCipher(key);
effective = args[1],
iv = Utils.convertToByteString(args[2].string, args[2].option),
[,,, inputType, outputType] = args,
cipher = forge.rc2.createEncryptionCipher(key, effective);
input = Utils.convertToByteString(input, inputType);

View file

@ -1488,6 +1488,7 @@ Triple DES uses a key length of 24 bytes (192 bits).`,
"op": "RC2 Encrypt",
"args": [
{"option": "Hex", "string": ""},
128,
{"option": "Hex", "string": ""},
"Hex", "Hex"
]
@ -1503,6 +1504,7 @@ Triple DES uses a key length of 24 bytes (192 bits).`,
"op": "RC2 Encrypt",
"args": [
{"option": "Hex", "string": "eb970554bb213430f4bb4e5988a6a218"},
128,
{"option": "Hex", "string": "ae817c784a097e0c"},
"Hex", "Hex"
]
@ -1518,6 +1520,7 @@ Triple DES uses a key length of 24 bytes (192 bits).`,
"op": "RC2 Encrypt",
"args": [
{"option": "Hex", "string": "eb970554bb213430f4bb4e5988a6a218"},
128,
{"option": "Hex", "string": ""},
"Hex", "Hex"
]
@ -1533,6 +1536,7 @@ Triple DES uses a key length of 24 bytes (192 bits).`,
"op": "RC2 Decrypt",
"args": [
{"option": "Hex", "string": ""},
128,
{"option": "Hex", "string": ""},
"Hex", "Hex"
]
@ -1548,6 +1552,7 @@ Triple DES uses a key length of 24 bytes (192 bits).`,
"op": "RC2 Decrypt",
"args": [
{"option": "Hex", "string": "eb970554bb213430f4bb4e5988a6a218"},
128,
{"option": "Hex", "string": "ae817c784a097e0c"},
"Hex", "Hex"
]
@ -1563,6 +1568,7 @@ Triple DES uses a key length of 24 bytes (192 bits).`,
"op": "RC2 Decrypt",
"args": [
{"option": "Hex", "string": "eb970554bb213430f4bb4e5988a6a218"},
128,
{"option": "Hex", "string": ""},
"Hex", "Hex"
]