Crates.io | asnfuzzgen-codecs-derive |
lib.rs | asnfuzzgen-codecs-derive |
version | 0.1.3 |
source | src |
created_at | 2024-07-03 15:36:46.359202 |
updated_at | 2024-07-05 12:11:33.364105 |
description | ASN.1 Codecs derive macros |
homepage | |
repository | https://github.com/nathaniel-bennett/asnfuzzgen |
max_upload_size | |
id | 1290626 |
size | 68,761 |
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 a trait
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 the derive
macros for the codecs in asn-codecs
. The code generated using asnfuzzgen
can be directed to derive
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.
build.rs
SupportTypically 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
cargo test
.Currently there are two ways of generating the 'ASN.1' spec files from the '.docx' specifications (This mainly applies to 3GPP specifications).
examples/specs/parse_specs.py
. This is recommended way. (note: this requires installation of docx
or python-docx
in the case of Python3).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 a build.rs
integration. But this is for now a work in progress. This is not available by default and is enabled only with a feature flag rs-specs-gen
.The source code of this project is licensed under the MIT License.