cyberchef 9.50.5 → 9.50.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cyberchef",
3
- "version": "9.50.5",
3
+ "version": "9.50.8",
4
4
  "description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
5
5
  "author": "n1474335 <n1474335@gmail.com>",
6
6
  "homepage": "https://gchq.github.io/CyberChef",
@@ -6925,7 +6925,7 @@
6925
6925
  {
6926
6926
  "name": "Margin (num modules)",
6927
6927
  "type": "number",
6928
- "value": 2,
6928
+ "value": 4,
6929
6929
  "min": 0
6930
6930
  },
6931
6931
  {
@@ -44,7 +44,7 @@ class GenerateQRCode extends Operation {
44
44
  {
45
45
  "name": "Margin (num modules)",
46
46
  "type": "number",
47
- "value": 2,
47
+ "value": 4,
48
48
  "min": 0
49
49
  },
50
50
  {
@@ -57,23 +57,29 @@ class ParseX509Certificate extends Operation {
57
57
  const cert = new r.X509(),
58
58
  inputFormat = args[0];
59
59
 
60
- switch (inputFormat) {
61
- case "DER Hex":
62
- input = input.replace(/\s/g, "").toLowerCase();
63
- cert.readCertHex(input);
64
- break;
65
- case "PEM":
66
- cert.readCertPEM(input);
67
- break;
68
- case "Base64":
69
- cert.readCertHex(toHex(fromBase64(input, null, "byteArray"), ""));
70
- break;
71
- case "Raw":
72
- cert.readCertHex(toHex(Utils.strToByteArray(input), ""));
73
- break;
74
- default:
75
- throw "Undefined input format";
60
+ let undefinedInputFormat = false;
61
+ try {
62
+ switch (inputFormat) {
63
+ case "DER Hex":
64
+ input = input.replace(/\s/g, "").toLowerCase();
65
+ cert.readCertHex(input);
66
+ break;
67
+ case "PEM":
68
+ cert.readCertPEM(input);
69
+ break;
70
+ case "Base64":
71
+ cert.readCertHex(toHex(fromBase64(input, null, "byteArray"), ""));
72
+ break;
73
+ case "Raw":
74
+ cert.readCertHex(toHex(Utils.strToByteArray(input), ""));
75
+ break;
76
+ default:
77
+ undefinedInputFormat = true;
78
+ }
79
+ } catch (e) {
80
+ throw "Certificate load error (non-certificate input?)";
76
81
  }
82
+ if (undefinedInputFormat) throw "Undefined input format";
77
83
 
78
84
  const sn = cert.getSerialNumberHex(),
79
85
  issuer = cert.getIssuer(),
@@ -70,7 +70,7 @@ class TripleDESDecrypt extends Operation {
70
70
  inputType = args[3],
71
71
  outputType = args[4];
72
72
 
73
- if (key.length !== 24) {
73
+ if (key.length !== 24 && key.length !== 16) {
74
74
  throw new OperationError(`Invalid key length: ${key.length} bytes
75
75
 
76
76
  Triple DES uses a key length of 24 bytes (192 bits).
@@ -85,7 +85,8 @@ Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
85
85
 
86
86
  input = Utils.convertToByteString(input, inputType);
87
87
 
88
- const decipher = forge.cipher.createDecipher("3DES-" + mode, key);
88
+ const decipher = forge.cipher.createDecipher("3DES-" + mode,
89
+ key.length === 16 ? key + key.substring(0, 8) : key);
89
90
 
90
91
  /* Allow for a "no padding" mode */
91
92
  if (noPadding) {
@@ -69,7 +69,7 @@ class TripleDESEncrypt extends Operation {
69
69
  inputType = args[3],
70
70
  outputType = args[4];
71
71
 
72
- if (key.length !== 24) {
72
+ if (key.length !== 24 && key.length !== 16) {
73
73
  throw new OperationError(`Invalid key length: ${key.length} bytes
74
74
 
75
75
  Triple DES uses a key length of 24 bytes (192 bits).
@@ -84,7 +84,8 @@ Make sure you have specified the type correctly (e.g. Hex vs UTF8).`);
84
84
 
85
85
  input = Utils.convertToByteString(input, inputType);
86
86
 
87
- const cipher = forge.cipher.createCipher("3DES-" + mode, key);
87
+ const cipher = forge.cipher.createCipher("3DES-" + mode,
88
+ key.length === 16 ? key + key.substring(0, 8) : key);
88
89
  cipher.start({iv: iv});
89
90
  cipher.update(forge.util.createBuffer(input));
90
91
  cipher.finish();