alex/rust-asn1

GitHub: alex/rust-asn1

一个轻量级、支持嵌入式环境的 Rust ASN.1 DER 编解码库,通过 derive 宏提供简洁的序列化与反序列化能力。

Stars: 129 | Forks: 33

# rust-asn1 [![Dependency Status](https://deps.rs/repo/github/alex/rust-asn1/status.svg)][deps-rs-link] [![Documentation](https://docs.rs/asn1/badge.svg)][docs-rs-link] 这是一个用于解析和生成 ASN.1 数据(仅限 DER)的 Rust 库。 ## 安装 将 `asn1` 添加到您的 `Cargo.toml` 中: ``` $ cargo add asn1 ``` 基于 Rust 1.83.0 及更新版本构建。 `rust-asn1` 兼容 `#![no_std]` 环境: ``` $ cargo add asn1 --no-default-features ``` ## 更新日志 ### 未发布 #### 新增 - 添加了 `Set`、`SetWriter` 和 `SetElementWriter` 类型,用于解析和 写入带有 DER 顺序验证的 ASN.1 `SET` 值。 ### [0.23.1] #### 新增 - `Tag` 现在公开了一个 `write_to` 方法,该方法将标签的编码 表示写入 `WriteBuf`。 ### [0.23.0] #### 新增 - `Writer` 现在公开了 `write_explicit_element` 和 `write_implicit_element` 方法,允许在编译时不知道标签号的情况下编码 EXPLICIT/IMPLICIT 元素。 - `NonZero` 数字现在实现了 `Asn1Writable`。 #### 变更 - 将 MSRV 更新至 1.83.0。 ### [0.22.0] #### 新增 - 添加了 `Asn1Writable::encoded_length`、`SimpleAsn1Writable::data_length` 和 `Asn1DefinedByWritable::encoded_length`。实现这些函数可减少 写入时所需的重新分配次数。如果 无法提供高效的实现,可以返回 `None`。 #### 变更 - 将 MSRV 更新至 1.74.0。 ### [0.21.3] #### 新增 - `BitString::new` 现在是 `const fn`。 ### [0.21.2] #### 新增 - `BigInt::new`、`BigUint::new` 和 `DateTime::new` 现在是 `const fn`。 ### [0.21.1] #### 新增 - `Parser` 现在公开了一个 `peek_tag` 方法,该方法返回 解析中下一个元素的标签,而不消耗该元素。 ([#532](https://github.com/alex/rust-asn1/pull/532)) - `Parser` 现在公开了 `read_explicit_element` 和 `read_implicit_element` 方法,允许在编译时不知道标签号的情况下解析 EXPLICIT/IMPLICIT 元素。 - `PrintableString`、`Utf8String`、`BMPString` 和 `UniversalString` 现在 `#[derive(Hash)]`。 ([#536](https://github.com/alex/rust-asn1/pull/536)) ### [0.21.0] #### 变更 - 将 MSRV 更新至 1.65.0。 #### 修复 - 修复了结合 `#[derive(Asn1DefinedByRead)]` 和 `#[derive(Asn1DefinedByWrite)]` 时的 ["perfect derives"](https://smallcultfollowing.com/babysteps/blog/2022/04/12/implied-bounds-and-perfect-derive/)。 ([#506](https://github.com/alex/rust-asn1/pull/506)) ### [0.20.0] #### :rotating_light: 破坏性变更 - 移除了 `Writer::{write_explicit_element, write_optional_explicit_element, write_implicit_element, write_optional_implicit_element}`。 这些都可以通过 `asn1::Explicit` 和 `asn1::Implicit` 类型更好地完成。 #### 修复 - 修复了结合 `#[implicit]` 和 `#[explicit]` 时的 ["perfect derives"](https://smallcultfollowing.com/babysteps/blog/2022/04/12/implied-bounds-and-perfect-derive/)。 ([#502](https://github.com/alex/rust-asn1/pull/502)) ### [0.19.0] #### :rotating_light: 破坏性变更 - `GeneralizedTime` 已重命名为 `X509GeneralizedTime`。该类型不 允许小数秒,但是此限制实际上并非 DER 规则,而是 X.509 特有的。 ([#494](https://github.com/alex/rust-asn1/pull/494)) - `GeneralizedTime` 是一个接受小数秒的新类型, 取代了旧的 `GeneralizedTime`。 ([#492](https://github.com/alex/rust-asn1/pull/492)) - `#[derive(asn1::Asn1Read)]` 和 `#[derive(asn1::Asn1Write)]` 现在实现了 ["perfect derives"](https://smallcultfollowing.com/babysteps/blog/2022/04/12/implied-bounds-and-perfect-derive/)。 ([#496](https://github.com/alex/rust-asn1/pull/496))
标签:ASN.1, DER, no_std, Rust, SOC Prime, TLS, X.509, 内存安全, 反序列化, 可视化界面, 密码学, 嵌入式系统, 序列化, 库, 应急响应, 开发工具, 手动系统调用, 数据编码, 网络安全, 网络流量审计, 解析器, 证书解析, 通知系统, 通知系统, 防御工具, 隐私保护