1*1dcdf01fSchristos /*
2*1dcdf01fSchristos  * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
3*1dcdf01fSchristos  *
4*1dcdf01fSchristos  * Licensed under the OpenSSL license (the "License").  You may not use
5*1dcdf01fSchristos  * this file except in compliance with the License.  You can obtain a copy
6*1dcdf01fSchristos  * in the file LICENSE in the source distribution or at
7*1dcdf01fSchristos  * https://www.openssl.org/source/license.html
8*1dcdf01fSchristos  */
9*1dcdf01fSchristos 
10*1dcdf01fSchristos #ifndef HEADER_UI_H
11*1dcdf01fSchristos # define HEADER_UI_H
12*1dcdf01fSchristos 
13*1dcdf01fSchristos # include <openssl/opensslconf.h>
14*1dcdf01fSchristos 
15*1dcdf01fSchristos # if OPENSSL_API_COMPAT < 0x10100000L
16*1dcdf01fSchristos #  include <openssl/crypto.h>
17*1dcdf01fSchristos # endif
18*1dcdf01fSchristos # include <openssl/safestack.h>
19*1dcdf01fSchristos # include <openssl/pem.h>
20*1dcdf01fSchristos # include <openssl/ossl_typ.h>
21*1dcdf01fSchristos # include <openssl/uierr.h>
22*1dcdf01fSchristos 
23*1dcdf01fSchristos /* For compatibility reasons, the macro OPENSSL_NO_UI is currently retained */
24*1dcdf01fSchristos # if OPENSSL_API_COMPAT < 0x10200000L
25*1dcdf01fSchristos #  ifdef OPENSSL_NO_UI_CONSOLE
26*1dcdf01fSchristos #   define OPENSSL_NO_UI
27*1dcdf01fSchristos #  endif
28*1dcdf01fSchristos # endif
29*1dcdf01fSchristos 
30*1dcdf01fSchristos # ifdef  __cplusplus
31*1dcdf01fSchristos extern "C" {
32*1dcdf01fSchristos # endif
33*1dcdf01fSchristos 
34*1dcdf01fSchristos /*
35*1dcdf01fSchristos  * All the following functions return -1 or NULL on error and in some cases
36*1dcdf01fSchristos  * (UI_process()) -2 if interrupted or in some other way cancelled. When
37*1dcdf01fSchristos  * everything is fine, they return 0, a positive value or a non-NULL pointer,
38*1dcdf01fSchristos  * all depending on their purpose.
39*1dcdf01fSchristos  */
40*1dcdf01fSchristos 
41*1dcdf01fSchristos /* Creators and destructor.   */
42*1dcdf01fSchristos UI *UI_new(void);
43*1dcdf01fSchristos UI *UI_new_method(const UI_METHOD *method);
44*1dcdf01fSchristos void UI_free(UI *ui);
45*1dcdf01fSchristos 
46*1dcdf01fSchristos /*-
47*1dcdf01fSchristos    The following functions are used to add strings to be printed and prompt
48*1dcdf01fSchristos    strings to prompt for data.  The names are UI_{add,dup}_<function>_string
49*1dcdf01fSchristos    and UI_{add,dup}_input_boolean.
50*1dcdf01fSchristos 
51*1dcdf01fSchristos    UI_{add,dup}_<function>_string have the following meanings:
52*1dcdf01fSchristos         add     add a text or prompt string.  The pointers given to these
53*1dcdf01fSchristos                 functions are used verbatim, no copying is done.
54*1dcdf01fSchristos         dup     make a copy of the text or prompt string, then add the copy
55*1dcdf01fSchristos                 to the collection of strings in the user interface.
56*1dcdf01fSchristos         <function>
57*1dcdf01fSchristos                 The function is a name for the functionality that the given
58*1dcdf01fSchristos                 string shall be used for.  It can be one of:
59*1dcdf01fSchristos                         input   use the string as data prompt.
60*1dcdf01fSchristos                         verify  use the string as verification prompt.  This
61*1dcdf01fSchristos                                 is used to verify a previous input.
62*1dcdf01fSchristos                         info    use the string for informational output.
63*1dcdf01fSchristos                         error   use the string for error output.
64*1dcdf01fSchristos    Honestly, there's currently no difference between info and error for the
65*1dcdf01fSchristos    moment.
66*1dcdf01fSchristos 
67*1dcdf01fSchristos    UI_{add,dup}_input_boolean have the same semantics for "add" and "dup",
68*1dcdf01fSchristos    and are typically used when one wants to prompt for a yes/no response.
69*1dcdf01fSchristos 
70*1dcdf01fSchristos    All of the functions in this group take a UI and a prompt string.
71*1dcdf01fSchristos    The string input and verify addition functions also take a flag argument,
72*1dcdf01fSchristos    a buffer for the result to end up with, a minimum input size and a maximum
73*1dcdf01fSchristos    input size (the result buffer MUST be large enough to be able to contain
74*1dcdf01fSchristos    the maximum number of characters).  Additionally, the verify addition
75*1dcdf01fSchristos    functions takes another buffer to compare the result against.
76*1dcdf01fSchristos    The boolean input functions take an action description string (which should
77*1dcdf01fSchristos    be safe to ignore if the expected user action is obvious, for example with
78*1dcdf01fSchristos    a dialog box with an OK button and a Cancel button), a string of acceptable
79*1dcdf01fSchristos    characters to mean OK and to mean Cancel.  The two last strings are checked
80*1dcdf01fSchristos    to make sure they don't have common characters.  Additionally, the same
81*1dcdf01fSchristos    flag argument as for the string input is taken, as well as a result buffer.
82*1dcdf01fSchristos    The result buffer is required to be at least one byte long.  Depending on
83*1dcdf01fSchristos    the answer, the first character from the OK or the Cancel character strings
84*1dcdf01fSchristos    will be stored in the first byte of the result buffer.  No NUL will be
85*1dcdf01fSchristos    added, so the result is *not* a string.
86*1dcdf01fSchristos 
87*1dcdf01fSchristos    On success, the all return an index of the added information.  That index
88*1dcdf01fSchristos    is useful when retrieving results with UI_get0_result(). */
89*1dcdf01fSchristos int UI_add_input_string(UI *ui, const char *prompt, int flags,
90*1dcdf01fSchristos                         char *result_buf, int minsize, int maxsize);
91*1dcdf01fSchristos int UI_dup_input_string(UI *ui, const char *prompt, int flags,
92*1dcdf01fSchristos                         char *result_buf, int minsize, int maxsize);
93*1dcdf01fSchristos int UI_add_verify_string(UI *ui, const char *prompt, int flags,
94*1dcdf01fSchristos                          char *result_buf, int minsize, int maxsize,
95*1dcdf01fSchristos                          const char *test_buf);
96*1dcdf01fSchristos int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
97*1dcdf01fSchristos                          char *result_buf, int minsize, int maxsize,
98*1dcdf01fSchristos                          const char *test_buf);
99*1dcdf01fSchristos int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
100*1dcdf01fSchristos                          const char *ok_chars, const char *cancel_chars,
101*1dcdf01fSchristos                          int flags, char *result_buf);
102*1dcdf01fSchristos int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
103*1dcdf01fSchristos                          const char *ok_chars, const char *cancel_chars,
104*1dcdf01fSchristos                          int flags, char *result_buf);
105*1dcdf01fSchristos int UI_add_info_string(UI *ui, const char *text);
106*1dcdf01fSchristos int UI_dup_info_string(UI *ui, const char *text);
107*1dcdf01fSchristos int UI_add_error_string(UI *ui, const char *text);
108*1dcdf01fSchristos int UI_dup_error_string(UI *ui, const char *text);
109*1dcdf01fSchristos 
110*1dcdf01fSchristos /* These are the possible flags.  They can be or'ed together. */
111*1dcdf01fSchristos /* Use to have echoing of input */
112*1dcdf01fSchristos # define UI_INPUT_FLAG_ECHO              0x01
113*1dcdf01fSchristos /*
114*1dcdf01fSchristos  * Use a default password.  Where that password is found is completely up to
115*1dcdf01fSchristos  * the application, it might for example be in the user data set with
116*1dcdf01fSchristos  * UI_add_user_data().  It is not recommended to have more than one input in
117*1dcdf01fSchristos  * each UI being marked with this flag, or the application might get
118*1dcdf01fSchristos  * confused.
119*1dcdf01fSchristos  */
120*1dcdf01fSchristos # define UI_INPUT_FLAG_DEFAULT_PWD       0x02
121*1dcdf01fSchristos 
122*1dcdf01fSchristos /*-
123*1dcdf01fSchristos  * The user of these routines may want to define flags of their own.  The core
124*1dcdf01fSchristos  * UI won't look at those, but will pass them on to the method routines.  They
125*1dcdf01fSchristos  * must use higher bits so they don't get confused with the UI bits above.
126*1dcdf01fSchristos  * UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use.  A good
127*1dcdf01fSchristos  * example of use is this:
128*1dcdf01fSchristos  *
129*1dcdf01fSchristos  *    #define MY_UI_FLAG1       (0x01 << UI_INPUT_FLAG_USER_BASE)
130*1dcdf01fSchristos  *
131*1dcdf01fSchristos */
132*1dcdf01fSchristos # define UI_INPUT_FLAG_USER_BASE 16
133*1dcdf01fSchristos 
134*1dcdf01fSchristos /*-
135*1dcdf01fSchristos  * The following function helps construct a prompt.  object_desc is a
136*1dcdf01fSchristos  * textual short description of the object, for example "pass phrase",
137*1dcdf01fSchristos  * and object_name is the name of the object (might be a card name or
138*1dcdf01fSchristos  * a file name.
139*1dcdf01fSchristos  * The returned string shall always be allocated on the heap with
140*1dcdf01fSchristos  * OPENSSL_malloc(), and need to be free'd with OPENSSL_free().
141*1dcdf01fSchristos  *
142*1dcdf01fSchristos  * If the ui_method doesn't contain a pointer to a user-defined prompt
143*1dcdf01fSchristos  * constructor, a default string is built, looking like this:
144*1dcdf01fSchristos  *
145*1dcdf01fSchristos  *       "Enter {object_desc} for {object_name}:"
146*1dcdf01fSchristos  *
147*1dcdf01fSchristos  * So, if object_desc has the value "pass phrase" and object_name has
148*1dcdf01fSchristos  * the value "foo.key", the resulting string is:
149*1dcdf01fSchristos  *
150*1dcdf01fSchristos  *       "Enter pass phrase for foo.key:"
151*1dcdf01fSchristos */
152*1dcdf01fSchristos char *UI_construct_prompt(UI *ui_method,
153*1dcdf01fSchristos                           const char *object_desc, const char *object_name);
154*1dcdf01fSchristos 
155*1dcdf01fSchristos /*
156*1dcdf01fSchristos  * The following function is used to store a pointer to user-specific data.
157*1dcdf01fSchristos  * Any previous such pointer will be returned and replaced.
158*1dcdf01fSchristos  *
159*1dcdf01fSchristos  * For callback purposes, this function makes a lot more sense than using
160*1dcdf01fSchristos  * ex_data, since the latter requires that different parts of OpenSSL or
161*1dcdf01fSchristos  * applications share the same ex_data index.
162*1dcdf01fSchristos  *
163*1dcdf01fSchristos  * Note that the UI_OpenSSL() method completely ignores the user data. Other
164*1dcdf01fSchristos  * methods may not, however.
165*1dcdf01fSchristos  */
166*1dcdf01fSchristos void *UI_add_user_data(UI *ui, void *user_data);
167*1dcdf01fSchristos /*
168*1dcdf01fSchristos  * Alternatively, this function is used to duplicate the user data.
169*1dcdf01fSchristos  * This uses the duplicator method function.  The destroy function will
170*1dcdf01fSchristos  * be used to free the user data in this case.
171*1dcdf01fSchristos  */
172*1dcdf01fSchristos int UI_dup_user_data(UI *ui, void *user_data);
173*1dcdf01fSchristos /* We need a user data retrieving function as well.  */
174*1dcdf01fSchristos void *UI_get0_user_data(UI *ui);
175*1dcdf01fSchristos 
176*1dcdf01fSchristos /* Return the result associated with a prompt given with the index i. */
177*1dcdf01fSchristos const char *UI_get0_result(UI *ui, int i);
178*1dcdf01fSchristos int UI_get_result_length(UI *ui, int i);
179*1dcdf01fSchristos 
180*1dcdf01fSchristos /* When all strings have been added, process the whole thing. */
181*1dcdf01fSchristos int UI_process(UI *ui);
182*1dcdf01fSchristos 
183*1dcdf01fSchristos /*
184*1dcdf01fSchristos  * Give a user interface parameterised control commands.  This can be used to
185*1dcdf01fSchristos  * send down an integer, a data pointer or a function pointer, as well as be
186*1dcdf01fSchristos  * used to get information from a UI.
187*1dcdf01fSchristos  */
188*1dcdf01fSchristos int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void));
189*1dcdf01fSchristos 
190*1dcdf01fSchristos /* The commands */
191*1dcdf01fSchristos /*
192*1dcdf01fSchristos  * Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the
193*1dcdf01fSchristos  * OpenSSL error stack before printing any info or added error messages and
194*1dcdf01fSchristos  * before any prompting.
195*1dcdf01fSchristos  */
196*1dcdf01fSchristos # define UI_CTRL_PRINT_ERRORS            1
197*1dcdf01fSchristos /*
198*1dcdf01fSchristos  * Check if a UI_process() is possible to do again with the same instance of
199*1dcdf01fSchristos  * a user interface.  This makes UI_ctrl() return 1 if it is redoable, and 0
200*1dcdf01fSchristos  * if not.
201*1dcdf01fSchristos  */
202*1dcdf01fSchristos # define UI_CTRL_IS_REDOABLE             2
203*1dcdf01fSchristos 
204*1dcdf01fSchristos /* Some methods may use extra data */
205*1dcdf01fSchristos # define UI_set_app_data(s,arg)         UI_set_ex_data(s,0,arg)
206*1dcdf01fSchristos # define UI_get_app_data(s)             UI_get_ex_data(s,0)
207*1dcdf01fSchristos 
208*1dcdf01fSchristos # define UI_get_ex_new_index(l, p, newf, dupf, freef) \
209*1dcdf01fSchristos     CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, l, p, newf, dupf, freef)
210*1dcdf01fSchristos int UI_set_ex_data(UI *r, int idx, void *arg);
211*1dcdf01fSchristos void *UI_get_ex_data(UI *r, int idx);
212*1dcdf01fSchristos 
213*1dcdf01fSchristos /* Use specific methods instead of the built-in one */
214*1dcdf01fSchristos void UI_set_default_method(const UI_METHOD *meth);
215*1dcdf01fSchristos const UI_METHOD *UI_get_default_method(void);
216*1dcdf01fSchristos const UI_METHOD *UI_get_method(UI *ui);
217*1dcdf01fSchristos const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);
218*1dcdf01fSchristos 
219*1dcdf01fSchristos # ifndef OPENSSL_NO_UI_CONSOLE
220*1dcdf01fSchristos 
221*1dcdf01fSchristos /* The method with all the built-in thingies */
222*1dcdf01fSchristos UI_METHOD *UI_OpenSSL(void);
223*1dcdf01fSchristos 
224*1dcdf01fSchristos # endif
225*1dcdf01fSchristos 
226*1dcdf01fSchristos /*
227*1dcdf01fSchristos  * NULL method.  Literally does nothing, but may serve as a placeholder
228*1dcdf01fSchristos  * to avoid internal default.
229*1dcdf01fSchristos  */
230*1dcdf01fSchristos const UI_METHOD *UI_null(void);
231*1dcdf01fSchristos 
232*1dcdf01fSchristos /* ---------- For method writers ---------- */
233*1dcdf01fSchristos /*-
234*1dcdf01fSchristos    A method contains a number of functions that implement the low level
235*1dcdf01fSchristos    of the User Interface.  The functions are:
236*1dcdf01fSchristos 
237*1dcdf01fSchristos         an opener       This function starts a session, maybe by opening
238*1dcdf01fSchristos                         a channel to a tty, or by opening a window.
239*1dcdf01fSchristos         a writer        This function is called to write a given string,
240*1dcdf01fSchristos                         maybe to the tty, maybe as a field label in a
241*1dcdf01fSchristos                         window.
242*1dcdf01fSchristos         a flusher       This function is called to flush everything that
243*1dcdf01fSchristos                         has been output so far.  It can be used to actually
244*1dcdf01fSchristos                         display a dialog box after it has been built.
245*1dcdf01fSchristos         a reader        This function is called to read a given prompt,
246*1dcdf01fSchristos                         maybe from the tty, maybe from a field in a
247*1dcdf01fSchristos                         window.  Note that it's called with all string
248*1dcdf01fSchristos                         structures, not only the prompt ones, so it must
249*1dcdf01fSchristos                         check such things itself.
250*1dcdf01fSchristos         a closer        This function closes the session, maybe by closing
251*1dcdf01fSchristos                         the channel to the tty, or closing the window.
252*1dcdf01fSchristos 
253*1dcdf01fSchristos    All these functions are expected to return:
254*1dcdf01fSchristos 
255*1dcdf01fSchristos         0       on error.
256*1dcdf01fSchristos         1       on success.
257*1dcdf01fSchristos         -1      on out-of-band events, for example if some prompting has
258*1dcdf01fSchristos                 been canceled (by pressing Ctrl-C, for example).  This is
259*1dcdf01fSchristos                 only checked when returned by the flusher or the reader.
260*1dcdf01fSchristos 
261*1dcdf01fSchristos    The way this is used, the opener is first called, then the writer for all
262*1dcdf01fSchristos    strings, then the flusher, then the reader for all strings and finally the
263*1dcdf01fSchristos    closer.  Note that if you want to prompt from a terminal or other command
264*1dcdf01fSchristos    line interface, the best is to have the reader also write the prompts
265*1dcdf01fSchristos    instead of having the writer do it.  If you want to prompt from a dialog
266*1dcdf01fSchristos    box, the writer can be used to build up the contents of the box, and the
267*1dcdf01fSchristos    flusher to actually display the box and run the event loop until all data
268*1dcdf01fSchristos    has been given, after which the reader only grabs the given data and puts
269*1dcdf01fSchristos    them back into the UI strings.
270*1dcdf01fSchristos 
271*1dcdf01fSchristos    All method functions take a UI as argument.  Additionally, the writer and
272*1dcdf01fSchristos    the reader take a UI_STRING.
273*1dcdf01fSchristos */
274*1dcdf01fSchristos 
275*1dcdf01fSchristos /*
276*1dcdf01fSchristos  * The UI_STRING type is the data structure that contains all the needed info
277*1dcdf01fSchristos  * about a string or a prompt, including test data for a verification prompt.
278*1dcdf01fSchristos  */
279*1dcdf01fSchristos typedef struct ui_string_st UI_STRING;
280*1dcdf01fSchristos DEFINE_STACK_OF(UI_STRING)
281*1dcdf01fSchristos 
282*1dcdf01fSchristos /*
283*1dcdf01fSchristos  * The different types of strings that are currently supported. This is only
284*1dcdf01fSchristos  * needed by method authors.
285*1dcdf01fSchristos  */
286*1dcdf01fSchristos enum UI_string_types {
287*1dcdf01fSchristos     UIT_NONE = 0,
288*1dcdf01fSchristos     UIT_PROMPT,                 /* Prompt for a string */
289*1dcdf01fSchristos     UIT_VERIFY,                 /* Prompt for a string and verify */
290*1dcdf01fSchristos     UIT_BOOLEAN,                /* Prompt for a yes/no response */
291*1dcdf01fSchristos     UIT_INFO,                   /* Send info to the user */
292*1dcdf01fSchristos     UIT_ERROR                   /* Send an error message to the user */
293*1dcdf01fSchristos };
294*1dcdf01fSchristos 
295*1dcdf01fSchristos /* Create and manipulate methods */
296*1dcdf01fSchristos UI_METHOD *UI_create_method(const char *name);
297*1dcdf01fSchristos void UI_destroy_method(UI_METHOD *ui_method);
298*1dcdf01fSchristos int UI_method_set_opener(UI_METHOD *method, int (*opener) (UI *ui));
299*1dcdf01fSchristos int UI_method_set_writer(UI_METHOD *method,
300*1dcdf01fSchristos                          int (*writer) (UI *ui, UI_STRING *uis));
301*1dcdf01fSchristos int UI_method_set_flusher(UI_METHOD *method, int (*flusher) (UI *ui));
302*1dcdf01fSchristos int UI_method_set_reader(UI_METHOD *method,
303*1dcdf01fSchristos                          int (*reader) (UI *ui, UI_STRING *uis));
304*1dcdf01fSchristos int UI_method_set_closer(UI_METHOD *method, int (*closer) (UI *ui));
305*1dcdf01fSchristos int UI_method_set_data_duplicator(UI_METHOD *method,
306*1dcdf01fSchristos                                   void *(*duplicator) (UI *ui, void *ui_data),
307*1dcdf01fSchristos                                   void (*destructor)(UI *ui, void *ui_data));
308*1dcdf01fSchristos int UI_method_set_prompt_constructor(UI_METHOD *method,
309*1dcdf01fSchristos                                      char *(*prompt_constructor) (UI *ui,
310*1dcdf01fSchristos                                                                   const char
311*1dcdf01fSchristos                                                                   *object_desc,
312*1dcdf01fSchristos                                                                   const char
313*1dcdf01fSchristos                                                                   *object_name));
314*1dcdf01fSchristos int UI_method_set_ex_data(UI_METHOD *method, int idx, void *data);
315*1dcdf01fSchristos int (*UI_method_get_opener(const UI_METHOD *method)) (UI *);
316*1dcdf01fSchristos int (*UI_method_get_writer(const UI_METHOD *method)) (UI *, UI_STRING *);
317*1dcdf01fSchristos int (*UI_method_get_flusher(const UI_METHOD *method)) (UI *);
318*1dcdf01fSchristos int (*UI_method_get_reader(const UI_METHOD *method)) (UI *, UI_STRING *);
319*1dcdf01fSchristos int (*UI_method_get_closer(const UI_METHOD *method)) (UI *);
320*1dcdf01fSchristos char *(*UI_method_get_prompt_constructor(const UI_METHOD *method))
321*1dcdf01fSchristos     (UI *, const char *, const char *);
322*1dcdf01fSchristos void *(*UI_method_get_data_duplicator(const UI_METHOD *method)) (UI *, void *);
323*1dcdf01fSchristos void (*UI_method_get_data_destructor(const UI_METHOD *method)) (UI *, void *);
324*1dcdf01fSchristos const void *UI_method_get_ex_data(const UI_METHOD *method, int idx);
325*1dcdf01fSchristos 
326*1dcdf01fSchristos /*
327*1dcdf01fSchristos  * The following functions are helpers for method writers to access relevant
328*1dcdf01fSchristos  * data from a UI_STRING.
329*1dcdf01fSchristos  */
330*1dcdf01fSchristos 
331*1dcdf01fSchristos /* Return type of the UI_STRING */
332*1dcdf01fSchristos enum UI_string_types UI_get_string_type(UI_STRING *uis);
333*1dcdf01fSchristos /* Return input flags of the UI_STRING */
334*1dcdf01fSchristos int UI_get_input_flags(UI_STRING *uis);
335*1dcdf01fSchristos /* Return the actual string to output (the prompt, info or error) */
336*1dcdf01fSchristos const char *UI_get0_output_string(UI_STRING *uis);
337*1dcdf01fSchristos /*
338*1dcdf01fSchristos  * Return the optional action string to output (the boolean prompt
339*1dcdf01fSchristos  * instruction)
340*1dcdf01fSchristos  */
341*1dcdf01fSchristos const char *UI_get0_action_string(UI_STRING *uis);
342*1dcdf01fSchristos /* Return the result of a prompt */
343*1dcdf01fSchristos const char *UI_get0_result_string(UI_STRING *uis);
344*1dcdf01fSchristos int UI_get_result_string_length(UI_STRING *uis);
345*1dcdf01fSchristos /*
346*1dcdf01fSchristos  * Return the string to test the result against.  Only useful with verifies.
347*1dcdf01fSchristos  */
348*1dcdf01fSchristos const char *UI_get0_test_string(UI_STRING *uis);
349*1dcdf01fSchristos /* Return the required minimum size of the result */
350*1dcdf01fSchristos int UI_get_result_minsize(UI_STRING *uis);
351*1dcdf01fSchristos /* Return the required maximum size of the result */
352*1dcdf01fSchristos int UI_get_result_maxsize(UI_STRING *uis);
353*1dcdf01fSchristos /* Set the result of a UI_STRING. */
354*1dcdf01fSchristos int UI_set_result(UI *ui, UI_STRING *uis, const char *result);
355*1dcdf01fSchristos int UI_set_result_ex(UI *ui, UI_STRING *uis, const char *result, int len);
356*1dcdf01fSchristos 
357*1dcdf01fSchristos /* A couple of popular utility functions */
358*1dcdf01fSchristos int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,
359*1dcdf01fSchristos                            int verify);
360*1dcdf01fSchristos int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,
361*1dcdf01fSchristos                     int verify);
362*1dcdf01fSchristos UI_METHOD *UI_UTIL_wrap_read_pem_callback(pem_password_cb *cb, int rwflag);
363*1dcdf01fSchristos 
364*1dcdf01fSchristos 
365*1dcdf01fSchristos # ifdef  __cplusplus
366*1dcdf01fSchristos }
367*1dcdf01fSchristos # endif
368*1dcdf01fSchristos #endif
369