UI_UTIL_READ_PW(3SSL)

πŸ’– UI_UTIL_READ_PW β€” the user interface utilities page, bestie edition πŸ’–

okay so this is from the OpenSSL manual, section 3SSL, and it's literally all about the lil helpers that ask a human for a password. sit down, hydrate, let's go 🫢


✨ NAME ✨

UI_UTIL_read_pw_string, UI_UTIL_read_pw, UI_UTIL_wrap_read_pem_callback β€” user interface utilities. that's it, that's the trio πŸ‘‘


🌸 SYNOPSIS 🌸

#include <openssl/ui.h>

int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,
                           int verify);
int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,
                    int verify);
UI_METHOD *UI_UTIL_wrap_read_pem_callback(pem_password_cb *cb, int rwflag);

like… copy that exactly, i am not joking, no typos allowed πŸ™ˆ


πŸ¦‹ DESCRIPTION πŸ¦‹

UI_UTIL_read_pw_string() is the one that straight up asks for a passphrase. you hand it prompt and it uses that as the prompt, then tucks the passphrase away in buf. the biggest size you're allowed is length, and yes bestie that count includes the terminating NUL byte, don't forget it. and if verify is nonzero? it also verifies the password. two-for-one, we love a secure queen πŸ’…

UI_UTIL_read_pw() does the exact same thing as UI_UTIL_read_pw_string() β€” same energy, same job β€” the only diff is you can give it an external buffer, buff, to hold the verification passphrase. that's the whole plot twist πŸŽ€

UI_UTIL_wrap_read_pem_callback() is for making a temporary UI_METHOD that wraps a PEM password callback you already have, cb. rwflag says whether this method is gonna be used for passphrase entry without verification (0) or with verification (1). and listen: when you're done with it, free that returned method with UI_destroy_method(). clean up after yourself, main character behaviour 🌈


⭐ NOTES ⭐

UI_UTIL_read_pw_string() and UI_UTIL_read_pw() use the default UI_METHOD. wanna know more? go look at UI_get_default_method(3) and friends πŸ‘―

the result from the UI_METHOD created by UI_UTIL_wrap_read_pem_callback() will generate password strings in the encoding that the given password callback generates β€” no cap, whatever cb spits out is what you get.

and the default password prompting functions β€” apart from UI_UTIL_read_pw_string() and UI_UTIL_read_pw(), there's also PEM_def_callback(), EVP_read_pw_string() and EVP_read_pw_string_min() β€” they all use the default UI_METHOD. so like, the whole squad is on the same default vibe ✨


πŸ’œ RETURN VALUES πŸ’œ

  • UI_UTIL_read_pw_string() and UI_UTIL_read_pw() return 0 on success, or a negative value on error. success is zero bestie, i know, it's giving chaos but that's just how it is 😭
  • UI_UTIL_wrap_read_pem_callback() returns a valid UI_METHOD structure, or NULL if something went wrong πŸ™ˆ

πŸ”₯ SEE ALSO πŸ”₯


Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page, bestie πŸ’– this was OpenSSL 4.0.3, dated 2026-09-29, and it lives in the UI_UTIL_READ_PW(3SSL) manual. go forth and prompt for passwords responsibly 🫢✨

πŸ“¦ where this page comes from