mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
ESM: Ported PublicKey operations
This commit is contained in:
parent
709630f39b
commit
049656ec6b
7 changed files with 518 additions and 0 deletions
54
src/core/operations/ParseASN1HexString.mjs
Normal file
54
src/core/operations/ParseASN1HexString.mjs
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2016
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import r from "jsrsasign";
|
||||
import Operation from "../Operation";
|
||||
|
||||
/**
|
||||
* Parse ASN.1 hex string operation
|
||||
*/
|
||||
class ParseASN1HexString extends Operation {
|
||||
|
||||
/**
|
||||
* ParseASN1HexString constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Parse ASN.1 hex string";
|
||||
this.module = "PublicKey";
|
||||
this.description = "Abstract Syntax Notation One (ASN.1) is a standard and notation that describes rules and structures for representing, encoding, transmitting, and decoding data in telecommunications and computer networking.<br><br>This operation parses arbitrary ASN.1 data and presents the resulting tree.";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Starting index",
|
||||
"type": "number",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"name": "Truncate octet strings longer than",
|
||||
"type": "number",
|
||||
"value": 32
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [index, truncateLen] = args;
|
||||
return r.ASN1HEX.dump(input.replace(/\s/g, ""), {
|
||||
"ommitLongOctet": truncateLen
|
||||
}, index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default ParseASN1HexString;
|
Loading…
Add table
Add a link
Reference in a new issue