Expand description
§tsumiki-pem
PEM (Privacy Enhanced Mail) format handling for cryptographic data.
This crate implements RFC 7468 for encoding and decoding PEM format.
§What is PEM?
PEM is a text-based format for encoding binary data. It wraps base64-encoded data with boundary markers like:
-----BEGIN CERTIFICATE-----
MIIBkTCB+wIJAKHHCgVZU...
-----END CERTIFICATE-----§Supported Labels
CERTIFICATE- X.509 certificatesPRIVATE KEY- PKCS#8 private keysENCRYPTED PRIVATE KEY- PKCS#8 encrypted private keysRSA PRIVATE KEY- PKCS#1 RSA private keysEC PRIVATE KEY- SEC1 EC private keysPUBLIC KEY- X.509 SubjectPublicKeyInfoRSA PUBLIC KEY- PKCS#1 RSA public keys
§Example
use std::str::FromStr;
use tsumiki_pem::{Pem, Label};
let pem_text = "-----BEGIN CERTIFICATE-----\nAAA=\n-----END CERTIFICATE-----";
let pem = Pem::from_str(pem_text)?;
assert_eq!(pem.label(), Label::Certificate);§Decoding to Raw Bytes
use std::str::FromStr;
use tsumiki::decoder::Decoder;
use tsumiki_pem::Pem;
let pem_text = "-----BEGIN CERTIFICATE-----\nAAA=\n-----END CERTIFICATE-----";
let pem = Pem::from_str(pem_text)?;
// Decode to raw bytes
let bytes: Vec<u8> = pem.decode()?;Modules§
Structs§
- Pem
- A PEM-encoded data structure.
Enums§
- Label
- PEM label identifying the type of data enclosed.
Traits§
- FromPem
- Trait for types that can be constructed from PEM format
- ToPem
- Trait for types that can be converted to PEM format
Functions§
- parse_
many - Parse multiple PEM blocks from a string.