Skip to content
A Rust ASN.1 (DER) serializer.
Rust
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
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
.travis.yml
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

README.rst

rust-asn1

https://travis-ci.org/alex/rust-asn1.svg?branch=master

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

Installation

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

[dependencies]
asn1 = "0.3"

A recent Rust nightly is currently required for const generics.

Usage

To parse a structure like:

Signature ::= SEQUENCE {
    r INTEGER,
    s 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.