Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • onion/asn1c
  • oai/asn1c
  • ptizoom/asn1c
  • havar_mind/asn1c
  • gao/asn1c
  • samlty/asn1c
  • tomrom/asn1c
  • tjamc80/asn1c
  • james862/asn1c
  • gaoridong2009/asn1c
  • zhourenquan/asn1c
11 results
Show changes
Commits on Source (1062)
*.o
*.la
*.lo
*.libs
*.deps
*.core
# /
/autom4te.cache
/config.h
/config.log
/config.cache
/config.status
/configure.lineno
/local-configure.sh
/libtool
/stamp-h*
/asn1c-*.tar.gz
/asn1c.spec
/Makefile
# /asn1c/
/asn1c/Makefile
/asn1c/asn1c
/asn1c/unber
/asn1c/enber
# /asn1c/tests/
/asn1c/tests/Makefile
/asn1c/tests/test-*
# /doc/
/doc/Makefile
# /doc/docsrc
/doc/docsrc/Makefile
doc/docsrc/*.aux
doc/docsrc/*.dvi
doc/docsrc/*.log
doc/docsrc/*.out
doc/docsrc/*.toc
doc/docsrc/*.xdv
# /examples/
/examples/Makefile
/examples/*.asn1
# /examples/*/
/examples/*/*.c
/examples/*/*.h
/examples/*/*dump
/examples/*/.tmp.*
# /libasn1compiler/
/libasn1compiler/Makefile
/libasn1compiler/check_compiler
# /libasn1fix/
/libasn1fix/Makefile
/libasn1fix/check_fixer
# /libasn1parser/
/libasn1parser/Makefile
/libasn1parser/check_parser
# /libasn1print/
/libasn1print/Makefile
# /skeletons/
/skeletons/Makefile
# /skeletons/standard-modules/
/skeletons/standard-modules/Makefile
# /skeletons/tests/
/skeletons/tests/Makefile
/skeletons/tests/check-*
# /tests/
/tests/Makefile
......@@ -11,8 +11,7 @@ by ASN.1. Not a problem as most specifications use very small values anyway.
NOTE: This statement does not apply to the target code _produced_
by the compiler.
2. ASN Macros are prohibited by the current ASN.1 standard,
and are not supported.
2. A MACRO facility is part of obsolete ASN.1 standard, and is not supported.
3. Multiple tags applied at the same level are not supported:
BadTags ::= [0] EXPLICIT [2] IMPLICIT OtherType
......@@ -27,8 +26,7 @@ length, and encode its substructure member using indefinite length. The BER
decoder is perfectly capable of decoding such sequences.
5. Encoding or decoding of structures with combined length greater than 16MB
is not tested. There are some size determination bugs lurking in the produced
code, which may cause integer overflow in certain edge cases. This restriction
should not cause a problem in the real world, as higher level protocol typically
have similar or tighter restrictions on the supported PDU size.
is not tested.
6. XER codec does not support integer (INTEGER, ENUMERATED) values
outside the signed long range.
/*-
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>
* Copyright (c) 2003, 2004, 2005, 2006, 2007 Lev Walkin <vlm@lionet.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......
???:
* Updated asn1c-usage.pdf.
* Made -fskeletons-copy a default option; removed cmdline option.
* Made -fnative-types a default option; removed cmdline option.
Added -fwide-types for backwards compatibility.
* Add -fline-refs to avoid being unfriendly to version control systems.
0.9.24: 2013-Mar-16
* GeneralizedTime fix for working with time offsets which are not
representable in whole hours. (Severity: low; Security impact: low)
Thanks to IP Fabrics, Inc.
* Added -fincludes-quoted to asn1c to generate #includes in "double"
instead of <angle> quotes.
* PER encoding correctness fix. (Severity: high; Security impact: low)
Reported by Grzegorz Aksamit.
* ENUMERATED extension values check relaxed. Reported by Gabriel Burca.
* Fixed decimal decoding of REAL values in -fnative-types mode
(Severity: medium; Security impact: medium)
* Removed webcgi subproject (introduced in 2004) as useless.
0.9.22: 2008-Nov-19
* Added -pdu=all and -pdu=<type> switches to asn1c.
* Added PER support for most known-multiplier string types:
IA5String, VisibleString, PrintableString, BMPString, UniversalString;
useful types: GeneralizedTime, UTCTime, ObjectDescriptor;
as well as REAL and OBJECT IDENTIFIER.
TODO: SET type.
* Added PER support for extensions in SEQUENCE.
* Multiple enhancements by Daniele Varrazzo <daniele.varrazzo@gmail.com>
* Fixed explicit tagging of an in-lined constructed type.
(Severity: low; Security impact: none).
* Memory leak fixed in SET OF / SEQUENCE OF when wrong encoding
is encountered. (Severity: medium; Security impact: low)
* Fixed extensibility handling of second SEQUENCE production.
(Severity: low; Security impact: none)
* Added DEFAULT handling for known multiplier string.
* Added a sample OMA ULP decoder (./examples/sample.source.ULP).
* Added full-width 32-bit integer encoding support in PER.
* Fixed 1-byte OOB write issue with non-standard and Windows
memory allocators (Severity: low; Security impact: medium).
Reported by Sheng Yu.
0.9.21: 2006-Sep-17
* skeletons/standard-modules directory is now used for standard types.
* Fixed class field access problem (Test case 98)
(Severity: medium; Security impact: none)
* Refactored Information Object Classes parsing.
* Refactored Parameterization support.
* [typedef enum foo {}] foo_e; is now e_foo, see #1287989
* Refactored ValueSetTypeAssignment parsing.
* asn-decoder-template.c renamed into converter-sample.c
* MEGACO (Media Gateway Control Protocol) decoder sample added.
* First release of PER encoder (does not encode SETs yet).
* Added a sample LDAP decoder (./examples/sample.source.LDAP3).
* Added a sample 3GPP RRC decoder (./examples/sample.source.RRC).
* Added a sample MEGACO (H.248.1) decoder (sample.source.MEGACO).
0.9.20: 2006-Mar-06
* SET OF CHOICE, SEQUENCE OF CHOICE and a certain named S/O types
are represented differently in XER. THIS IS AN INCOMPATIBLE CHANGE.
(Test case 70) (Severity: low; Security impact: low)
* asn1c: Removed -ftypes88 command line option.
* Started PER implementation. Somewhat experimental!
0.9.19: 2005-Oct-06
* A proper solution to circular references. No kludge flags
should be necessary anymore to produce reference-free code:
recursive dependencies are resolved automatically.
* Test cases 73 & 92 keep track of various circular references.
* Introduced compiler directives to allow finer control over the
generated code ("--<ASN1C...>--" in comments), (Test case 93).
* New feature for unber(1): -s <skip> bytes.
* Mandatory elements map for SET was not getting generated properly.
(Test case 94) (Severity: high; Security impact: low)
* asn1c: new command line option: -fskeletons-copy.
0.9.18: 2005-Aug-14
* The obsolete X.208 syntax is handled gracefully now (compound types'
member names are invented on the fly). (Test case 87).
* Generating enumeration tables for INTEGER types (Test case 88).
* Generating enumeration tables for BIT STRING types (Test case 89).
* Conditional INTEGER/ENUMERATED representation: long vs. INTEGER_t
type is chosen based on PER visible constraints (Test cases 90, 91).
* Union structures for CHOICE type are not anonymous anymore.
* Made unber(1) program more verbose: effective structure length is
now displayed as L="<n>" at the closing tag. (Test check-xxber.sh).
* Fixed unber(1)'s -1 switch for indefinite encoding length.
* New command line option for unber(1): -m to enable minimalistic mode.
0.9.17: 2005-Aug-07
* Tagging mode is implicitly IMPLICIT if AUTOMATIC TAGS is used, #30.6.
(Test cases 55, 86).
* Started to use extern "C" {} in skeleton headers.
* Introduced -finline-choice command line option to fix
yet another class of circular references.
0.9.16: 2005-July-04
* GeneralizedTime API now supports fractions of seconds.
Thanks to Bent Nicolaisen <BN@JAI.com> for support.
* ASN.1 parser has been tweaked to allow parsing something like
"SEQUENCE----comment----", which is ambiguous for many reasons.
* XER decoder better handles not-yet-defined future extensions.
0.9.15: 2005-July-02
* Compiler now checks 64-bit overflows in constraints range handling
code. No effect on the code produced by the compiler.
* Compiler support for tagged and marked parametrized members.
* Empty tags to element map avoided.
* Compiled code GCC 4.x compatibility.
0.9.14: 2005-Apr-29
* Fixed check-70.-fnative-integers.c test (it was failing
when no test directory was found).
0.9.13: 2005-Apr-24
* Added extra const qualifiers into the support code.
* More RFC variations supported in crfc2asn1.pl.
* Refined string values compatibility. (Test cases 77, 78).
* Support for ContainedSubtype constraints. (Test case 16).
* Parsing support for CONSTRAINED BY. (Test case 79).
* Support for CharsDefn (Quadruple and Tuple, most used in
ASN1-CHARACTER-MODULE) (Test case 80).
* Pretty-printing support for WITH COMPONENT[S]. (Test case 82).
* Streamed OCTET STRING decoding of large values: fixed allocation
problem introduced in 0.9.9. (Severity: high; Security impact: medium)
Reported by Yann Grossel <olrick@users.sourceforge.net>.
* Fixed BASIC-XER encoding of REAL numbers.
0.9.12: 2005-Mar-10
* Fixed a name clash in produced constraint checking code.
* #includes are now in single quotes (to solve a name
clash with system's <time.h> on a Win32 system).
* Small refinement of XML DTD generation (`asn1c -X`).
* Relaxed XER processing rules to skip extra whitespace
in some more places. It also skips XML comments (although
XML comments in XER are prohibited by X.693, #8.2.1).
(Test case 70) (Severity: medium; Security impact: none)
Reported by <Dominique.Nerriec@alcatel.fr>.
* Constraints on primitive types being defined are now supported.
(Test case 74) (Severity: low; Security impact: none)
* XMLValueList generation fixed for CHOICE type.
(Severity: medium; Security impact: none)
* Added the GSM TAP3 decoder into ./examples/sample.source.TAP3
0.9.11: 2005-Mar-04
* Released -fcompound-names to fix the name clashes in the code
produced by the asn1c.
* Released -fno-include-deps to avoid #including non-critical
external dependencies.
* Compiler is taught to produce compilable code for yet another class
of circular ASN.1 type references.
* X.693:8.3.4 prohibits anything but SignedNumber; fixed XER codec.
* Fixed ENUMERATED identifier to value conversion in XER.
Reported by <jacque.celaire@caramail.com>.
* If the compiled file contents are the same as in already existing
file (left from previous compilation), the old file is retained.
This prevents thrashing `make` dependencies if amount of changes in
the original ASN.1 module(s) is small.
0.9.10: 2005-Feb-25
* Completed the XER XMLValueList encoding and decoding.
* Native integer type is now using "long".
* Fixed #1150856. Reported by <vvvy@users.sourceforge.net>.
* Some WIN32 portability fixes.
0.9.9: 2005-Feb-22
* First release of XER (XML) decoding implementation (somewhat
experimental).
* ANY allocation routine fixed.
Reported by <mikko.ahonen@elma.net>.
* Fixed tag parsing (tags like "[ 0 ]" were not supported).
* Compiler now checks for duplicate ASN.1 types across modules.
0.9.8: 2005-Jan-17
* [NEW PLATFORM] Compiled and tested on Linux @ alpha64 (LP64).
Some code needed to be fixed regarding int-long conversions
(mostly inside the test suite), and floating point handling
code needed to be restructured to handle signalling NAN and
other floating point exceptions quietly. Smooth transition!
* [NEW PLATFORM] Compiled and tested on Sun Solaris 9 @ sparc.
Improved includes/defines of/for system headers.
* -X command line option added to asn1c to generate XML DTD.
* Empty SEQUENCE and SET clauses are now allowed.
* Removed confusion between &xNN; and &#xNN; in enber and unber.
* Removed order dependency in DEFAULT references to ENUMERATED
identifiers (./tests/68-*-OK.asn1).
* ber_dec_rval_t renamed into asn_dec_rval_t: more generality.
* Extensions in CHOICE types are properly marked as non-pointers
(Test case 59) (Severity: medium; Security impact: medium)
Reported by <roman.pfender@sdm.de>.
* Tagged CHOICE type is now supported again.
(Test case 59) (Severity: low; Security impact: low)
Reported by <orlinkata@dir.bg>.
* Implemented der_encode_to_buffer() procedure.
0.9.7.1: 2004-Oct-12
* Fixed automatic tagging for extensions of compound types.
* Fixed ParametrizedReference parsing: {} are now recognized.
0.9.7: 2004-Oct-11
* Finished CXER implementation by adding SET and SET OF canonical
ordering support.
* Fixed unber(1) limits controlling logic.
* Removed C99'izm from the x509dump, now understood by older compilers.
* Enhanced UTF8String constraint validation, now it checks
for the minimal encoding length; API of UTF8String_length() changed.
* Fixed SEQUENCE dealing with premature termination of the
optionals-laden indefinite length structure. The code was previously
refusing to parse such structures.
* Fixed explicitly tagged ANY type encoding and decoding
(Severity: medium; Security impact: low).
* Fixed CHOICE code spin when indefinite length structures appear
in the extensions (Severity: medium; Security impact: medium).
Reported by <siden@ul-gsm.ru>.
* BIT STRING now stores the number of unused octets in a separate field.
0.9.6: 2004-Sep-29
* Added several security firewalls: decoder's stack usage control
......@@ -11,11 +245,11 @@
* Added -fno-constraints option to asn1c, which disabled generation of
ASN.1 subtype constraints checking code.
* Added ASN1C_ENVIRONMENT_VERSION and get_asn1c_environment_version().
* Fixed ANY type decoding (Severity: high, Secruity impact: low).
* Fixed ANY type decoding (Severity: high; Security impact: low).
* Fixed BER decoder restartability problem with certain primitive
types (BOOLEAN, INTEGER, and REAL). The problem occured when the
encoding of such type is split between several bytes.
(Severity: high, Security impact: low)
(Severity: high; Security impact: low)
* Support for cross-referencing type definitions (updated ./tests/43-*).
* Fixed pretty-printing of the REAL type. Added lots of test cases.
* Renamed asn1_* into asn_* in function and type names.
......@@ -28,7 +262,7 @@
encoding must be tagged by stripping off the outer tag for each
subsequent containment level. See also X.690: 8.21.5.4 and
the "Spouse" case in A.3.
(Severity: medium, Security impact: low)
(Severity: medium; Security impact: low)
* Added converters between any generic type and the ANY type.
* Parser fixed: Information Object Class fields may be taged.
* Parser fixed: tagged types inside SEQUENCE OF/SET OF support.
......@@ -47,7 +281,7 @@
* Explicit support for ANY type decoding.
* Refactored tags processing code.
* Fixed constraints checking code: non-exploitable buffer overflow.
(Severity: medium, Security impact: low)
(Severity: medium; Security impact: low)
0.9.3: 2004-Sep-07
......@@ -83,7 +317,7 @@
0.8.19: 2004-Aug-18
* Fixed BER encoder (problem encoding large tag values)
(Severity: medium, Security impact: low)
(Severity: medium; Security impact: low)
0.8.18: 2004-Aug-12
......@@ -99,16 +333,16 @@
0.8.16: 2004-Jul-22
* Fixed application-level problem in SET OF/SEQUENCE OF array cleanup.
(Severity: medium, Security impact: low)
(Severity: medium; Security impact: low)
* Improved asn_GT2time() and added asn_time2{GT,UT}() functions.
* BIT STRING pretty-printing.
0.8.15: 2004-Jul-20
* Fixed parser: memory leak in free_struct code for SET OF/SEQUENCE OF.
(Severity: high, Security impact: medium)
(Severity: high; Security impact: medium)
* Fixed parser: invalid memory reference in code constructing tags.
(Test case 48) (Severity: high, Security impact: medium)
(Test case 48) (Severity: high; Security impact: medium)
When encoding data for certain ASN.1 specifications containing
explicit tags, the tag is always written incorrectly due to
incorrect memory reference. The encoding will almost always produce
......@@ -125,13 +359,13 @@
* Fixed compiler: extensibility of CHOICE and SET type has not been
taken into account during table construction.
(Test case 47) (Severity: high, Security impact: low)
(Test case 47) (Severity: high; Security impact: low)
0.8.13: 2004-Jun-29
* Fixed compiler: the skip values for IMPLICIT tagging were broken
in some complex cases where one type is defined using another.
(Test case 46) (Severity: medium, Security impact: low).
(Test case 46) (Severity: medium; Security impact: low).
* Added -fknown-extern-type command line parameter to asn1c.
* Removed -N command line flag and underlying functionality
to honor KISS principle.
......@@ -143,7 +377,7 @@
size of an integer must be provided explicitly.
See {OBJECT_IDENTIFIER|RELATIVE_OID}_{get|set}_arcs().
* SEQUENCE BER decoder fixed again for complex CHOICE case
(Test case 44) (Severity: medium, Security impact: low).
(Test case 44) (Severity: medium; Security impact: low).
0.8.11: 2004-Jun-05
......@@ -168,18 +402,18 @@
* Fixed compiler. If the last member of the SEQUENCE is OPTIONAL
and absent in the encoding, and the type is extensible (...) or
EXTENSIBILITY IMPLIED flag is set, then the structure could not
be correctly decoded. (Severity: high, Security impact: low).
be correctly decoded. (Severity: high; Security impact: low).
* Compiler: fixed recursive ASN.1 types inclusion (Severity: low,
Security impact: none).
* Parser: IMPORTS/FROM fixes, now allowing multiple sections.
* Code compiled and checked on PowerPC (@MacOS X). No major portability
issues experienced.
* NEW PLATFORM: Compiled and tested on MacOS X (@ PowerPC).
No major portability issues experienced.
0.8.7: 2004-Apr-11 T-version-0-8-7
* Fixed SEQUENCE BER decoder: if the last member of the SEQUENCE is
OPTIONAL and absent in the encoding, RC_FAIL was returned instead
of RC_OK (Severity: high, Security impact: low).
of RC_OK (Severity: high; Security impact: low).
* Added test case to check the above problem.
* Added test case to check -fnative-integers mode.
......@@ -189,7 +423,7 @@
0.8.5: 2004-Mar-28 T-version-0-8-5
* Fixed ber_tlv_length() computation problem (Severity: blocker,
* Fixed ber_tlv_length() computation problem (Severity: high,
Security impact: none).
Reported by <vss@high.net.ru>
......@@ -201,9 +435,9 @@
0.8.3: 2004-Mar-14 T-version-0-8-3
* Fixed SET::BER decoder: restart after reaching a buffer boundary
weas broken (Severity: blocker, Security impact: low).
weas broken (Severity: high; Security impact: low).
* Fixed OCTET STRING::BER decoder: restart after reaching a buffer
boundary was broken (Severity: blocker, Security impact: low).
boundary was broken (Severity: high; Security impact: low).
Reported by <vss@high.net.ru>
* Added test cases to check decoders restartability.
* Slightly more general INTEGER2long decoder.
......@@ -280,3 +514,30 @@
0.1: 2003-Nov-28
* Programming started.
=== Bug importance disclosure terms ===
SEVERITY.
This term applies to the frequence the particular construct is used
in the real world. The higher the frequency, the more chances of triggering
this bug.
low: The ASN.1 specifications which could trigger
this kind of bug are not widespread.
medium: The particular ASN.1 construct is used quite often,
so the chance of triggering an error is considerable.
high: This fix is considered urgent, or the particular ASN.1
construct triggering this bug is in wide use.
SECURITY IMPACT.
This term applies to the amount of potential damage a bug exploitation
could cause.
none: No malicious exploitation is possible.
low: The local exploitation is unlikely; the remote exploitation
is impossible.
medium: The remote exploitation is possible when a particular ASN.1
construct is being used. If possible, only hard failure, spin
or memory leak are the possible outcome: no shellcode
injection could possibly be carried by the attack.
high: The remote shellcode injection is possible, or the bug is
otherwise remotely exploitable for most specifications.
Q: Your compiler supplies a der_encode() procedure. How do I encode BER?
A:
1.Q: Is it possible to build the asn1c compiler on Win32?
1.A:
At this point, the asn1c source code is tied to GCC-specific
extensions in several key places. The CYGWIN environment with
gcc compiler may be what are you looking for.
Please also consider using the Online ASN.1 compiler at
http://lionet.info/asn1c
which generates platform-independent code.
2.Q: How to build a simplest BER (XER) encoder or decoder?
2.A:
Please check the "Quick Start Guide" on ./doc/asn1c-quick.pdf
Please check the "Examples" section of ./doc/asn1c-usage.pdf
Also, try the following to build the X.509v3 parser:
cd ./examples/sample.source.PKIX1
make
./x509dump -h
3.Q: Your compiler supplies a der_encode() procedure. How do I encode BER?
3.A:
The DER (and CER) are stricter subsets of a more generic BER encoding
method. If you encode data with DER or CER, all BER-conformant decoders
will easily understand that. Hence, to encode data in the BER format,
......@@ -13,29 +36,6 @@ A:
Distinguished Encoding Rules (DER)"
Q: I've tried doing ./asn1c/asn1c -P examples/*PKIX*93*, but compiler spits
several fatal failures and exits.
A:
The old (RFC2459) PKIX1 specifications used ASN.1 Information Object
Classes, which is arguably one of the most complex ASN.1 concepts.
The asn1c parser and fixer subsystems currently understand most of
IOC syntax, but the compiler can cope with only the very basic
IOC semantics.
The goal of asn1c is to adequately support the practically necessary
subset of IOCs to compile PKIX1 and other real-world specs,
but this milestone isn't yet reached. Please contact me in case
you have special requirements, we can work it out.
However, the asn1c compiler is able to understand the newer PKIX1
ASN.1 specs, contained in RFC3280, which obsole RFC2459.
Try this one out instead:
cd ./examples/sample.source.PKIX1
make
./x509dump -h
--
Lev Walkin
......
......@@ -2,9 +2,13 @@ QUICK START INSTALLATION
========================
./configure # Configure the build infrastructure for your platform
make # Build the libraries and the compiler
make check # Ensure that the code is still behaving well
# after compiling on your platform
# PLEASE CONTACT ME IF THIS FAILS ON YOUR PLATFORM!
make install # Install the compiler into standard location
man asn1c # Display the asn1c manual page
......@@ -14,3 +18,12 @@ QUICK USAGE GUIDE
=================
For usage guide and more information please refer to the README file.
In case of any difficulties with installing the compiler, consider using
the Online ASN.1 Compiler at
http://lionet.info/asn1c
--
Lev Walkin
vlm@lionet.info
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = \
libasn1parser libasn1fix \
libasn1print libasn1compiler \
......
This diff is collapsed.
......@@ -7,7 +7,8 @@ a short installation guide.
For the list of asn1c command line options, see `asn1c -h` or `man asn1c`.
For more complete documentation on this compiler and on using the
results of compilation phase, please look into asn1c-usage.{pdf,html}.
results of compilation phase, please look into asn1c-quick.pdf and
asn1c-usage.{pdf,html}.
If you are building the compiler from the sources, these documents reside
in the ./doc directory, otherwise they lie nearby the README file you're
reading right now.
......@@ -17,8 +18,8 @@ Please also read the FAQ file.
An excellent book on ASN.1 is written by Olivier Dubuisson:
"ASN.1 Communication between heterogeneous systems", ISBN:0-12-6333361-0.
QUICK START
===========
QUICK START (also check out asn1c-quick.pdf)
============================================
After building [and installing] the compiler (see INSTALL), you may use
the asn1c command to compile the ASN.1 specification:
......
MAJOR:
1. MAJOR:
1. Support for PER encoding. Requires advanced subtype constraints support,
which is already completed.
1.1 Support for Information Object Classes.
Status: Support for parsing IOCs is mostly present.
Support for slicing the IOCs to produce "views"
is not yet designed.
2. Support for XER encoding.
2. MEDIUM:
3. Support for Information Object Classes.
Status: support for parsing IOCs is mostly present. Support for slicing
the IOCs to produce "views" is not yet designed.
MINOR:
1. Support for DEFAULT encoding and decoding, at least in INTEGER/ENUMERATED types.
2. Support for EXTERNAL, EMBEDDED-PDV and CHARACTER STRING types.
2.1 Support for EXTERNAL, EMBEDDED-PDV and CHARACTER STRING types.
Requires something from 1.2 (Information Object Classes).
This diff is collapsed.
......@@ -4,7 +4,7 @@
Name: @PACKAGE@
Version: @VERSION@
Release: 1
Release: 2
Copyright: Lev Walkin <vlm@lionet.info>
Source: %{name}-%{version}.tar.gz
Url: http://asn1c.sourceforge.net/
......@@ -15,9 +15,9 @@ Group: Development/Languages
Summary: The ASN.1 to C compiler
%description
The asn1c compiler turns ASN.1 specifications into C language source files.
The source files would contain BER/CER/DER encoders and decoders for the
given abstract notation.
The asn1c compiler turns ASN.1 specifications into C language
source files containing the BER/CER/DER/PER/XER encoders and decoders
for the given abstract notation.
%prep
%setup -q
......@@ -45,6 +45,9 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Sun Sep 18 2006 Lev Walkin <vlm@lionet.info>
- Added PER support into description
* Sun Sep 26 2004 Lev Walkin <vlm@lionet.info>
- All manuals are now getting installed, including new ones: unber.1 and enber.1
......
SUBDIRS = . webcgi tests
SUBDIRS = . tests
AM_CFLAGS = @ADD_CFLAGS@
AM_CPPFLAGS = \
......@@ -18,9 +18,10 @@ asn1c_LDADD = \
bin_PROGRAMS = asn1c unber enber
noinst_HEADERS = sys-common.h
dist_man1_MANS = asn1c.1 unber.1 enber.1
check_SCRIPTS = check-parsing.sh
TESTS = check-parsing.sh
EXTRA_DIST = check-parsing.sh
CLEANFILES = .check-parsing.*.tmp
dist_check_SCRIPTS = check-xxber.sh check-parsing.sh
TESTS = $(dist_check_SCRIPTS)
CLEANFILES = .check-xxber.*.tmp .check-parsing.*.tmp
This diff is collapsed.
asn1c - The ASN.1 Compiler
unber - The ASN.1 BER Decoder
enber - Reverse unber(1) output back into BER
......@@ -3,18 +3,20 @@
asn1c \- ASN.1 Compiler
.SH SYNOPSIS
asn1c [\fB\-E\fR [\fB-F\fR] | \fB\-P\fR | \fB\-R\fR]
[\fB\-S\fR\fIdir\fR]
[\fB\-W\fR\fIdebug-\fR...] [\fB\-f\fR\fIoption\fR...] [\fB\-p\fR\fIrint-\fR...]
[\fB\-S\fR\fIdir\fR] [\fB-X\fR]
[\fB\-W\fR\fIdebug-\fR...] [\fB\-f\fR\fIoption\fR] [\fB\-gen-\fR\fIoption\fR] [\fB\-pdu=\fR{\fBall\fR|\fBauto\fR|\fIType\fR}\fR]
[\fB\-print-\fR\fIoption\fR]
\fIinfile\fR...
.SH DESCRIPTION
asn1c compiles the ASN.1 specifications into the set of
target language (C/C++) encoders and decoders for BER, DER,
and other encoding standards.
asn1c compiles ASN.1 specifications into a set of
target language (C/C++) encoders and decoders for BER, DER, PER, XER
and other encoding rules.
.SH OPTIONS
.TP
\fIOverall Options\fR
\fB\-E \-F \-P \-R\fR
.BI "\-S " directory
\fB\-X
.TP
\fIWarning Options\fR
.br
......@@ -22,7 +24,13 @@ and other encoding standards.
.TP
\fILanguage Options\fR
.br
\fB\-fall-defs-global \-fbless-SIZE \-fnative-types \-fno-constraints \-funnamed-unions \-ftypes88\fR
\fB\-fbless-SIZE \-fcompound-names \-findirect-choice
.BI "\-fknown-extern-type="<name>
\fB\-fno-constraints \-fno-include-deps \-funnamed-unions \-fwide-types
.TP
\fICodecs Generation Options\fR
.br
.B \-gen-PER \-pdu=\fR{\fBall\fR|\fBauto\fR|\fIType\fR}
.TP
\fIOutput Options\fR
.br
......@@ -50,6 +58,9 @@ omitting the usual support code.
.TP
\fB\-S\fR \fIdirectory\fR
Use the specified directory with ASN.1 skeleton files.
.TP
.B \-X
Generate an XML DTD schema for the specified ASN.1 files.
.SH WARNING OPTIONS
.TP
.B \-Werror
......@@ -65,31 +76,53 @@ Enable ASN.1 syntax tree fixer debugging during the fixing stage.
Enable debugging during the actual compile time.
.SH LANGUAGE OPTIONS
.TP
.B \-fall-defs-global
Normally the compiler hides the definitions (asn1_DEF_xxx) of the inner
structure elements (members of SEQUENCE, SET and other types). This option
makes all such definitions global.
Enabling this option may pollute the namespace by making lots of asn1_DEF_xxx
structures globally visible, but will allow you to manipulate
(encode and decode) the individual members of any complex ASN.1 structure.
.TP
.B \-fbless-SIZE
Allow SIZE() constraint for INTEGER, ENUMERATED, and other types for which this
constraint is normally prohibited by the standard. This is a violation of
an ASN.1 standard and compiler may fail to produce the meaningful code.
ASN.1 standard, and the compiler may fail to produce a meaningful code.
.TP
.B \-fnative-types
Use the native machine's data types (int, double) whenever possible,
instead of the compound ASN.1 INTEGER_t, ENUMERATED_t and REAL_t types.
.B \-fcompound-names
Using this option prevents name collisions in the target source code
by using complex names for target language structures. (Name collisions
may occur if the ASN.1 module reuses the same identifiers in multiple
contexts).
.TP
.B \-findirect-choice
When generating code for a CHOICE type, compile the CHOICE members as indirect
pointers instead of declaring them inline. Consider using this option
together with
.B \-fno-include-deps
to prevent circular references.
.TP
.BI "\-fknown-extern-type="<name>
Pretend the specified type is known. The compiler will assume the target
language source files for the given type have been provided manually.
.TP
.B \-fno-constraints
Do not generate ASN.1 subtype constraint checking code. This may make a shorter executable.
.TP
.B \-fno-include-deps
Do not generate courtesy #include lines for non-critical type dependencies.
Helps prevent namespace collisions.
.TP
.B \-funnamed-unions
Enable unnamed unions in the definitions of target language's structures.
.TP
.B \-ftypes88
Use only ASN.1:1988 embedded types.
.B \-fwide-types
Use the unbounded size data types (INTEGER_t, ENUMERATED_t, REAL_t) by default,
instead of the native machine's data types (long, double).
.SH CODECS GENERATION OPTIONS
.TP
.B \-gen-PER
Generate Packed Encoding Rules (PER) support code.
.TP
.B \-pdu=\fR{\fBall\fR|\fBauto\fR|\fIType\fR}
Create a PDU table for specified types, or discover Protocol Data Units
automatically. In case of -pdu=\fBall\fR, all ASN.1 types defined in
all modules will form a PDU table. In case of -pdu=\fBauto\fR, all types
not referenced by any other type will form a PDU table.
If \fIType\fR is an ASN.1 type identifier, it is added to a PDU table.
The last form may be specified multiple times to add any number of PDUs.
.SH OUTPUT OPTIONS
.TP
.B \-print-constraints
......
/*-
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>
* All rights reserved.
* Copyright (c) 2003, 2004, 2005, 2006, 2013
* Lev Walkin <vlm@lionet.info>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -29,15 +29,11 @@
* This is the program that connects the libasn1* libraries together.
* It uses them in turn to parse, fix and then compile or print the ASN.1 tree.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h> /* for stat(2) */
#include <unistd.h>
#include <sysexits.h> /* for EX_USAGE */
#include <assert.h>
#include <errno.h>
#include "sys-common.h"
#undef COPYRIGHT
#define COPYRIGHT \
"Copyright (c) 2003, 2004, 2005, 2006 Lev Walkin <vlm@lionet.info>\n"
#include <asn1parser.h> /* Parse the ASN.1 file and build a tree */
#include <asn1fix.h> /* Fix the ASN.1 tree */
......@@ -46,11 +42,15 @@
#include <asn1c_compat.h> /* Portable basename(3) and dirname(3) */
static void usage(const char *av0); /* Print the Usage screen and exit */
#ifdef _WIN32
#include <io.h>
#include <direct.h>
#else
#include <dirent.h>
#endif
#undef COPYRIGHT
#define COPYRIGHT \
"Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>\n"
static void usage(const char *av0); /* Print the Usage screen and exit */
static int importStandardModules(asn1p_t *asn, const char *skeletons_dir);
int
main(int ac, char **av) {
......@@ -70,7 +70,7 @@ main(int ac, char **av) {
/*
* Process command-line options.
*/
while((ch = getopt(ac, av, "EFf:hLPp:RS:vW:")) != -1)
while((ch = getopt(ac, av, "EFf:g:hLPp:RS:vW:X")) != -1)
switch(ch) {
case 'E':
print_arg__print_out = 1;
......@@ -83,25 +83,49 @@ main(int ac, char **av) {
asn1_compiler_flags |= A1C_ALL_DEFS_GLOBAL;
} else if(strcmp(optarg, "bless-SIZE") == 0) {
asn1_fixer_flags |= A1F_EXTENDED_SizeConstraint;
} else if(strcmp(optarg, "compound-names") == 0) {
asn1_compiler_flags |= A1C_COMPOUND_NAMES;
} else if(strcmp(optarg, "indirect-choice") == 0) {
asn1_compiler_flags |= A1C_INDIRECT_CHOICE;
} else if(strncmp(optarg, "known-extern-type=", 18) == 0) {
char *known_type = optarg + 18;
ret = asn1f_make_known_external_type(known_type);
assert(ret == 0 || errno == EEXIST);
} else if(strcmp(optarg, "native-integers") == 0) {
asn1_compiler_flags |= A1C_USE_NATIVE_TYPES;
} else if(strcmp(optarg, "native-types") == 0) {
asn1_compiler_flags |= A1C_USE_NATIVE_TYPES;
fprintf(stderr, "-f%s: Deprecated option\n", optarg);
asn1_compiler_flags &= ~A1C_USE_WIDE_TYPES;
} else if(strcmp(optarg, "wide-types") == 0) {
asn1_compiler_flags |= A1C_USE_WIDE_TYPES;
} else if(strcmp(optarg, "line-refs") == 0) {
asn1_compiler_flags |= A1C_LINE_REFS;
} else if(strcmp(optarg, "no-constraints") == 0) {
asn1_compiler_flags |= A1C_NO_CONSTRAINTS;
} else if(strcmp(optarg, "no-include-deps") == 0) {
asn1_compiler_flags |= A1C_NO_INCLUDE_DEPS;
} else if(strcmp(optarg, "includes-quoted") == 0) {
asn1_compiler_flags |= A1C_INCLUDES_QUOTED;
} else if(strcmp(optarg, "unnamed-unions") == 0) {
asn1_compiler_flags |= A1C_UNNAMED_UNIONS;
} else if(strcmp(optarg, "types88") == 0) {
asn1_parser_flags |= A1P_TYPES_RESTRICT_TO_1988;
} else if(strcmp(optarg, "skeletons-copy") == 0) {
fprintf(stderr, "-f%s: Deprecated option\n", optarg);
asn1_compiler_flags &= ~A1C_LINK_SKELETONS;
} else if(strcmp(optarg, "link-skeletons") == 0) {
asn1_compiler_flags |= A1C_LINK_SKELETONS;
} else if(strcmp(optarg, "have_native64") == 0) {
asn1_compiler_flags |= A1C_HAVE_NATIVE_64;
} else {
fprintf(stderr, "-f%s: Invalid argument\n", optarg);
exit(EX_USAGE);
}
break;
case 'g':
if(strcmp(optarg, "en-PER") == 0) {
asn1_compiler_flags |= A1C_GEN_PER;
} else {
fprintf(stderr, "-g%s: Invalid argument\n", optarg);
exit(EX_USAGE);
}
break;
case 'h':
usage(av[0]);
case 'P':
......@@ -109,8 +133,25 @@ main(int ac, char **av) {
asn1_compiler_flags &= ~A1C_NO_C99;
break;
case 'p':
if(strcmp(optarg, "rint-constraints") == 0) {
asn1_printer_flags |= APF_DEBUG_CONSTRAINTS;
if(strncmp(optarg, "du=", 3) == 0) {
char *pduname = optarg + 3;
if(strcmp(pduname, "all") == 0) {
asn1_compiler_flags |= A1C_PDU_ALL;
} else if(strcmp(pduname, "auto") == 0) {
asn1_compiler_flags |= A1C_PDU_AUTO;
} else if(pduname[0] >= 'A' && pduname[0] <= 'Z') {
asn1c__add_pdu_type(pduname);
asn1_compiler_flags |= A1C_PDU_TYPE;
} else {
fprintf(stderr, "-pdu=%s"
": expected -pdu={all|auto|Type}\n",
pduname);
exit(EX_USAGE);
}
} else if(strcmp(optarg, "rint-class-matrix") == 0) {
asn1_printer_flags |= APF_PRINT_CLASS_MATRIX;
} else if(strcmp(optarg, "rint-constraints") == 0) {
asn1_printer_flags |= APF_PRINT_CONSTRAINTS;
} else if(strcmp(optarg, "rint-lines") == 0) {
asn1_printer_flags |= APF_LINE_COMMENTS;
} else {
......@@ -146,6 +187,11 @@ main(int ac, char **av) {
exit(EX_USAGE);
}
break;
case 'X':
print_arg__print_out = 1; /* Implicit -E */
print_arg__fix_n_print = 1; /* Implicit -F */
asn1_printer_flags |= APF_PRINT_XML_DTD;
break;
default:
usage(av[0]);
}
......@@ -172,11 +218,46 @@ main(int ac, char **av) {
ac -= optind;
av += optind;
} else {
fprintf(stderr, "%s: No input files specified\n",
a1c_basename(av[0]));
char *bin_name = a1c_basename(av[0]);
fprintf(stderr, "%s: No input files specified. "
"Try '%s -h' for more information\n",
bin_name, bin_name);
exit(1);
}
/*
* Make sure the skeleton directory is out there.
*/
if(skeletons_dir == NULL) {
struct stat sb;
skeletons_dir = DATADIR;
if((av[-optind][0] == '.' || av[-optind][1] == '/')
&& stat(skeletons_dir, &sb)) {
/*
* The default skeletons directory does not exist,
* compute it from my file name:
* ./asn1c/asn1c -> ./skeletons
*/
char *p;
size_t len;
p = a1c_dirname(av[-optind]);
len = strlen(p) + sizeof("/../skeletons");
skeletons_dir = malloc(len);
assert(skeletons_dir);
snprintf(skeletons_dir, len, "%s/../skeletons", p);
if(stat(skeletons_dir, &sb)) {
fprintf(stderr,
"WARNING: skeletons are neither in "
"\"%s\" nor in \"%s\"!\n",
DATADIR, skeletons_dir);
if(warnings_as_errors)
exit(EX_OSFILE);
}
}
}
/*
* Iterate over input files and parse each.
* All syntax trees from all files will be bundled together.
......@@ -197,13 +278,16 @@ main(int ac, char **av) {
asn1p_module_t *mod;
while((mod = TQ_REMOVE(&(new_asn->modules), mod_next)))
TQ_ADD(&(asn->modules), mod, mod_next);
asn1p_free(new_asn);
asn1p_delete(new_asn);
} else {
asn = new_asn;
}
}
/* These are mostly notes for the human readers */
assert(asn);
assert(skeletons_dir);
/*
* Dump the parsed ASN.1 tree if -E specified and -F is NOT given.
*/
......@@ -213,6 +297,13 @@ main(int ac, char **av) {
return 0;
}
/*
* Read in the files from skeletons/standard-modules
*/
if(importStandardModules(asn, skeletons_dir)) {
if(warnings_as_errors)
exit(EX_DATAERR);
}
/*
* Process the ASN.1 specification: perform semantic checks,
......@@ -241,46 +332,110 @@ main(int ac, char **av) {
}
/*
* Make sure the skeleton directory is out there.
* Compile the ASN.1 tree into a set of source files
* of another language.
*/
if(skeletons_dir == NULL) {
struct stat sb;
skeletons_dir = DATADIR;
if((av[-optind][0] == '.' || av[-optind][1] == '/')
&& stat(skeletons_dir, &sb)) {
/*
* The default skeletons directory does not exist,
* compute it from my file name:
* ./asn1c/asn1c -> ./skeletons
*/
char *p;
int len;
if(asn1_compile(asn, skeletons_dir, asn1_compiler_flags,
ac + optind, optind - 1, av - optind)) {
exit(EX_SOFTWARE);
}
p = a1c_dirname(av[-optind]);
return 0;
}
len = strlen(p) + sizeof("/../skeletons");
skeletons_dir = alloca(len);
snprintf(skeletons_dir, len, "%s/../skeletons", p);
if(stat(skeletons_dir, &sb)) {
fprintf(stderr,
"WARNING: skeletons are neither in "
"\"%s\" nor in \"%s\"!\n",
DATADIR, skeletons_dir);
if(warnings_as_errors)
exit(EX_SOFTWARE);
}
}
}
/*
* Parse and import *.asn1 from skeletons/standard-modules
*/
static int
importStandardModules(asn1p_t *asn, const char *skeletons_dir) {
asn1p_t *new_asn;
asn1p_module_t *mod;
const char *filename;
char *fullname;
char *target_dir;
int target_dir_len;
int len;
#ifdef _WIN32
intptr_t dir;
struct _finddata_t c_file;
char *pattern;
#else
struct dirent *dp;
DIR *dir;
#endif
int ret = 0;
/* Notes for the human reader */
assert(asn);
assert(skeletons_dir);
/*
* Compile the ASN.1 tree into a set of source files
* of another language.
* Figure out the standard-modules directory.
*/
if(asn1_compile(asn, skeletons_dir, asn1_compiler_flags)) {
exit(EX_SOFTWARE);
target_dir_len = strlen(skeletons_dir)
+ sizeof("/standard-modules") - 1;
target_dir = malloc(target_dir_len + 1);
assert(target_dir);
snprintf(target_dir, target_dir_len + 1, "%s/standard-modules",
skeletons_dir);
#ifdef _WIN32
len = target_dir_len + sizeof("/*.asn1");
pattern = malloc(len);
assert(pattern);
snprintf(pattern, len, "%s/*.asn1", target_dir);
dir = _findfirst(pattern, &c_file);
if(dir == -1L) {
#else
dir = opendir(target_dir);
if(!dir) {
#endif
fprintf(stderr,
"WARNING: Cannot find standard modules in %s\n",
target_dir);
return -1;
}
return 0;
#ifdef _WIN32
do {
filename = c_file.name;
#else
while((dp = readdir(dir))) {
filename = dp->d_name;
#endif
len = strlen(filename);
if(len <= 5 || strcmp(filename + len - 5, ".asn1"))
continue;
len = target_dir_len + 1 + len + 1;
fullname = malloc(len);
if(!fullname) continue; /* Just skip it, no big deal */
snprintf(fullname, len, "%s/%s", target_dir, filename);
filename = fullname;
new_asn = asn1p_parse_file(filename, A1P_NOFLAGS);
if(new_asn == NULL) {
fprintf(stderr, "WARNING: Cannot parse standard module \"%s\"\n", filename);
ret = -1;
continue;
}
/* Import these modules and mark them as "standard" */
while((mod = TQ_REMOVE(&(new_asn->modules), mod_next))) {
mod->_tags |= MT_STANDARD_MODULE;
TQ_ADD(&(asn->modules), mod, mod_next);
}
asn1p_delete(new_asn);
#ifdef _WIN32
} while(_findnext(dir, &c_file) == 0);
_findclose(dir);
#else
free(fullname);
} /* while(readdir()) */
closedir(dir);
#endif
return ret;
}
/*
......@@ -299,6 +454,7 @@ usage(const char *av0) {
" -R Restrict output (tables only, no support code)\n"
" -S <dir> Directory with support (skeleton?) files\n"
" (Default is \"%s\")\n"
" -X Generate and print the XML DTD\n"
"\n"
" -Werror Treat warnings as errors; abort if any warning\n"
......@@ -307,15 +463,24 @@ usage(const char *av0) {
" -Wdebug-compiler --//-- compiler\n"
"\n"
" -fall-defs-global Don't make the asn1_DEF_'s of structure members \"static\"\n"
" -fbless-SIZE Allow SIZE() constraint for INTEGER etc (non-std.)\n"
" -fknown-extern-type=<name> Pretend this type is known\n"
" -fnative-types Use \"int\" instead of INTEGER_t whenever possible\n"
" -fcompound-names Disambiguate C's struct NAME's inside top-level types\n"
" -findirect-choice Compile members of CHOICE as indirect pointers\n"
" -fincludes-quoted Generate #includes in \"double\" instead of <angle> quotes\n"
" -fknown-extern-type=<name> Pretend the specified type is known\n"
" -fline-refs Include ASN.1 module's line numbers in comments\n"
" -fno-constraints Do not generate constraint checking code\n"
" -fno-include-deps Do not generate courtesy #includes for dependencies\n"
" -funnamed-unions Enable unnamed unions in structures\n"
" -ftypes88 Use only ASN.1:1988 embedded types\n"
" -fwide-types Use INTEGER_t instead of \"long\" by default, etc.\n"
" -fhave_native64 Use int64_t/uint64_t for target platform\n"
"\n"
" -gen-PER Generate PER support code\n"
" -pdu={all|auto|Type} Generate PDU table (discover PDUs automatically)\n"
"\n"
" -print-class-matrix Print out the collected object class matrix (debug)\n"
" -print-constraints Explain subtype constraints (debug)\n"
" -print-lines Generate \"-- #line\" comments in -E output\n"
......
......@@ -2,15 +2,19 @@
tmpfile=".check-parsing.$$.tmp"
# Test diff(1) capabilities
diff -a . . 2>/dev/null && diffArgs="-a" # Assume text files
diff -u . . 2>/dev/null && diffArgs="$diffArgs -u" # Unified diff output
ec=0
for ref in ../tests/*.asn1.-*; do
src=`echo "$ref" | sed -e 's/\.-[-a-zA-Z0-9=]*$//'`
flags=`echo "$ref" | sed -e 's/.*\.-//'`
echo "Checking $src against $ref"
./asn1c "-$flags" "$src" > "$tmpfile" || ec=$?
./asn1c -S../skeletons "-$flags" "$src" > "$tmpfile" || ec=$?
if [ $? = 0 ]; then
diff -a -u "$ref" "$tmpfile" || ec=$?
diff $diffArgs "$ref" "$tmpfile" || ec=$?
fi
if [ "$1" != "regenerate" ]; then
rm -f "$tmpfile"
......
#!/bin/sh
ORIG="./.check-xxber.orig.$$.tmp"
TEST="./.check-xxber.test.$$.tmp"
# Test diff(1) capabilities
diff -a . . 2>/dev/null && diffArgs="-a" # Assume text files
diff -u . . 2>/dev/null && diffArgs="$diffArgs -u" # Unified diff output
cat<<EOM > $ORIG
<I O="0" T="[UNIVERSAL 16]" TL="2" V="Indefinite" A="SEQUENCE">
<P O="2" T="[UNIVERSAL 19]" TL="2" V="2" A="PrintableString">&#x55;&#x53;</P>
<C O="6" T="[UNIVERSAL 16]" TL="2" V="22" A="SEQUENCE">
<P O="8" T="[UNIVERSAL 2]" TL="2" V="4" A="INTEGER">&#x31;&#xa6;&#x20;&#x47;</P>
<C O="14" T="[UNIVERSAL 16]" TL="2" V="6" A="SEQUENCE">
<P O="16" T="[UNIVERSAL 2]" TL="2" V="4" A="INTEGER">&#x31;&#xa6;&#x20;&#x47;</P>
</C O="22" T="[UNIVERSAL 16]" A="SEQUENCE" L="8">
<C O="22" T="[UNIVERSAL 16]" TL="2" V="6" A="SEQUENCE">
<P O="24" T="[UNIVERSAL 2]" TL="2" V="4" A="INTEGER">&#x31;&#xa6;&#x20;&#x47;</P>
</C O="30" T="[UNIVERSAL 16]" A="SEQUENCE" L="8">
</C O="30" T="[UNIVERSAL 16]" A="SEQUENCE" L="24">
<I O="30" T="[UNIVERSAL 16]" TL="2" V="Indefinite" A="SEQUENCE">
</I O="32" T="[UNIVERSAL 0]" TL="2" L="4">
EOM
./enber $ORIG | ./unber -p -i 0 - > $TEST 2>&1
diff $diffArgs $ORIG $TEST >/dev/null 2>&1
diffExitCode=$?
if [ "$diffExitCode" = "0" ]; then
echo "FAILED: $0: expected failure, got success"
exit 42;
fi
# Append necessary terminator
echo '</I O="34" T="[UNIVERSAL 0]" TL="2" L="36">' >> $ORIG
# Try trancoding again
./enber $ORIG | ./unber -p -i 0 - > $TEST 2>&1
diff $diffArgs $ORIG $TEST
diffExitCode=$?
rm -f $ORIG $TEST
exit $diffExitCode