Skip to content

A very effective Java Tool for Asn1 BER Encoder/Decoder by Line Command.

License

Notifications You must be signed in to change notification settings

gpalleschi/JAsn1LC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JAsn1LC

Description

A JAVA ASN1 BER (Basic Encoding Rules) encoder/decoder. This tool can decode/encode any type of ASN1 BER File.

Use: java -jar JAsn1LC.jar <File Asn1/Text> [-s<File Name Conversion>] [-h] [-o] [-t] [-npv] [-lt] [-ll] [-nl] [-ni] [-b] [-e] [-c<File Name Asn1 Output>] [-help]

Parameters [...] are optional Parameters <...> are mandatory

<File Asn1/Text> : Input File Asn1 (DECODE MODE) or Text (ENCODE)
[-s<File Name Conversion>] : Conversion File. (DECODE MODE)
[-h] : Display Hexadecimal Value for Tags (DECODE MODE)
[-o] : Display Offset for each Tag with relative level (DECODE MODE)
[-t] : Display Only value of Tag Class instead of Id-Tag Class (Used for TAP rappresentation) (DECODE MODE)
[-npv] : No Display primitive Values (DECODE MODE)
[-nl] : No Display Length for Tags (DECODE MODE)
[-ni] : No Tag Indentation (DECODE MODE)
[-b] : Specify Byte From (DECODE MODE)
[-e] : Specify Byte To (DECODE MODE)
[-c<File Name Asn1 Output>]: Asn1 File Output (ENCODE MODE)
[-help] : Show help informations (ENCODE/DECODE MODE)

Decode Mode

This modality permits to show in standard output an ASN1 BER File.
Here an example of output :

java -jar JAsn1LC ./CDARGTMARGTP02595.encoded -o -t


ASN1 FILE ./CDARGTMARGTP02595.encoded SIZE : 501810

00000000:001 [1] {TransferBatch} length : 491534
00000005:002 [1.4] {BatchControlInfo} length : 121
00000007:003 [1.4.196] {Sender} length : 5 "415247544d"h Value (ARGTM)A
00000016:003 [1.4.182] {Recipient} length : 5 "4152475450"h Value (ARGTP)A
00000025:003 [1.4.109] {FileSequenceNumber} length : 5 "3032353935"h Value (02595)A
00000033:003 [1.4.108] {FileCreationTimeStamp} length : 25
00000036:004 [1.4.108.16] {LocalTimeStamp} length : 14 "3230313831323238303730313134"h Value (20181228070114)A
00000052:004 [1.4.108.231] {UtcTimeOffset} length : 5 "2d30333030"h Value (-0300)A
00000061:003 [1.4.227] {TransferCutOffTimeStamp} length : 25
00000065:004 [1.4.227.16] {LocalTimeStamp} length : 14 "3230313831323238303730313134"h Value (20181228070114)A


In DECODE Modality is possible specify in addition to the input file, a convertion csv file with parameter -s. Each record of this file has this format : <Tag Name>|<Conversion Type>|<Desc Tag> {See TAG312 and RAP15 CONV_FILE in project ASN.1-Reader}.

  • <Tag Name> : In format Id-Class or only Class (-t parameter)
  • <Conversion Type> : Type of conversion
Type description
A Hex to Ascii
B Hex to Binary
N Hex to Number
  • <Desc Tag> : Description of Tag to visualize in (DECODE MODE)

Example Record : 1-15|N|Total Records

Running Examples :

  • java -jar JAsn1LC.jar ../TAP312/CDARGTPARGTM00012 -sConv_TAP312 -t -h -o
  • java -jar JAsn1LC.jar ../TAP312/CDARGTPARGTM00012 -h -npv

Encode Mode

In ENCODE Modality is necesary specify in addition to the input file, the parameter -c with the output file Asn1 to create, if are presents others parameters will be ingnored.

In this modality, the input file is important that is in ascii format producer for previous DECODE run. It's very important that each record contains Tag, between [...] and Hexadecimal Value between "..." (if Tag is primitve). If in a record is present string indefinite length, Tag will be generated with infinitive length. It's very important that Tag respect hierarchical structure where each level is separated by character dot '.'. Length will be recalculated, if present in input Record the length value it not will be considerated. If is not present Id in Id-Tag Class will be assgned Id value to 1.

Here an example (In this case without Id will be assigned value to 1) :

00000000:001 [1] {TransferBatch} length : 10140490
00000005:002 [1.4] {BatchControlInfo} length : 119
00000007:003 [1.4.196]{Sender} length : 5 "415247544d"h Value (ARGTM)A
00000007:003 [1.4.101]{Sender} length : 2 "4152"h Value (AR)A
00000126:002 [1.5] {AccountingInfo} length : 42
00000128:003 [1.5.211] {TaxationList} length : 0

Running Example :

  • java -jar JAsn1LC.jar -c./OUTPUT/CDARGTPARGTM00013.new ../TAP312/CDARGTPARGTM00013.txt

Getting Started

Copy jar on your local machine. Run it "java -jar JAsn1LC.jar ....."

Prerequisites

>= Java 1.7

Built With

Authors

License

This project is licensed under the GNU GENERAL PUBLIC LICENSE 3.0 License - see the LICENSE file for details