Added 'RC2 Encrypt' and 'RC2 Decrypt' operations.
parent
b58942f69a
commit
f52f5a0edb
|
@ -79,6 +79,8 @@ const Categories = [
|
|||
"DES Decrypt",
|
||||
"Triple DES Encrypt",
|
||||
"Triple DES Decrypt",
|
||||
"RC2 Encrypt",
|
||||
"RC2 Decrypt",
|
||||
"RC4",
|
||||
"RC4 Drop",
|
||||
"ROT13",
|
||||
|
|
|
@ -1388,7 +1388,7 @@ const OperationConfig = {
|
|||
},
|
||||
"RC4": {
|
||||
module: "Ciphers",
|
||||
description: "RC4 is a widely-used stream cipher. It is used in popular protocols such as SSL and WEP. Although remarkable for its simplicity and speed, the algorithm's history doesn't inspire confidence in its security.",
|
||||
description: "RC4 (also known as ARC4) is a widely-used stream cipher designed by Ron Rivest. It is used in popular protocols such as SSL and WEP. Although remarkable for its simplicity and speed, the algorithm's history doesn't inspire confidence in its security.",
|
||||
highlight: true,
|
||||
highlightReverse: true,
|
||||
inputType: "string",
|
||||
|
@ -1443,6 +1443,66 @@ const OperationConfig = {
|
|||
},
|
||||
]
|
||||
},
|
||||
"RC2 Decrypt": {
|
||||
module: "Ciphers",
|
||||
description: "RC2 (also known as ARC2) is a symmetric-key block cipher designed by Ron Rivest in 1987. 'RC' stands for 'Rivest Cipher'.<br><br><b>Key:</b> RC2 uses a variable size key.<br><br><b>IV:</b> To run the cipher in CBC mode, the Initialization Vector should be 8 bytes long. If the IV is left blank, the cipher will run in ECB mode.<br><br><b>Padding:</b> In both CBC and ECB mode, PKCS#7 padding will be used.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Input",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT4
|
||||
},
|
||||
{
|
||||
name: "Output",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT3
|
||||
},
|
||||
]
|
||||
},
|
||||
"RC2 Encrypt": {
|
||||
module: "Ciphers",
|
||||
description: "RC2 (also known as ARC2) is a symmetric-key block cipher designed by Ron Rivest in 1987. 'RC' stands for 'Rivest Cipher'.<br><br><b>Key:</b> RC2 uses a variable size key.<br><br>You can generate a password-based key using one of the KDF operations.<br><br><b>IV:</b> To run the cipher in CBC mode, the Initialization Vector should be 8 bytes long. If the IV is left blank, the cipher will run in ECB mode.<br><br><b>Padding:</b> In both CBC and ECB mode, PKCS#7 padding will be used.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Input",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT3
|
||||
},
|
||||
{
|
||||
name: "Output",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT4
|
||||
},
|
||||
]
|
||||
},
|
||||
"Derive PBKDF2 key": {
|
||||
module: "Ciphers",
|
||||
description: "PBKDF2 is a password-based key derivation function. It is part of RSA Laboratories' Public-Key Cryptography Standards (PKCS) series, specifically PKCS #5 v2.0, also published as Internet Engineering Task Force's RFC 2898.<br><br>In many applications of cryptography, user security is ultimately dependent on a password, and because a password usually can't be used directly as a cryptographic key, some processing is required.<br><br>A salt provides a large set of keys for any given password, and an iteration count increases the cost of producing keys from a password, thereby also increasing the difficulty of attack.<br><br>If you leave the salt argument empty, a random salt will be generated.",
|
||||
|
|
|
@ -28,6 +28,8 @@ OpModules.Ciphers = {
|
|||
"Derive EVP key": Cipher.runEvpkdf,
|
||||
"RC4": Cipher.runRc4,
|
||||
"RC4 Drop": Cipher.runRc4drop,
|
||||
"RC2 Encrypt": Cipher.runRc2Enc,
|
||||
"RC2 Decrypt": Cipher.runRc2Dec,
|
||||
"Vigenère Encode": Cipher.runVigenereEnc,
|
||||
"Vigenère Decode": Cipher.runVigenereDec,
|
||||
"Bifid Cipher Encode": Cipher.runBifidEnc,
|
||||
|
|
|
@ -271,6 +271,54 @@ DES uses a key length of 8 bytes (64 bits).`;
|
|||
},
|
||||
|
||||
|
||||
/**
|
||||
* RC2 Encrypt operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
runRc2Enc: function (input, args) {
|
||||
const key = Utils.convertToByteString(args[0].string, args[0].option),
|
||||
iv = Utils.convertToByteString(args[1].string, args[1].option),
|
||||
inputType = args[2],
|
||||
outputType = args[3],
|
||||
cipher = forge.rc2.createEncryptionCipher(key);
|
||||
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
cipher.start(iv || null);
|
||||
cipher.update(forge.util.createBuffer(input));
|
||||
cipher.finish();
|
||||
|
||||
return outputType === "Hex" ? cipher.output.toHex() : cipher.output.getBytes();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* RC2 Decrypt operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
runRc2Dec: function (input, args) {
|
||||
const key = Utils.convertToByteString(args[0].string, args[0].option),
|
||||
iv = Utils.convertToByteString(args[1].string, args[1].option),
|
||||
inputType = args[2],
|
||||
outputType = args[3],
|
||||
decipher = forge.rc2.createDecryptionCipher(key);
|
||||
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
decipher.start(iv || null);
|
||||
decipher.update(forge.util.createBuffer(input));
|
||||
decipher.finish();
|
||||
|
||||
return outputType === "Hex" ? decipher.output.toHex() : decipher.output.getBytes();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
|
|
@ -1269,7 +1269,7 @@ DES uses a key length of 8 bytes (64 bits).`,
|
|||
],
|
||||
},
|
||||
{
|
||||
name: "Triple DES Decrypt: DES-EDE3-ECB Binary",
|
||||
name: "Triple DES Decrypt: DES-EDE3-ECB, Binary",
|
||||
input: "aa81f23d1b3abebd68ac560e051a711c2923843beecddb0f7fe4113bd1874e73cccf3a2a494bb011e154ca2737b4d0eb5978a10316361074ed368d85d5aff5c8555ea101b0a468e58780a74c7830c561674c183c972a2b48931adf789cb16df304e169500f8c95ad",
|
||||
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
recipeConfig: [
|
||||
|
@ -1283,4 +1283,94 @@ DES uses a key length of 8 bytes (64 bits).`,
|
|||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "RC2 Encrypt: no key",
|
||||
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
expectedOutput: "d3644d898b51a544f690b506c3fd0caeb7a1e6097f7ea28f69b909a4d8805c9a05f4cade8b281d3f044fa069374efb90e94723622c86afc17caee394ffbee0abe627de299208460eb981c9d56f9df885091c6c89e2ee173264b2820b8e67675214e6545a05dc0d3f",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RC2 Encrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": ""},
|
||||
{"option": "Hex", "string": ""},
|
||||
"Hex", "Hex"
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "RC2 Encrypt: RC2-CBC, Binary",
|
||||
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
expectedOutput: "d25e5bc6c9311ef196d6f21cc4b0274b29fcca366aba5256406e02bf4ae628398f84e7d72ad92025ede76df4752d1510fe9c3492efb1dcf0be2cd41d619e10b9dd5a2304c2efbd3598d3b87f1a21f326d45e65537563436cfb6e4a41ec3733182ddc058f96f74a6c",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RC2 Encrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "eb970554bb213430f4bb4e5988a6a218"},
|
||||
{"option": "Hex", "string": "ae817c784a097e0c"},
|
||||
"Hex", "Hex"
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "RC2 Encrypt: RC2-ECB, Binary",
|
||||
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
expectedOutput: "a160bf23b2a85eaa43d26753e51aaa899f162ec0da7280fffd41b705c5309c7fef2bbb56bf261cab4eadd3a5c69e0a67d45e426d1097187cc9a959b4d979a9d40df26f3dc8d030453fe27701438b78d3ce044330b4b5dca7832537ecf40b914f1b1dc16d4e6d7229",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RC2 Encrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "eb970554bb213430f4bb4e5988a6a218"},
|
||||
{"option": "Hex", "string": ""},
|
||||
"Hex", "Hex"
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "RC2 Decrypt: no key",
|
||||
input: "d3644d898b51a544f690b506c3fd0caeb7a1e6097f7ea28f69b909a4d8805c9a05f4cade8b281d3f044fa069374efb90e94723622c86afc17caee394ffbee0abe627de299208460eb981c9d56f9df885091c6c89e2ee173264b2820b8e67675214e6545a05dc0d3f",
|
||||
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RC2 Decrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": ""},
|
||||
{"option": "Hex", "string": ""},
|
||||
"Hex", "Hex"
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "RC2 Decrypt: RC2-CBC, Binary",
|
||||
input: "d25e5bc6c9311ef196d6f21cc4b0274b29fcca366aba5256406e02bf4ae628398f84e7d72ad92025ede76df4752d1510fe9c3492efb1dcf0be2cd41d619e10b9dd5a2304c2efbd3598d3b87f1a21f326d45e65537563436cfb6e4a41ec3733182ddc058f96f74a6c",
|
||||
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RC2 Decrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "eb970554bb213430f4bb4e5988a6a218"},
|
||||
{"option": "Hex", "string": "ae817c784a097e0c"},
|
||||
"Hex", "Hex"
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "RC2 Decrypt: RC2-ECB, Binary",
|
||||
input: "a160bf23b2a85eaa43d26753e51aaa899f162ec0da7280fffd41b705c5309c7fef2bbb56bf261cab4eadd3a5c69e0a67d45e426d1097187cc9a959b4d979a9d40df26f3dc8d030453fe27701438b78d3ce044330b4b5dca7832537ecf40b914f1b1dc16d4e6d7229",
|
||||
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "RC2 Decrypt",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "eb970554bb213430f4bb4e5988a6a218"},
|
||||
{"option": "Hex", "string": ""},
|
||||
"Hex", "Hex"
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
|
Loading…
Reference in New Issue