#asn1-der #asn-1 #der #serialization

eagre-asn1

A asn1 library, currently only supporting DER

3 releases (breaking)

Uses old Rust 2015

0.3.0 May 18, 2018
0.2.0 Aug 18, 2016
0.1.0 Jun 16, 2016

#11 in #asn1-der

Download history 17/week @ 2023-12-18 39/week @ 2024-01-01 26/week @ 2024-01-22 8/week @ 2024-01-29 13/week @ 2024-02-05 61/week @ 2024-02-12 92/week @ 2024-02-19 26/week @ 2024-02-26 21/week @ 2024-03-04 9/week @ 2024-03-11 77/week @ 2024-03-25

109 downloads per month

MIT/Apache

51KB
1K SLoC

Build Status eagre-asn1

eagre-asn1 is an asn1 library for Rust.

It makes heavy use of macros to make the interface easy to use.

Currently only DER and a very small bit of xer is supported.

Documentation

Documentation can be found at https://rahix.github.io/eagre-asn1/

Example

Say you have the following asn1 structure:

User ::= SEQUENCE {
	username         UTF8String,
	passwordHash     [CONTEXT 12] IMPLICIT OctetString,
	age              [APPLICATION 1] EXPLICIT Integer,
	admin            Boolean
}

In Rust it would look like this:

struct User {
	pub username: String,
	pub password_hash: Vec<u8>,
	pub age: i32,
	pub admin: bool,
}

der_sequence!{
	User:
		username:      NOTAG                       TYPE String,
		password_hash: IMPLICIT TAG CONTEXT 12;    TYPE Vec<u8>,
		age:           EXPLICIT TAG APPLICATION 1; TYPE i32,
		admin:         NOTAG                       TYPE bool,
}

And serializing is as easy as:

use eagre_asn1::der::DER;

let some_user = User { ... };
let encoded = some_user.der_bytes().unwrap();
// Send to far away planet
let decoded = User::der_from_bytes(encoded).unwrap();
assert_eq!(some_user, decoded);

Implemented Types

  • Any types::Any
  • BitString types::BitString
  • BMPString types::BMPString
  • Boolean bool
  • CharacterString types::CharacterString
  • Choice enum
  • Date types::Date
  • DateTime types::DateTime
  • Duration std::time::Duration
  • EmbeddedPDV types::EmbeddedPDV
  • Enumeration enum
  • External
  • GeneralString types::GeneralString
  • GraphicString types::GraphicString
  • IA5String types::IA5String
  • InstanceOf
  • Integer i32
  • IRI
  • Null types::Null
  • NumericString types::NumericString
  • ObjectClassField
  • ObjectIdentifier
  • OctetString Vec<u8>
  • PrintableString types::PrintableString
  • Real f32
  • RelativeIRI
  • RelativeOID
  • Sequence struct
  • Sequence Of Vec<T>
  • Set struct
  • Set Of types::SetOf
  • T61String types::T61String
  • Time types::Time
  • TimeOfDay types::TimeOfDay
  • UniversalString types::UniversalString
  • UTF8String String or &str
  • VideotexString types::VideotexString
  • VisibleString types::VisibleString

License

eagre-asn1 is licensed under either of

at your option.

Dependencies

~165KB