mirror of
https://github.com/gchq/CyberChef.git
synced 2026-02-21 09:11:46 +01:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bff490fa4 | ||
|
|
d38375a08c | ||
|
|
0ba28dc891 | ||
|
|
ac9af6d2ba | ||
|
|
90d9e087f7 | ||
|
|
50b24d9a56 | ||
|
|
10f42e9a7f | ||
|
|
987bd303a0 | ||
|
|
a3f58fb831 | ||
|
|
f52f5a0edb | ||
|
|
b58942f69a | ||
|
|
68e52d1645 | ||
|
|
9fc7e6cd98 |
21
README.md
21
README.md
@@ -27,7 +27,7 @@ Cryptographic operations in CyberChef should not be relied upon to provide secur
|
||||
|
||||
There are four main areas in CyberChef:
|
||||
|
||||
1. The **input** box in the top right, where you can paste, type or drag the data you want to operate on.
|
||||
1. The **input** box in the top right, where you can paste, type or drag the text or file you want to operate on.
|
||||
2. The **output** box in the bottom right, where the outcome of your processing will be displayed.
|
||||
3. The **operations** list on the far left, where you can find all the operations that CyberChef is capable of in categorised lists, or by searching.
|
||||
4. The **recipe** area in the middle, where you can drag the operations that you want to use and specify arguments and options.
|
||||
@@ -42,32 +42,32 @@ You can use as many operations as you like in simple or complex ways. Some examp
|
||||
- [Display multiple timestamps as full dates][7]
|
||||
- [Carry out different operations on data of different types][8]
|
||||
- [Use parts of the input as arguments to operations][9]
|
||||
- [Perform AES decryption, extracting the IV from the beginning of the cipher stream][10]
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- Drag and drop
|
||||
- Operations can be dragged in and out of the recipe list, or reorganised.
|
||||
- Files can be dragged over the input box to load them directly.
|
||||
- Files can be dragged over the input box to load them directly into the browser.
|
||||
- Auto Bake
|
||||
- Whenever you modify the input or the recipe, CyberChef will automatically “bake” for you and produce the output immediately.
|
||||
- Whenever you modify the input or the recipe, CyberChef will automatically "bake" for you and produce the output immediately.
|
||||
- This can be turned off and operated manually if it is affecting performance (if the input is very large, for instance).
|
||||
- If any bake takes longer than 200 milliseconds, auto bake will be switched off automatically to prevent further performance issues.
|
||||
- Breakpoints
|
||||
- You can set breakpoints on any operation in your recipe to pause execution before running it.
|
||||
- You can also step through the recipe one operation at a time to see what the data looks like at each stage.
|
||||
- Save and load recipes
|
||||
- If you come up with an awesome recipe that you know you’ll want to use again, just click save and add it to your local storage. It'll be waiting for you next time you visit CyberChef.
|
||||
- You can also copy a URL which includes your recipe and input which can be shared with others.
|
||||
- If you come up with an awesome recipe that you know you’ll want to use again, just click "Save recipe" and add it to your local storage. It'll be waiting for you next time you visit CyberChef.
|
||||
- You can also copy the URL, which includes your recipe and input, to easily share it with others.
|
||||
- Search
|
||||
- If you know the name of the operation you want or a word associated with it, start typing it into the search field and any matching operations will immediately be shown.
|
||||
- Highlighting
|
||||
- When you highlight text in the input or output, the offset and length values will be displayed and, if possible, the corresponding data will be highlighted in the output or input respectively (example: [highlight the word 'question' in the input to see where it appears in the output][10]).
|
||||
- When you highlight text in the input or output, the offset and length values will be displayed and, if possible, the corresponding data will be highlighted in the output or input respectively (example: [highlight the word 'question' in the input to see where it appears in the output][11]).
|
||||
- Save to file and load from file
|
||||
- You can save the output to a file at any time or load a file by dragging and dropping it into the input field. Files up to around 500MB are supported (depending on your browser), however some operations may take a very long time to run over this much data.
|
||||
- CyberChef is entirely client-side
|
||||
- It should be noted that none of your recipe configuration or input (either text or files) is ever sent to the CyberChef web server - all processing is carried out within your browser, on your own computer.
|
||||
- Due to this feature, CyberChef can be compiled into a single HTML file. You can download this file and drop it into a virtual machine, share it with other people, or use it independently on your desktop.
|
||||
- Due to this feature, CyberChef can be compiled into a single HTML file. You can download this file and drop it into a virtual machine, share it with other people, or use it independently on your local machine.
|
||||
|
||||
|
||||
## Browser support
|
||||
@@ -100,6 +100,7 @@ CyberChef is released under the [Apache 2.0 Licence](https://www.apache.org/lice
|
||||
[5]: https://gchq.github.io/CyberChef/#recipe=From_Hexdump()Gunzip()&input=MDAwMDAwMDAgIDFmIDhiIDA4IDAwIDEyIGJjIGYzIDU3IDAwIGZmIDBkIGM3IGMxIDA5IDAwIDIwICB8Li4uLi6881cu/y7HwS4uIHwKMDAwMDAwMTAgIDA4IDA1IGQwIDU1IGZlIDA0IDJkIGQzIDA0IDFmIGNhIDhjIDQ0IDIxIDViIGZmICB8Li7QVf4uLdMuLsouRCFb/3wKMDAwMDAwMjAgIDYwIGM3IGQ3IDAzIDE2IGJlIDQwIDFmIDc4IDRhIDNmIDA5IDg5IDBiIDlhIDdkICB8YMfXLi6%2BQC54Sj8uLi4ufXwKMDAwMDAwMzAgIDRlIGM4IDRlIDZkIDA1IDFlIDAxIDhiIDRjIDI0IDAwIDAwIDAwICAgICAgICAgICB8TshObS4uLi5MJC4uLnw
|
||||
[6]: https://gchq.github.io/CyberChef/#recipe=RC4(%7B'option':'UTF8','string':'secret'%7D,'Hex','Hex')Disassemble_x86('64','Full%20x86%20architecture',16,0,true,true)&input=MjFkZGQyNTQwMTYwZWU2NWZlMDc3NzEwM2YyYTM5ZmJlNWJjYjZhYTBhYWJkNDE0ZjkwYzZjYWY1MzEyNzU0YWY3NzRiNzZiM2JiY2QxOTNjYjNkZGZkYmM1YTI2NTMzYTY4NmI1OWI4ZmVkNGQzODBkNDc0NDIwMWFlYzIwNDA1MDcxMzhlMmZlMmIzOTUwNDQ2ZGIzMWQyYmM2MjliZTRkM2YyZWIwMDQzYzI5M2Q3YTVkMjk2MmMwMGZlNmRhMzAwNzJkOGM1YTZiNGZlN2Q4NTlhMDQwZWVhZjI5OTczMzYzMDJmNWEwZWMxOQ
|
||||
[7]: https://gchq.github.io/CyberChef/#recipe=Fork('%5C%5Cn','%5C%5Cn',false)From_UNIX_Timestamp('Seconds%20(s)')&input=OTc4MzQ2ODAwCjEwMTI2NTEyMDAKMTA0NjY5NjQwMAoxMDgxMDg3MjAwCjExMTUzMDUyMDAKMTE0OTYwOTYwMA
|
||||
[8]: https://gchq.github.ioeCyberChef/#recipe=Fork('%5C%5Cn','%5C%5Cn',false)Conditional_Jump('1',false,'base64',10)To_Hex('Space')Return()Label('base64')To_Base64('A-Za-z0-9%2B/%3D')&input=U29tZSBkYXRhIHdpdGggYSAxIGluIGl0ClNvbWUgZGF0YSB3aXRoIGEgMiBpbiBpdA
|
||||
[8]: https://gchq.github.io/CyberChef/#recipe=Fork('%5C%5Cn','%5C%5Cn',false)Conditional_Jump('1',false,'base64',10)To_Hex('Space')Return()Label('base64')To_Base64('A-Za-z0-9%2B/%3D')&input=U29tZSBkYXRhIHdpdGggYSAxIGluIGl0ClNvbWUgZGF0YSB3aXRoIGEgMiBpbiBpdA
|
||||
[9]: https://gchq.github.io/CyberChef/#recipe=Register('key%3D(%5B%5C%5Cda-f%5D*)',true,false)Find_/_Replace(%7B'option':'Regex','string':'.*data%3D(.*)'%7D,'$1',true,false,true)RC4(%7B'option':'Hex','string':'$R0'%7D,'Hex','Latin1')&input=aHR0cDovL21hbHdhcmV6LmJpei9iZWFjb24ucGhwP2tleT0wZTkzMmE1YyZkYXRhPThkYjdkNWViZTM4NjYzYTU0ZWNiYjMzNGUzZGIxMQ
|
||||
[10]: https://gchq.github.io/CyberChef/#recipe=XOR(%7B'option':'Hex','string':'3a'%7D,'',false)To_Hexdump(16,false,false)&input=VGhlIGFuc3dlciB0byB0aGUgdWx0aW1hdGUgcXVlc3Rpb24gb2YgbGlmZSwgdGhlIFVuaXZlcnNlLCBhbmQgZXZlcnl0aGluZyBpcyA0Mi4
|
||||
[10]: https://gchq.github.io/CyberChef/#recipe=Register('(.%7B32%7D)',true,false)Drop_bytes(0,32,false)AES_Decrypt(%7B'option':'Hex','string':'1748e7179bd56570d51fa4ba287cc3e5'%7D,%7B'option':'Hex','string':'$R0'%7D,'CTR','Hex','Raw',%7B'option':'Hex','string':''%7D)&input=NTFlMjAxZDQ2MzY5OGVmNWY3MTdmNzFmNWI0NzEyYWYyMGJlNjc0YjNiZmY1M2QzODU0NjM5NmVlNjFkYWFjNDkwOGUzMTljYTNmY2Y3MDg5YmZiNmIzOGVhOTllNzgxZDI2ZTU3N2JhOWRkNmYzMTFhMzk0MjBiODk3OGU5MzAxNGIwNDJkNDQ3MjZjYWVkZjU0MzZlYWY2NTI0MjljMGRmOTRiNTIxNjc2YzdjMmNlODEyMDk3YzI3NzI3M2M3YzcyY2Q4OWFlYzhkOWZiNGEyNzU4NmNjZjZhYTBhZWUyMjRjMzRiYTNiZmRmN2FlYjFkZGQ0Nzc2MjJiOTFlNzJjOWU3MDlhYjYwZjhkYWY3MzFlYzBjYzg1Y2UwZjc0NmZmMTU1NGE1YTNlYzI5MWNhNDBmOWU2MjlhODcyNTkyZDk4OGZkZDgzNDUzNGFiYTc5YzFhZDE2NzY3NjlhN2MwMTBiZjA0NzM5ZWNkYjY1ZDk1MzAyMzcxZDYyOWQ5ZTM3ZTdiNGEzNjFkYTQ2OGYxZWQ1MzU4OTIyZDJlYTc1MmRkMTFjMzY2ZjMwMTdiMTRhYTAxMWQyYWYwM2M0NGY5NTU3OTA5OGExNWUzY2Y5YjQ0ODZmOGZmZTljMjM5ZjM0ZGU3MTUxZjZjYTY1MDBmZTRiODUwYzNmMWMwMmU4MDFjYWYzYTI0NDY0NjE0ZTQyODAxNjE1YjhmZmFhMDdhYzgyNTE0OTNmZmRhN2RlNWRkZjMzNjg4ODBjMmI5NWIwMzBmNDFmOGYxNTA2NmFkZDA3MWE2NmNmNjBlNWY0NmYzYTIzMGQzOTdiNjUyOTYzYTIxYTUzZg
|
||||
[11]: https://gchq.github.io/CyberChef/#recipe=XOR(%7B'option':'Hex','string':'3a'%7D,'',false)To_Hexdump(16,false,false)&input=VGhlIGFuc3dlciB0byB0aGUgdWx0aW1hdGUgcXVlc3Rpb24gb2YgbGlmZSwgdGhlIFVuaXZlcnNlLCBhbmQgZXZlcnl0aGluZyBpcyA0Mi4
|
||||
|
||||
17
package-lock.json
generated
17
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cyberchef",
|
||||
"version": "7.1.0",
|
||||
"version": "7.2.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@@ -6500,10 +6500,9 @@
|
||||
}
|
||||
},
|
||||
"node-forge": {
|
||||
"version": "0.6.33",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.6.33.tgz",
|
||||
"integrity": "sha1-RjgRh59XPUUVWtap9D3ClujoXrw=",
|
||||
"dev": true
|
||||
"version": "0.7.1",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.1.tgz",
|
||||
"integrity": "sha1-naYR6giYL0uUIGs760zJZl8gwwA="
|
||||
},
|
||||
"node-libs-browser": {
|
||||
"version": "2.1.0",
|
||||
@@ -8701,6 +8700,14 @@
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"node-forge": "0.6.33"
|
||||
},
|
||||
"dependencies": {
|
||||
"node-forge": {
|
||||
"version": "0.6.33",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.6.33.tgz",
|
||||
"integrity": "sha1-RjgRh59XPUUVWtap9D3ClujoXrw=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"semver": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cyberchef",
|
||||
"version": "7.1.0",
|
||||
"version": "7.2.2",
|
||||
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
||||
"author": "n1474335 <n1474335@gmail.com>",
|
||||
"homepage": "https://gchq.github.io/CyberChef",
|
||||
@@ -91,6 +91,7 @@
|
||||
"loglevel-message-prefix": "^3.0.0",
|
||||
"moment": "^2.20.1",
|
||||
"moment-timezone": "^0.5.14",
|
||||
"node-forge": "^0.7.1",
|
||||
"node-md6": "^0.1.0",
|
||||
"nwmatcher": "^1.4.3",
|
||||
"otp": "^0.1.3",
|
||||
|
||||
@@ -283,18 +283,18 @@ const Utils = {
|
||||
/**
|
||||
* Coverts data of varying types to a byteArray.
|
||||
* Accepts hex, Base64, UTF8 and Latin1 strings.
|
||||
*
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {string} type - One of "Hex", "Base64", "UTF8" or "Latin1"
|
||||
* @returns {byteArray}
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* // returns [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
|
||||
* Utils.convertToByteArray("Привет", "utf8");
|
||||
*
|
||||
*
|
||||
* // returns [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
|
||||
* Utils.convertToByteArray("d097d0b4d180d0b0d0b2d181d182d0b2d183d0b9d182d0b5", "hex");
|
||||
*
|
||||
*
|
||||
* // returns [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
|
||||
* Utils.convertToByteArray("0JfQtNGA0LDQstGB0YLQstGD0LnRgtC1", "base64");
|
||||
*/
|
||||
@@ -313,6 +313,39 @@ const Utils = {
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Coverts data of varying types to a byte string.
|
||||
* Accepts hex, Base64, UTF8 and Latin1 strings.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {string} type - One of "Hex", "Base64", "UTF8" or "Latin1"
|
||||
* @returns {string}
|
||||
*
|
||||
* @example
|
||||
* // returns [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
|
||||
* Utils.convertToByteArray("Привет", "utf8");
|
||||
*
|
||||
* // returns [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
|
||||
* Utils.convertToByteArray("d097d0b4d180d0b0d0b2d181d182d0b2d183d0b9d182d0b5", "hex");
|
||||
*
|
||||
* // returns [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
|
||||
* Utils.convertToByteArray("0JfQtNGA0LDQstGB0YLQstGD0LnRgtC1", "base64");
|
||||
*/
|
||||
convertToByteString: function(str, type) {
|
||||
switch (type.toLowerCase()) {
|
||||
case "hex":
|
||||
return Utils.byteArrayToChars(Utils.fromHex(str));
|
||||
case "base64":
|
||||
return Utils.byteArrayToChars(Utils.fromBase64(str, null, "byteArray"));
|
||||
case "utf8":
|
||||
return utf8.encode(str);
|
||||
case "latin1":
|
||||
default:
|
||||
return str;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Converts a string to a byte array.
|
||||
* Treats the string as UTF-8 if any values are over 255.
|
||||
@@ -460,10 +493,10 @@ const Utils = {
|
||||
|
||||
/**
|
||||
* Converts an ArrayBuffer to a string.
|
||||
*
|
||||
*
|
||||
* @param {ArrayBuffer} arrayBuffer
|
||||
* @returns {string}
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* // returns "hello"
|
||||
* Utils.arrayBufferToStr(Uint8Array.from([104,101,108,108,111]).buffer);
|
||||
|
||||
@@ -79,8 +79,8 @@ const Categories = [
|
||||
"DES Decrypt",
|
||||
"Triple DES Encrypt",
|
||||
"Triple DES Decrypt",
|
||||
"Rabbit Encrypt",
|
||||
"Rabbit Decrypt",
|
||||
"RC2 Encrypt",
|
||||
"RC2 Decrypt",
|
||||
"RC4",
|
||||
"RC4 Drop",
|
||||
"ROT13",
|
||||
@@ -99,6 +99,7 @@ const Categories = [
|
||||
"Substitute",
|
||||
"Derive PBKDF2 key",
|
||||
"Derive EVP key",
|
||||
"Pseudo-Random Number Generator",
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -198,6 +199,7 @@ const Categories = [
|
||||
"Parse colour code",
|
||||
"Escape string",
|
||||
"Unescape string",
|
||||
"Pseudo-Random Number Generator",
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -313,6 +315,7 @@ const Categories = [
|
||||
"Detect File Type",
|
||||
"Scan for Embedded Files",
|
||||
"Disassemble x86",
|
||||
"Pseudo-Random Number Generator",
|
||||
"Generate UUID",
|
||||
"Generate TOTP",
|
||||
"Generate HOTP",
|
||||
|
||||
@@ -1102,287 +1102,7 @@ const OperationConfig = {
|
||||
},
|
||||
"AES Decrypt": {
|
||||
module: "Ciphers",
|
||||
description: "To successfully decrypt AES, you need either:<ul><li>The passphrase</li><li>Or the key and IV</li></ul>The IV should be the first 16 bytes of encrypted material.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Passphrase/Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Salt",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.MODES
|
||||
},
|
||||
{
|
||||
name: "Padding",
|
||||
type: "option",
|
||||
value: Cipher.PADDING
|
||||
},
|
||||
{
|
||||
name: "Input format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT2
|
||||
},
|
||||
]
|
||||
},
|
||||
"AES Encrypt": {
|
||||
module: "Ciphers",
|
||||
description: "Input: Either enter a passphrase (which will be used to derive a key using the OpenSSL KDF) or both the key and IV.<br><br>Advanced Encryption Standard (AES) is a U.S. Federal Information Processing Standard (FIPS). It was selected after a 5-year process where 15 competing designs were evaluated.<br><br>AES-128, AES-192, and AES-256 are supported. The variant will be chosen based on the size of the key passed in. If a passphrase is used, a 256-bit key will be generated.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Passphrase/Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Salt",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.MODES
|
||||
},
|
||||
{
|
||||
name: "Padding",
|
||||
type: "option",
|
||||
value: Cipher.PADDING
|
||||
},
|
||||
{
|
||||
name: "Output result",
|
||||
type: "option",
|
||||
value: Cipher.RESULT_TYPE
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT1
|
||||
},
|
||||
]
|
||||
},
|
||||
"DES Decrypt": {
|
||||
module: "Ciphers",
|
||||
description: "To successfully decrypt DES, you need either:<ul><li>The passphrase</li><li>Or the key and IV</li></ul>The IV should be the first 8 bytes of encrypted material.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Passphrase/Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
|
||||
},
|
||||
{
|
||||
name: "Salt",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.MODES
|
||||
},
|
||||
{
|
||||
name: "Padding",
|
||||
type: "option",
|
||||
value: Cipher.PADDING
|
||||
},
|
||||
{
|
||||
name: "Input format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT2
|
||||
},
|
||||
]
|
||||
},
|
||||
"DES Encrypt": {
|
||||
module: "Ciphers",
|
||||
description: "Input: Either enter a passphrase (which will be used to derive a key using the OpenSSL KDF) or both the key and IV.<br><br>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.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Passphrase/Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
|
||||
},
|
||||
{
|
||||
name: "Salt",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.MODES
|
||||
},
|
||||
{
|
||||
name: "Padding",
|
||||
type: "option",
|
||||
value: Cipher.PADDING
|
||||
},
|
||||
{
|
||||
name: "Output result",
|
||||
type: "option",
|
||||
value: Cipher.RESULT_TYPE
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT1
|
||||
},
|
||||
]
|
||||
},
|
||||
"Triple DES Decrypt": {
|
||||
module: "Ciphers",
|
||||
description: "To successfully decrypt Triple DES, you need either:<ul><li>The passphrase</li><li>Or the key and IV</li></ul>The IV should be the first 8 bytes of encrypted material.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Passphrase/Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
|
||||
},
|
||||
{
|
||||
name: "Salt",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.MODES
|
||||
},
|
||||
{
|
||||
name: "Padding",
|
||||
type: "option",
|
||||
value: Cipher.PADDING
|
||||
},
|
||||
{
|
||||
name: "Input format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT2
|
||||
},
|
||||
]
|
||||
},
|
||||
"Triple DES Encrypt": {
|
||||
module: "Ciphers",
|
||||
description: "Input: Either enter a passphrase (which will be used to derive a key using the OpenSSL KDF) or both the key and IV.<br><br>Triple DES applies DES three times to each block to increase key size.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Passphrase/Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
|
||||
},
|
||||
{
|
||||
name: "Salt",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.MODES
|
||||
},
|
||||
{
|
||||
name: "Padding",
|
||||
type: "option",
|
||||
value: Cipher.PADDING
|
||||
},
|
||||
{
|
||||
name: "Output result",
|
||||
type: "option",
|
||||
value: Cipher.RESULT_TYPE
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT1
|
||||
},
|
||||
]
|
||||
},
|
||||
"Blowfish Decrypt": {
|
||||
module: "Ciphers",
|
||||
description: "Blowfish is a symmetric-key block cipher designed in 1993 by Bruce Schneier and included in a large number of cipher suites and encryption products. AES now receives more attention.",
|
||||
description: "Advanced Encryption Standard (AES) is a U.S. Federal Information Processing Standard (FIPS). It was selected after a 5-year process where 15 competing designs were evaluated.<br><br><b>Key:</b> The following algorithms will be used based on the size of the key:<ul><li>16 bytes = AES-128</li><li>24 bytes = AES-192</li><li>32 bytes = AES-256</li></ul><br><br><b>IV:</b> The Initialization Vector should be 16 bytes long. If not entered, it will default to 16 null bytes.<br><br><b>Padding:</b> In CBC and ECB mode, PKCS#7 padding will be used.<br><br><b>GCM Tag:</b> This field is ignored unless 'GCM' mode is used.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
@@ -1390,7 +1110,229 @@ const OperationConfig = {
|
||||
name: "Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.AES_MODES
|
||||
},
|
||||
{
|
||||
name: "Input",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT4
|
||||
},
|
||||
{
|
||||
name: "Output",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT3
|
||||
},
|
||||
{
|
||||
name: "GCM Tag",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
]
|
||||
},
|
||||
"AES Encrypt": {
|
||||
module: "Ciphers",
|
||||
description: "Advanced Encryption Standard (AES) is a U.S. Federal Information Processing Standard (FIPS). It was selected after a 5-year process where 15 competing designs were evaluated.<br><br><b>Key:</b> The following algorithms will be used based on the size of the key:<ul><li>16 bytes = AES-128</li><li>24 bytes = AES-192</li><li>32 bytes = AES-256</li></ul>You can generate a password-based key using one of the KDF operations.<br><br><b>IV:</b> The Initialization Vector should be 16 bytes long. If not entered, it will default to 16 null bytes.<br><br><b>Padding:</b> In 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: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.AES_MODES
|
||||
},
|
||||
{
|
||||
name: "Input",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT3
|
||||
},
|
||||
{
|
||||
name: "Output",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT4
|
||||
},
|
||||
]
|
||||
},
|
||||
"DES Decrypt": {
|
||||
module: "Ciphers",
|
||||
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.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.DES_MODES
|
||||
},
|
||||
{
|
||||
name: "Input",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT4
|
||||
},
|
||||
{
|
||||
name: "Output",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT3
|
||||
},
|
||||
]
|
||||
},
|
||||
"DES Encrypt": {
|
||||
module: "Ciphers",
|
||||
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.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.DES_MODES
|
||||
},
|
||||
{
|
||||
name: "Input",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT3
|
||||
},
|
||||
{
|
||||
name: "Output",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT4
|
||||
},
|
||||
]
|
||||
},
|
||||
"Triple DES Decrypt": {
|
||||
module: "Ciphers",
|
||||
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.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.DES_MODES
|
||||
},
|
||||
{
|
||||
name: "Input",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT4
|
||||
},
|
||||
{
|
||||
name: "Output",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT3
|
||||
},
|
||||
]
|
||||
},
|
||||
"Triple DES Encrypt": {
|
||||
module: "Ciphers",
|
||||
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.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.DES_MODES
|
||||
},
|
||||
{
|
||||
name: "Input",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT3
|
||||
},
|
||||
{
|
||||
name: "Output",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT4
|
||||
},
|
||||
]
|
||||
},
|
||||
"Blowfish Decrypt": {
|
||||
module: "Ciphers",
|
||||
description: "Blowfish is a symmetric-key block cipher designed in 1993 by Bruce Schneier and included in a large number of cipher suites and encryption products. AES now receives more attention.<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
@@ -1398,7 +1340,12 @@ const OperationConfig = {
|
||||
value: Cipher.BLOWFISH_MODES
|
||||
},
|
||||
{
|
||||
name: "Input format",
|
||||
name: "Input",
|
||||
type: "option",
|
||||
value: Cipher.BLOWFISH_OUTPUT_TYPES
|
||||
},
|
||||
{
|
||||
name: "Output",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT3
|
||||
},
|
||||
@@ -1406,7 +1353,7 @@ const OperationConfig = {
|
||||
},
|
||||
"Blowfish Encrypt": {
|
||||
module: "Ciphers",
|
||||
description: "Blowfish is a symmetric-key block cipher designed in 1993 by Bruce Schneier and included in a large number of cipher suites and encryption products. AES now receives more attention.",
|
||||
description: "Blowfish is a symmetric-key block cipher designed in 1993 by Bruce Schneier and included in a large number of cipher suites and encryption products. AES now receives more attention.<br><br><b>IV:</b> The Initialization Vector should be 8 bytes long. If not entered, it will default to 8 null bytes.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
@@ -1414,7 +1361,13 @@ const OperationConfig = {
|
||||
name: "Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
@@ -1422,109 +1375,20 @@ const OperationConfig = {
|
||||
value: Cipher.BLOWFISH_MODES
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
name: "Input",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT3
|
||||
},
|
||||
]
|
||||
},
|
||||
"Rabbit Decrypt": {
|
||||
module: "Ciphers",
|
||||
description: "To successfully decrypt Rabbit, you need either:<ul><li>The passphrase</li><li>Or the key and IV (This is currently broken. You need the key and salt at the moment.)</li></ul>The IV should be the first 8 bytes of encrypted material.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Passphrase/Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
|
||||
},
|
||||
{
|
||||
name: "Salt",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
name: "Output",
|
||||
type: "option",
|
||||
value: Cipher.MODES
|
||||
},
|
||||
{
|
||||
name: "Padding",
|
||||
type: "option",
|
||||
value: Cipher.PADDING
|
||||
},
|
||||
{
|
||||
name: "Input format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT2
|
||||
},
|
||||
]
|
||||
},
|
||||
"Rabbit Encrypt": {
|
||||
module: "Ciphers",
|
||||
description: "Input: Either enter a passphrase (which will be used to derive a key using the OpenSSL KDF) or both the key and IV.<br><br>Rabbit is a high-performance stream cipher and a finalist in the eSTREAM Portfolio. It is one of the four designs selected after a 3 1/2 year process where 22 designs were evaluated.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Passphrase/Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
},
|
||||
{
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
|
||||
},
|
||||
{
|
||||
name: "Salt",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Mode",
|
||||
type: "option",
|
||||
value: Cipher.MODES
|
||||
},
|
||||
{
|
||||
name: "Padding",
|
||||
type: "option",
|
||||
value: Cipher.PADDING
|
||||
},
|
||||
{
|
||||
name: "Output result",
|
||||
type: "option",
|
||||
value: Cipher.RESULT_TYPE
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT1
|
||||
value: Cipher.BLOWFISH_OUTPUT_TYPES
|
||||
},
|
||||
]
|
||||
},
|
||||
"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",
|
||||
@@ -1534,17 +1398,17 @@ const OperationConfig = {
|
||||
name: "Passphrase",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
toggleValues: Cipher.RC4_KEY_FORMAT
|
||||
},
|
||||
{
|
||||
name: "Input format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT4
|
||||
value: Cipher.CJS_IO_FORMAT
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT4
|
||||
value: Cipher.CJS_IO_FORMAT
|
||||
},
|
||||
]
|
||||
},
|
||||
@@ -1560,17 +1424,17 @@ const OperationConfig = {
|
||||
name: "Passphrase",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
toggleValues: Cipher.RC4_KEY_FORMAT
|
||||
},
|
||||
{
|
||||
name: "Input format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT4
|
||||
value: Cipher.CJS_IO_FORMAT
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT4
|
||||
value: Cipher.CJS_IO_FORMAT
|
||||
},
|
||||
{
|
||||
name: "Number of bytes to drop",
|
||||
@@ -1579,50 +1443,96 @@ const OperationConfig = {
|
||||
},
|
||||
]
|
||||
},
|
||||
"Derive PBKDF2 key": {
|
||||
"RC2 Decrypt": {
|
||||
module: "Ciphers",
|
||||
description: "PBKDF2 is a password-based key derivation function. 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>Enter your passphrase as the input and then set the relevant options to generate a key.",
|
||||
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 size",
|
||||
type: "number",
|
||||
value: Cipher.KDF_KEY_SIZE
|
||||
name: "Key",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Iterations",
|
||||
type: "number",
|
||||
value: Cipher.KDF_ITERATIONS
|
||||
name: "IV",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
{
|
||||
name: "Hashing function",
|
||||
name: "Input",
|
||||
type: "option",
|
||||
value: Cipher.HASHERS
|
||||
value: Cipher.IO_FORMAT4
|
||||
},
|
||||
{
|
||||
name: "Salt (hex)",
|
||||
type: "string",
|
||||
value: ""
|
||||
},
|
||||
{
|
||||
name: "Input format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT2
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
name: "Output",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT3
|
||||
},
|
||||
]
|
||||
},
|
||||
"Derive EVP key": {
|
||||
"RC2 Encrypt": {
|
||||
module: "Ciphers",
|
||||
description: "EVP is a password-based key derivation function used extensively in OpenSSL. 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>Enter your passphrase as the input and then set the relevant options to generate a key.",
|
||||
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
|
||||
},
|
||||
]
|
||||
},
|
||||
"Pseudo-Random Number Generator": {
|
||||
module: "Ciphers",
|
||||
description: "A cryptographically-secure pseudo-random number generator (PRNG).<br><br>This operation uses the browser's built-in <code>crypto.getRandomValues()</code> method if available. If this cannot be found, it falls back to a Fortuna-based PRNG algorithm.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Number of bytes",
|
||||
type: "number",
|
||||
value: Cipher.PRNG_BYTES
|
||||
},
|
||||
{
|
||||
name: "Output as",
|
||||
type: "option",
|
||||
value: Cipher.PRNG_OUTPUT
|
||||
}
|
||||
]
|
||||
},
|
||||
"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.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Passphrase",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
},
|
||||
{
|
||||
name: "Key size",
|
||||
type: "number",
|
||||
@@ -1639,19 +1549,45 @@ const OperationConfig = {
|
||||
value: Cipher.HASHERS
|
||||
},
|
||||
{
|
||||
name: "Salt (hex)",
|
||||
type: "string",
|
||||
value: ""
|
||||
name: "Salt",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
]
|
||||
},
|
||||
"Derive EVP key": {
|
||||
module: "Ciphers",
|
||||
description: "EVP is a password-based key derivation function (PBKDF) used extensively in OpenSSL. 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.",
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
args: [
|
||||
{
|
||||
name: "Passphrase",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT2
|
||||
},
|
||||
{
|
||||
name: "Input format",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT2
|
||||
name: "Key size",
|
||||
type: "number",
|
||||
value: Cipher.KDF_KEY_SIZE
|
||||
},
|
||||
{
|
||||
name: "Output format",
|
||||
name: "Iterations",
|
||||
type: "number",
|
||||
value: Cipher.KDF_ITERATIONS
|
||||
},
|
||||
{
|
||||
name: "Hashing function",
|
||||
type: "option",
|
||||
value: Cipher.IO_FORMAT3
|
||||
value: Cipher.HASHERS
|
||||
},
|
||||
{
|
||||
name: "Salt",
|
||||
type: "toggleString",
|
||||
value: "",
|
||||
toggleValues: Cipher.IO_FORMAT1
|
||||
},
|
||||
]
|
||||
},
|
||||
@@ -1977,9 +1913,9 @@ const OperationConfig = {
|
||||
},
|
||||
"Drop bytes": {
|
||||
module: "Default",
|
||||
description: "Cuts the specified number of bytes out of the data.",
|
||||
inputType: "byteArray",
|
||||
outputType: "byteArray",
|
||||
description: "Cuts a slice of the specified number of bytes out of the data.",
|
||||
inputType: "ArrayBuffer",
|
||||
outputType: "ArrayBuffer",
|
||||
args: [
|
||||
{
|
||||
name: "Start",
|
||||
@@ -2001,8 +1937,8 @@ const OperationConfig = {
|
||||
"Take bytes": {
|
||||
module: "Default",
|
||||
description: "Takes a slice of the specified number of bytes from the data.",
|
||||
inputType: "byteArray",
|
||||
outputType: "byteArray",
|
||||
inputType: "ArrayBuffer",
|
||||
outputType: "ArrayBuffer",
|
||||
args: [
|
||||
{
|
||||
name: "Start",
|
||||
|
||||
@@ -6,7 +6,6 @@ import CharEnc from "../../operations/CharEnc.js";
|
||||
*
|
||||
* Libraries:
|
||||
* - cptable
|
||||
* - CryptoJS
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2017
|
||||
|
||||
@@ -7,6 +7,7 @@ import Cipher from "../../operations/Cipher.js";
|
||||
* Libraries:
|
||||
* - CryptoJS
|
||||
* - Blowfish
|
||||
* - Forge
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2017
|
||||
@@ -23,12 +24,12 @@ OpModules.Ciphers = {
|
||||
"DES Decrypt": Cipher.runDesDec,
|
||||
"Triple DES Encrypt": Cipher.runTripleDesEnc,
|
||||
"Triple DES Decrypt": Cipher.runTripleDesDec,
|
||||
"Rabbit Encrypt": Cipher.runRabbitEnc,
|
||||
"Rabbit Decrypt": Cipher.runRabbitDec,
|
||||
"Derive PBKDF2 key": Cipher.runPbkdf2,
|
||||
"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,
|
||||
@@ -37,6 +38,7 @@ OpModules.Ciphers = {
|
||||
"Affine Cipher Decode": Cipher.runAffineDec,
|
||||
"Atbash Cipher": Cipher.runAtbash,
|
||||
"Substitute": Cipher.runSubstitute,
|
||||
"Pseudo-Random Number Generator": Cipher.runPRNG,
|
||||
};
|
||||
|
||||
export default OpModules;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Utils from "../Utils.js";
|
||||
import CryptoJS from "crypto-js";
|
||||
import forge from "imports-loader?jQuery=>null!node-forge/dist/forge.min.js";
|
||||
import {blowfish as Blowfish} from "sladex-blowfish";
|
||||
|
||||
|
||||
@@ -18,132 +19,27 @@ const Cipher = {
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
IO_FORMAT1: ["Hex", "Base64", "UTF8", "UTF16", "UTF16LE", "UTF16BE", "Latin1"],
|
||||
IO_FORMAT1: ["Hex", "UTF8", "Latin1", "Base64"],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
IO_FORMAT2: ["UTF8", "Latin1", "Hex", "Base64"],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
IO_FORMAT3: ["Raw", "Hex"],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
IO_FORMAT4: ["Hex", "Raw"],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
IO_FORMAT2: ["UTF8", "UTF16", "UTF16LE", "UTF16BE", "Latin1", "Hex", "Base64"],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
IO_FORMAT3: ["Hex", "Base64", "UTF16", "UTF16LE", "UTF16BE", "Latin1"],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
IO_FORMAT4: ["Latin1", "UTF8", "UTF16", "UTF16LE", "UTF16BE", "Hex", "Base64"],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
MODES: ["CBC", "CFB", "CTR", "OFB", "ECB"],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
PADDING: ["Pkcs7", "Iso97971", "AnsiX923", "Iso10126", "ZeroPadding", "NoPadding"],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
RESULT_TYPE: ["Show all", "Ciphertext", "Key", "IV", "Salt"],
|
||||
|
||||
|
||||
/**
|
||||
* Runs encryption operations using the CryptoJS framework.
|
||||
*
|
||||
* @private
|
||||
* @param {function} algo - The CryptoJS algorithm to use
|
||||
* @param {byteArray} input
|
||||
* @param {function} args
|
||||
* @returns {string}
|
||||
*/
|
||||
_enc: function (algo, input, args) {
|
||||
let key = Cipher._format[args[0].option].parse(args[0].string || ""),
|
||||
iv = Cipher._format[args[1].option].parse(args[1].string || ""),
|
||||
salt = Cipher._format[args[2].option].parse(args[2].string || ""),
|
||||
mode = CryptoJS.mode[args[3]],
|
||||
padding = CryptoJS.pad[args[4]],
|
||||
resultOption = args[5].toLowerCase(),
|
||||
outputFormat = args[6];
|
||||
|
||||
if (iv.sigBytes === 0) {
|
||||
// Use passphrase rather than key. Need to convert it to a string.
|
||||
key = key.toString(CryptoJS.enc.Latin1);
|
||||
}
|
||||
|
||||
const encrypted = algo.encrypt(input, key, {
|
||||
salt: salt.sigBytes > 0 ? salt : false,
|
||||
iv: iv.sigBytes > 0 ? iv : null,
|
||||
mode: mode,
|
||||
padding: padding
|
||||
});
|
||||
|
||||
let result = "";
|
||||
if (resultOption === "show all") {
|
||||
result += "Key: " + encrypted.key.toString(Cipher._format[outputFormat]);
|
||||
result += "\nIV: " + encrypted.iv.toString(Cipher._format[outputFormat]);
|
||||
if (encrypted.salt) result += "\nSalt: " + encrypted.salt.toString(Cipher._format[outputFormat]);
|
||||
result += "\n\nCiphertext: " + encrypted.ciphertext.toString(Cipher._format[outputFormat]);
|
||||
} else {
|
||||
result = encrypted[resultOption].toString(Cipher._format[outputFormat]);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Runs decryption operations using the CryptoJS framework.
|
||||
*
|
||||
* @private
|
||||
* @param {function} algo - The CryptoJS algorithm to use
|
||||
* @param {byteArray} input
|
||||
* @param {function} args
|
||||
* @returns {string}
|
||||
*/
|
||||
_dec: function (algo, input, args) {
|
||||
let key = Cipher._format[args[0].option].parse(args[0].string || ""),
|
||||
iv = Cipher._format[args[1].option].parse(args[1].string || ""),
|
||||
salt = Cipher._format[args[2].option].parse(args[2].string || ""),
|
||||
mode = CryptoJS.mode[args[3]],
|
||||
padding = CryptoJS.pad[args[4]],
|
||||
inputFormat = args[5],
|
||||
outputFormat = args[6];
|
||||
|
||||
// The ZeroPadding option causes a crash when the input length is 0
|
||||
if (!input.length) {
|
||||
return "No input";
|
||||
}
|
||||
|
||||
const ciphertext = Cipher._format[inputFormat].parse(input);
|
||||
|
||||
if (iv.sigBytes === 0) {
|
||||
// Use passphrase rather than key. Need to convert it to a string.
|
||||
key = key.toString(CryptoJS.enc.Latin1);
|
||||
}
|
||||
|
||||
const decrypted = algo.decrypt({
|
||||
ciphertext: ciphertext,
|
||||
salt: salt.sigBytes > 0 ? salt : false
|
||||
}, key, {
|
||||
iv: iv.sigBytes > 0 ? iv : null,
|
||||
mode: mode,
|
||||
padding: padding
|
||||
});
|
||||
|
||||
let result;
|
||||
try {
|
||||
result = decrypted.toString(Cipher._format[outputFormat]);
|
||||
} catch (err) {
|
||||
result = "Decrypt error: " + err.message;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
AES_MODES: ["CBC", "CFB", "OFB", "CTR", "GCM", "ECB"],
|
||||
|
||||
/**
|
||||
* AES Encrypt operation.
|
||||
@@ -153,7 +49,41 @@ const Cipher = {
|
||||
* @returns {string}
|
||||
*/
|
||||
runAesEnc: function (input, args) {
|
||||
return Cipher._enc(CryptoJS.AES, input, args);
|
||||
const key = Utils.convertToByteArray(args[0].string, args[0].option),
|
||||
iv = Utils.convertToByteArray(args[1].string, args[1].option),
|
||||
mode = args[2],
|
||||
inputType = args[3],
|
||||
outputType = args[4];
|
||||
|
||||
if ([16, 24, 32].indexOf(key.length) < 0) {
|
||||
return `Invalid key length: ${key.length} bytes
|
||||
|
||||
The following algorithms will be used based on the size of the key:
|
||||
16 bytes = AES-128
|
||||
24 bytes = AES-192
|
||||
32 bytes = AES-256`;
|
||||
}
|
||||
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
const cipher = forge.cipher.createCipher("AES-" + mode, key);
|
||||
cipher.start({iv: iv});
|
||||
cipher.update(forge.util.createBuffer(input));
|
||||
cipher.finish();
|
||||
|
||||
if (outputType === "Hex") {
|
||||
if (mode === "GCM") {
|
||||
return cipher.output.toHex() + "\n\n" +
|
||||
"Tag: " + cipher.mode.tag.toHex();
|
||||
}
|
||||
return cipher.output.toHex();
|
||||
} else {
|
||||
if (mode === "GCM") {
|
||||
return cipher.output.getBytes() + "\n\n" +
|
||||
"Tag: " + cipher.mode.tag.getBytes();
|
||||
}
|
||||
return cipher.output.getBytes();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -165,10 +95,46 @@ const Cipher = {
|
||||
* @returns {string}
|
||||
*/
|
||||
runAesDec: function (input, args) {
|
||||
return Cipher._dec(CryptoJS.AES, input, args);
|
||||
const key = Utils.convertToByteArray(args[0].string, args[0].option),
|
||||
iv = Utils.convertToByteArray(args[1].string, args[1].option),
|
||||
mode = args[2],
|
||||
inputType = args[3],
|
||||
outputType = args[4],
|
||||
gcmTag = Utils.convertToByteString(args[5].string, args[5].option);
|
||||
|
||||
if ([16, 24, 32].indexOf(key.length) < 0) {
|
||||
return `Invalid key length: ${key.length} bytes
|
||||
|
||||
The following algorithms will be used based on the size of the key:
|
||||
16 bytes = AES-128
|
||||
24 bytes = AES-192
|
||||
32 bytes = AES-256`;
|
||||
}
|
||||
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
const decipher = forge.cipher.createDecipher("AES-" + mode, key);
|
||||
decipher.start({
|
||||
iv: iv,
|
||||
tag: gcmTag
|
||||
});
|
||||
decipher.update(forge.util.createBuffer(input));
|
||||
const result = decipher.finish();
|
||||
|
||||
if (result) {
|
||||
return outputType === "Hex" ? decipher.output.toHex() : decipher.output.getBytes();
|
||||
} else {
|
||||
return "Unable to decrypt input with these parameters.";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
DES_MODES: ["CBC", "CFB", "OFB", "CTR", "ECB"],
|
||||
|
||||
/**
|
||||
* DES Encrypt operation.
|
||||
*
|
||||
@@ -177,7 +143,27 @@ const Cipher = {
|
||||
* @returns {string}
|
||||
*/
|
||||
runDesEnc: function (input, args) {
|
||||
return Cipher._enc(CryptoJS.DES, input, args);
|
||||
const key = Utils.convertToByteString(args[0].string, args[0].option),
|
||||
iv = Utils.convertToByteArray(args[1].string, args[1].option),
|
||||
mode = args[2],
|
||||
inputType = args[3],
|
||||
outputType = args[4];
|
||||
|
||||
if (key.length !== 8) {
|
||||
return `Invalid key length: ${key.length} bytes
|
||||
|
||||
DES uses a key length of 8 bytes (64 bits).
|
||||
Triple DES uses a key length of 24 bytes (192 bits).`;
|
||||
}
|
||||
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
const cipher = forge.cipher.createCipher("DES-" + mode, key);
|
||||
cipher.start({iv: iv});
|
||||
cipher.update(forge.util.createBuffer(input));
|
||||
cipher.finish();
|
||||
|
||||
return outputType === "Hex" ? cipher.output.toHex() : cipher.output.getBytes();
|
||||
},
|
||||
|
||||
|
||||
@@ -189,7 +175,31 @@ const Cipher = {
|
||||
* @returns {string}
|
||||
*/
|
||||
runDesDec: function (input, args) {
|
||||
return Cipher._dec(CryptoJS.DES, input, args);
|
||||
const key = Utils.convertToByteString(args[0].string, args[0].option),
|
||||
iv = Utils.convertToByteArray(args[1].string, args[1].option),
|
||||
mode = args[2],
|
||||
inputType = args[3],
|
||||
outputType = args[4];
|
||||
|
||||
if (key.length !== 8) {
|
||||
return `Invalid key length: ${key.length} bytes
|
||||
|
||||
DES uses a key length of 8 bytes (64 bits).
|
||||
Triple DES uses a key length of 24 bytes (192 bits).`;
|
||||
}
|
||||
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
const decipher = forge.cipher.createDecipher("DES-" + mode, key);
|
||||
decipher.start({iv: iv});
|
||||
decipher.update(forge.util.createBuffer(input));
|
||||
const result = decipher.finish();
|
||||
|
||||
if (result) {
|
||||
return outputType === "Hex" ? decipher.output.toHex() : decipher.output.getBytes();
|
||||
} else {
|
||||
return "Unable to decrypt input with these parameters.";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -201,7 +211,27 @@ const Cipher = {
|
||||
* @returns {string}
|
||||
*/
|
||||
runTripleDesEnc: function (input, args) {
|
||||
return Cipher._enc(CryptoJS.TripleDES, input, args);
|
||||
const key = Utils.convertToByteString(args[0].string, args[0].option),
|
||||
iv = Utils.convertToByteArray(args[1].string, args[1].option),
|
||||
mode = args[2],
|
||||
inputType = args[3],
|
||||
outputType = args[4];
|
||||
|
||||
if (key.length !== 24) {
|
||||
return `Invalid key length: ${key.length} bytes
|
||||
|
||||
Triple DES uses a key length of 24 bytes (192 bits).
|
||||
DES uses a key length of 8 bytes (64 bits).`;
|
||||
}
|
||||
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
const cipher = forge.cipher.createCipher("3DES-" + mode, key);
|
||||
cipher.start({iv: iv});
|
||||
cipher.update(forge.util.createBuffer(input));
|
||||
cipher.finish();
|
||||
|
||||
return outputType === "Hex" ? cipher.output.toHex() : cipher.output.getBytes();
|
||||
},
|
||||
|
||||
|
||||
@@ -213,31 +243,79 @@ const Cipher = {
|
||||
* @returns {string}
|
||||
*/
|
||||
runTripleDesDec: function (input, args) {
|
||||
return Cipher._dec(CryptoJS.TripleDES, input, args);
|
||||
const key = Utils.convertToByteString(args[0].string, args[0].option),
|
||||
iv = Utils.convertToByteArray(args[1].string, args[1].option),
|
||||
mode = args[2],
|
||||
inputType = args[3],
|
||||
outputType = args[4];
|
||||
|
||||
if (key.length !== 24) {
|
||||
return `Invalid key length: ${key.length} bytes
|
||||
|
||||
Triple DES uses a key length of 24 bytes (192 bits).
|
||||
DES uses a key length of 8 bytes (64 bits).`;
|
||||
}
|
||||
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
const decipher = forge.cipher.createDecipher("3DES-" + mode, key);
|
||||
decipher.start({iv: iv});
|
||||
decipher.update(forge.util.createBuffer(input));
|
||||
const result = decipher.finish();
|
||||
|
||||
if (result) {
|
||||
return outputType === "Hex" ? decipher.output.toHex() : decipher.output.getBytes();
|
||||
} else {
|
||||
return "Unable to decrypt input with these parameters.";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Rabbit Encrypt operation.
|
||||
* RC2 Encrypt operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
runRabbitEnc: function (input, args) {
|
||||
return Cipher._enc(CryptoJS.Rabbit, input, args);
|
||||
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();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Rabbit Decrypt operation.
|
||||
* RC2 Decrypt operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
runRabbitDec: function (input, args) {
|
||||
return Cipher._dec(CryptoJS.Rabbit, input, args);
|
||||
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();
|
||||
},
|
||||
|
||||
|
||||
@@ -245,12 +323,29 @@ const Cipher = {
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
BLOWFISH_MODES: ["ECB", "CBC", "PCBC", "CFB", "OFB", "CTR"],
|
||||
BLOWFISH_MODES: ["CBC", "PCBC", "CFB", "OFB", "CTR", "ECB"],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
BLOWFISH_OUTPUT_TYPES: ["Base64", "Hex", "String", "Raw"],
|
||||
BLOWFISH_OUTPUT_TYPES: ["Hex", "Base64", "Raw"],
|
||||
|
||||
/**
|
||||
* Lookup table for Blowfish output types.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_BLOWFISH_OUTPUT_TYPE_LOOKUP: {
|
||||
Base64: 0, Hex: 1, String: 2, Raw: 3
|
||||
},
|
||||
/**
|
||||
* Lookup table for Blowfish modes.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_BLOWFISH_MODE_LOOKUP: {
|
||||
ECB: 0, CBC: 1, PCBC: 2, CFB: 3, OFB: 4, CTR: 5
|
||||
},
|
||||
|
||||
/**
|
||||
* Blowfish Encrypt operation.
|
||||
@@ -260,19 +355,24 @@ const Cipher = {
|
||||
* @returns {string}
|
||||
*/
|
||||
runBlowfishEnc: function (input, args) {
|
||||
let key = Cipher._format[args[0].option].parse(args[0].string).toString(Cipher._format.Latin1),
|
||||
mode = args[1],
|
||||
outputFormat = args[2];
|
||||
const key = Utils.convertToByteString(args[0].string, args[0].option),
|
||||
iv = Utils.convertToByteArray(args[1].string, args[1].option),
|
||||
mode = args[2],
|
||||
inputType = args[3],
|
||||
outputType = args[4];
|
||||
|
||||
if (key.length === 0) return "Enter a key";
|
||||
|
||||
let encHex = Blowfish.encrypt(input, key, {
|
||||
outputType: 1,
|
||||
cipherMode: Cipher.BLOWFISH_MODES.indexOf(mode)
|
||||
}),
|
||||
enc = CryptoJS.enc.Hex.parse(encHex);
|
||||
input = Utils.convertToByteString(input, inputType);
|
||||
|
||||
return enc.toString(Cipher._format[outputFormat]);
|
||||
Blowfish.setIV(Utils.toBase64(iv), 0);
|
||||
|
||||
const enc = Blowfish.encrypt(input, key, {
|
||||
outputType: Cipher._BLOWFISH_OUTPUT_TYPE_LOOKUP[outputType],
|
||||
cipherMode: Cipher._BLOWFISH_MODE_LOOKUP[mode]
|
||||
});
|
||||
|
||||
return outputType === "Raw" ? Utils.byteArrayToChars(enc) : enc ;
|
||||
},
|
||||
|
||||
|
||||
@@ -284,18 +384,24 @@ const Cipher = {
|
||||
* @returns {string}
|
||||
*/
|
||||
runBlowfishDec: function (input, args) {
|
||||
let key = Cipher._format[args[0].option].parse(args[0].string).toString(Cipher._format.Latin1),
|
||||
mode = args[1],
|
||||
inputFormat = args[2];
|
||||
const key = Utils.convertToByteString(args[0].string, args[0].option),
|
||||
iv = Utils.convertToByteArray(args[1].string, args[1].option),
|
||||
mode = args[2],
|
||||
inputType = args[3],
|
||||
outputType = args[4];
|
||||
|
||||
if (key.length === 0) return "Enter a key";
|
||||
|
||||
input = Cipher._format[inputFormat].parse(input);
|
||||
input = inputType === "Raw" ? Utils.strToByteArray(input) : input;
|
||||
|
||||
return Blowfish.decrypt(input.toString(CryptoJS.enc.Base64), key, {
|
||||
outputType: 0, // This actually means inputType. The library is weird.
|
||||
cipherMode: Cipher.BLOWFISH_MODES.indexOf(mode)
|
||||
Blowfish.setIV(Utils.toBase64(iv), 0);
|
||||
|
||||
const result = Blowfish.decrypt(input, key, {
|
||||
outputType: Cipher._BLOWFISH_OUTPUT_TYPE_LOOKUP[inputType], // This actually means inputType. The library is weird.
|
||||
cipherMode: Cipher._BLOWFISH_MODE_LOOKUP[mode]
|
||||
});
|
||||
|
||||
return outputType === "Hex" ? Utils.toHexFast(Utils.strToByteArray(result)) : result;
|
||||
},
|
||||
|
||||
|
||||
@@ -303,7 +409,7 @@ const Cipher = {
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
KDF_KEY_SIZE: 256,
|
||||
KDF_KEY_SIZE: 128,
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
@@ -313,7 +419,7 @@ const Cipher = {
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
HASHERS: ["MD5", "SHA1", "SHA224", "SHA256", "SHA384", "SHA512", "SHA3", "RIPEMD160"],
|
||||
HASHERS: ["SHA1", "SHA256", "SHA384", "SHA512", "MD5"],
|
||||
|
||||
/**
|
||||
* Derive PBKDF2 key operation.
|
||||
@@ -323,20 +429,15 @@ const Cipher = {
|
||||
* @returns {string}
|
||||
*/
|
||||
runPbkdf2: function (input, args) {
|
||||
let keySize = args[0] / 32,
|
||||
iterations = args[1],
|
||||
hasher = args[2],
|
||||
salt = CryptoJS.enc.Hex.parse(args[3] || ""),
|
||||
inputFormat = args[4],
|
||||
outputFormat = args[5],
|
||||
passphrase = Cipher._format[inputFormat].parse(input),
|
||||
key = CryptoJS.PBKDF2(passphrase, salt, {
|
||||
keySize: keySize,
|
||||
hasher: CryptoJS.algo[hasher],
|
||||
iterations: iterations,
|
||||
});
|
||||
const passphrase = Utils.convertToByteString(args[0].string, args[0].option),
|
||||
keySize = args[1],
|
||||
iterations = args[2],
|
||||
hasher = args[3],
|
||||
salt = Utils.convertToByteString(args[4].string, args[4].option) ||
|
||||
forge.random.getBytesSync(keySize),
|
||||
derivedKey = forge.pkcs5.pbkdf2(passphrase, salt, iterations, keySize / 8, hasher.toLowerCase());
|
||||
|
||||
return key.toString(Cipher._format[outputFormat]);
|
||||
return forge.util.bytesToHex(derivedKey);
|
||||
},
|
||||
|
||||
|
||||
@@ -348,23 +449,33 @@ const Cipher = {
|
||||
* @returns {string}
|
||||
*/
|
||||
runEvpkdf: function (input, args) {
|
||||
let keySize = args[0] / 32,
|
||||
iterations = args[1],
|
||||
hasher = args[2],
|
||||
salt = CryptoJS.enc.Hex.parse(args[3] || ""),
|
||||
inputFormat = args[4],
|
||||
outputFormat = args[5],
|
||||
passphrase = Cipher._format[inputFormat].parse(input),
|
||||
const passphrase = Utils.convertToByteString(args[0].string, args[0].option),
|
||||
keySize = args[1] / 32,
|
||||
iterations = args[2],
|
||||
hasher = args[3],
|
||||
salt = Utils.convertToByteString(args[4].string, args[4].option),
|
||||
key = CryptoJS.EvpKDF(passphrase, salt, {
|
||||
keySize: keySize,
|
||||
hasher: CryptoJS.algo[hasher],
|
||||
iterations: iterations,
|
||||
});
|
||||
|
||||
return key.toString(Cipher._format[outputFormat]);
|
||||
return key.toString(CryptoJS.enc.Hex);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
RC4_KEY_FORMAT: ["UTF8", "UTF16", "UTF16LE", "UTF16BE", "Latin1", "Hex", "Base64"],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
CJS_IO_FORMAT: ["Latin1", "UTF8", "UTF16", "UTF16LE", "UTF16BE", "Hex", "Base64"],
|
||||
|
||||
|
||||
/**
|
||||
* RC4 operation.
|
||||
*
|
||||
@@ -404,6 +515,53 @@ const Cipher = {
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
PRNG_BYTES: 32,
|
||||
PRNG_OUTPUT: ["Hex", "Number", "Byte array", "Raw"],
|
||||
|
||||
/**
|
||||
* Pseudo-Random Number Generator operation.
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
runPRNG: function(input, args) {
|
||||
const numBytes = args[0],
|
||||
outputAs = args[1];
|
||||
|
||||
let bytes;
|
||||
|
||||
if (ENVIRONMENT_IS_WORKER() && self.crypto) {
|
||||
bytes = self.crypto.getRandomValues(new Uint8Array(numBytes));
|
||||
bytes = Utils.arrayBufferToStr(bytes.buffer);
|
||||
} else {
|
||||
bytes = forge.random.getBytesSync(numBytes);
|
||||
}
|
||||
|
||||
let value = 0,
|
||||
i;
|
||||
|
||||
switch (outputAs) {
|
||||
case "Hex":
|
||||
return forge.util.bytesToHex(bytes);
|
||||
case "Number":
|
||||
for (i = bytes.length - 1; i >= 0; i--) {
|
||||
value = (value * 256) + bytes.charCodeAt(i);
|
||||
}
|
||||
return value.toString();
|
||||
case "Byte array":
|
||||
return JSON.stringify(Utils.strToCharcode(bytes));
|
||||
case "Raw":
|
||||
default:
|
||||
return bytes;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Vigenère Encode operation.
|
||||
*
|
||||
@@ -786,7 +944,7 @@ const Cipher = {
|
||||
|
||||
/**
|
||||
* A mapping of string formats to their classes in the CryptoJS library.
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @constant
|
||||
*/
|
||||
|
||||
@@ -101,32 +101,39 @@ const Tidy = {
|
||||
/**
|
||||
* Drop bytes operation.
|
||||
*
|
||||
* @param {byteArray} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byteArray}
|
||||
* @returns {ArrayBuffer}
|
||||
*/
|
||||
runDropBytes: function(input, args) {
|
||||
let start = args[0],
|
||||
const start = args[0],
|
||||
length = args[1],
|
||||
applyToEachLine = args[2];
|
||||
|
||||
if (start < 0 || length < 0)
|
||||
throw "Error: Invalid value";
|
||||
|
||||
if (!applyToEachLine)
|
||||
return input.slice(0, start).concat(input.slice(start+length, input.length));
|
||||
if (!applyToEachLine) {
|
||||
const left = input.slice(0, start),
|
||||
right = input.slice(start + length, input.byteLength);
|
||||
let result = new Uint8Array(left.byteLength + right.byteLength);
|
||||
result.set(new Uint8Array(left), 0);
|
||||
result.set(new Uint8Array(right), left.byteLength);
|
||||
return result.buffer;
|
||||
}
|
||||
|
||||
// Split input into lines
|
||||
const data = new Uint8Array(input);
|
||||
let lines = [],
|
||||
line = [],
|
||||
i;
|
||||
|
||||
for (i = 0; i < input.length; i++) {
|
||||
if (input[i] === 0x0a) {
|
||||
for (i = 0; i < data.length; i++) {
|
||||
if (data[i] === 0x0a) {
|
||||
lines.push(line);
|
||||
line = [];
|
||||
} else {
|
||||
line.push(input[i]);
|
||||
line.push(data[i]);
|
||||
}
|
||||
}
|
||||
lines.push(line);
|
||||
@@ -136,7 +143,7 @@ const Tidy = {
|
||||
output = output.concat(lines[i].slice(0, start).concat(lines[i].slice(start+length, lines[i].length)));
|
||||
output.push(0x0a);
|
||||
}
|
||||
return output.slice(0, output.length-1);
|
||||
return new Uint8Array(output.slice(0, output.length-1)).buffer;
|
||||
},
|
||||
|
||||
|
||||
@@ -154,12 +161,12 @@ const Tidy = {
|
||||
/**
|
||||
* Take bytes operation.
|
||||
*
|
||||
* @param {byteArray} input
|
||||
* @param {ArrayBuffer} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byteArray}
|
||||
* @returns {ArrayBuffer}
|
||||
*/
|
||||
runTakeBytes: function(input, args) {
|
||||
let start = args[0],
|
||||
const start = args[0],
|
||||
length = args[1],
|
||||
applyToEachLine = args[2];
|
||||
|
||||
@@ -170,16 +177,17 @@ const Tidy = {
|
||||
return input.slice(start, start+length);
|
||||
|
||||
// Split input into lines
|
||||
const data = new Uint8Array(input);
|
||||
let lines = [],
|
||||
line = [];
|
||||
let i;
|
||||
line = [],
|
||||
i;
|
||||
|
||||
for (i = 0; i < input.length; i++) {
|
||||
if (input[i] === 0x0a) {
|
||||
for (i = 0; i < data.length; i++) {
|
||||
if (data[i] === 0x0a) {
|
||||
lines.push(line);
|
||||
line = [];
|
||||
} else {
|
||||
line.push(input[i]);
|
||||
line.push(data[i]);
|
||||
}
|
||||
}
|
||||
lines.push(line);
|
||||
@@ -189,7 +197,7 @@ const Tidy = {
|
||||
output = output.concat(lines[i].slice(start, start+length));
|
||||
output.push(0x0a);
|
||||
}
|
||||
return output.slice(0, output.length-1);
|
||||
return new Uint8Array(output.slice(0, output.length-1)).buffer;
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -214,6 +214,10 @@ InputWaiter.prototype.handleLoaderMessage = function(e) {
|
||||
fileLoaded.textContent = r.progress + "%";
|
||||
}
|
||||
|
||||
if (r.hasOwnProperty("error")) {
|
||||
this.app.alert(r.error, "danger", 10000);
|
||||
}
|
||||
|
||||
if (r.hasOwnProperty("fileBuffer")) {
|
||||
log.debug("Input file loaded");
|
||||
this.fileBuffer = r.fileBuffer;
|
||||
|
||||
@@ -20,7 +20,7 @@ self.addEventListener("message", function(e) {
|
||||
|
||||
/**
|
||||
* Loads a file object into an ArrayBuffer, then transfers it back to the parent thread.
|
||||
*
|
||||
*
|
||||
* @param {File} file
|
||||
*/
|
||||
self.loadFile = function(file) {
|
||||
@@ -46,5 +46,9 @@ self.loadFile = function(file) {
|
||||
seek();
|
||||
};
|
||||
|
||||
reader.onerror = function(e) {
|
||||
self.postMessage({"error": file.error.message});
|
||||
};
|
||||
|
||||
seek();
|
||||
};
|
||||
|
||||
@@ -154,7 +154,7 @@ OptionsWaiter.prototype.setWordWrap = function() {
|
||||
|
||||
/**
|
||||
* Changes the theme by setting the class of the <html> element.
|
||||
*
|
||||
*
|
||||
* @param {Event} e
|
||||
*/
|
||||
OptionsWaiter.prototype.themeChange = function (e) {
|
||||
@@ -166,7 +166,7 @@ OptionsWaiter.prototype.themeChange = function (e) {
|
||||
|
||||
/**
|
||||
* Changes the console logging level.
|
||||
*
|
||||
*
|
||||
* @param {Event} e
|
||||
*/
|
||||
OptionsWaiter.prototype.logLevelChange = function (e) {
|
||||
|
||||
@@ -170,7 +170,7 @@ OutputWaiter.prototype.displayFileSlice = function() {
|
||||
|
||||
/**
|
||||
* Handler for show file overlay events.
|
||||
*
|
||||
*
|
||||
* @param {Event} e
|
||||
*/
|
||||
OutputWaiter.prototype.showFileOverlayClick = function(e) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user