A language for generating BER decoders. Simpler than a full ASN.1 compiler — it only deals with BER-encoded messages — and aimed at smartcard and RFID applications, where most on-device data is BER-encoded TLV. The template syntax deliberately tracks the format specifications actually use.
Example
The autober definition for the EF.DG2 file on ICAO-9303 machine-readable travel documents ("ePassports"):
/* Biometric data from EF.DG2 file in ICAO9303 compliant e-passport */
0x7f61 bio_group 'Biometric Information Group Template' {
0x2 uint8_t num_instances;
0x7f60 bio_inf[] 'Biometric \'Information\' Template' {
0xa1 bio_hdr 'Biometric Header Template' {
0x80 uint16_t vers;
0x81 OPTIONAL octet[1-3] type;
0x82 OPTIONAL uint8_t subtype;
0x83 OPTIONAL octet[7] date;
0x85 OPTIONAL octet[8] validity;
0x86 OPTIONAL octet[2] creator_pid;
0x87 octet[2] format_owner;
0x88 octet[2] format_type;
}
union bdb 'Biometric Data Block' {
0x5f2e blob bdb_nc;
0x7f2e NOCONSTRUCT blob bdb_c;
}
}
}
20 lines that map almost exactly onto the documentation's own diagram of the structure. The equivalent hand-written C runs several hundred lines — and had errors that only surfaced while building this tool. Generated source and header for this example.
Planned features
- Include statements
- Better error reporting during lexical and syntax analysis
- A CONSTRUCT keyword to force template construction on tags without the constructed bits set (useful for BER-encoded blobs like certificates, tagged application-specific non-constructed)
- Allow OPTIONAL to work on templates and maybe unions
- Allow the top-level template to be a union, and permit multiple top-level items
- A target that generates pure Python code
- A target that generates a Python module matching the C target's output
Downloads
GNU GPL v3.
autober-0.1.tar.gz
autober-0.0.tar.gz
Follow development:
git clone git://github.com/giannitedesco/autober.git
License
GNU GPL v3.