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",
|
"RS512",
|
||||||
"ES256",
|
"ES256",
|
||||||
"ES384",
|
"ES384",
|
||||||
"ES512",
|
"ES512"
|
||||||
"None"
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -26,6 +26,7 @@ class JWTSign extends Operation {
|
||||||
this.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token";
|
this.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token";
|
||||||
this.inputType = "JSON";
|
this.inputType = "JSON";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
|
const algorithmList = JWT_ALGORITHMS.concat(["None"]);
|
||||||
this.args = [
|
this.args = [
|
||||||
{
|
{
|
||||||
name: "Private/Secret Key",
|
name: "Private/Secret Key",
|
||||||
|
@ -35,7 +36,7 @@ class JWTSign extends Operation {
|
||||||
{
|
{
|
||||||
name: "Signing algorithm",
|
name: "Signing algorithm",
|
||||||
type: "option",
|
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.infoURL = "https://wikipedia.org/wiki/JSON_Web_Token";
|
||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "JSON";
|
this.outputType = "JSON";
|
||||||
const algOptions = JWT_ALGORITHMS;
|
const algorithmList = JWT_ALGORITHMS.concat(["Any"]);
|
||||||
algOptions.push("Any");
|
|
||||||
this.args = [
|
this.args = [
|
||||||
{
|
{
|
||||||
name: "Public/Secret Key",
|
name: "Public/Secret Key",
|
||||||
|
@ -37,7 +36,7 @@ class JWTVerify extends Operation {
|
||||||
{
|
{
|
||||||
name: "Signing algorithm",
|
name: "Signing algorithm",
|
||||||
type: "option",
|
type: "option",
|
||||||
value: algOptions
|
value: algorithmList
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -49,19 +48,7 @@ class JWTVerify extends Operation {
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const [key, alg] = args;
|
const [key, alg] = args;
|
||||||
let algos = [];
|
let algos = (alg == "Any" ? JWT_ALGORITHMS : alg);
|
||||||
switch (alg) {
|
|
||||||
case "Any":
|
|
||||||
algos = JWT_ALGORITHMS;
|
|
||||||
break;
|
|
||||||
case "None":
|
|
||||||
algos.push("none");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
algos.push(alg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const verified = jwt.verify(input, key, { algorithms: algos });
|
const verified = jwt.verify(input, key, { algorithms: algos });
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue