{"id":22281886,"url":"https://github.com/kizzycode/asn1_der-rust","last_synced_at":"2026-01-15T22:20:19.341Z","repository":{"id":57496654,"uuid":"116991033","full_name":"KizzyCode/asn1_der-rust","owner":"KizzyCode","description":"This library provides a simple ASN.1-DER en-/decoder","archived":false,"fork":false,"pushed_at":"2023-04-06T02:26:22.000Z","size":1230,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-09T02:36:19.805Z","etag":null,"topics":["asn","asn1","asn1-der","der"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KizzyCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE BSD 2-CLAUSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-01-10T17:47:25.000Z","updated_at":"2025-03-27T20:02:19.000Z","dependencies_parsed_at":"2023-07-14T09:02:56.354Z","dependency_job_id":null,"html_url":"https://github.com/KizzyCode/asn1_der-rust","commit_stats":{"total_commits":82,"total_committers":1,"mean_commits":82.0,"dds":0.0,"last_synced_commit":"0f042778234a747e47803fa26e167baca466209a"},"previous_names":["kizzycode/asn1_der"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/KizzyCode/asn1_der-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KizzyCode%2Fasn1_der-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KizzyCode%2Fasn1_der-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KizzyCode%2Fasn1_der-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KizzyCode%2Fasn1_der-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KizzyCode","download_url":"https://codeload.github.com/KizzyCode/asn1_der-rust/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KizzyCode%2Fasn1_der-rust/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267580462,"owners_count":24110845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asn","asn1","asn1-der","der"],"created_at":"2024-12-03T16:23:04.375Z","updated_at":"2026-01-15T22:20:19.309Z","avatar_url":"https://github.com/KizzyCode.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![docs.rs](https://docs.rs/asn1_der/badge.svg)](https://docs.rs/asn1_der)\n[![License BSD-2-Clause](https://img.shields.io/badge/License-BSD--2--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)\n[![License MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![crates.io](https://img.shields.io/crates/v/asn1_der.svg)](https://crates.io/crates/asn1_der)\n[![Download numbers](https://img.shields.io/crates/d/asn1_der.svg)](https://crates.io/crates/asn1_der)\n[![AppVeyor CI](https://ci.appveyor.com/api/projects/status/github/KizzyCode/asn1_der-rust?svg=true)](https://ci.appveyor.com/project/KizzyCode/asn1-der-rust)\n[![dependency status](https://deps.rs/crate/asn1_der/latest/status.svg)](https://deps.rs/crate/asn1_der)\n\n# asn1_der\nWelcome to `asn1_der` 🎉\n\nThis crate provides a basic `no_std`-compatible, [no-panic](#no-panic) and [zero-copy](#zero-copy)\nDER implementation. It is designed to be reliable and reasonable fast without getting too large or\nsacrificing too much comfort. To achieve this, `asn1_der` makes extensive use of the\n[`no-panic`](https://crates.io/crates/no-panic) crate and offers slice-based object views to avoid\nallocations and unnecessary copies.\n\n\n## Example\n```ignore\nuse asn1_der::{\n    DerObject,\n    typed::{ DerEncodable, DerDecodable }\n};\n\nfn main() {\n    /// An ASN.1-DER encoded integer `7`\n    const INT7: \u0026'static[u8] = b\"\\x02\\x01\\x07\";\n\n    // Decode an arbitrary DER object\n    let object = DerObject::decode(INT7).expect(\"Failed to decode object\");\n\n    // Encode an arbitrary DER object\n    let mut encoded_object = Vec::new();\n    object.encode(\u0026mut encoded_object).expect(\"Failed to encode object\");\n\n    // Decode a `u8`\n    let number = u8::decode(INT7).expect(\"Failed to decode number\");\n    assert_eq!(number, 7);\n\n    // Encode a new `u8`\n    let mut encoded_number = Vec::new();\n    7u8.encode(\u0026mut encoded_number).expect(\"Failed to encode number\");\n}\n```\n\nFor the (de-)serialization of structs and similar via `derive`, see \n[`serde_asn1_der`](https://crates.io/crates/serde_asn1_der).\n\n\n## Typed Implementations\nThere are also some direct `DerDecodable`/`DerDecodable` implementations for native Rust type \nequivalents:\n - The ASN.1-`BOOLEAN` type as Rust-`bool`\n - The ASN.1-`INTEGER` type as Rust-[`u8`, `u16`, `u32`, `u64`, `u128`, `usize`]\n - The ASN.1-`NULL` type as either `()` or `Option::None` (which allows the encoding of\n   optionals)\n - The ASN.1-`OctetString` type as `Vec\u003cu8\u003e`\n - The ASN.1-`SEQUENCE` type as `SequenceVec(Vec\u003cT\u003e)`\n - The ASN.1-`UTF8String` type as `String`\n\n\n## No-Panic\n`asn1_der` is designed to be as panic-free as possible. To ensure that, nearly every function is\nattributed with `#[no_panic]`, which forces the compiler to prove that a function cannot panic in\nthe given circumstances. However since `no_panic` can cause a lot of false-positives, it is\ncurrently only used by the CI-tests and disabled by default in normal builds. If you want to use\nthis crate with `no_panic` enabled, you can do so by specifying the `no_panic` feature.\n\n### What No-Panic Does Not Cover\nIt is important to know that `no_panic` is no silver bullet and does not help against certain kinds\nof errors that can also happen in this crate. This especially includes:\n - Dynamic memory allocation errors: Since it is not possible to predict memory allocation errors,\n   everything that requires dynamic memory allocation is mutually exclusive to `no_panic` and will\n   be omitted if `no_panic` is enabled.\n   \n   This crate might allocate memory in the following circumstances:\n    - When writing to a dynamically allocating sink (e.g. `Vec\u003cu8\u003e`, `VecBacking(Vec\u003cu8\u003e)`)\n    - When decoding a native owned type such as `Vec\u003cu8\u003e`, `SequenceVec(Vec\u003cT\u003e)` or `String`\n    - During error propagation\n   \n   If the crate is compiled without `std` enabled, it does performy any dynamic memory allocation \n   directly by itself – however for foreign implementations passed to this crate may still allocate \n   memory and fail (e.g. a custom `Sink` implementation).\n   \n - Stack overflows: Since the stack size is not necessarily known during compile time, it is not\n   possible to predict stack overflow errors e.g. caused by recursion.\n - Calls to `abort` or similar: Since calls to `abort` or similar do not trigger stack unwinding,\n   they can also no be detected by `no_panic`. __This also means that `no_panic` does not work for\n   builds that use `panic = \"abort\"` in their config.__\n   \n   This crate by itself does never call `abort` directly.\n\nDue to the limitations described above, the following functions are mutually exclusive to\n`no_panic` and disabled if `no_panic` is set:\n - Error stacking/propagation (`propagate` is a no-op if compiled with `no_panic`)\n - The sink implementation for a byte vector (`impl Sink for Vec\u003cu8\u003e`)\n - The `VecBacking(Vec\u003cu8\u003e)` type\n - The native OctetString type which uses `Vec\u003cu8\u003e` (`impl\u003c'a\u003e DerDecodable\u003c'a\u003e for Vec\u003cu8\u003e` and\n   `impl DerEncodable for Vec\u003cu8\u003e`)\n - The native Sequence type wrapper `SequenceVec` since it is based upon `Vec`\n - The native Utf8String type based upon `String` (`impl\u003c'a\u003e DerDecodable\u003c'a\u003e for String` and\n   `impl DerEncodable for String`)\n\n\n## Zero-Copy\nThe crate is designed to be as much zero-copy as possible. In fact this means that the `DerObject`\ntype and all typed views are zero-copy views over the underlying slice. Of course, zero-copy is not\nalways reasonable: The `new`-constructors are not zero-copy because they construct a new object into\na sink and the native type implementations are not zero-copy because they are either `Copy`-types\n(e.g. `u128`) or owned (e.g. `String`).\n\n\n## What happened to `asn1_der_derive`?\nSince version 0.7.0, the `asn1_der_derive`-crates has been deprecated in favor of\n[`serde_asn1_der`](https://crates.io/crates/serde_asn1_der). If you have a specific use-case why you\ncannot use `serde`, let me know; it's probably not that hard to revive `asn1_der_derive` 😊","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkizzycode%2Fasn1_der-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkizzycode%2Fasn1_der-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkizzycode%2Fasn1_der-rust/lists"}