asnfuzzgen is an ASN.1 compiler capable of producing structure-aware fuzzing modules for arbitrary ASN.1 specifications. It currently supports Packed Encoding Rules (PER), and it generates a Rust module that can be exported into a linked C-ABI library for cross-compatibility with other languages.
This project is divided into three crates, described below.
-
asnfuzzgen
: This crate provides the actual ASN.1 Compiler. Typically a utility (asnfuzzgen
) will generate Rust structures starting with ASN.1 Specifications. Basic working features required to work with the 3GPP specifications is provided by the compiler, this includes Parameterized Types, Information Object Classes and Type Constraints. -
asnfuzzgen-codecs
: Support for different encodings supported by individual ASN.1 specifications is provided in this crate. As of the current release, APER/UPER Codecs are supported. Every Codec is supported as atrait
implementing respective 'encode' and 'decode' functions. Support for different 'encoding rules' will be implemented in this crate and then the derive macros will utilize this code to actually generate the encoding support for Rust Structures generated by the compiler above. -
asnfuzzgen-codecs-derive
: This crate provides thederive
macros for the codecs inasn-codecs
. The code generated usingasnfuzzgen
can be directed toderive
appropriate codecs by passing the flags during compilation.
This project makes use of source code from the Hampi Rust ASN.1 Toolkit, which is likewise licensed under the MIT License. Special thanks goes to Abhijit Gadgil for authoring the Rust ASN.1 Toolkit that has contributed significantly to this project.
- APER
- UPER
Typically the compiler can be invoked also using build.rs
mechanism. An example build.rs
is provided in the examples/
sub project. And the code generated through this build.rs
can be integrated into your project. Examples of that is provided in examples/tests/
directory.
A tool asnfuzzgen
can be installed using cargo install asnfuzzgen
and then following the CLI usage.
cargo install asnfuzzgen
asnfuzzgen --help
- Test cases can be run through
cargo test
.
Currently there are two ways of generating the 'ASN.1' spec files from the '.docx' specifications (This mainly applies to 3GPP specifications).
- Using the script inside
examples/specs/parse_specs.py
. This is recommended way. (note: this requires installation ofdocx
orpython-docx
in the case of Python3). - Using the rust binary
extract-asn-spec
. Note: this is not the recommended way and your mileage may vary. Eventual goal is to make this the default way - so as to also have abuild.rs
integration. But this is for now a work in progress. This is not available by default and is enabled only with a feature flagrs-specs-gen
.
The source code of this project is licensed under the MIT License.