PEM
Encode bytes as an RFC 7468 document with a type label.
from oxcrypto.encoding.pem import PEM
document = PEM.RFC7468.encode(der, label="PRIVATE KEY")
label, der = PEM.RFC7468.decode(document)encode wraps the Base64 body at 64 columns. Pass line_ending="\r\n" or
"\r" to change the default "\n". decode returns the type label as str
and the decoded data as bytes.
Decoding follows the strict RFC 7468 grammar. It rejects explanatory headers
such as legacy OpenSSL Proc-Type, mismatched labels, and invalid Base64. An
invalid label raises ValueError. A document with an empty body does not
decode in pem-rfc7468 1.0.0, even though encode produces one.
| Standard | RFC 7468 (Proposed Standard) |
| Crate | pem-rfc7468 1.0.0 (RustCrypto formats), stable |
| Audit | No published audit |
| MSRV | 1.85, builds with the project MSRV 1.88 |
| Experimental | No |
| Test vectors | pem-rfc7468 tests (PKCS #1 and PKCS #8 examples) |