Initial import from FreeBSD RELENG_4:
[dragonfly.git] / secure / lib / libcrypto / man / ui.3
1 .\" Automatically generated by Pod::Man version 1.15
2 .\" Wed Feb 19 16:43:07 2003
3 .\"
4 .\" Standard preamble:
5 .\" ======================================================================
6 .de Sh \" Subsection heading
7 .br
8 .if t .Sp
9 .ne 5
10 .PP
11 \fB\\$1\fR
12 .PP
13 ..
14 .de Sp \" Vertical space (when we can't use .PP)
15 .if t .sp .5v
16 .if n .sp
17 ..
18 .de Ip \" List item
19 .br
20 .ie \\n(.$>=3 .ne \\$3
21 .el .ne 3
22 .IP "\\$1" \\$2
23 ..
24 .de Vb \" Begin verbatim text
25 .ft CW
26 .nf
27 .ne \\$1
28 ..
29 .de Ve \" End verbatim text
30 .ft R
31
32 .fi
33 ..
34 .\" Set up some character translations and predefined strings.  \*(-- will
35 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
36 .\" double quote, and \*(R" will give a right double quote.  | will give a
37 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used
38 .\" to do unbreakable dashes and therefore won't be available.  \*(C` and
39 .\" \*(C' expand to `' in nroff, nothing in troff, for use with C<>
40 .tr \(*W-|\(bv\*(Tr
41 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
42 .ie n \{\
43 .    ds -- \(*W-
44 .    ds PI pi
45 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
46 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
47 .    ds L" ""
48 .    ds R" ""
49 .    ds C` ""
50 .    ds C' ""
51 'br\}
52 .el\{\
53 .    ds -- \|\(em\|
54 .    ds PI \(*p
55 .    ds L" ``
56 .    ds R" ''
57 'br\}
58 .\"
59 .\" If the F register is turned on, we'll generate index entries on stderr
60 .\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
61 .\" index entries marked with X<> in POD.  Of course, you'll have to process
62 .\" the output yourself in some meaningful fashion.
63 .if \nF \{\
64 .    de IX
65 .    tm Index:\\$1\t\\n%\t"\\$2"
66 ..
67 .    nr % 0
68 .    rr F
69 .\}
70 .\"
71 .\" For nroff, turn off justification.  Always turn off hyphenation; it
72 .\" makes way too many mistakes in technical documents.
73 .hy 0
74 .if n .na
75 .\"
76 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
77 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
78 .bd B 3
79 .    \" fudge factors for nroff and troff
80 .if n \{\
81 .    ds #H 0
82 .    ds #V .8m
83 .    ds #F .3m
84 .    ds #[ \f1
85 .    ds #] \fP
86 .\}
87 .if t \{\
88 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
89 .    ds #V .6m
90 .    ds #F 0
91 .    ds #[ \&
92 .    ds #] \&
93 .\}
94 .    \" simple accents for nroff and troff
95 .if n \{\
96 .    ds ' \&
97 .    ds ` \&
98 .    ds ^ \&
99 .    ds , \&
100 .    ds ~ ~
101 .    ds /
102 .\}
103 .if t \{\
104 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
105 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
106 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
107 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
108 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
109 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
110 .\}
111 .    \" troff and (daisy-wheel) nroff accents
112 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
113 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
114 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
115 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
116 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
117 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
118 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
119 .ds ae a\h'-(\w'a'u*4/10)'e
120 .ds Ae A\h'-(\w'A'u*4/10)'E
121 .    \" corrections for vroff
122 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
123 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
124 .    \" for low resolution devices (crt and lpr)
125 .if \n(.H>23 .if \n(.V>19 \
126 \{\
127 .    ds : e
128 .    ds 8 ss
129 .    ds o a
130 .    ds d- d\h'-1'\(ga
131 .    ds D- D\h'-1'\(hy
132 .    ds th \o'bp'
133 .    ds Th \o'LP'
134 .    ds ae ae
135 .    ds Ae AE
136 .\}
137 .rm #[ #] #H #V #F C
138 .\" ======================================================================
139 .\"
140 .IX Title "ui 3"
141 .TH ui 3 "0.9.7a" "2003-02-19" "OpenSSL"
142 .UC
143 .SH "NAME"
144 UI_new, UI_new_method, UI_free, UI_add_input_string, UI_dup_input_string,
145 UI_add_verify_string, UI_dup_verify_string, UI_add_input_boolean,
146 UI_dup_input_boolean, UI_add_info_string, UI_dup_info_string,
147 UI_add_error_string, UI_dup_error_string, UI_construct_prompt
148 UI_add_user_data, UI_get0_user_data, UI_get0_result, UI_process,
149 UI_ctrl, UI_set_default_method, UI_get_default_method, UI_get_method,
150 UI_set_method, UI_OpenSSL, ERR_load_UI_strings \- New User Interface
151 .SH "SYNOPSIS"
152 .IX Header "SYNOPSIS"
153 .Vb 1
154 \& #include <openssl/ui.h>
155 .Ve
156 .Vb 2
157 \& typedef struct ui_st UI;
158 \& typedef struct ui_method_st UI_METHOD;
159 .Ve
160 .Vb 3
161 \& UI *UI_new(void);
162 \& UI *UI_new_method(const UI_METHOD *method);
163 \& void UI_free(UI *ui);
164 .Ve
165 .Vb 18
166 \& int UI_add_input_string(UI *ui, const char *prompt, int flags,
167 \&        char *result_buf, int minsize, int maxsize);
168 \& int UI_dup_input_string(UI *ui, const char *prompt, int flags,
169 \&        char *result_buf, int minsize, int maxsize);
170 \& int UI_add_verify_string(UI *ui, const char *prompt, int flags,
171 \&        char *result_buf, int minsize, int maxsize, const char *test_buf);
172 \& int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
173 \&        char *result_buf, int minsize, int maxsize, const char *test_buf);
174 \& int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
175 \&        const char *ok_chars, const char *cancel_chars,
176 \&        int flags, char *result_buf);
177 \& int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
178 \&        const char *ok_chars, const char *cancel_chars,
179 \&        int flags, char *result_buf);
180 \& int UI_add_info_string(UI *ui, const char *text);
181 \& int UI_dup_info_string(UI *ui, const char *text);
182 \& int UI_add_error_string(UI *ui, const char *text);
183 \& int UI_dup_error_string(UI *ui, const char *text);
184 .Ve
185 .Vb 3
186 \& /* These are the possible flags.  They can be or'ed together. */
187 \& #define UI_INPUT_FLAG_ECHO             0x01
188 \& #define UI_INPUT_FLAG_DEFAULT_PWD      0x02
189 .Ve
190 .Vb 2
191 \& char *UI_construct_prompt(UI *ui_method,
192 \&        const char *object_desc, const char *object_name);
193 .Ve
194 .Vb 2
195 \& void *UI_add_user_data(UI *ui, void *user_data);
196 \& void *UI_get0_user_data(UI *ui);
197 .Ve
198 .Vb 1
199 \& const char *UI_get0_result(UI *ui, int i);
200 .Ve
201 .Vb 1
202 \& int UI_process(UI *ui);
203 .Ve
204 .Vb 3
205 \& int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)());
206 \& #define UI_CTRL_PRINT_ERRORS           1
207 \& #define UI_CTRL_IS_REDOABLE            2
208 .Ve
209 .Vb 4
210 \& void UI_set_default_method(const UI_METHOD *meth);
211 \& const UI_METHOD *UI_get_default_method(void);
212 \& const UI_METHOD *UI_get_method(UI *ui);
213 \& const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);
214 .Ve
215 .Vb 1
216 \& UI_METHOD *UI_OpenSSL(void);
217 .Ve
218 .SH "DESCRIPTION"
219 .IX Header "DESCRIPTION"
220 \&\s-1UI\s0 stands for User Interface, and is general purpose set of routines to
221 prompt the user for text-based information.  Through user-written methods
222 (see ui_create(3)), prompting can be done in any way
223 imaginable, be it plain text prompting, through dialog boxes or from a
224 cell phone.
225 .PP
226 All the functions work through a context of the type \s-1UI\s0.  This context
227 contains all the information needed to prompt correctly as well as a
228 reference to a \s-1UI_METHOD\s0, which is an ordered vector of functions that
229 carry out the actual prompting.
230 .PP
231 The first thing to do is to create a \s-1UI\s0 with \fIUI_new()\fR or \fIUI_new_method()\fR,
232 then add information to it with the UI_add or UI_dup functions.  Also,
233 user-defined random data can be passed down to the underlying method
234 through calls to UI_add_user_data.  The default \s-1UI\s0 method doesn't care
235 about these data, but other methods might.  Finally, use \fIUI_process()\fR
236 to actually perform the prompting and \fIUI_get0_result()\fR to find the result
237 to the prompt.
238 .PP
239 A \s-1UI\s0 can contain more than one prompt, which are performed in the given
240 sequence.  Each prompt gets an index number which is returned by the
241 UI_add and UI_dup functions, and has to be used to get the corresponding
242 result with \fIUI_get0_result()\fR.
243 .PP
244 The functions are as follows:
245 .PP
246 \&\fIUI_new()\fR creates a new \s-1UI\s0 using the default \s-1UI\s0 method.  When done with
247 this \s-1UI\s0, it should be freed using \fIUI_free()\fR.
248 .PP
249 \&\fIUI_new_method()\fR creates a new \s-1UI\s0 using the given \s-1UI\s0 method.  When done with
250 this \s-1UI\s0, it should be freed using \fIUI_free()\fR.
251 .PP
252 \&\fIUI_OpenSSL()\fR returns the built-in \s-1UI\s0 method (note: not the default one,
253 since the default can be changed.  See further on).  This method is the
254 most machine/OS dependent part of OpenSSL and normally generates the
255 most problems when porting.
256 .PP
257 \&\fIUI_free()\fR removes a \s-1UI\s0 from memory, along with all other pieces of memory
258 that's connected to it, like duplicated input strings, results and others.
259 .PP
260 \&\fIUI_add_input_string()\fR and \fIUI_add_verify_string()\fR add a prompt to the \s-1UI\s0,
261 as well as flags and a result buffer and the desired minimum and maximum
262 sizes of the result.  The given information is used to prompt for
263 information, for example a password, and to verify a password (i.e. having
264 the user enter it twice and check that the same string was entered twice).
265 \&\fIUI_add_verify_string()\fR takes and extra argument that should be a pointer
266 to the result buffer of the input string that it's supposed to verify, or
267 verification will fail.
268 .PP
269 \&\fIUI_add_input_boolean()\fR adds a prompt to the \s-1UI\s0 that's supposed to be answered
270 in a boolean way, with a single character for yes and a different character
271 for no.  A set of characters that can be used to cancel the prompt is given
272 as well.  The prompt itself is really divided in two, one part being the
273 descriptive text (given through the \fIprompt\fR argument) and one describing
274 the possible answers (given through the \fIaction_desc\fR argument).
275 .PP
276 \&\fIUI_add_info_string()\fR and \fIUI_add_error_string()\fR add strings that are shown at
277 the same time as the prompt for extra information or to show an error string.
278 The difference between the two is only conceptual.  With the builtin method,
279 there's no technical difference between them.  Other methods may make a
280 difference between them, however.
281 .PP
282 The flags currently supported are \s-1UI_INPUT_FLAG_ECHO\s0, which is relevant for
283 \&\fIUI_add_input_string()\fR and will have the users response be echoed (when
284 prompting for a password, this flag should obviously not be used, and
285 \&\s-1UI_INPUT_FLAG_DEFAULT_PWD\s0, which means that a default password of some
286 sort will be used (completely depending on the application and the \s-1UI\s0
287 method).
288 .PP
289 \&\fIUI_dup_input_string()\fR, \fIUI_dup_verify_string()\fR, \fIUI_dup_input_boolean()\fR,
290 \&\fIUI_dup_info_string()\fR and \fIUI_dup_error_string()\fR are basically the same
291 as their UI_add counterparts, except that they make their own copies
292 of all strings.
293 .PP
294 \&\fIUI_construct_prompt()\fR is a helper function that can be used to create
295 a prompt from two pieces of information: an description and a name.
296 The default constructor (if there is none provided by the method used)
297 creates a string "Enter \fIdescription\fR for \fIname\fR:\*(L".  With the
298 description \*(R"pass phrase\*(L" and the file name \*(R"foo.key\*(L", that becomes
299 \&\*(R"Enter pass phrase for foo.key:".  Other methods may create whatever
300 string and may include encodings that will be processed by the other
301 method functions.
302 .PP
303 \&\fIUI_add_user_data()\fR adds a piece of memory for the method to use at any
304 time.  The builtin \s-1UI\s0 method doesn't care about this info.  Note that several
305 calls to this function doesn't add data, it replaces the previous blob
306 with the one given as argument.
307 .PP
308 \&\fIUI_get0_user_data()\fR retrieves the data that has last been given to the
309 \&\s-1UI\s0 with \fIUI_add_user_data()\fR.
310 .PP
311 \&\fIUI_get0_result()\fR returns a pointer to the result buffer associated with
312 the information indexed by \fIi\fR.
313 .PP
314 \&\fIUI_process()\fR goes through the information given so far, does all the printing
315 and prompting and returns.
316 .PP
317 \&\fIUI_ctrl()\fR adds extra control for the application author.  For now, it
318 understands two commands: \s-1UI_CTRL_PRINT_ERRORS\s0, which makes \fIUI_process()\fR
319 print the OpenSSL error stack as part of processing the \s-1UI\s0, and
320 \&\s-1UI_CTRL_IS_REDOABLE\s0, which returns a flag saying if the used \s-1UI\s0 can
321 be used again or not.
322 .PP
323 \&\fIUI_set_default_method()\fR changes the default \s-1UI\s0 method to the one given.
324 .PP
325 \&\fIUI_get_default_method()\fR returns a pointer to the current default \s-1UI\s0 method.
326 .PP
327 \&\fIUI_get_method()\fR returns the \s-1UI\s0 method associated with a given \s-1UI\s0.
328 .PP
329 \&\fIUI_set_method()\fR changes the \s-1UI\s0 method associated with a given \s-1UI\s0.
330 .SH "SEE ALSO"
331 .IX Header "SEE ALSO"
332 ui_create(3), ui_compat(3)
333 .SH "HISTORY"
334 .IX Header "HISTORY"
335 The \s-1UI\s0 section was first introduced in OpenSSL 0.9.7.
336 .SH "AUTHOR"
337 .IX Header "AUTHOR"
338 Richard Levitte (richard@levitte.org) for the OpenSSL project
339 (http://www.openssl.org).