GitXplorerGitXplorer
q

yasna.rs

public
47 stars
31 forks
6 issues

Commits

List of commits on branch master.
Verified
95c343ecb66ddec50ff30719096a2a867e469b73

Merge pull request #78 from caizhengxin/master

eest31 committed 5 months ago
Unverified
f39d1925a8f790d40496e13a80637df37546ffa2

Update the no_std compilation

committed 5 months ago
Verified
8f22a7f021f1829ca38a7e7ad1e269f72607a46e

Merge pull request #77 from decathorpe/master

eest31 committed 6 months ago
Verified
d116bac75b6db79c9da6754a7055f3ca6e11d51d

Ensure license files and README are included in published crates

ddecathorpe committed 6 months ago
Verified
3c626fbfa7ae1e90275242a91bccc5b4e23cc397

Merge pull request #75 from Snarpix/fix-slice-and-tuple-serialization

eest31 committed a year ago
Unverified
06d131c7234f0e2b27ac0874da78559704f5507b

Fix slices and tuples serialization

committed a year 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.