diff options
Diffstat (limited to 'src/lib/libcrypto/man/ui_new.3')
-rw-r--r-- | src/lib/libcrypto/man/ui_new.3 | 384 |
1 files changed, 384 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/ui_new.3 b/src/lib/libcrypto/man/ui_new.3 new file mode 100644 index 0000000000..d841c212d8 --- /dev/null +++ b/src/lib/libcrypto/man/ui_new.3 | |||
@@ -0,0 +1,384 @@ | |||
1 | .Dd $Mdocdate: November 12 2015 $ | ||
2 | .Dt UI_NEW 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm UI_new , | ||
6 | .Nm UI_new_method , | ||
7 | .Nm UI_free , | ||
8 | .Nm UI_add_input_string , | ||
9 | .Nm UI_dup_input_string , | ||
10 | .Nm UI_add_verify_string , | ||
11 | .Nm UI_dup_verify_string , | ||
12 | .Nm UI_add_input_boolean , | ||
13 | .Nm UI_dup_input_boolean , | ||
14 | .Nm UI_add_info_string , | ||
15 | .Nm UI_dup_info_string , | ||
16 | .Nm UI_add_error_string , | ||
17 | .Nm UI_dup_error_string , | ||
18 | .Nm UI_construct_prompt , | ||
19 | .Nm UI_add_user_data , | ||
20 | .Nm UI_get0_user_data , | ||
21 | .Nm UI_get0_result , | ||
22 | .Nm UI_process , | ||
23 | .Nm UI_ctrl , | ||
24 | .Nm UI_set_default_method , | ||
25 | .Nm UI_get_default_method , | ||
26 | .Nm UI_get_method , | ||
27 | .Nm UI_set_method , | ||
28 | .Nm UI_OpenSSL , | ||
29 | .Nm ERR_load_UI_strings | ||
30 | .Nd New User Interface | ||
31 | .Sh SYNOPSIS | ||
32 | .In openssl/ui.h | ||
33 | .Fd typedef struct ui_st UI; | ||
34 | .Fd typedef struct ui_method_st UI_METHOD; | ||
35 | .Ft UI * | ||
36 | .Fn UI_new void | ||
37 | .Ft UI * | ||
38 | .Fo UI_new_method | ||
39 | .Fa "const UI_METHOD *method" | ||
40 | .Fc | ||
41 | .Ft void | ||
42 | .Fo UI_free | ||
43 | .Fa "UI *ui" | ||
44 | .Fc | ||
45 | .Ft int | ||
46 | .Fo UI_add_input_string | ||
47 | .Fa "UI *ui" | ||
48 | .Fa "const char *prompt" | ||
49 | .Fa "int flags" | ||
50 | .Fa "char *result_buf" | ||
51 | .Fa "int minsize" | ||
52 | .Fa "int maxsize" | ||
53 | .Fc | ||
54 | .Ft int | ||
55 | .Fo UI_dup_input_string | ||
56 | .Fa "UI *ui" | ||
57 | .Fa "const char *prompt" | ||
58 | .Fa "int flags" | ||
59 | .Fa "char *result_buf" | ||
60 | .Fa "int minsize" | ||
61 | .Fa "int maxsize" | ||
62 | .Fc | ||
63 | .Ft int | ||
64 | .Fo UI_add_verify_string | ||
65 | .Fa "UI *ui" | ||
66 | .Fa "const char *prompt" | ||
67 | .Fa "int flags" | ||
68 | .Fa "char *result_buf" | ||
69 | .Fa "int minsize" | ||
70 | .Fa "int maxsize" | ||
71 | .Fa "const char *test_buf" | ||
72 | .Fc | ||
73 | .Ft int | ||
74 | .Fo UI_dup_verify_string | ||
75 | .Fa "UI *ui" | ||
76 | .Fa "const char *prompt" | ||
77 | .Fa "int flags" | ||
78 | .Fa "char *result_buf" | ||
79 | .Fa "int minsize" | ||
80 | .Fa "int maxsize" | ||
81 | .Fa "const char *test_buf" | ||
82 | .Fc | ||
83 | .Ft int | ||
84 | .Fo UI_add_input_boolean | ||
85 | .Fa "UI *ui" | ||
86 | .Fa "const char *prompt" | ||
87 | .Fa "const char *action_desc" | ||
88 | .Fa "const char *ok_chars" | ||
89 | .Fa "const char *cancel_chars" | ||
90 | .Fa "int flags" | ||
91 | .Fa "char *result_buf" | ||
92 | .Fc | ||
93 | .Ft int | ||
94 | .Fo UI_dup_input_boolean | ||
95 | .Fa "UI *ui" | ||
96 | .Fa "const char *prompt" | ||
97 | .Fa "const char *action_desc" | ||
98 | .Fa "const char *ok_chars" | ||
99 | .Fa "const char *cancel_chars" | ||
100 | .Fa "int flags" | ||
101 | .Fa "char *result_buf" | ||
102 | .Fc | ||
103 | .Ft int | ||
104 | .Fo UI_add_info_string | ||
105 | .Fa "UI *ui" | ||
106 | .Fa "const char *text" | ||
107 | .Fc | ||
108 | .Ft int | ||
109 | .Fo UI_dup_info_string | ||
110 | .Fa "UI *ui" | ||
111 | .Fa "const char *text" | ||
112 | .Fc | ||
113 | .Ft int | ||
114 | .Fo UI_add_error_string | ||
115 | .Fa "UI *ui" | ||
116 | .Fa "const char *text" | ||
117 | .Fc | ||
118 | .Ft int | ||
119 | .Fo UI_dup_error_string | ||
120 | .Fa "UI *ui" | ||
121 | .Fa "const char *text" | ||
122 | .Fc | ||
123 | .Fd /* These are the possible flags. They can be OR'ed together. */ | ||
124 | .Fd #define UI_INPUT_FLAG_ECHO 0x01 | ||
125 | .Fd #define UI_INPUT_FLAG_DEFAULT_PWD 0x02 | ||
126 | .Ft char * | ||
127 | .Fo UI_construct_prompt | ||
128 | .Fa "UI *ui_method" | ||
129 | .Fa "const char *object_desc" | ||
130 | .Fa "const char *object_name" | ||
131 | .Fc | ||
132 | .Ft void * | ||
133 | .Fo UI_add_user_data | ||
134 | .Fa "UI *ui" | ||
135 | .Fa "void *user_data" | ||
136 | .Fc | ||
137 | .Ft void * | ||
138 | .Fo UI_get0_user_data | ||
139 | .Fa "UI *ui" | ||
140 | .Fc | ||
141 | .Ft const char * | ||
142 | .Fo UI_get0_result | ||
143 | .Fa "UI *ui" | ||
144 | .Fa "int i" | ||
145 | .Fc | ||
146 | .Ft int | ||
147 | .Fo UI_process | ||
148 | .Fa "UI *ui" | ||
149 | .Fc | ||
150 | .Ft int | ||
151 | .Fo UI_ctrl | ||
152 | .Fa "UI *ui" | ||
153 | .Fa "int cmd" | ||
154 | .Fa "long i" | ||
155 | .Fa "void *p" | ||
156 | .Fa "void (*f)()" | ||
157 | .Fc | ||
158 | .Fd #define UI_CTRL_PRINT_ERRORS 1 | ||
159 | .Fd #define UI_CTRL_IS_REDOABLE 2 | ||
160 | .Ft void | ||
161 | .Fo UI_set_default_method | ||
162 | .Fa "const UI_METHOD *meth" | ||
163 | .Fc | ||
164 | .Ft const UI_METHOD * | ||
165 | .Fo UI_get_default_method | ||
166 | .Fa void | ||
167 | .Fc | ||
168 | .Ft const UI_METHOD * | ||
169 | .Fo UI_get_method | ||
170 | .Fa "UI *ui" | ||
171 | .Fc | ||
172 | .Ft const UI_METHOD * | ||
173 | .Fo UI_set_method | ||
174 | .Fa "UI *ui" | ||
175 | .Fa "const UI_METHOD *meth" | ||
176 | .Fc | ||
177 | .Ft UI_METHOD * | ||
178 | .Fo UI_OpenSSL | ||
179 | .Fa void | ||
180 | .Fc | ||
181 | .Sh DESCRIPTION | ||
182 | UI stands for User Interface, and is general purpose set of routines | ||
183 | to prompt the user for text-based information. | ||
184 | Through user-written methods (see | ||
185 | .Xr ui_create 3 Ns ), | ||
186 | prompting can be done in any way imaginable, be it plain text prompting, | ||
187 | through dialog boxes or from a cell phone. | ||
188 | .Pp | ||
189 | All the functions work through a context of the type | ||
190 | .Vt UI . | ||
191 | This context contains all the information needed to prompt correctly | ||
192 | as well as a reference to a | ||
193 | .Vt UI_METHOD , | ||
194 | which is an ordered vector of functions that carry out the actual | ||
195 | prompting. | ||
196 | .Pp | ||
197 | The first thing to do is to create a | ||
198 | .Vt UI | ||
199 | with | ||
200 | .Fn UI_new | ||
201 | or | ||
202 | .Fn UI_new_method , | ||
203 | then add information to it with the | ||
204 | .Fn UI_add_* | ||
205 | or | ||
206 | .Fn UI_dup_* | ||
207 | functions. | ||
208 | Also, user-defined random data can be passed down to the underlying | ||
209 | method through calls to | ||
210 | .Fn UI_add_user_data . | ||
211 | The default UI method doesn't care about these data, but other methods | ||
212 | might. | ||
213 | Finally, use | ||
214 | .Fn UI_process | ||
215 | to actually perform the prompting and | ||
216 | .Fn UI_get0_result | ||
217 | to find the result to the prompt. | ||
218 | .Pp | ||
219 | A | ||
220 | .Vt UI | ||
221 | can contain more than one prompt, which are performed in the given | ||
222 | sequence. | ||
223 | Each prompt gets an index number which is returned by the | ||
224 | .Fn UI_add_* | ||
225 | and | ||
226 | .Fn UI_dup_* | ||
227 | functions, and has to be used to get the corresponding result with | ||
228 | .Fn UI_get0_result . | ||
229 | .Pp | ||
230 | The functions are as follows: | ||
231 | .Pp | ||
232 | .Fn UI_new | ||
233 | creates a new | ||
234 | .Vt UI | ||
235 | using the default UI method. | ||
236 | When done with this UI, it should be freed using | ||
237 | .Fn UI_free . | ||
238 | .Pp | ||
239 | .Fn UI_new_method | ||
240 | creates a new | ||
241 | .Vt UI | ||
242 | using the given UI method. | ||
243 | When done with this UI, it should be freed using | ||
244 | .Fn UI_free . | ||
245 | .Pp | ||
246 | .Fn UI_OpenSSL | ||
247 | returns the built-in UI method (note: not the default one, since | ||
248 | the default can be changed. | ||
249 | See further on). | ||
250 | This method is the most machine/OS dependent part of OpenSSL and | ||
251 | normally generates the most problems when porting. | ||
252 | .Pp | ||
253 | .Fn UI_free | ||
254 | removes | ||
255 | .Fa ui | ||
256 | from memory, along with all other pieces of memory that are connected | ||
257 | to it, like duplicated input strings, results and others. | ||
258 | .Pp | ||
259 | .Fn UI_add_input_string | ||
260 | and | ||
261 | .Fn UI_add_verify_string | ||
262 | add a prompt to | ||
263 | .Fa ui , | ||
264 | as well as flags and a result buffer and the desired minimum and | ||
265 | maximum sizes of the result. | ||
266 | The given information is used to prompt for information, for example | ||
267 | a password, and to verify a password (i.e. having the user enter | ||
268 | it twice and check that the same string was entered twice). | ||
269 | .Fn UI_add_verify_string | ||
270 | takes and extra argument that should be a pointer to the result buffer | ||
271 | of the input string that it's supposed to verify, or verification will | ||
272 | fail. | ||
273 | .Pp | ||
274 | .Fn UI_add_input_boolean | ||
275 | adds a prompt to | ||
276 | .Fa ui | ||
277 | that's supposed to be answered in a boolean way, with a single | ||
278 | character for yes and a different character for no. | ||
279 | A set of characters that can be used to cancel the prompt is given as | ||
280 | well. | ||
281 | The prompt itself is really divided in two, one part being the | ||
282 | descriptive text (given through the | ||
283 | .Fa prompt | ||
284 | argument) and one describing the possible answers (given through the | ||
285 | .Fa action_desc | ||
286 | argument). | ||
287 | .Pp | ||
288 | .Fn UI_add_info_string | ||
289 | and | ||
290 | .Fn UI_add_error_string | ||
291 | add strings that are shown at the same time as the prompt for extra | ||
292 | information or to show an error string. | ||
293 | The difference between the two is only conceptual. | ||
294 | With the builtin method, there's no technical difference between them. | ||
295 | Other methods may make a difference between them, however. | ||
296 | .Pp | ||
297 | The flags currently supported are | ||
298 | .Dv UI_INPUT_FLAG_ECHO, | ||
299 | which is relevant for | ||
300 | .Fn UI_add_input_string | ||
301 | and will have the users response be echoed (when prompting for a | ||
302 | password, this flag should obviously not be used), and | ||
303 | .Dv UI_INPUT_FLAG_DEFAULT_PWD , | ||
304 | which means that a default password of some sort will be used | ||
305 | (completely depending on the application and the UI method). | ||
306 | .Pp | ||
307 | .Fn UI_dup_input_string , | ||
308 | .Fn UI_dup_verify_string , | ||
309 | .Fn UI_dup_input_boolean , | ||
310 | .Fn UI_dup_info_string , | ||
311 | and | ||
312 | .Fn UI_dup_error_string | ||
313 | are basically the same as their | ||
314 | .Fn UI_add_* | ||
315 | counterparts, except that they make their own copies of all strings. | ||
316 | .Pp | ||
317 | .Fn UI_construct_prompt | ||
318 | is a helper function that can be used to create a prompt from two pieces | ||
319 | of information: an description and a name. | ||
320 | The default constructor (if there is none provided by the method used) | ||
321 | creates a string "Enter | ||
322 | .Em description | ||
323 | for | ||
324 | .Em name Ns :". | ||
325 | With the description "pass phrase" and the file name "foo.key", that | ||
326 | becomes "Enter pass phrase for foo.key:". Other methods may create | ||
327 | whatever string and may include encodings that will be processed by the | ||
328 | other method functions. | ||
329 | .Pp | ||
330 | .Fn UI_add_user_data | ||
331 | adds a piece of memory for the method to use at any time. | ||
332 | The builtin UI method doesn't care about this info. | ||
333 | Note that several calls to this function doesn't add data, it replaces | ||
334 | the previous blob with the one given as argument. | ||
335 | .Pp | ||
336 | .Fn UI_get0_user_data | ||
337 | retrieves the data that has last been given to the | ||
338 | .Fa ui | ||
339 | with | ||
340 | .Fn UI_add_user_data . | ||
341 | .Pp | ||
342 | .Fn UI_get0_result | ||
343 | returns a pointer to the result buffer associated with the information | ||
344 | indexed by | ||
345 | .Fa i . | ||
346 | .Pp | ||
347 | .Fn UI_process | ||
348 | goes through the information given so far, does all the printing and | ||
349 | prompting and returns. | ||
350 | .Pp | ||
351 | .Fn UI_ctrl | ||
352 | adds extra control for the application author. | ||
353 | For now, it understands two commands: | ||
354 | .Dv UI_CTRL_PRINT_ERRORS , | ||
355 | which makes | ||
356 | .Fn UI_process | ||
357 | print the OpenSSL error stack as part of processing the | ||
358 | .Fa ui , | ||
359 | and | ||
360 | .Dv UI_CTRL_IS_REDOABLE , | ||
361 | which returns a flag saying if the used | ||
362 | .Fa ui | ||
363 | can be used again or not. | ||
364 | .Pp | ||
365 | .Fn UI_set_default_method | ||
366 | changes the default UI method to the one given. | ||
367 | .Pp | ||
368 | .Fn UI_get_default_method | ||
369 | returns a pointer to the current default UI method. | ||
370 | .Pp | ||
371 | .Fn UI_get_method | ||
372 | returns the UI method associated with a given | ||
373 | .Fa ui . | ||
374 | .Pp | ||
375 | .Fn UI_set_method | ||
376 | changes the UI method associated with a given | ||
377 | .Fa ui . | ||
378 | .Sh SEE ALSO | ||
379 | .Xr des_read_pw 3 | ||
380 | .Sh HISTORY | ||
381 | The UI section was first introduced in OpenSSL 0.9.7. | ||
382 | .Sh AUTHORS | ||
383 | .An Richard Levitte Aq Mt richard@levitte.org | ||
384 | for the OpenSSL project. | ||