DES_READ_PW(3)
π DES_READ_PW(3) β like, the password-prompting girlies of the library functions manual β¨
okay so this page is DES_READ_PW(3) from the Library Functions Manual, and it's all about a little squad of compatibility user interface functions that read passwords for you. they're lowkey old-school but they still show up, so let's get into it π«Ά
πΈ NAME πΈ
EVP_read_pw_string, EVP_read_pw_string_min, EVP_set_pw_prompt, EVP_get_pw_prompt β compatibility user interface functions, bestie. that's the whole vibe. π
β¨ SYNOPSIS β¨
#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 EVP_read_pw_string() is the main character here β it writes the prompt to /dev/tty and, if that could not be opened, it goes to standard output instead. then it turns echo off (so nobody sees you typing your secret, iconic) and reads an input string from /dev/tty or, if that could not be opened, from standard input. the string gets returned in buf, which must have space for at least length bytes β do not skimp on the buffer, she needs room to breathe. π
and like, if the length argument exceeds BUFSIZ, then BUFSIZ is used instead. that's the cap, periodt.
if verify is set, the user gets asked for the password twice, and unless the two copies match, an error is returned. it's giving "confirm your password" energy. π₯
EVP_read_pw_string_min() is the same deal but it additionally checks that the password is at least min_length bytes long. so if you're the type to set a three-character password, she will notice. π
EVP_set_pw_prompt() sets a default prompt to a copy of default_prompt, or clears the default prompt entirely if the default_prompt argument is NULL or an empty string. and heads up: if default_prompt is longer than 79 bytes, the copy is silently truncated to a string length of 79 bytes. no warning, no drama, it just happens. π
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. convenient? yes. π¦
π RETURN VALUES π
so EVP_read_pw_string() and EVP_read_pw_string_min() return 0 on success, or a negative value on failure. simple enough.
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. two negative options, no notes. π
and 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. so many ways to fail but honestly? fair.
EVP_get_pw_prompt() returns an internal pointer to static memory containing the default prompt, or NULL if no default prompt is set. it's a pointer to static memory, bestie β don't go freeing it, that's not her story. β
π SEE ALSO π
π HISTORY π
EVP_read_pw_string() first appeared in SSLeay 0.5.1, and EVP_set_pw_prompt() and EVP_get_pw_prompt() showed up in SSLeay 0.6.0. these functions have been available since OpenBSD 2.4 β like, ancient in internet years. π
EVP_read_pw_string_min() first appeared in OpenSSL 1.0.0 and has been available since OpenBSD 4.9. late to the party but she made it. π
ngl this whole page is "compatibility" functions, so they're around for the old code that still loves them β no cap, that's the vibe. π
okay that's the whole thing!! this page came from Debian, dated August 24, 2024 β mwah, ty for reading, love u, bye!! πβ¨ππ§ββοΈ
π¦ where this page comes from
- opensuse-leap 16.0: libressl-devel-doc 4.1.0-bp160.1.1 Β· OpenSSL
- Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2000 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms