License License Travis CI AppVeyor CI

asn1_der

Welcome to my asn1_der-crate 🎉

What this crate is:

This crate helps you to DER-(de-)serialize various types. It provides some traits to convert between encoded data, DER-objects and native types as well and implements them for some common types. If you build it with the derive-feature (enabled by default), you can use #[derive(Asn1Der)] to derive the traits for your named structs.

The following types have built-in support: - DerObject: A generic DER-object-wrapper that can hold any object (DerObject{ tag: u8, payload: Vec<u8> }) - (): The ASN.1-NULL-type - bool: The ASN.1-BOOLEAN-type - Vec<u8>: The ASN.1-OctetString-type - String: The ASN.1-UTF8String-type - u128: The ASN.1-INTEGER-type (within [0, 2^128)) - Vec<T>: The ASN.1-SEQUENCE-type for any type T that implements FromDerObject and IntoDerObject

With the derive-feature you can automatically derive FromDerObject and IntoDerObject: ```rust

[derive(Asn1Der)] // Now our struct supports all DER-conversion-traits

struct Address { street: String, housenumber: u128, postalcode: u128, state: String, country: String }

[derive(Asn1Der)]

struct Customer { name: String, emailaddress: String, postal_address: Address }

// Serialization: let mut serialized = vec![0u8; mycustomer.serializedlen()]; mycustomer.serialize(serialized.itermut()).unwrap();

// Deserialization: let my_customer = Customer::deserialize(serialized.iter()).unwrap(); // This returns our customer (if the data is valid) ```

Changes from 0.5.10 to 0.6.0

From 0.5.10 to 0.6.0 the library was nearly completely rewritten with a much more modular approach.

If you are looking for the old version, you can find it here – however please note that the old version is deprecated and may contain some serious issues.

Dependencies

This depends on your selected features. If you use the derive-feature (enabled by default), the crate depends on the quote and syn crates which are used in the procedural macro implementation.

If you don't use the derive-feature, this crate is dependency-less.

Long-Term Goals: