ui.3 13 KB

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