summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/ui_new.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/ui_new.3')
-rw-r--r--src/lib/libcrypto/man/ui_new.3384
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
182UI stands for User Interface, and is general purpose set of routines
183to prompt the user for text-based information.
184Through user-written methods (see
185.Xr ui_create 3 Ns ),
186prompting can be done in any way imaginable, be it plain text prompting,
187through dialog boxes or from a cell phone.
188.Pp
189All the functions work through a context of the type
190.Vt UI .
191This context contains all the information needed to prompt correctly
192as well as a reference to a
193.Vt UI_METHOD ,
194which is an ordered vector of functions that carry out the actual
195prompting.
196.Pp
197The first thing to do is to create a
198.Vt UI
199with
200.Fn UI_new
201or
202.Fn UI_new_method ,
203then add information to it with the
204.Fn UI_add_*
205or
206.Fn UI_dup_*
207functions.
208Also, user-defined random data can be passed down to the underlying
209method through calls to
210.Fn UI_add_user_data .
211The default UI method doesn't care about these data, but other methods
212might.
213Finally, use
214.Fn UI_process
215to actually perform the prompting and
216.Fn UI_get0_result
217to find the result to the prompt.
218.Pp
219A
220.Vt UI
221can contain more than one prompt, which are performed in the given
222sequence.
223Each prompt gets an index number which is returned by the
224.Fn UI_add_*
225and
226.Fn UI_dup_*
227functions, and has to be used to get the corresponding result with
228.Fn UI_get0_result .
229.Pp
230The functions are as follows:
231.Pp
232.Fn UI_new
233creates a new
234.Vt UI
235using the default UI method.
236When done with this UI, it should be freed using
237.Fn UI_free .
238.Pp
239.Fn UI_new_method
240creates a new
241.Vt UI
242using the given UI method.
243When done with this UI, it should be freed using
244.Fn UI_free .
245.Pp
246.Fn UI_OpenSSL
247returns the built-in UI method (note: not the default one, since
248the default can be changed.
249See further on).
250This method is the most machine/OS dependent part of OpenSSL and
251normally generates the most problems when porting.
252.Pp
253.Fn UI_free
254removes
255.Fa ui
256from memory, along with all other pieces of memory that are connected
257to it, like duplicated input strings, results and others.
258.Pp
259.Fn UI_add_input_string
260and
261.Fn UI_add_verify_string
262add a prompt to
263.Fa ui ,
264as well as flags and a result buffer and the desired minimum and
265maximum sizes of the result.
266The given information is used to prompt for information, for example
267a password, and to verify a password (i.e. having the user enter
268it twice and check that the same string was entered twice).
269.Fn UI_add_verify_string
270takes and extra argument that should be a pointer to the result buffer
271of the input string that it's supposed to verify, or verification will
272fail.
273.Pp
274.Fn UI_add_input_boolean
275adds a prompt to
276.Fa ui
277that's supposed to be answered in a boolean way, with a single
278character for yes and a different character for no.
279A set of characters that can be used to cancel the prompt is given as
280well.
281The prompt itself is really divided in two, one part being the
282descriptive text (given through the
283.Fa prompt
284argument) and one describing the possible answers (given through the
285.Fa action_desc
286argument).
287.Pp
288.Fn UI_add_info_string
289and
290.Fn UI_add_error_string
291add strings that are shown at the same time as the prompt for extra
292information or to show an error string.
293The difference between the two is only conceptual.
294With the builtin method, there's no technical difference between them.
295Other methods may make a difference between them, however.
296.Pp
297The flags currently supported are
298.Dv UI_INPUT_FLAG_ECHO,
299which is relevant for
300.Fn UI_add_input_string
301and will have the users response be echoed (when prompting for a
302password, this flag should obviously not be used), and
303.Dv UI_INPUT_FLAG_DEFAULT_PWD ,
304which 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 ,
311and
312.Fn UI_dup_error_string
313are basically the same as their
314.Fn UI_add_*
315counterparts, except that they make their own copies of all strings.
316.Pp
317.Fn UI_construct_prompt
318is a helper function that can be used to create a prompt from two pieces
319of information: an description and a name.
320The default constructor (if there is none provided by the method used)
321creates a string "Enter
322.Em description
323for
324.Em name Ns :".
325With the description "pass phrase" and the file name "foo.key", that
326becomes "Enter pass phrase for foo.key:". Other methods may create
327whatever string and may include encodings that will be processed by the
328other method functions.
329.Pp
330.Fn UI_add_user_data
331adds a piece of memory for the method to use at any time.
332The builtin UI method doesn't care about this info.
333Note that several calls to this function doesn't add data, it replaces
334the previous blob with the one given as argument.
335.Pp
336.Fn UI_get0_user_data
337retrieves the data that has last been given to the
338.Fa ui
339with
340.Fn UI_add_user_data .
341.Pp
342.Fn UI_get0_result
343returns a pointer to the result buffer associated with the information
344indexed by
345.Fa i .
346.Pp
347.Fn UI_process
348goes through the information given so far, does all the printing and
349prompting and returns.
350.Pp
351.Fn UI_ctrl
352adds extra control for the application author.
353For now, it understands two commands:
354.Dv UI_CTRL_PRINT_ERRORS ,
355which makes
356.Fn UI_process
357print the OpenSSL error stack as part of processing the
358.Fa ui ,
359and
360.Dv UI_CTRL_IS_REDOABLE ,
361which returns a flag saying if the used
362.Fa ui
363can be used again or not.
364.Pp
365.Fn UI_set_default_method
366changes the default UI method to the one given.
367.Pp
368.Fn UI_get_default_method
369returns a pointer to the current default UI method.
370.Pp
371.Fn UI_get_method
372returns the UI method associated with a given
373.Fa ui .
374.Pp
375.Fn UI_set_method
376changes the UI method associated with a given
377.Fa ui .
378.Sh SEE ALSO
379.Xr des_read_pw 3
380.Sh HISTORY
381The UI section was first introduced in OpenSSL 0.9.7.
382.Sh AUTHORS
383.An Richard Levitte Aq Mt richard@levitte.org
384for the OpenSSL project.