| 1 | # [RustCrypto]: ASN.1 DER |
| 2 | |
| 3 | [![Crate][crate-image]][crate-link] |
| 4 | [![Docs][docs-image]][docs-link] |
| 5 | [![Build Status][build-image]][build-link] |
| 6 | ![Apache2/MIT licensed][license-image] |
| 7 | ![Rust Version][rustc-image] |
| 8 | [![Project Chat][chat-image]][chat-link] |
| 9 | |
| 10 | Pure Rust embedded-friendly implementation of the Distinguished Encoding Rules (DER) |
| 11 | for Abstract Syntax Notation One (ASN.1) as described in [ITU X.690]. |
| 12 | |
| 13 | [Documentation][docs-link] |
| 14 | |
| 15 | ## About |
| 16 | |
| 17 | This crate provides a `no_std`/`no_alloc`-friendly implementation of a subset of ASN.1 DER |
| 18 | necessary for decoding/encoding the following cryptography-related formats |
| 19 | implemented as crates maintained by the [RustCrypto] project: |
| 20 | |
| 21 | - [`cms`]: Cryptographic Message Syntax |
| 22 | - [`pkcs1`]: RSA Cryptography Specifications |
| 23 | - [`pkcs5`]: Password-Based Cryptography Specification |
| 24 | - [`pkcs8`]: Private-Key Information Syntax Specification |
| 25 | - [`pkcs12`]: Personal Information Exchange Syntax |
| 26 | - [`sec1`]: Elliptic Curve Cryptography |
| 27 | - [`spki`]: X.509 Subject Public Key Info |
| 28 | - [`x509-cert`]: Public Key Infrastructure Certificate |
| 29 | - [`x509-ocsp`]: Online Certificate Status Protocol |
| 30 | |
| 31 | The core implementation avoids any heap usage (with convenience methods that allocate gated under |
| 32 | the off-by-default `alloc` feature). |
| 33 | |
| 34 | The DER decoder in this crate performs checks to ensure that the input document |
| 35 | is in canonical form, and will return errors if non-canonical productions are |
| 36 | encountered. There is currently no way to disable these checks. |
| 37 | |
| 38 | ### Features |
| 39 | |
| 40 | - Rich support for ASN.1 types used by PKCS/PKIX documents |
| 41 | - Performs DER canonicalization checks at decoding time |
| 42 | - `no_std`/`no_alloc` friendly (supports "heapless" usage) |
| 43 | - Optionally supports `alloc` and `std` if desired |
| 44 | - No hard dependencies! Self-contained implementation with optional integrations with the following crates, all of |
| 45 | which are `no_std`/`no_alloc` friendly: |
| 46 | - `const-oid`: const-friendly OID implementation |
| 47 | - `pem-rfc7468`: PKCS/PKIX-flavored PEM library with constant-time decoder/encoders |
| 48 | - `time` crate: date/time library |
| 49 | |
| 50 | ## Minimum Supported Rust Version (MSRV) Policy |
| 51 | |
| 52 | MSRV increases are not considered breaking changes and can happen in patch releases. |
| 53 | |
| 54 | The crate MSRV accounts for all supported targets and crate feature combinations, excluding |
| 55 | explicitly unstable features. |
| 56 | |
| 57 | ## License |
| 58 | |
| 59 | Licensed under either of: |
| 60 | |
| 61 | * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) |
| 62 | * [MIT license](http://opensource.org/licenses/MIT) |
| 63 | |
| 64 | at your option. |
| 65 | |
| 66 | ### Contribution |
| 67 | |
| 68 | Unless you explicitly state otherwise, any contribution intentionally submitted |
| 69 | for inclusion in the work by you, as defined in the Apache-2.0 license, shall be |
| 70 | dual licensed as above, without any additional terms or conditions. |
| 71 | |
| 72 | [//]: # (badges) |
| 73 | |
| 74 | [crate-image]: https://img.shields.io/crates/v/der?logo=rust |
| 75 | [crate-link]: https://crates.io/crates/der |
| 76 | [docs-image]: https://docs.rs/der/badge.svg |
| 77 | [docs-link]: https://docs.rs/der/ |
| 78 | [build-image]: https://github.com/RustCrypto/formats/actions/workflows/der.yml/badge.svg |
| 79 | [build-link]: https://github.com/RustCrypto/formats/actions/workflows/der.yml |
| 80 | [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg |
| 81 | [rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg |
| 82 | [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg |
| 83 | [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/300570-formats |
| 84 | |
| 85 | [//]: # (links) |
| 86 | |
| 87 | [RustCrypto]: https://github.com/rustcrypto |
| 88 | [ITU X.690]: https://www.itu.int/rec/T-REC-X.690/en |
| 89 | [`cms`]: https://github.com/RustCrypto/formats/tree/master/cms |
| 90 | [`pkcs1`]: https://github.com/RustCrypto/formats/tree/master/pkcs1 |
| 91 | [`pkcs5`]: https://github.com/RustCrypto/formats/tree/master/pkcs5 |
| 92 | [`pkcs8`]: https://github.com/RustCrypto/formats/tree/master/pkcs8 |
| 93 | [`pkcs12`]: https://github.com/RustCrypto/formats/tree/master/pkcs12 |
| 94 | [`sec1`]: https://github.com/RustCrypto/formats/tree/master/sec1 |
| 95 | [`spki`]: https://github.com/RustCrypto/formats/tree/master/spki |
| 96 | [`x509-cert`]: https://github.com/RustCrypto/formats/tree/master/x509-cert |
| 97 | [`x509-ocsp`]: https://github.com/RustCrypto/formats/tree/master/x509-ocsp |