Crates.io | pem-rfc7468 |
lib.rs | pem-rfc7468 |
version | 1.0.0-rc.2 |
source | src |
created_at | 2021-02-16 16:40:33.169667 |
updated_at | 2024-10-15 20:03:30.229881 |
description | PEM Encoding (RFC 7468) for PKIX, PKCS, and CMS Structures, implementing a strict subset of the original Privacy-Enhanced Mail encoding intended specifically for use with cryptographic keys, certificates, and other messages. Provides a no_std-friendly, constant-time implementation suitable for use with cryptographic private keys. |
homepage | https://github.com/RustCrypto/formats/tree/master/pem-rfc7468 |
repository | https://github.com/RustCrypto/formats |
max_upload_size | |
id | 356052 |
size | 72,411 |
Pure Rust implementation of PEM Encoding (RFC 7468) for PKIX, PKCS, and CMS Structures, a strict subset of the original Privacy-Enhanced Mail encoding intended specifically for use with cryptographic keys, certificates, and other messages.
Provides a no_std
-friendly, constant-time implementation suitable for use with
cryptographic private keys.
Many cryptography-related document formats, such as certificates (PKIX), private and public keys/keypairs (PKCS), and other cryptographic messages (CMS) provide an ASCII encoding which can be traced back to Privacy-Enhanced Mail (PEM) as defined RFC 1421, which look like the following:
-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIBftnHPp22SewYmmEoMcX8VwI4IHwaqd+9LFPj/15eqF
-----END PRIVATE KEY-----
However, all of these formats actually implement a text-based encoding that is similar but not identical to the legacy PEM encoding as described in RFC 1421.
For this reason, RFC 7468 was created to describe a stricter form of "PEM encoding" for use in these applications which codifies the previously de facto rules that most implementations operate by, and makes recommendations to promote interoperability.
This crate provides a strict interpretation of the RFC 7468 rules, implementing MUSTs and SHOULDs while avoiding the MAYs, targeting the "ABNF (Strict)" subset of the grammar as described in RFC 7468 Section 3 Figure 3 (p6).
no_std
-friendly core implementation which requires no heap allocations
and avoids copies and temporary buffers.alloc
-dependent convenience features and buffered decoder/encoder.base64ct
crate to decode/encode Base64 in constant-time.The paper Util::Lookup: Exploiting key decoding in cryptographic libraries demonstrates how the leakage from non-constant-time PEM parsers can be used to practically extract RSA private keys from SGX enclaves.
This crate requires Rust 1.81 at a minimum.
We may change the MSRV in the future, but it will be accompanied by a minor version bump.
Licensed under either of:
at your option.
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.