Crate facet_asn1_legacy

Crate facet_asn1_legacy 

Source
Expand description

§facet-asn1-legacy

Coverage Status crates.io documentation MIT/Apache-2.0 licensed Discord

§facet-asn1

A #![no_std] ASN.1 serializer and deserializer based on facet

Currently supports Distinguished Encoding Rules (DER) only

§Basic Types

ASN.1 TypeRust
BOOLEANbool
INTEGERi8, i16, i32, or i64
OCTET STRINGVec<u8>
NULLAny unit struct
REALf32 or f64
UTF8StringString
CHOICEenum
SEQUENCEstruct

§Other ASN.1 Types

Newtype structs using the facet::Shape::type_tag property can be used to create other basic types without any content validation:

use facet::Facet;

#[derive(Debug, Clone, Facet, PartialEq, Eq)]
#[facet(type_tag = "IA5String", transparent)]
struct IA5String(String);

§Context Specific Type Tags

You can also set context specific BER/DER tags to a given number. Implicit tags must be set as transparent.

use facet::Facet;

// ImplicitString ::= [5] IMPLICIT UTF8String
#[derive(Debug, Facet, PartialEq, Eq)]
#[facet(type_tag = "5", transparent)]
struct ImplicitString(String);

// ExplciitString ::= [5] EXPLICIT UTF8String
#[derive(Debug, Facet, PartialEq, Eq)]
#[facet(type_tag = "5")]
struct ExplicitString(String);

The tag classes UNIVERSAL, APPLICATION, and PRIVATE are also supported in type_tags for greater flexibility.

§Sponsors

Thanks to all individual sponsors:

GitHub Sponsors Patreon

…along with corporate sponsors:

AWS Zed Depot

…without whom this work could not exist.

§Special thanks

The facet logo was drawn by Misiasart.

§License

Licensed under either of:

at your option.

Enums§

Asn1DeserError
Errors when deserializing from ASN.1 BER or DER bytes
Asn1SerError
Errors when serializing to an ASN.1 format

Traits§

Asn1Write
no_std compatible Write trait used by the ASN.1 serializer.

Functions§

deserialize_der
Deserialize a slice of ASN.1 DER bytes into a Facet type
deserialize_der_wip
Deserialize an ASN.1 DER slice given some some Partial into a HeapValue
to_vec_der
Serialize a Facet type to ASN.1 DER bytes