asn1_der
Welcome to my asn1_der
-library 🎉
What this library is:
This library helps you to DER-en-/-decode various types. It provides some traits to convert between encoded data,
DER-objects and native types as well as some trait-implementations for common types. There is also a macro
(asn1_der_impl!
) that helps you to implement the traits for your 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-typebool
: The ASN.1-BOOLEAN-typeVec<u8>
: The ASN.1-OctetString-typeString
: The ASN.1-UTF8String-typeu64
: The ASN.1-INTEGER-type (within0..u64::MAX
)Vec<DerObject>
: The ASN.1-SEQUENCE-typeVec<T>
: The ASN.1-SEQUENCE-type for sequences that contain only one typeT
(e.g.Vec<String>
for a sequence that contains only UTF8Strings)- Experimental: Each map-type with strings as key and any supported type as value. This is feature-gated with "map". For implementation- and format-details (DER has no standardized support for maps), take a look at the module documentation.
The macro asn1_der_impl!
helps you to "derive" the trait-implementations for your own structs; e.g.:
asn1_der_impl!; // Now our struct supports all DER-conversion-traits
asn1_der_impl!; // Now this struct supports all DER-conversion-traits too! It's only necessary that all fields implement these traits
// Serialization:
let encoded = my_customer.into_der_encoded; // This returns a vector containing the DER-encoded representation of this customer (a sequence containing the struct's fields)
// Parsing:
let my_customer = from_der_encoded.unwrap; // This returns our customer (if the data is valid)
Dependencies
Only my etrace
-crate
Build Documentation and Library:
To build and open the documentation, go into the project's root-directory and run cargo doc --release --open
To build this library, change into the projects root-directory and run cargo build --release
; you can find the build
in target/release
.
Long-Term Goals:
- Create a C-interface to make this library usable from C-FFI-compatible languages