DES_READ_PW(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

Okay bestie, this is DES_READ_PW(3) from the Library Functions Manual, and it’s giving β€œcompatibility era but make it password-prompt realness.” πŸ’–

🌸 NAME 🌸

EVP_read_pw_string, EVP_read_pw_string_min, EVP_set_pw_prompt, EVP_get_pw_prompt β€” the compatibility user interface functions. They’re the little crew that handles prompting for passwords and remembering a default prompt, periodt. πŸ’…


✨ SYNOPSIS ✨

It’s libcrypto time, bestie, with #include <openssl/evp.h>:

library β€œlibcrypto” #include <openssl/evp.h>

int
EVP_read_pw_string(char *buf, int length, const char *prompt,
    int verify);

int
EVP_read_pw_string_min(char *buf, int min_length, int length,
    const char *prompt, int verify);

void
EVP_set_pw_prompt(const char *default_prompt);

char *
EVP_get_pw_prompt(void);

πŸŽ€ DESCRIPTION πŸŽ€

Okay so here’s the tea, function by function:

  • EVP_read_pw_string() β€” writes the prompt to /dev/tty; if that could not be opened, it writes the prompt to standard output instead. It turns echo off. Then it reads an input string from /dev/tty; if that could not be opened, it reads from standard input instead. That string is returned in buf, and buf must have space for at least length bytes. If the length argument exceeds BUFSIZ, then BUFSIZ is used instead. If verify is set, the user is asked for the password twice, and unless the two copies match, an error is returned. πŸ”₯
  • EVP_read_pw_string_min() β€” does all the above, and additionally checks that the password is at least min_length bytes long. Lowkey the extra-vigilant bestie of the group. 🫢
  • EVP_set_pw_prompt() β€” sets a default prompt to a copy of default_prompt. If the default_prompt argument is NULL or an empty string, it clears the default prompt. If the default_prompt argument is longer than 79 bytes, that copy is silently truncated to a string length of 79 bytes. No drama, just truncation. πŸ’€
  • default prompt behavior β€” as long as a default prompt is set, EVP_read_pw_string() and EVP_read_pw_string_min() can be called with a prompt argument of NULL, and in that case the default prompt is used instead. Iconic convenience behavior. πŸ‘‘

⭐ RETURN VALUES ⭐

  • EVP_read_pw_string() and EVP_read_pw_string_min() return 0 on success or a negative value on failure.
  • They return -1 if length is less than or equal to zero or on memory allocation failure.
  • They return -1 or -2 if the internal call to UI_process(3) fails. 😭
  • In addition, EVP_read_pw_string_min returns -1 if min_length is negative, if length is less than or equal to min_length, or if the user entered a password shorter than min_length.
  • EVP_get_pw_prompt() returns an internal pointer to static memory containing the default prompt, or NULL if no default prompt is set.

πŸ¦‹ SEE ALSO πŸ¦‹


🌈 HISTORY 🌈

EVP_read_pw_string() first appeared in SSLeay 0.5.1, and EVP_set_pw_prompt() and EVP_get_pw_prompt() first appeared in SSLeay 0.6.0. These functions have been available since OpenBSD 2.4. πŸ•°οΈ

EVP_read_pw_string_min() first appeared in OpenSSL 1.0.0 and has been available since OpenBSD 4.9. ✨


That’s the whole page, bestie β€” the footer says Debian, June 8, 2025, for DES_READ_PW(3). Mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from