GitXplorerGitXplorer
q

yasna.rs

public
47 stars
31 forks
6 issues

Commits

List of commits on branch master.
Verified
bf5afbe1ebc7bd2ac1a90483ccec8965f83620fa

Merge pull request #73 from alexanderkjall/fix-test-failure-on-32-bit

eest31 committed 2 years ago
Verified
c9205e8a61ce6b0763a57826c8a9105a3c11782d

document the different behavior between 64 and 32 bit platforms

aalexanderkjall committed 2 years ago
Verified
5568e7998c492af34bb60d28632daf9a1fc15690

Merge pull request #70 from est31/release_0_5_2

eest31 committed 2 years ago
Unverified
b7e65f9a4c317494cce2d18ea02b3d6eaaea7985

Release 0.5.2

eest31 committed 2 years ago
Unverified
6a3307f68083703a4ee3b6aa3d228a005e62ed1c

Changelog for 0.5.2

eest31 committed 2 years ago
Verified
f2d48e6a13a4180ba6ca177956c29245670f785b

Merge pull request #69 from est31/bigint_bytes_zero_trim

eest31 committed 2 years ago

README

The README file for this repository.

yasna.rs: ASN.1 library for Rust

Build Status

This is a Rust library for reading and writing ASN.1 data.

Since this library is at an early stage, the APIs are subject to change. However, BERReader and DERWriter functionalities are getting stable.

Serialization/Construction

Serialization in DER (Distinguished Encoding Rules) is supported. It can also be used for serialization in BER (Basic Encoding Rules).

fn main() {
    let der = yasna::construct_der(|writer| {
        writer.write_sequence(|writer| {
            writer.next().write_i64(10);
            writer.next().write_bool(true);
            return Ok(());
        })
    });
    println!("(10, true) = {:?}", der);
}

Currently, these datatypes are supported:

  • BOOLEAN, INTEGER, BITSTRING, OCTETSTRING, NULL, OBJECT IDENTIFIER,
  • SEQUENCE, SEQUENCE OF, SET, SET OF, CHOICE,
  • UTF8String, NumericString, PrintableString, VisibleString, IA5String, BMPString,
  • UTCTime, GeneralizedTime,
  • Explicitly/Implicitly tagged types,
  • DEFAULT/OPTIONAL in SEQUENCE/SET.

These datatypes are not supported:

  • REAL
  • TeletexString, VideotexString, GraphicString, GeneralString, UniversalString,
  • TIME, DATE, TIME-OF-DAY, DATE-TIME, DURATION.

Deserialization/Parsing

Deserialization in BER (Basic Encoding Rules) or DER (Distinguished Encoding Rules) is supported.

fn main() {
    let asn = yasna::parse_der(&[48, 6, 2, 1, 10, 1, 1, 255], |reader| {
        reader.read_sequence(|reader| {
            let i = reader.next().read_i64()?;
            let b = reader.next().read_bool()?;
            return Ok((i, b));
        })
    }).unwrap();
    println!("{:?} = [48, 6, 2, 1, 10, 1, 1, 255]", asn);
}

Currently, these datatypes are supported:

  • BOOLEAN, INTEGER, BITSTRING, OCTETSTRING, NULL, OBJECT IDENTIFIER,
  • SEQUENCE, SEQUENCE OF, SET, SET OF, CHOICE,
  • UTF8String, NumericString, PrintableString, VisibleString, IA5String, BMPString,
  • UTCTime, GeneralizedTime,
  • Explicitly/Implicitly tagged types,
  • DEFAULT/OPTIONAL in SEQUENCE.

These datatypes are not supported:

  • REAL
  • TeletexString, VideotexString, GraphicString, GeneralString, UniversalString,
  • TIME, DATE, TIME-OF-DAY, DATE-TIME, DURATION.
  • DEFAULT/OPTIONAL in SET.

Other encodings

This library is currently specialized for BER (Basic Encoding Rules) and DER (Distinguished Encoding Rules). Other encodings such as CER (Canonical Encoding Rules), PER (Packed Encoding Rules), and XER (XML Encoding Rules) are currently out of scope.

Streaming

This library is currently specialized for on-memory serialization/deserialization. There are no plans for streaming ones.

Compatibility

The minimum supported Rust version (MSRV) of yasna.rs is Rust 1.36.0. Optional feature flags that enable interoperability with third-party crates (e.g. time) follow the policy of that crate if stricter.

License

This library is distributed under MIT/Apache-2.0 dual license.