Crates.io | yasna |
lib.rs | yasna |
version | 0.5.2 |
source | src |
created_at | 2016-07-02 05:49:33.674203 |
updated_at | 2023-04-06 01:12:13.650001 |
description | ASN.1 library for Rust |
homepage | https://github.com/qnighy/yasna.rs |
repository | https://github.com/qnighy/yasna.rs |
max_upload_size | |
id | 5564 |
size | 250,063 |
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 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:
These datatypes are not supported:
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:
These datatypes are not supported:
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.
This library is currently specialized for on-memory serialization/deserialization. There are no plans for streaming ones.
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.
This library is distributed under MIT/Apache-2.0 dual license.