This is a Rust library for parsing and generating ASN.1 data (DER only).
Add asn1 to your Cargo.toml:
$ cargo add asn1Builds on Rust 1.74.0 and newer.
rust-asn1 is compatible with #![no_std] environments:
$ cargo add asn1 --no-default-featuresWriternow exposeswrite_explicit_elementandwrite_implicit_elementmethods that allow encoding EXPLICIT/IMPLICIT elements when the tag number is not known at compile time.
- Added
Asn1Writable::encoded_length,SimpleAsn1Writable::data_length, andAsn1DefinedByWritable::encoded_length. Implementing these functions reduces the number of re-allocations required when writing.Nonecan be returned if it is not possible to provide an efficient implementation.
- Updated MSRV to 1.74.0.
BitString::newis nowconst fn.
BigInt::new,BigUint::new, andDateTime::neware nowconst fn.
Parsernow exposes apeek_tagmethod that returns the tag of the next element in the parse, without consuming that element. (#532)Parsernow exposesread_explicit_elementandread_implicit_elementmethods that allow parsing EXPLICIT/IMPLICIT elements when the tag number is not known at compile time.PrintableString,Utf8String,BMPString, andUniversalStringnow#[derive(Hash)]. (#536)
- Updated MSRV to 1.65.0.
- Fixed "perfect derives"
in conjunction with
#[derive(Asn1DefinedByRead)]and#[derive(Asn1DefinedByWrite)]. (#506)
- Removed
Writer::{write_explicit_element, write_optional_explicit_element, write_implicit_element, write_optional_implicit_element}. These can all be better accomplished with theasn1::Explicitandasn1::Implicittypes.
- Fixed "perfect derives"
in conjunction with
#[implicit]and#[explicit]. (#502)
-
GeneralizedTimehas been renamed toX509GeneralizedTime. The type does not allow fractional seconds, however this restriction is not actually a DER rule, it is specific to X.509. (#494) -
GeneralizedTimeis a new type that accepts fractional seconds replacing the oldGeneralizedTime. (#492) -
#[derive(asn1::Asn1Read)]and#[derive(asn1::Asn1Write)]now implement "perfect derives". (#496)