UI_UTIL_READ_PW(3ossl)

πŸ’– UI_UTIL_READ_PW(3ossl) β€” the OpenSSL girlies' guide to asking for passwords πŸ’–

okay so bestie, this is UI_UTIL_READ_PW(3ossl) from the OpenSSL manual, and it's literally all about the user interface utilities β€” the ones that pop up and go "hey, type your passphrase πŸ₯Ί". Three little functions, one very cute job. Let's get into it ✨


✨ NAME ✨

UI_UTIL_read_pw_string, UI_UTIL_read_pw, UI_UTIL_wrap_read_pem_callback β€” user interface utilities, aka the passphrase-prompting squad 🫢


🌸 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);

πŸŽ€ DESCRIPTION πŸŽ€

okay so first up: UI_UTIL_read_pw_string() asks for a passphrase β€” it uses prompt as, you know, the prompt β€” and then stores what you typed in buf. the maximum allowed size is given by length, and no cap, that size includes the terminating NUL byte, so budget accordingly bestie. and if verify is nonzero? the password gets verified too. double-checking the vibe πŸ’…

UI_UTIL_read_pw() does the exact same thing as UI_UTIL_read_pw_string(), except β€” plot twist β€” you can hand it an external buffer buff for the verification passphrase. so it's the same energy, just with a second spot to stash the re-typed password πŸ¦‹

UI_UTIL_wrap_read_pem_callback() is the main character here. it creates a temporary UI_METHOD that wraps a given PEM password callback cb. the rwflag tells it whether this method will be used for passphrase entry without verification (0) or with verification (1). and listen β€” when you're not using the returned method anymore, you have to free it with UI_destroy_method(). don't leave it hanging, that's not the vibe πŸ™ˆ


⭐ NOTES ⭐

UI_UTIL_read_pw_string() and UI_UTIL_read_pw() both use the default UI_METHOD. wanna know more about that? go check UI_get_default_method(3) and friends, they got the lore πŸ“š

the result from the UI_METHOD that UI_UTIL_wrap_read_pem_callback() creates will generate password strings in the encoding that the given password callback generates. so whatever your callback does, that's the encoding you're getting, periodt.

also, the default password prompting functions β€” and yes, apart from UI_UTIL_read_pw_string() and UI_UTIL_read_pw(), that list is PEM_def_callback(), EVP_read_pw_string() and EVP_read_pw_string_min() β€” all use the default UI_METHOD. every single one of them. consistency queen πŸ‘‘


πŸ”₯ RETURN VALUES πŸ”₯

  • UI_UTIL_read_pw_string() and UI_UTIL_read_pw() return 0 on success or a negative value on error. (yes, 0 means good here, it's giving backwards but that's just how it is 😭)
  • UI_UTIL_wrap_read_pem_callback() returns a valid UI_METHOD structure, or NULL if an error occurred. if you get NULL, something went wrong, no cap πŸ’€

🌈 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, we ate and left no crumbs πŸ’– this was OpenSSL 3.5.9, dated 2026-09-29, and it's the UI_UTIL_READ_PW(3ossl) page β€” go forth and prompt responsibly πŸŽ€βœ¨

πŸ“¦ where this page comes from