Function readpassphrase_buf

Source
pub fn readpassphrase_buf(
    prompt: &CStr,
    buf: Vec<u8>,
    flags: RppFlags,
) -> Result<String, Error>
Expand description

Reads a passphrase using readpassphrase(3) into the passed buffer. Returns a String consisting of the same memory from the buffer. If the zeroize feature is enabled (which it is by default), memory is cleared on errors.

§Security

The returned String is not cleared on success; it is the caller’s responsibility to do so, e.g.:

let buf = vec![0u8; PASSWORD_LEN];
let pass = Zeroizing::new(readpassphrase_buf(c"Pass: ", buf, RppFlags::default())?);