pub fn encapsulated_len(
    label: &str,
    line_ending: LineEnding,
    input_len: usize
) -> Result<usize>
Expand description

Compute the length of a PEM encoded document which encapsulates a Base64-encoded body including line endings every 64 characters.

The input_len parameter specifies the length of the raw input bytes prior to Base64 encoding.

Note that the current implementation of this function computes an upper bound of the length and the actual encoded document may be slightly shorter (typically 1-byte). Downstream consumers of this function should check the actual encoded length and potentially truncate buffers allocated using this function to estimate the encapsulated size.

Use encoded_len (when possible) to obtain a precise length.

§Returns

  • Ok(len) on success
  • Err(Error::Length) on length overflow