Crates.io | eagre-asn1 |
lib.rs | eagre-asn1 |
version | 0.3.0 |
source | src |
created_at | 2016-06-16 15:59:41.391979 |
updated_at | 2018-05-18 19:39:34.66441 |
description | A asn1 library, currently only supporting DER |
homepage | https://github.com/Rahix/eagre-asn1 |
repository | https://github.com/Rahix/eagre-asn1 |
max_upload_size | |
id | 5392 |
size | 56,155 |
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 can be found at https://rahix.github.io/eagre-asn1/
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);
types::Any
types::BitString
types::BMPString
bool
types::CharacterString
enum
types::Date
types::DateTime
std::time::Duration
types::EmbeddedPDV
enum
types::GeneralString
types::GraphicString
types::IA5String
i32
types::Null
types::NumericString
Vec<u8>
types::PrintableString
f32
struct
Vec<T>
struct
types::SetOf
types::T61String
types::Time
types::TimeOfDay
types::UniversalString
String
or &str
types::VideotexString
types::VisibleString
eagre-asn1 is licensed under either of
at your option.