-
-
Notifications
You must be signed in to change notification settings - Fork 644
/
asn1dump
executable file
·48 lines (42 loc) · 1.31 KB
/
asn1dump
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env node
/*
* asn1dump - simple ASN.1 dumper for ASN.1 DER binary file
*
* Copyright (c) 2015-2016 Kenji Urushima (kenji.urushima@gmail.com)
*
* This software is licensed under the terms of the MIT License.
* https://kjur.github.io/jsrsasign/license
*
* The above copyright and license notice shall be
* included in all copies or substantial portions of the Software.
*
* Please use '-h' option for this script usage.
* ---------------------------------------------------------
* DESCRIPTION
* This script shows ASN.1 dump of ASN.1 DER binary file.
*
* USAGE
* % asn1dump req.der
* SEQUENCE
* SEQUENCE
* SEQUENCE
* ObjectIdentifier sha1 (1 3 14 3 2 26)
* NULL
* OCTETSTRING 7ae13ee8a0c42a2cb428cbe7a605461940e2a1e9
* OCTETSTRING 90af6a3a945a0bd890ea125673df43b43a28dae7
* INTEGER 00d09282634303a97fadf55568a48ca87e
*/
var program = require('commander');
var rs = require('jsrsasign');
var rsu = require('jsrsasign-util');
program
.version('0.0.2')
.usage('[options] <input file>')
.description('show dump of ASN.1 DER file')
.parse(process.argv);
if (program.args.length !== 1)
throw "wrong number of arguments";
var file = program.args[0];
var bin = rsu.readFile(file);
var hex = rs.rstrtohex(bin);
console.log(rs.ASN1HEX.dump(hex));