mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-09 07:45:00 -04:00
Updated algorithm selection
This commit is contained in:
parent
8332e39b6b
commit
d23d98d2a0
3 changed files with 6 additions and 19 deletions
|
@ -19,6 +19,5 @@ export const JWT_ALGORITHMS = [
|
|||
"RS512",
|
||||
"ES256",
|
||||
"ES384",
|
||||
"ES512",
|
||||
"None"
|
||||
"ES512"
|
||||
];
|
||||
|
|
|
@ -26,6 +26,7 @@ class JWTSign extends Operation {
|
|||
this.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token";
|
||||
this.inputType = "JSON";
|
||||
this.outputType = "string";
|
||||
const algorithmList = JWT_ALGORITHMS.concat(["None"]);
|
||||
this.args = [
|
||||
{
|
||||
name: "Private/Secret Key",
|
||||
|
@ -35,7 +36,7 @@ class JWTSign extends Operation {
|
|||
{
|
||||
name: "Signing algorithm",
|
||||
type: "option",
|
||||
value: JWT_ALGORITHMS
|
||||
value: algorithmList
|
||||
}
|
||||
];
|
||||
}
|
||||
|
|
|
@ -26,8 +26,7 @@ class JWTVerify extends Operation {
|
|||
this.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token";
|
||||
this.inputType = "string";
|
||||
this.outputType = "JSON";
|
||||
const algOptions = JWT_ALGORITHMS;
|
||||
algOptions.push("Any");
|
||||
const algorithmList = JWT_ALGORITHMS.concat(["Any"]);
|
||||
this.args = [
|
||||
{
|
||||
name: "Public/Secret Key",
|
||||
|
@ -37,7 +36,7 @@ class JWTVerify extends Operation {
|
|||
{
|
||||
name: "Signing algorithm",
|
||||
type: "option",
|
||||
value: algOptions
|
||||
value: algorithmList
|
||||
}
|
||||
];
|
||||
}
|
||||
|
@ -49,19 +48,7 @@ class JWTVerify extends Operation {
|
|||
*/
|
||||
run(input, args) {
|
||||
const [key, alg] = args;
|
||||
let algos = [];
|
||||
switch (alg) {
|
||||
case "Any":
|
||||
algos = JWT_ALGORITHMS;
|
||||
break;
|
||||
case "None":
|
||||
algos.push("none");
|
||||
break;
|
||||
default:
|
||||
algos.push(alg);
|
||||
break;
|
||||
}
|
||||
|
||||
let algos = (alg == "Any" ? JWT_ALGORITHMS : alg);
|
||||
try {
|
||||
const verified = jwt.verify(input, key, { algorithms: algos });
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue