ASN2XML 1.7.x help

Overview of ASN2XML

ASN2XML translates a BER/DER encoded binary data file to XML format. BER refers to the ASN.1 Basic Encoding Rules as published in the ITU X.690 standard. DER refers to the Distinguished Encoding Rules as published in the same standard. This tool can decode BER or DER messages with or without an associated ASN.1 definition as follows:

  1. If ASN.1 definitions are not used, an XML message will be created with tag numbers and decoded values.
  2. If an ASN.1 source definition is used (via the -schema command-line option), an XML message will be created using element names and other metadata from the ASN.1 definitions.
Using ASN2XML

To test if the tool was successfully installed, enter asn2xml with no parameters as follows (note: if the PATH variable is not updated, you will need to enter the full pathname of asn2xml executable):

asn2xml
You should observe the following display (or something similar):

ASN2XML, Version 1.7.x
ASN.1 to XML translation tool
Copyright (c) 2004-2009 Objective Systems, Inc. All Rights Reserved.

Usage: asn2xml <filename> options

<filename> ASN.1 message file name

options:
-schema <filename>  ASN.1 definition file name(s)
-ber                Use basic encoding rules (BER)
-per                Use aligned packed encoding rules (PER)
-uper               Use unaligned packed encoding rules (U-PER)
-pdu <typename>     Message PDU type name
-o <filename>       Output XML filename
-nobcd              Disable BCD conversion
-noopentype         Disable automatic Open Type decoding
-blocksize <size>   Decode message from fixed size block
-noofblock <blocks> Decode number of blocks
-paddingbyte <hexbyte>  Additional padding byte
-singlemessage      Decode first message only
-rootelement <name> Root element name
-bitsfmt <hex|bin>  BIT STRING content output format
-inputFileType <binary|hextext|base64> Format of data in input file

 

This indicates that to use the translator, at a minimum, the name of a message file containing ASN.1 encoded data must be provided. The file may contain data that has been encoded using any of the ASN.1 binary encoding rules (BER, DER, CER, or PER - aligned or unaligned). The file may contain binary data or textual data in hexadecimal text or base64 format.

The following table lists all of the command line options and what they are used for:

Option

Argument

Description

-schema <filenames> This option defines the ASN.1 files used to encode the binary message. This file must strictly adhere to the syntax specified in ASN.1 standard ITU X.680. More than one ASN.1 filename may be specified by separating the names with spaces (e.g. asn2xml message.dat -schema X.asn Y.asn Z.asn).

This argument is optional in the case of BER messages (this includes DER and CER) but is required for PER.

-ber   This option indicates that the given data file contains binary data encoded using the Basic Encoding Rules (BER) as specified in the ITU-T X.690 standard. It is also used to indicate data encoded in Distinguished Encoding Rules (DER) format or Canonical Encoding Rules (CER) format.
-per   This option indicates that the given data file contains binary data encoded using the Packed Encoding Rules (PER) aligned variant as specified in the ITU-T X.691 standard.
-uper   This option indicates that the given data file contains binary data encoded using the Packed Encoding Rules (PER) unaligned variant as specified in the ITU-T X.691 standard.
-pdu <typename>

Note: This option works only with the -schema option.

This option explicitly defines the PDU (Protocol Data Unit) type name for the binary message. By default, the asn2xml program will try to determine the PDU of the message using a tag-matching algorithm. If multiple matches are found, the program will exit with an error condition.

Note that this option, as well as the -schema option, are required for translation of PER messages to XML.

-noopentype  

Note: This option works only with the -schema option.

If this option is defined, ASN2XML will disable automatic open type decoding and print the open type data as hexadecimal digits.

Without this option, ASN2XML will try to decode the open type automatically. It will try to find a matching ASN.1 type definition in the assigned ASN.1 files for the open type data and will decode the data using this type. If ASN2XML is not able to find a single ASN.1 type, then it will display the data in hexadecimal format.

-o <filename> This option defines the output XML filename. The XML message will be printed to this filename. If not specified, the XML message will be printed to standard output.
-nobcd  

This option is used for the following assignment:

TBCDSTRING ::= OCTET STRING

The TBCDSTRING assignment can have constraints. By default, the translator will assume this type refers to a binary coded decimal type and will do the appropriate translation of the characters within. This flag suppresses this translation and causes the type to be treated as a normal OCTET STRING type.

-paddingbyte <hexbyte>

This option allows the default padding byte value to be changed. Padding bytes are bytes that have no meaning which may occur between messages in binary files. The default padding byte is zero. This option allows the padding byte to be changed to a different value (for example, 0xFF).

-blocksize <size>

This option defines the value of the block size in bytes. The maximum possible value for this field is 50000000. This option will instruct the ASN2XML to decode message from fixed size block.

This option is related to fixed size blocks in messages. Several known Call Detail Record (CDR) formats use this type of storage.

-noofblock <blocks>

This field accepts the value for the number of blocks to be decoded. By default, ASN2XML will decode all the blocks in the message.

This option requires the usage of -blocksize option.

This option is related to fixed size blocks in messages. Several known Call Detail Record (CDR) formats use this type of storage.

-rootelement <name>

This option sets the name for an additional wrapper XML element at the root level.

By default, ASN2XML uses <message> as the outer wrapper tag name.

-bitsfmt hex or bin This option sets the format for how BIT STRING data should be displayed in the XML document. If hex, the string content is displayed in hexadecimal format. If bin, the string is displayed in binary format (1's and 0's).
-inputFileType binary
hextext
base64
This option specifies the format of the data in the input file to br translated. binary (the default) indicates the data is in raw binary form. hextext indicates the data is in hexadecimal text format. base64 indicates the data is encoded in base64 text format.

 
Binary to XML Message Translation

ASN2XML translates a binary message to XML with or without an associated ASN.1 definition file.

  • Decoding without an ASN.1 file
  • Decoding with an ASN.1 file
Decoding Without an ASN.1 File
ASN2XML decodes the binary message according to the BER tag, length, and value structure. The known tag values are decoded with type names as defined in the following table.

Tag

Type

UNIVERSAL 1 Boolean
UNIVERSAL 2 Integer
UNIVERSAL 3 Bitstring
UNIVERSAL 4 Octetstring
UNIVERSAL 5 Null
UNIVERSAL 6 Object identifier
UNIVERSAL 7 Object descriptor
UNIVERSAL 8 External
UNIVERSAL 9 Real
UNIVERSAL 10 Enumerated
UNIVERSAL 11 Embedded-pdv
UNIVERSAL 12 UTF8String
UNIVERSAL 13 Relative object identifier
UNIVERSAL 16 Sequence and Sequence-of
UNIVERSAL 17 Set and Set-of
UNIVERSAL 18-22, 25-30 Character string
UNIVERSAL 23-24 Time

 

All other tag values will be printed in the following format: <TagClass_TagValue>

where TagClass is the tag class name (APPLICATION, CONTEXT, or PRIVATE) and TagValue is the numeric tag value. For example, an [APPLICATION 1] tag would be printed as <APPLICATION_1> and a [0] tag (context-specific zero) would be printed as <CONTEXT_0>.

The XML message will be created using the tag and value. Tag will be used as the XML element name and value will be used as the XML element content.

 
Decoding Message with an ASN.1 File

ASN2XML can decode a binary message using an associated ASN.1 definition. This is done by specifying one of more ASN.1 source files that contain the definition of the binary message being decoded. ASN2XML will print an ASN.1 / message mismatch error if the ASN.1 file does not contain the type definition of the message.

It is possible to use the -pdu command-line switch to force the association of a type within the specification to the message. This is only necessary if the ASN.1 files contain multiple types with the same start tag as the message type. Otherwise, the program will be able to determine on its own which type to use by matching tags.

The XML message will be created using the ASN.1 definition element names and decoded message values. The ASN.1 definition element names will be used as the XML element names and decoded message values will be used for XML element content.

 

Objective Systems Inc
http://www.obj-sys.com
Phone: +1 (484) 875-9841
Report any problem or issues to us at support@obj-sys.com
Copyright © 2004-2009 Objective Systems, Inc. All Rights Reserved.