JFLib

netio/pem.rs#

Source: lib/netio/pem.rs

pem -- "-----BEGIN LABEL-----" blocks (RFC 7468): each marker on a line of its own
  • fn encode(label: &str, der: &[u8]) -> String a PEM block of DER bytes

  • fn decode_all(text: &str, label: &str) -> Vec<Vec<u8>> every block with this label, decoded. Read line by line: the lines of a body (a private key is secret) are only compared with the markers, which no Base64 line equals (none begins with '-'); no substring search runs over them, whose steps would depend on the characters

  • fn decode(text: &str, label: &str) -> Option<Vec<u8>> the first block with this label

Source: docs/API.md in the JFLib repository.