#asn-1 #asn1-der #pkcs #der-encoding #target #public-key

no-std der

Pure Rust embedded-friendly implementation of the Distinguished Encoding Rules (DER) for Abstract Syntax Notation One (ASN.1) as described in ITU X.690 with full support for heapless no_std targets

35 releases

Uses new Rust 2024

0.8.0-rc.4 Jun 5, 2025
0.8.0-rc.2 Apr 23, 2025
0.8.0-rc.1 Aug 18, 2024
0.8.0-rc.0 Jul 26, 2024
0.1.0 Dec 22, 2020

#98 in Cryptography

Download history 2582336/week @ 2025-02-28 2832509/week @ 2025-03-07 2462433/week @ 2025-03-14 3740502/week @ 2025-03-21 2141516/week @ 2025-03-28 2307994/week @ 2025-04-04 2033846/week @ 2025-04-11 1813464/week @ 2025-04-18 1793886/week @ 2025-04-25 1913117/week @ 2025-05-02 1950283/week @ 2025-05-09 2013100/week @ 2025-05-16 1714558/week @ 2025-05-23 1854177/week @ 2025-05-30 1835318/week @ 2025-06-06 1901223/week @ 2025-06-13

7,696,658 downloads per month
Used in 6,618 crates (114 directly)

Apache-2.0 OR MIT

480KB
11K SLoC

RustCrypto: ASN.1 DER

Crate Docs Build Status Apache2/MIT licensed Rust Version Project Chat

Pure Rust embedded-friendly implementation of the Distinguished Encoding Rules (DER) for Abstract Syntax Notation One (ASN.1) as described in ITU X.690.

Documentation

About

This crate provides a no_std-friendly implementation of a subset of ASN.1 DER necessary for decoding/encoding the following cryptography-related formats implemented as crates maintained by the RustCrypto project:

  • cms: Cryptographic Message Syntax
  • pkcs1: RSA Cryptography Specifications
  • pkcs5: Password-Based Cryptography Specification
  • pkcs8: Private-Key Information Syntax Specification
  • pkcs12: Personal Information Exchange Syntax
  • sec1: Elliptic Curve Cryptography
  • spki: X.509 Subject Public Key Info
  • x509-cert: Public Key Infrastructure Certificate
  • x509-ocsp: Online Certificate Status Protocol

The core implementation avoids any heap usage (with convenience methods that allocate gated under the off-by-default alloc feature).

The DER decoder in this crate performs checks to ensure that the input document is in canonical form, and will return errors if non-canonical productions are encountered. There is currently no way to disable these checks.

Features

  • Rich support for ASN.1 types used by PKCS/PKIX documents
  • Performs DER canonicalization checks at decoding time
  • no_std friendly: supports "heapless" usage
  • Optionally supports alloc and std if desired
  • No hard dependencies! Self-contained implementation with optional integrations with the following crates, all of which are no_std friendly:
    • const-oid: const-friendly OID implementation
    • pem-rfc7468: PKCS/PKIX-flavored PEM library with constant-time decoder/encoders
    • time crate: date/time library

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0–495KB