Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
7a080483
Commit
7a080483
authored
Aug 15, 2005
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minimalistic mode
parent
291d3f2b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
8 deletions
+18
-8
asn1c/check-xxber.sh
asn1c/check-xxber.sh
+2
-2
asn1c/unber.1
asn1c/unber.1
+4
-1
asn1c/unber.c
asn1c/unber.c
+12
-5
No files found.
asn1c/check-xxber.sh
View file @
7a080483
...
@@ -15,7 +15,7 @@ cat<<EOM > $ORIG
...
@@ -15,7 +15,7 @@ cat<<EOM > $ORIG
</C O="14" T="[UNIVERSAL 16]" A="SEQUENCE" L="8">
</C O="14" T="[UNIVERSAL 16]" A="SEQUENCE" L="8">
EOM
EOM
./enber
<
$ORIG
-
| ./unber
-p
-i
0 -
>
$TEST
2>&1
./enber
$ORIG
| ./unber
-p
-i
0 -
>
$TEST
2>&1
diff
$diffArgs
$ORIG
$TEST
>
/dev/null 2>&1
diff
$diffArgs
$ORIG
$TEST
>
/dev/null 2>&1
diffExitCode
=
$?
diffExitCode
=
$?
...
@@ -28,7 +28,7 @@ fi
...
@@ -28,7 +28,7 @@ fi
echo
'</I O="14" T="[UNIVERSAL 0]" TL="2" L="16">'
>>
$ORIG
echo
'</I O="14" T="[UNIVERSAL 0]" TL="2" L="16">'
>>
$ORIG
# Try trancoding again
# Try trancoding again
./enber
<
$ORIG
-
| ./unber
-p
-i
0 -
>
$TEST
2>&1
./enber
$ORIG
| ./unber
-p
-i
0 -
>
$TEST
2>&1
diff
$diffArgs
$ORIG
$TEST
diff
$diffArgs
$ORIG
$TEST
diffExitCode
=
$?
diffExitCode
=
$?
...
...
asn1c/unber.1
View file @
7a080483
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
.SH NAME
.SH NAME
unber \- ASN.1 BER Decoder
unber \- ASN.1 BER Decoder
.SH SYNOPSIS
.SH SYNOPSIS
unber [\fB-1\fR] [\fB-i\fRindent] [\fB-p\fR] [\fB\-t\fR\fIdata-string\fR] [\fB-\fR] [\fIinfile\fR...]
unber [\fB-1\fR] [\fB-i\fRindent] [\fB-
m\fR] [\fB-
p\fR] [\fB\-t\fR\fIdata-string\fR] [\fB-\fR] [\fIinfile\fR...]
.SH DESCRIPTION
.SH DESCRIPTION
unber takes the BER-encoded files and dumps their internal structure as human readable text.
unber takes the BER-encoded files and dumps their internal structure as human readable text.
A single dash represents the standard input.
A single dash represents the standard input.
...
@@ -28,6 +28,9 @@ By default, unber continues decoding until the end of file (input stream).
...
@@ -28,6 +28,9 @@ By default, unber continues decoding until the end of file (input stream).
\fB\-i\fR \fIindent\fR
\fB\-i\fR \fIindent\fR
Use the specified number of spaces for output indentation. Default is 4 spaces.
Use the specified number of spaces for output indentation. Default is 4 spaces.
.TP
.TP
\fB\-m\fR
Generate minimum amount of output while still preserving BER encoding information.
.TP
\fB\-p\fR
\fB\-p\fR
Do \fInot\fR attempt pretty-printing of known ASN.1 types (OBJECT IDENTIFIER, INTEGER, BOOLEAN, etc). By default, some ASN.1 types are converted into
Do \fInot\fR attempt pretty-printing of known ASN.1 types (OBJECT IDENTIFIER, INTEGER, BOOLEAN, etc). By default, some ASN.1 types are converted into
the text representation. This option is required for \&\fIenber\fR\|(1).
the text representation. This option is required for \&\fIenber\fR\|(1).
...
...
asn1c/unber.c
View file @
7a080483
...
@@ -45,6 +45,7 @@ static int process(const char *fname); /* Perform the BER decoding */
...
@@ -45,6 +45,7 @@ static int process(const char *fname); /* Perform the BER decoding */
static
int
decode_tlv_from_string
(
const
char
*
datastring
);
static
int
decode_tlv_from_string
(
const
char
*
datastring
);
static
int
single_type_decoding
=
0
;
/* -1 enables that */
static
int
single_type_decoding
=
0
;
/* -1 enables that */
static
int
minimalistic
=
0
;
/* -m enables that */
static
int
pretty_printing
=
1
;
/* -p disables that */
static
int
pretty_printing
=
1
;
/* -p disables that */
static
char
*
indent_buffer
=
" "
;
/* -i controls that */
static
char
*
indent_buffer
=
" "
;
/* -i controls that */
...
@@ -56,7 +57,7 @@ main(int ac, char **av) {
...
@@ -56,7 +57,7 @@ main(int ac, char **av) {
/*
/*
* Process command-line options.
* Process command-line options.
*/
*/
while
((
ch
=
getopt
(
ac
,
av
,
"1hi:pt:v"
))
!=
-
1
)
while
((
ch
=
getopt
(
ac
,
av
,
"1hi:
m
pt:v"
))
!=
-
1
)
switch
(
ch
)
{
switch
(
ch
)
{
case
'1'
:
case
'1'
:
single_type_decoding
=
1
;
single_type_decoding
=
1
;
...
@@ -65,6 +66,9 @@ main(int ac, char **av) {
...
@@ -65,6 +66,9 @@ main(int ac, char **av) {
if
(
decode_tlv_from_string
(
optarg
))
if
(
decode_tlv_from_string
(
optarg
))
exit
(
EX_DATAERR
);
exit
(
EX_DATAERR
);
exit
(
0
);
exit
(
0
);
case
'm'
:
minimalistic
=
1
;
break
;
case
'p'
:
case
'p'
:
pretty_printing
=
0
;
pretty_printing
=
0
;
break
;
break
;
...
@@ -124,6 +128,7 @@ usage(const char *av0) {
...
@@ -124,6 +128,7 @@ usage(const char *av0) {
"Options:
\n
"
"Options:
\n
"
" -1 Decode only the first BER structure (otherwise, until EOF)
\n
"
" -1 Decode only the first BER structure (otherwise, until EOF)
\n
"
" -i <indent> Amount of spaces for output indentation (default is 4)
\n
"
" -i <indent> Amount of spaces for output indentation (default is 4)
\n
"
" -m Minimalistic mode: print as little as possible
\n
"
" -p Do not attempt pretty-printing of known ASN.1 types
\n
"
" -p Do not attempt pretty-printing of known ASN.1 types
\n
"
" -t <data-string> Decode the given tag[/length] sequence (e.g. -t
\"
bf20
\"
)
\n
"
" -t <data-string> Decode the given tag[/length] sequence (e.g. -t
\"
bf20
\"
)
\n
"
"
\n
"
"
\n
"
...
@@ -363,13 +368,14 @@ print_TL(int fin, asn1c_integer_t offset, int level, int constr, ssize_t tlen, b
...
@@ -363,13 +368,14 @@ print_TL(int fin, asn1c_integer_t offset, int level, int constr, ssize_t tlen, b
printf
(
constr
?
((
tlv_len
==
-
1
)
?
"I"
:
"C"
)
:
"P"
);
printf
(
constr
?
((
tlv_len
==
-
1
)
?
"I"
:
"C"
)
:
"P"
);
/* Print out the offset of this boundary, even if closing tag */
/* Print out the offset of this boundary, even if closing tag */
if
(
!
minimalistic
)
printf
(
" O=
\"
%"
PRIdASN
"
\"
"
,
offset
);
printf
(
" O=
\"
%"
PRIdASN
"
\"
"
,
offset
);
printf
(
" T=
\"
"
);
printf
(
" T=
\"
"
);
ber_tlv_tag_fwrite
(
tlv_tag
,
stdout
);
ber_tlv_tag_fwrite
(
tlv_tag
,
stdout
);
printf
(
"
\"
"
);
printf
(
"
\"
"
);
if
(
!
fin
||
tlv_len
==
-
1
)
if
(
!
fin
||
(
tlv_len
==
-
1
&&
!
minimalistic
)
)
printf
(
" TL=
\"
%ld
\"
"
,
(
long
)
tlen
);
printf
(
" TL=
\"
%ld
\"
"
,
(
long
)
tlen
);
if
(
!
fin
)
{
if
(
!
fin
)
{
if
(
tlv_len
==
-
1
)
if
(
tlv_len
==
-
1
)
...
@@ -378,7 +384,8 @@ print_TL(int fin, asn1c_integer_t offset, int level, int constr, ssize_t tlen, b
...
@@ -378,7 +384,8 @@ print_TL(int fin, asn1c_integer_t offset, int level, int constr, ssize_t tlen, b
printf
(
" V=
\"
%ld
\"
"
,
(
long
)
tlv_len
);
printf
(
" V=
\"
%ld
\"
"
,
(
long
)
tlv_len
);
}
}
if
(
BER_TAG_CLASS
(
tlv_tag
)
==
ASN_TAG_CLASS_UNIVERSAL
)
{
if
(
!
minimalistic
&&
BER_TAG_CLASS
(
tlv_tag
)
==
ASN_TAG_CLASS_UNIVERSAL
)
{
const
char
*
str
;
const
char
*
str
;
ber_tlv_tag_t
tvalue
=
BER_TAG_VALUE
(
tlv_tag
);
ber_tlv_tag_t
tvalue
=
BER_TAG_VALUE
(
tlv_tag
);
str
=
ASN_UNIVERSAL_TAG2STR
(
tvalue
);
str
=
ASN_UNIVERSAL_TAG2STR
(
tvalue
);
...
@@ -386,7 +393,7 @@ print_TL(int fin, asn1c_integer_t offset, int level, int constr, ssize_t tlen, b
...
@@ -386,7 +393,7 @@ print_TL(int fin, asn1c_integer_t offset, int level, int constr, ssize_t tlen, b
}
}
if
(
fin
)
{
if
(
fin
)
{
if
(
constr
)
if
(
constr
&&
!
minimalistic
)
printf
(
" L=
\"
%ld
\"
"
,
(
long
)
effective_size
);
printf
(
" L=
\"
%ld
\"
"
,
(
long
)
effective_size
);
printf
(
">
\n
"
);
printf
(
">
\n
"
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment