Skip to content
A Rust ASN.1 (DER) serializer.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Redo the API, starting with the parser (#54) Sep 2, 2019
src Write module level documentation. Sep 2, 2019
.gitignore initial commit, does ints and bools Jul 18, 2015
Cargo.toml Redo the API, starting with the parser (#54) Sep 2, 2019
LICENSE Added more crap to Cargo.toml and a license Jul 20, 2015
README.rst Updates to the readme Sep 2, 2019



This is a Rust library for parsing ASN.1 data (DER only).


Add asn1 to the [dependencies] section of your Cargo.toml:

asn1 = "0.3"

A recent Rust nightly is currently required for const generics.


To parse a structure like:

Signature ::= SEQUENCE {
    r INTEGER,

you would write:

let result = asn1::parse(data, |d| {
    return d.read_element::<asn1::Sequence>()?.parse(|d| {
        let r = d.read_element::<IntegerType>()?;
        let s = d.read_element::<IntegerType>()?;
        return Ok((r, s));

match result {
    Ok((r, s)) => println("r={}, s={}", r, s),
    Err(e) => println!("Error! {:?}", e),
You can’t perform that action at this time.