Coder Social home page Coder Social logo

asn1_der's Introduction

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:

#[derive(Asn1Der)] // Now our struct supports all DER-conversion-traits
struct Address {
	street: String,
	house_number: u128,
	postal_code: u128,
	state: String,
	country: String
}

#[derive(Asn1Der)]
struct Customer {
	name: String,
	e_mail_address: String,
	postal_address: Address
}

// Serialization:
let mut serialized = vec![0u8; my_customer.serialized_len()];
my_customer.serialize(serialized.iter_mut()).unwrap();

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

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.

  • The library is now separated into two modules:

    • The der module which contains the generic DER implementation which is more stringent than the previous version and uses iterators instead of slices to avoid unexpected panics
    • The types module which defines the FromDerObject and IntoDerObject traits and already implements them for some native types
  • The tests are also separated into multiple files that map to the modules

  • The asn1_der_impl!-macro was replaced with a procedural derive macro in the asn1_der_derive-subcrate

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:

  • Create a C-interface to make this library usable from C-FFI-compatible languages

asn1_der's People

Contributors

kizzycode avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.