1.\" $OpenBSD: des_read_pw.3,v 1.12 2024/08/24 07:48:37 tb Exp $ 2.\" full merge up to: OpenSSL doc/crypto/des.pod 3.\" 53934822 Jun 9 16:39:19 2016 -0400 4.\" 5.\" This file is a derived work. 6.\" The changes are covered by the following Copyright and license: 7.\" 8.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org> 9.\" 10.\" Permission to use, copy, modify, and distribute this software for any 11.\" purpose with or without fee is hereby granted, provided that the above 12.\" copyright notice and this permission notice appear in all copies. 13.\" 14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21.\" 22.\" The original file was written by Ulf Moeller <ulf@openssl.org>. 23.\" Copyright (c) 2000 The OpenSSL Project. All rights reserved. 24.\" 25.\" Redistribution and use in source and binary forms, with or without 26.\" modification, are permitted provided that the following conditions 27.\" are met: 28.\" 29.\" 1. Redistributions of source code must retain the above copyright 30.\" notice, this list of conditions and the following disclaimer. 31.\" 32.\" 2. Redistributions in binary form must reproduce the above copyright 33.\" notice, this list of conditions and the following disclaimer in 34.\" the documentation and/or other materials provided with the 35.\" distribution. 36.\" 37.\" 3. All advertising materials mentioning features or use of this 38.\" software must display the following acknowledgment: 39.\" "This product includes software developed by the OpenSSL Project 40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 41.\" 42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 43.\" endorse or promote products derived from this software without 44.\" prior written permission. For written permission, please contact 45.\" openssl-core@openssl.org. 46.\" 47.\" 5. Products derived from this software may not be called "OpenSSL" 48.\" nor may "OpenSSL" appear in their names without prior written 49.\" permission of the OpenSSL Project. 50.\" 51.\" 6. Redistributions of any form whatsoever must retain the following 52.\" acknowledgment: 53.\" "This product includes software developed by the OpenSSL Project 54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 55.\" 56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" 69.Dd $Mdocdate: August 24 2024 $ 70.Dt DES_READ_PW 3 71.Os 72.Sh NAME 73.Nm EVP_read_pw_string , 74.Nm EVP_read_pw_string_min , 75.Nm EVP_set_pw_prompt , 76.Nm EVP_get_pw_prompt 77.Nd compatibility user interface functions 78.Sh SYNOPSIS 79.In openssl/evp.h 80.Ft int 81.Fo EVP_read_pw_string 82.Fa "char *buf" 83.Fa "int length" 84.Fa "const char *prompt" 85.Fa "int verify" 86.Fc 87.Ft int 88.Fo EVP_read_pw_string_min 89.Fa "char *buf" 90.Fa "int min_length" 91.Fa "int length" 92.Fa "const char *prompt" 93.Fa "int verify" 94.Fc 95.Ft void 96.Fo EVP_set_pw_prompt 97.Fa "const char *default_prompt" 98.Fc 99.Ft char * 100.Fn EVP_get_pw_prompt void 101.Sh DESCRIPTION 102.Fn EVP_read_pw_string 103writes the 104.Fa prompt 105to 106.Pa /dev/tty , 107or, if that could not be opened, to standard output, turns echo off, 108and reads an input string from 109.Pa /dev/tty , 110or, if that could not be opened, from standard input. 111The string is returned in 112.Fa buf , 113which must have space for at least 114.Fa length 115bytes. 116If the 117.Fa length 118argument exceeds 119.Dv BUFSIZ , 120.Dv BUFSIZ 121is used instead. 122If 123.Fa verify 124is set, the user is asked for the password twice and unless the two 125copies match, an error is returned. 126.Pp 127.Fn EVP_read_pw_string_min 128additionally checks that the password is at least 129.Fa min_length 130bytes long. 131.Pp 132.Fn EVP_set_pw_prompt 133sets a default prompt to a copy of 134.Fa default_prompt , 135or clears the default prompt if the 136.Fa default_prompt 137argument is 138.Dv NULL 139or an empty string. 140If the 141.Fa default_prompt 142argument is longer than 79 bytes, 143the copy is silently truncated to a string length of 79 bytes. 144.Pp 145As long as a default prompt is set, 146.Fn EVP_read_pw_string 147and 148.Fn EVP_read_pw_string_min 149can be called with a 150.Fa prompt 151argument of 152.Dv NULL , 153in which case the default prompt is used instead. 154.Sh RETURN VALUES 155.Fn EVP_read_pw_string 156and 157.Fn EVP_read_pw_string_min 158return 0 on success or a negative value on failure. 159.Pp 160They return \-1 if 161.Fa length 162is less than or equal to zero or on memory allocation failure. 163They return \-1 or \-2 if the internal call to 164.Xr UI_process 3 165fails. 166.Pp 167In addition, 168.Fa EVP_read_pw_string_min 169returns \-1 if 170.Fa min_length 171is negative, if 172.Fa length 173is less than or equal to 174.Fa min_length , 175or if the user entered a password shorter than 176.Fa min_length . 177.Pp 178.Fn EVP_get_pw_prompt 179returns an internal pointer to static memory containing the default prompt, or 180.Dv NULL 181if no default prompt is set. 182.Sh SEE ALSO 183.Xr UI_new 3 184.Sh HISTORY 185.Fn EVP_read_pw_string 186first appeared in SSLeay 0.5.1 and 187.Fn EVP_set_pw_prompt 188and 189.Fn EVP_get_pw_prompt 190in SSLeay 0.6.0. 191These functions have been available since 192.Ox 2.4 . 193.Pp 194.Fn EVP_read_pw_string_min 195first appeared in OpenSSL 1.0.0 196and has been available since 197.Ox 4.9 . 198