summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2014-04-18 05:37:44 +0000
committerjsing <>2014-04-18 05:37:44 +0000
commitf843014abcc7498613638ca7bdc47b3123ea2544 (patch)
treefc08a86c3d277a550737fd859bfcfb80547a2c6b
parentf737947057a1a777dafba073b92264e698047b6c (diff)
downloadopenbsd-f843014abcc7498613638ca7bdc47b3123ea2544.tar.gz
openbsd-f843014abcc7498613638ca7bdc47b3123ea2544.tar.bz2
openbsd-f843014abcc7498613638ca7bdc47b3123ea2544.zip
More KNF.
-rw-r--r--src/lib/libcrypto/ui/ui.h41
-rw-r--r--src/lib/libcrypto/ui/ui_compat.c4
-rw-r--r--src/lib/libcrypto/ui/ui_compat.h6
-rw-r--r--src/lib/libcrypto/ui/ui_err.c9
-rw-r--r--src/lib/libcrypto/ui/ui_lib.c227
-rw-r--r--src/lib/libcrypto/ui/ui_locl.h34
-rw-r--r--src/lib/libcrypto/ui/ui_openssl.c66
-rw-r--r--src/lib/libcrypto/ui/ui_util.c11
-rw-r--r--src/lib/libssl/src/crypto/ui/ui.h41
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_compat.c4
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_compat.h6
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_err.c9
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_lib.c227
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_locl.h34
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_openssl.c66
-rw-r--r--src/lib/libssl/src/crypto/ui/ui_util.c11
16 files changed, 390 insertions, 406 deletions
diff --git a/src/lib/libcrypto/ui/ui.h b/src/lib/libcrypto/ui/ui.h
index ed35e50eb4..7970f893d6 100644
--- a/src/lib/libcrypto/ui/ui.h
+++ b/src/lib/libcrypto/ui/ui.h
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -128,19 +128,19 @@ void UI_free(UI *ui);
128 On success, the all return an index of the added information. That index 128 On success, the all return an index of the added information. That index
129 is usefull when retrieving results with UI_get0_result(). */ 129 is usefull when retrieving results with UI_get0_result(). */
130int UI_add_input_string(UI *ui, const char *prompt, int flags, 130int UI_add_input_string(UI *ui, const char *prompt, int flags,
131 char *result_buf, int minsize, int maxsize); 131 char *result_buf, int minsize, int maxsize);
132int UI_dup_input_string(UI *ui, const char *prompt, int flags, 132int UI_dup_input_string(UI *ui, const char *prompt, int flags,
133 char *result_buf, int minsize, int maxsize); 133 char *result_buf, int minsize, int maxsize);
134int UI_add_verify_string(UI *ui, const char *prompt, int flags, 134int UI_add_verify_string(UI *ui, const char *prompt, int flags,
135 char *result_buf, int minsize, int maxsize, const char *test_buf); 135 char *result_buf, int minsize, int maxsize, const char *test_buf);
136int UI_dup_verify_string(UI *ui, const char *prompt, int flags, 136int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
137 char *result_buf, int minsize, int maxsize, const char *test_buf); 137 char *result_buf, int minsize, int maxsize, const char *test_buf);
138int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, 138int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
139 const char *ok_chars, const char *cancel_chars, 139 const char *ok_chars, const char *cancel_chars,
140 int flags, char *result_buf); 140 int flags, char *result_buf);
141int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, 141int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
142 const char *ok_chars, const char *cancel_chars, 142 const char *ok_chars, const char *cancel_chars,
143 int flags, char *result_buf); 143 int flags, char *result_buf);
144int UI_add_info_string(UI *ui, const char *text); 144int UI_add_info_string(UI *ui, const char *text);
145int UI_dup_info_string(UI *ui, const char *text); 145int UI_dup_info_string(UI *ui, const char *text);
146int UI_add_error_string(UI *ui, const char *text); 146int UI_add_error_string(UI *ui, const char *text);
@@ -185,8 +185,8 @@ int UI_dup_error_string(UI *ui, const char *text);
185 185
186 "Enter pass phrase for foo.key:" 186 "Enter pass phrase for foo.key:"
187*/ 187*/
188char *UI_construct_prompt(UI *ui_method, 188char *UI_construct_prompt(UI *ui_method, const char *object_desc,
189 const char *object_desc, const char *object_name); 189 const char *object_name);
190 190
191 191
192/* The following function is used to store a pointer to user-specific data. 192/* The following function is used to store a pointer to user-specific data.
@@ -228,8 +228,8 @@ int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void));
228#define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg) 228#define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg)
229#define UI_get_app_data(s) UI_get_ex_data(s,0) 229#define UI_get_app_data(s) UI_get_ex_data(s,0)
230int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 230int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
231 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); 231 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
232int UI_set_ex_data(UI *r,int idx,void *arg); 232int UI_set_ex_data(UI *r, int idx, void *arg);
233void *UI_get_ex_data(UI *r, int idx); 233void *UI_get_ex_data(UI *r, int idx);
234 234
235/* Use specific methods instead of the built-in one */ 235/* Use specific methods instead of the built-in one */
@@ -292,15 +292,14 @@ DECLARE_STACK_OF(UI_STRING)
292 292
293/* The different types of strings that are currently supported. 293/* The different types of strings that are currently supported.
294 This is only needed by method authors. */ 294 This is only needed by method authors. */
295enum UI_string_types 295enum UI_string_types {
296 { 296 UIT_NONE = 0,
297 UIT_NONE=0,
298 UIT_PROMPT, /* Prompt for a string */ 297 UIT_PROMPT, /* Prompt for a string */
299 UIT_VERIFY, /* Prompt for a string and verify */ 298 UIT_VERIFY, /* Prompt for a string and verify */
300 UIT_BOOLEAN, /* Prompt for a yes/no response */ 299 UIT_BOOLEAN, /* Prompt for a yes/no response */
301 UIT_INFO, /* Send info to the user */ 300 UIT_INFO, /* Send info to the user */
302 UIT_ERROR /* Send an error message to the user */ 301 UIT_ERROR /* Send an error message to the user */
303 }; 302};
304 303
305/* Create and manipulate methods */ 304/* Create and manipulate methods */
306UI_METHOD *UI_create_method(char *name); 305UI_METHOD *UI_create_method(char *name);
@@ -312,9 +311,9 @@ int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis
312int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)); 311int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui));
313int UI_method_set_prompt_constructor(UI_METHOD *method, char *(*prompt_constructor)(UI* ui, const char* object_desc, const char* object_name)); 312int UI_method_set_prompt_constructor(UI_METHOD *method, char *(*prompt_constructor)(UI* ui, const char* object_desc, const char* object_name));
314int (*UI_method_get_opener(UI_METHOD *method))(UI*); 313int (*UI_method_get_opener(UI_METHOD *method))(UI*);
315int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*); 314int (*UI_method_get_writer(UI_METHOD *method))(UI*, UI_STRING*);
316int (*UI_method_get_flusher(UI_METHOD *method))(UI*); 315int (*UI_method_get_flusher(UI_METHOD *method))(UI*);
317int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*); 316int (*UI_method_get_reader(UI_METHOD *method))(UI*, UI_STRING*);
318int (*UI_method_get_closer(UI_METHOD *method))(UI*); 317int (*UI_method_get_closer(UI_METHOD *method))(UI*);
319char * (*UI_method_get_prompt_constructor(UI_METHOD *method))(UI*, const char*, const char*); 318char * (*UI_method_get_prompt_constructor(UI_METHOD *method))(UI*, const char*, const char*);
320 319
@@ -342,8 +341,8 @@ int UI_set_result(UI *ui, UI_STRING *uis, const char *result);
342 341
343 342
344/* A couple of popular utility functions */ 343/* A couple of popular utility functions */
345int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify); 344int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify);
346int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); 345int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify);
347 346
348 347
349/* BEGIN ERROR CODES */ 348/* BEGIN ERROR CODES */
diff --git a/src/lib/libcrypto/ui/ui_compat.c b/src/lib/libcrypto/ui/ui_compat.c
index 2c5ee4dcee..416e035bdf 100644
--- a/src/lib/libcrypto/ui/ui_compat.c
+++ b/src/lib/libcrypto/ui/ui_compat.c
@@ -56,13 +56,13 @@
56#include <string.h> 56#include <string.h>
57#include <openssl/ui_compat.h> 57#include <openssl/ui_compat.h>
58 58
59int 59int
60_ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, int verify) 60_ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, int verify)
61{ 61{
62 return UI_UTIL_read_pw_string(buf, length, prompt, verify); 62 return UI_UTIL_read_pw_string(buf, length, prompt, verify);
63} 63}
64 64
65int 65int
66_ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify) 66_ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify)
67{ 67{
68 return UI_UTIL_read_pw(buf, buff, size, prompt, verify); 68 return UI_UTIL_read_pw(buf, buff, size, prompt, verify);
diff --git a/src/lib/libcrypto/ui/ui_compat.h b/src/lib/libcrypto/ui/ui_compat.h
index b35c9bb7fd..75c2ae1ef9 100644
--- a/src/lib/libcrypto/ui/ui_compat.h
+++ b/src/lib/libcrypto/ui/ui_compat.h
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -74,8 +74,8 @@ extern "C" {
74#define des_read_pw(b,bf,s,p,v) \ 74#define des_read_pw(b,bf,s,p,v) \
75 _ossl_old_des_read_pw((b),(bf),(s),(p),(v)) 75 _ossl_old_des_read_pw((b),(bf),(s),(p),(v))
76 76
77int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify); 77int _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, int verify);
78int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); 78int _ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify);
79 79
80#ifdef __cplusplus 80#ifdef __cplusplus
81} 81}
diff --git a/src/lib/libcrypto/ui/ui_err.c b/src/lib/libcrypto/ui/ui_err.c
index a9b22e2e57..e8b841eb0d 100644
--- a/src/lib/libcrypto/ui/ui_err.c
+++ b/src/lib/libcrypto/ui/ui_err.c
@@ -68,8 +68,7 @@
68#define ERR_FUNC(func) ERR_PACK(ERR_LIB_UI,func,0) 68#define ERR_FUNC(func) ERR_PACK(ERR_LIB_UI,func,0)
69#define ERR_REASON(reason) ERR_PACK(ERR_LIB_UI,0,reason) 69#define ERR_REASON(reason) ERR_PACK(ERR_LIB_UI,0,reason)
70 70
71static ERR_STRING_DATA UI_str_functs[] = 71static ERR_STRING_DATA UI_str_functs[] = {
72{
73 {ERR_FUNC(UI_F_GENERAL_ALLOCATE_BOOLEAN), "GENERAL_ALLOCATE_BOOLEAN"}, 72 {ERR_FUNC(UI_F_GENERAL_ALLOCATE_BOOLEAN), "GENERAL_ALLOCATE_BOOLEAN"},
74 {ERR_FUNC(UI_F_GENERAL_ALLOCATE_PROMPT), "GENERAL_ALLOCATE_PROMPT"}, 73 {ERR_FUNC(UI_F_GENERAL_ALLOCATE_PROMPT), "GENERAL_ALLOCATE_PROMPT"},
75 {ERR_FUNC(UI_F_GENERAL_ALLOCATE_STRING), "GENERAL_ALLOCATE_STRING"}, 74 {ERR_FUNC(UI_F_GENERAL_ALLOCATE_STRING), "GENERAL_ALLOCATE_STRING"},
@@ -85,8 +84,7 @@ static ERR_STRING_DATA UI_str_functs[] =
85 {0, NULL} 84 {0, NULL}
86}; 85};
87 86
88static ERR_STRING_DATA UI_str_reasons[] = 87static ERR_STRING_DATA UI_str_reasons[] = {
89{
90 {ERR_REASON(UI_R_COMMON_OK_AND_CANCEL_CHARACTERS), "common ok and cancel characters"}, 88 {ERR_REASON(UI_R_COMMON_OK_AND_CANCEL_CHARACTERS), "common ok and cancel characters"},
91 {ERR_REASON(UI_R_INDEX_TOO_LARGE), "index too large"}, 89 {ERR_REASON(UI_R_INDEX_TOO_LARGE), "index too large"},
92 {ERR_REASON(UI_R_INDEX_TOO_SMALL), "index too small"}, 90 {ERR_REASON(UI_R_INDEX_TOO_SMALL), "index too small"},
@@ -99,11 +97,10 @@ static ERR_STRING_DATA UI_str_reasons[] =
99 97
100#endif 98#endif
101 99
102void 100void
103ERR_load_UI_strings(void) 101ERR_load_UI_strings(void)
104{ 102{
105#ifndef OPENSSL_NO_ERR 103#ifndef OPENSSL_NO_ERR
106
107 if (ERR_func_error_string(UI_str_functs[0].error) == NULL) { 104 if (ERR_func_error_string(UI_str_functs[0].error) == NULL) {
108 ERR_load_strings(0, UI_str_functs); 105 ERR_load_strings(0, UI_str_functs);
109 ERR_load_strings(0, UI_str_reasons); 106 ERR_load_strings(0, UI_str_reasons);
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c
index 32fb9d7dbb..fc03d9b7d4 100644
--- a/src/lib/libcrypto/ui/ui_lib.c
+++ b/src/lib/libcrypto/ui/ui_lib.c
@@ -64,16 +64,16 @@
64#include <openssl/err.h> 64#include <openssl/err.h>
65#include "ui_locl.h" 65#include "ui_locl.h"
66 66
67IMPLEMENT_STACK_OF(UI_STRING_ST) 67IMPLEMENT_STACK_OF(UI_STRING_ST) static const UI_METHOD *default_UI_meth = NULL;
68 static const UI_METHOD *default_UI_meth = NULL;
69 68
70 UI *UI_new(void) 69UI *
70UI_new(void)
71{ 71{
72 return (UI_new_method(NULL)); 72 return (UI_new_method(NULL));
73} 73}
74 74
75UI * 75UI *
76UI_new_method(const UI_METHOD * method) 76UI_new_method(const UI_METHOD *method)
77{ 77{
78 UI *ret; 78 UI *ret;
79 79
@@ -94,16 +94,16 @@ UI_new_method(const UI_METHOD * method)
94 return ret; 94 return ret;
95} 95}
96 96
97static void 97static void
98free_string(UI_STRING * uis) 98free_string(UI_STRING *uis)
99{ 99{
100 if (uis->flags & OUT_STRING_FREEABLE) { 100 if (uis->flags & OUT_STRING_FREEABLE) {
101 free((char *) uis->out_string); 101 free((char *) uis->out_string);
102 switch (uis->type) { 102 switch (uis->type) {
103 case UIT_BOOLEAN: 103 case UIT_BOOLEAN:
104 free((char *) uis->_.boolean_data.action_desc); 104 free((char *)uis->_.boolean_data.action_desc);
105 free((char *) uis->_.boolean_data.ok_chars); 105 free((char *)uis->_.boolean_data.ok_chars);
106 free((char *) uis->_.boolean_data.cancel_chars); 106 free((char *)uis->_.boolean_data.cancel_chars);
107 break; 107 break;
108 default: 108 default:
109 break; 109 break;
@@ -112,8 +112,8 @@ free_string(UI_STRING * uis)
112 free(uis); 112 free(uis);
113} 113}
114 114
115void 115void
116UI_free(UI * ui) 116UI_free(UI *ui)
117{ 117{
118 if (ui == NULL) 118 if (ui == NULL)
119 return; 119 return;
@@ -122,8 +122,8 @@ UI_free(UI * ui)
122 free(ui); 122 free(ui);
123} 123}
124 124
125static int 125static int
126allocate_string_stack(UI * ui) 126allocate_string_stack(UI *ui)
127{ 127{
128 if (ui->strings == NULL) { 128 if (ui->strings == NULL) {
129 ui->strings = sk_UI_STRING_new_null(); 129 ui->strings = sk_UI_STRING_new_null();
@@ -135,7 +135,7 @@ allocate_string_stack(UI * ui)
135} 135}
136 136
137static UI_STRING * 137static UI_STRING *
138general_allocate_prompt(UI * ui, const char *prompt, 138general_allocate_prompt(UI *ui, const char *prompt,
139 int prompt_freeable, enum UI_string_types type, int input_flags, 139 int prompt_freeable, enum UI_string_types type, int input_flags,
140 char *result_buf) 140 char *result_buf)
141{ 141{
@@ -143,8 +143,8 @@ general_allocate_prompt(UI * ui, const char *prompt,
143 143
144 if (prompt == NULL) { 144 if (prompt == NULL) {
145 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, ERR_R_PASSED_NULL_PARAMETER); 145 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, ERR_R_PASSED_NULL_PARAMETER);
146 } else if ((type == UIT_PROMPT || type == UIT_VERIFY 146 } else if ((type == UIT_PROMPT || type == UIT_VERIFY ||
147 || type == UIT_BOOLEAN) && result_buf == NULL) { 147 type == UIT_BOOLEAN) && result_buf == NULL) {
148 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER); 148 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER);
149 } else if ((ret = (UI_STRING *) malloc(sizeof(UI_STRING)))) { 149 } else if ((ret = (UI_STRING *) malloc(sizeof(UI_STRING)))) {
150 ret->out_string = prompt; 150 ret->out_string = prompt;
@@ -156,8 +156,8 @@ general_allocate_prompt(UI * ui, const char *prompt,
156 return ret; 156 return ret;
157} 157}
158 158
159static int 159static int
160general_allocate_string(UI * ui, const char *prompt, 160general_allocate_string(UI *ui, const char *prompt,
161 int prompt_freeable, enum UI_string_types type, int input_flags, 161 int prompt_freeable, enum UI_string_types type, int input_flags,
162 char *result_buf, int minsize, int maxsize, const char *test_buf) 162 char *result_buf, int minsize, int maxsize, const char *test_buf)
163{ 163{
@@ -180,8 +180,8 @@ general_allocate_string(UI * ui, const char *prompt,
180 return ret; 180 return ret;
181} 181}
182 182
183static int 183static int
184general_allocate_boolean(UI * ui, 184general_allocate_boolean(UI *ui,
185 const char *prompt, const char *action_desc, 185 const char *prompt, const char *action_desc,
186 const char *ok_chars, const char *cancel_chars, 186 const char *ok_chars, const char *cancel_chars,
187 int prompt_freeable, enum UI_string_types type, int input_flags, 187 int prompt_freeable, enum UI_string_types type, int input_flags,
@@ -227,8 +227,8 @@ general_allocate_boolean(UI * ui,
227 227
228/* Returns the index to the place in the stack or -1 for error. Uses a 228/* Returns the index to the place in the stack or -1 for error. Uses a
229 direct reference to the prompt. */ 229 direct reference to the prompt. */
230int 230int
231UI_add_input_string(UI * ui, const char *prompt, int flags, 231UI_add_input_string(UI *ui, const char *prompt, int flags,
232 char *result_buf, int minsize, int maxsize) 232 char *result_buf, int minsize, int maxsize)
233{ 233{
234 return general_allocate_string(ui, prompt, 0, 234 return general_allocate_string(ui, prompt, 0,
@@ -236,8 +236,8 @@ UI_add_input_string(UI * ui, const char *prompt, int flags,
236} 236}
237 237
238/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */ 238/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */
239int 239int
240UI_dup_input_string(UI * ui, const char *prompt, int flags, 240UI_dup_input_string(UI *ui, const char *prompt, int flags,
241 char *result_buf, int minsize, int maxsize) 241 char *result_buf, int minsize, int maxsize)
242{ 242{
243 char *prompt_copy = NULL; 243 char *prompt_copy = NULL;
@@ -253,16 +253,16 @@ UI_dup_input_string(UI * ui, const char *prompt, int flags,
253 UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); 253 UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL);
254} 254}
255 255
256int 256int
257UI_add_verify_string(UI * ui, const char *prompt, int flags, 257UI_add_verify_string(UI *ui, const char *prompt, int flags,
258 char *result_buf, int minsize, int maxsize, const char *test_buf) 258 char *result_buf, int minsize, int maxsize, const char *test_buf)
259{ 259{
260 return general_allocate_string(ui, prompt, 0, 260 return general_allocate_string(ui, prompt, 0,
261 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); 261 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf);
262} 262}
263 263
264int 264int
265UI_dup_verify_string(UI * ui, const char *prompt, int flags, 265UI_dup_verify_string(UI *ui, const char *prompt, int flags,
266 char *result_buf, int minsize, int maxsize, const char *test_buf) 266 char *result_buf, int minsize, int maxsize, const char *test_buf)
267{ 267{
268 char *prompt_copy = NULL; 268 char *prompt_copy = NULL;
@@ -278,8 +278,8 @@ UI_dup_verify_string(UI * ui, const char *prompt, int flags,
278 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); 278 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf);
279} 279}
280 280
281int 281int
282UI_add_input_boolean(UI * ui, const char *prompt, const char *action_desc, 282UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
283 const char *ok_chars, const char *cancel_chars, 283 const char *ok_chars, const char *cancel_chars,
284 int flags, char *result_buf) 284 int flags, char *result_buf)
285{ 285{
@@ -287,8 +287,8 @@ UI_add_input_boolean(UI * ui, const char *prompt, const char *action_desc,
287 ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf); 287 ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf);
288} 288}
289 289
290int 290int
291UI_dup_input_boolean(UI * ui, const char *prompt, const char *action_desc, 291UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
292 const char *ok_chars, const char *cancel_chars, 292 const char *ok_chars, const char *cancel_chars,
293 int flags, char *result_buf) 293 int flags, char *result_buf)
294{ 294{
@@ -328,6 +328,7 @@ UI_dup_input_boolean(UI * ui, const char *prompt, const char *action_desc,
328 return general_allocate_boolean(ui, prompt_copy, action_desc_copy, 328 return general_allocate_boolean(ui, prompt_copy, action_desc_copy,
329 ok_chars_copy, cancel_chars_copy, 1, UIT_BOOLEAN, flags, 329 ok_chars_copy, cancel_chars_copy, 1, UIT_BOOLEAN, flags,
330 result_buf); 330 result_buf);
331
331err: 332err:
332 if (prompt_copy) 333 if (prompt_copy)
333 free(prompt_copy); 334 free(prompt_copy);
@@ -340,15 +341,15 @@ err:
340 return -1; 341 return -1;
341} 342}
342 343
343int 344int
344UI_add_info_string(UI * ui, const char *text) 345UI_add_info_string(UI *ui, const char *text)
345{ 346{
346 return general_allocate_string(ui, text, 0, UIT_INFO, 0, NULL, 0, 0, 347 return general_allocate_string(ui, text, 0, UIT_INFO, 0, NULL, 0, 0,
347 NULL); 348 NULL);
348} 349}
349 350
350int 351int
351UI_dup_info_string(UI * ui, const char *text) 352UI_dup_info_string(UI *ui, const char *text)
352{ 353{
353 char *text_copy = NULL; 354 char *text_copy = NULL;
354 355
@@ -363,15 +364,15 @@ UI_dup_info_string(UI * ui, const char *text)
363 0, 0, NULL); 364 0, 0, NULL);
364} 365}
365 366
366int 367int
367UI_add_error_string(UI * ui, const char *text) 368UI_add_error_string(UI *ui, const char *text)
368{ 369{
369 return general_allocate_string(ui, text, 0, UIT_ERROR, 0, NULL, 0, 0, 370 return general_allocate_string(ui, text, 0, UIT_ERROR, 0, NULL, 0, 0,
370 NULL); 371 NULL);
371} 372}
372 373
373int 374int
374UI_dup_error_string(UI * ui, const char *text) 375UI_dup_error_string(UI *ui, const char *text)
375{ 376{
376 char *text_copy = NULL; 377 char *text_copy = NULL;
377 378
@@ -387,8 +388,7 @@ UI_dup_error_string(UI * ui, const char *text)
387} 388}
388 389
389char * 390char *
390UI_construct_prompt(UI * ui, const char *object_desc, 391UI_construct_prompt(UI *ui, const char *object_desc, const char *object_name)
391 const char *object_name)
392{ 392{
393 char *prompt = NULL; 393 char *prompt = NULL;
394 394
@@ -408,7 +408,7 @@ UI_construct_prompt(UI * ui, const char *object_desc,
408 len += sizeof(prompt2) - 1 + strlen(object_name); 408 len += sizeof(prompt2) - 1 + strlen(object_name);
409 len += sizeof(prompt3) - 1; 409 len += sizeof(prompt3) - 1;
410 410
411 prompt = (char *) malloc(len + 1); 411 prompt = (char *)malloc(len + 1);
412 BUF_strlcpy(prompt, prompt1, len + 1); 412 BUF_strlcpy(prompt, prompt1, len + 1);
413 BUF_strlcat(prompt, object_desc, len + 1); 413 BUF_strlcat(prompt, object_desc, len + 1);
414 if (object_name) { 414 if (object_name) {
@@ -421,7 +421,7 @@ UI_construct_prompt(UI * ui, const char *object_desc,
421} 421}
422 422
423void * 423void *
424UI_add_user_data(UI * ui, void *user_data) 424UI_add_user_data(UI *ui, void *user_data)
425{ 425{
426 void *old_data = ui->user_data; 426 void *old_data = ui->user_data;
427 ui->user_data = user_data; 427 ui->user_data = user_data;
@@ -429,13 +429,13 @@ UI_add_user_data(UI * ui, void *user_data)
429} 429}
430 430
431void * 431void *
432UI_get0_user_data(UI * ui) 432UI_get0_user_data(UI *ui)
433{ 433{
434 return ui->user_data; 434 return ui->user_data;
435} 435}
436 436
437const char * 437const char *
438UI_get0_result(UI * ui, int i) 438UI_get0_result(UI *ui, int i)
439{ 439{
440 if (i < 0) { 440 if (i < 0) {
441 UIerr(UI_F_UI_GET0_RESULT, UI_R_INDEX_TOO_SMALL); 441 UIerr(UI_F_UI_GET0_RESULT, UI_R_INDEX_TOO_SMALL);
@@ -448,8 +448,8 @@ UI_get0_result(UI * ui, int i)
448 return UI_get0_result_string(sk_UI_STRING_value(ui->strings, i)); 448 return UI_get0_result_string(sk_UI_STRING_value(ui->strings, i));
449} 449}
450 450
451static int 451static int
452print_error(const char *str, size_t len, UI * ui) 452print_error(const char *str, size_t len, UI *ui)
453{ 453{
454 UI_STRING uis; 454 UI_STRING uis;
455 455
@@ -457,14 +457,14 @@ print_error(const char *str, size_t len, UI * ui)
457 uis.type = UIT_ERROR; 457 uis.type = UIT_ERROR;
458 uis.out_string = str; 458 uis.out_string = str;
459 459
460 if (ui->meth->ui_write_string 460 if (ui->meth->ui_write_string &&
461 && !ui->meth->ui_write_string(ui, &uis)) 461 !ui->meth->ui_write_string(ui, &uis))
462 return -1; 462 return -1;
463 return 0; 463 return 0;
464} 464}
465 465
466int 466int
467UI_process(UI * ui) 467UI_process(UI *ui)
468{ 468{
469 int i, ok = 0; 469 int i, ok = 0;
470 470
@@ -473,12 +473,12 @@ UI_process(UI * ui)
473 473
474 if (ui->flags & UI_FLAG_PRINT_ERRORS) 474 if (ui->flags & UI_FLAG_PRINT_ERRORS)
475 ERR_print_errors_cb( 475 ERR_print_errors_cb(
476 (int (*) (const char *, size_t, void *)) print_error, 476 (int (*)(const char *, size_t, void *)) print_error,
477 (void *) ui); 477 (void *)ui);
478 478
479 for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) { 479 for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) {
480 if (ui->meth->ui_write_string 480 if (ui->meth->ui_write_string &&
481 && !ui->meth->ui_write_string(ui, 481 !ui->meth->ui_write_string(ui,
482 sk_UI_STRING_value(ui->strings, i))) { 482 sk_UI_STRING_value(ui->strings, i))) {
483 ok = -1; 483 ok = -1;
484 goto err; 484 goto err;
@@ -490,7 +490,7 @@ UI_process(UI * ui)
490 case -1: /* Interrupt/Cancel/something... */ 490 case -1: /* Interrupt/Cancel/something... */
491 ok = -2; 491 ok = -2;
492 goto err; 492 goto err;
493 case 0: /* Errors */ 493 case 0: /* Errors */
494 ok = -1; 494 ok = -1;
495 goto err; 495 goto err;
496 default: /* Success */ 496 default: /* Success */
@@ -501,11 +501,11 @@ UI_process(UI * ui)
501 for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) { 501 for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) {
502 if (ui->meth->ui_read_string) { 502 if (ui->meth->ui_read_string) {
503 switch (ui->meth->ui_read_string(ui, 503 switch (ui->meth->ui_read_string(ui,
504 sk_UI_STRING_value(ui->strings, i))) { 504 sk_UI_STRING_value(ui->strings, i))) {
505 case -1: /* Interrupt/Cancel/something... */ 505 case -1: /* Interrupt/Cancel/something... */
506 ok = -2; 506 ok = -2;
507 goto err; 507 goto err;
508 case 0:/* Errors */ 508 case 0: /* Errors */
509 ok = -1; 509 ok = -1;
510 goto err; 510 goto err;
511 default: /* Success */ 511 default: /* Success */
@@ -520,8 +520,8 @@ err:
520 return ok; 520 return ok;
521} 521}
522 522
523int 523int
524UI_ctrl(UI * ui, int cmd, long i, void *p, void (*f) (void)) 524UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void))
525{ 525{
526 if (ui == NULL) { 526 if (ui == NULL) {
527 UIerr(UI_F_UI_CTRL, ERR_R_PASSED_NULL_PARAMETER); 527 UIerr(UI_F_UI_CTRL, ERR_R_PASSED_NULL_PARAMETER);
@@ -546,28 +546,28 @@ UI_ctrl(UI * ui, int cmd, long i, void *p, void (*f) (void))
546 return -1; 546 return -1;
547} 547}
548 548
549int 549int
550UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new * new_func, 550UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
551 CRYPTO_EX_dup * dup_func, CRYPTO_EX_free * free_func) 551 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
552{ 552{
553 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, argl, argp, 553 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, argl, argp,
554 new_func, dup_func, free_func); 554 new_func, dup_func, free_func);
555} 555}
556 556
557int 557int
558UI_set_ex_data(UI * r, int idx, void *arg) 558UI_set_ex_data(UI *r, int idx, void *arg)
559{ 559{
560 return (CRYPTO_set_ex_data(&r->ex_data, idx, arg)); 560 return (CRYPTO_set_ex_data(&r->ex_data, idx, arg));
561} 561}
562 562
563void * 563void *
564UI_get_ex_data(UI * r, int idx) 564UI_get_ex_data(UI *r, int idx)
565{ 565{
566 return (CRYPTO_get_ex_data(&r->ex_data, idx)); 566 return (CRYPTO_get_ex_data(&r->ex_data, idx));
567} 567}
568 568
569void 569void
570UI_set_default_method(const UI_METHOD * meth) 570UI_set_default_method(const UI_METHOD *meth)
571{ 571{
572 default_UI_meth = meth; 572 default_UI_meth = meth;
573} 573}
@@ -582,13 +582,13 @@ UI_get_default_method(void)
582} 582}
583 583
584const UI_METHOD * 584const UI_METHOD *
585UI_get_method(UI * ui) 585UI_get_method(UI *ui)
586{ 586{
587 return ui->meth; 587 return ui->meth;
588} 588}
589 589
590const UI_METHOD * 590const UI_METHOD *
591UI_set_method(UI * ui, const UI_METHOD * meth) 591UI_set_method(UI *ui, const UI_METHOD *meth)
592{ 592{
593 ui->meth = meth; 593 ui->meth = meth;
594 return ui->meth; 594 return ui->meth;
@@ -610,16 +610,16 @@ UI_create_method(char *name)
610/* BIG FSCKING WARNING!!!! If you use this on a statically allocated method 610/* BIG FSCKING WARNING!!!! If you use this on a statically allocated method
611 (that is, it hasn't been allocated using UI_create_method(), you deserve 611 (that is, it hasn't been allocated using UI_create_method(), you deserve
612 anything Murphy can throw at you and more! You have been warned. */ 612 anything Murphy can throw at you and more! You have been warned. */
613void 613void
614UI_destroy_method(UI_METHOD * ui_method) 614UI_destroy_method(UI_METHOD *ui_method)
615{ 615{
616 free(ui_method->name); 616 free(ui_method->name);
617 ui_method->name = NULL; 617 ui_method->name = NULL;
618 free(ui_method); 618 free(ui_method);
619} 619}
620 620
621int 621int
622UI_method_set_opener(UI_METHOD * method, int (*opener) (UI * ui)) 622UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui))
623{ 623{
624 if (method) { 624 if (method) {
625 method->ui_open_session = opener; 625 method->ui_open_session = opener;
@@ -628,8 +628,8 @@ UI_method_set_opener(UI_METHOD * method, int (*opener) (UI * ui))
628 return -1; 628 return -1;
629} 629}
630 630
631int 631int
632UI_method_set_writer(UI_METHOD * method, int (*writer) (UI * ui, UI_STRING * uis)) 632UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis))
633{ 633{
634 if (method) { 634 if (method) {
635 method->ui_write_string = writer; 635 method->ui_write_string = writer;
@@ -638,8 +638,8 @@ UI_method_set_writer(UI_METHOD * method, int (*writer) (UI * ui, UI_STRING * uis
638 return -1; 638 return -1;
639} 639}
640 640
641int 641int
642UI_method_set_flusher(UI_METHOD * method, int (*flusher) (UI * ui)) 642UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui))
643{ 643{
644 if (method) { 644 if (method) {
645 method->ui_flush = flusher; 645 method->ui_flush = flusher;
@@ -648,8 +648,8 @@ UI_method_set_flusher(UI_METHOD * method, int (*flusher) (UI * ui))
648 return -1; 648 return -1;
649} 649}
650 650
651int 651int
652UI_method_set_reader(UI_METHOD * method, int (*reader) (UI * ui, UI_STRING * uis)) 652UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis))
653{ 653{
654 if (method) { 654 if (method) {
655 method->ui_read_string = reader; 655 method->ui_read_string = reader;
@@ -658,8 +658,8 @@ UI_method_set_reader(UI_METHOD * method, int (*reader) (UI * ui, UI_STRING * uis
658 return -1; 658 return -1;
659} 659}
660 660
661int 661int
662UI_method_set_closer(UI_METHOD * method, int (*closer) (UI * ui)) 662UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui))
663{ 663{
664 if (method) { 664 if (method) {
665 method->ui_close_session = closer; 665 method->ui_close_session = closer;
@@ -668,8 +668,10 @@ UI_method_set_closer(UI_METHOD * method, int (*closer) (UI * ui))
668 return -1; 668 return -1;
669} 669}
670 670
671int 671int
672UI_method_set_prompt_constructor(UI_METHOD * method, char *(*prompt_constructor) (UI * ui, const char *object_desc, const char *object_name)) 672UI_method_set_prompt_constructor(UI_METHOD *method,
673 char *(*prompt_constructor)(UI *ui, const char *object_desc,
674 const char *object_name))
673{ 675{
674 if (method) { 676 if (method) {
675 method->ui_construct_prompt = prompt_constructor; 677 method->ui_construct_prompt = prompt_constructor;
@@ -678,8 +680,8 @@ UI_method_set_prompt_constructor(UI_METHOD * method, char *(*prompt_constructor)
678 return -1; 680 return -1;
679} 681}
680 682
681int (* 683int
682 UI_method_get_opener(UI_METHOD * method)) (UI *) 684(*UI_method_get_opener(UI_METHOD * method))(UI *)
683{ 685{
684 if (method) 686 if (method)
685 return method->ui_open_session; 687 return method->ui_open_session;
@@ -687,8 +689,8 @@ int (*
687 return NULL; 689 return NULL;
688} 690}
689 691
690int (* 692int
691 UI_method_get_writer(UI_METHOD * method)) (UI *, UI_STRING *) 693(*UI_method_get_writer(UI_METHOD *method))(UI *, UI_STRING *)
692{ 694{
693 if (method) 695 if (method)
694 return method->ui_write_string; 696 return method->ui_write_string;
@@ -696,8 +698,8 @@ int (*
696 return NULL; 698 return NULL;
697} 699}
698 700
699int (* 701int
700 UI_method_get_flusher(UI_METHOD * method)) (UI *) 702(*UI_method_get_flusher(UI_METHOD *method)) (UI *)
701{ 703{
702 if (method) 704 if (method)
703 return method->ui_flush; 705 return method->ui_flush;
@@ -705,8 +707,8 @@ int (*
705 return NULL; 707 return NULL;
706} 708}
707 709
708int (* 710int
709 UI_method_get_reader(UI_METHOD * method)) (UI *, UI_STRING *) 711(*UI_method_get_reader(UI_METHOD *method))(UI *, UI_STRING *)
710{ 712{
711 if (method) 713 if (method)
712 return method->ui_read_string; 714 return method->ui_read_string;
@@ -714,8 +716,8 @@ int (*
714 return NULL; 716 return NULL;
715} 717}
716 718
717int (* 719int
718 UI_method_get_closer(UI_METHOD * method)) (UI *) 720(*UI_method_get_closer(UI_METHOD *method))(UI *)
719{ 721{
720 if (method) 722 if (method)
721 return method->ui_close_session; 723 return method->ui_close_session;
@@ -723,8 +725,9 @@ int (*
723 return NULL; 725 return NULL;
724} 726}
725 727
726char *(* 728char *
727 UI_method_get_prompt_constructor(UI_METHOD * method)) (UI *, const char *, const char *) 729(*UI_method_get_prompt_constructor(UI_METHOD *method))(UI *, const char *,
730 const char *)
728{ 731{
729 if (method) 732 if (method)
730 return method->ui_construct_prompt; 733 return method->ui_construct_prompt;
@@ -732,16 +735,16 @@ char *(*
732 return NULL; 735 return NULL;
733} 736}
734 737
735enum UI_string_types 738enum UI_string_types
736UI_get_string_type(UI_STRING * uis) 739UI_get_string_type(UI_STRING *uis)
737{ 740{
738 if (!uis) 741 if (!uis)
739 return UIT_NONE; 742 return UIT_NONE;
740 return uis->type; 743 return uis->type;
741} 744}
742 745
743int 746int
744UI_get_input_flags(UI_STRING * uis) 747UI_get_input_flags(UI_STRING *uis)
745{ 748{
746 if (!uis) 749 if (!uis)
747 return 0; 750 return 0;
@@ -749,7 +752,7 @@ UI_get_input_flags(UI_STRING * uis)
749} 752}
750 753
751const char * 754const char *
752UI_get0_output_string(UI_STRING * uis) 755UI_get0_output_string(UI_STRING *uis)
753{ 756{
754 if (!uis) 757 if (!uis)
755 return NULL; 758 return NULL;
@@ -757,7 +760,7 @@ UI_get0_output_string(UI_STRING * uis)
757} 760}
758 761
759const char * 762const char *
760UI_get0_action_string(UI_STRING * uis) 763UI_get0_action_string(UI_STRING *uis)
761{ 764{
762 if (!uis) 765 if (!uis)
763 return NULL; 766 return NULL;
@@ -771,7 +774,7 @@ UI_get0_action_string(UI_STRING * uis)
771} 774}
772 775
773const char * 776const char *
774UI_get0_result_string(UI_STRING * uis) 777UI_get0_result_string(UI_STRING *uis)
775{ 778{
776 if (!uis) 779 if (!uis)
777 return NULL; 780 return NULL;
@@ -785,7 +788,7 @@ UI_get0_result_string(UI_STRING * uis)
785} 788}
786 789
787const char * 790const char *
788UI_get0_test_string(UI_STRING * uis) 791UI_get0_test_string(UI_STRING *uis)
789{ 792{
790 if (!uis) 793 if (!uis)
791 return NULL; 794 return NULL;
@@ -797,8 +800,8 @@ UI_get0_test_string(UI_STRING * uis)
797 } 800 }
798} 801}
799 802
800int 803int
801UI_get_result_minsize(UI_STRING * uis) 804UI_get_result_minsize(UI_STRING *uis)
802{ 805{
803 if (!uis) 806 if (!uis)
804 return -1; 807 return -1;
@@ -811,8 +814,8 @@ UI_get_result_minsize(UI_STRING * uis)
811 } 814 }
812} 815}
813 816
814int 817int
815UI_get_result_maxsize(UI_STRING * uis) 818UI_get_result_maxsize(UI_STRING *uis)
816{ 819{
817 if (!uis) 820 if (!uis)
818 return -1; 821 return -1;
@@ -825,8 +828,8 @@ UI_get_result_maxsize(UI_STRING * uis)
825 } 828 }
826} 829}
827 830
828int 831int
829UI_set_result(UI * ui, UI_STRING * uis, const char *result) 832UI_set_result(UI *ui, UI_STRING *uis, const char *result)
830{ 833{
831 int l = strlen(result); 834 int l = strlen(result);
832 835
@@ -890,7 +893,7 @@ UI_set_result(UI * ui, UI_STRING * uis, const char *result)
890 break; 893 break;
891 } 894 }
892 } 895 }
893 default: 896 default:
894 break; 897 break;
895 } 898 }
896 } 899 }
diff --git a/src/lib/libcrypto/ui/ui_locl.h b/src/lib/libcrypto/ui/ui_locl.h
index 39789e2638..d6c4e26192 100644
--- a/src/lib/libcrypto/ui/ui_locl.h
+++ b/src/lib/libcrypto/ui/ui_locl.h
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -66,8 +66,7 @@
66#undef _ 66#undef _
67#endif 67#endif
68 68
69struct ui_method_st 69struct ui_method_st {
70 {
71 char *name; 70 char *name;
72 71
73 /* All the functions return 1 or non-NULL for success and 0 or NULL 72 /* All the functions return 1 or non-NULL for success and 0 or NULL
@@ -96,11 +95,10 @@ struct ui_method_st
96 The returned string shall always be allocated on the heap with 95 The returned string shall always be allocated on the heap with
97 malloc(), and need to be free'd with free(). */ 96 malloc(), and need to be free'd with free(). */
98 char *(*ui_construct_prompt)(UI *ui, const char *object_desc, 97 char *(*ui_construct_prompt)(UI *ui, const char *object_desc,
99 const char *object_name); 98 const char *object_name);
100 }; 99};
101 100
102struct ui_string_st 101struct ui_string_st {
103 {
104 enum UI_string_types type; /* Input */ 102 enum UI_string_types type; /* Input */
105 const char *out_string; /* Input */ 103 const char *out_string; /* Input */
106 int input_flags; /* Flags from the user */ 104 int input_flags; /* Flags from the user */
@@ -111,10 +109,8 @@ struct ui_string_st
111 with size in result_maxsize. Otherwise, it 109 with size in result_maxsize. Otherwise, it
112 may be allocated by the UI routine, meaning 110 may be allocated by the UI routine, meaning
113 result_minsize is going to be overwritten.*/ 111 result_minsize is going to be overwritten.*/
114 union 112 union {
115 { 113 struct {
116 struct
117 {
118 int result_minsize; /* Input: minimum required 114 int result_minsize; /* Input: minimum required
119 size of the result. 115 size of the result.
120 */ 116 */
@@ -123,21 +119,19 @@ struct ui_string_st
123 119
124 const char *test_buf; /* Input: test string to verify 120 const char *test_buf; /* Input: test string to verify
125 against */ 121 against */
126 } string_data; 122 } string_data;
127 struct 123 struct {
128 {
129 const char *action_desc; /* Input */ 124 const char *action_desc; /* Input */
130 const char *ok_chars; /* Input */ 125 const char *ok_chars; /* Input */
131 const char *cancel_chars; /* Input */ 126 const char *cancel_chars; /* Input */
132 } boolean_data; 127 } boolean_data;
133 } _; 128 } _;
134 129
135#define OUT_STRING_FREEABLE 0x01 130#define OUT_STRING_FREEABLE 0x01
136 int flags; /* flags for internal use */ 131 int flags; /* flags for internal use */
137 }; 132};
138 133
139struct ui_st 134struct ui_st {
140 {
141 const UI_METHOD *meth; 135 const UI_METHOD *meth;
142 STACK_OF(UI_STRING) *strings; /* We might want to prompt for more 136 STACK_OF(UI_STRING) *strings; /* We might want to prompt for more
143 than one thing at a time, and 137 than one thing at a time, and
@@ -148,6 +142,6 @@ struct ui_st
148#define UI_FLAG_REDOABLE 0x0001 142#define UI_FLAG_REDOABLE 0x0001
149#define UI_FLAG_PRINT_ERRORS 0x0100 143#define UI_FLAG_PRINT_ERRORS 0x0100
150 int flags; 144 int flags;
151 }; 145};
152 146
153#endif 147#endif
diff --git a/src/lib/libcrypto/ui/ui_openssl.c b/src/lib/libcrypto/ui/ui_openssl.c
index 94a999baa8..ef483352ea 100644
--- a/src/lib/libcrypto/ui/ui_openssl.c
+++ b/src/lib/libcrypto/ui/ui_openssl.c
@@ -114,7 +114,6 @@
114 * [including the GNU Public Licence.] 114 * [including the GNU Public Licence.]
115 */ 115 */
116 116
117
118#include <openssl/e_os2.h> 117#include <openssl/e_os2.h>
119 118
120#include <signal.h> 119#include <signal.h>
@@ -187,18 +186,17 @@ static int read_till_nl(FILE *);
187static void recsig(int); 186static void recsig(int);
188static void pushsig(void); 187static void pushsig(void);
189static void popsig(void); 188static void popsig(void);
190static int read_string_inner(UI * ui, UI_STRING * uis, int echo, int strip_nl); 189static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl);
191 190
192static int read_string(UI * ui, UI_STRING * uis); 191static int read_string(UI *ui, UI_STRING *uis);
193static int write_string(UI * ui, UI_STRING * uis); 192static int write_string(UI *ui, UI_STRING *uis);
194 193
195static int open_console(UI * ui); 194static int open_console(UI *ui);
196static int echo_console(UI * ui); 195static int echo_console(UI *ui);
197static int noecho_console(UI * ui); 196static int noecho_console(UI *ui);
198static int close_console(UI * ui); 197static int close_console(UI *ui);
199 198
200static UI_METHOD ui_openssl = 199static UI_METHOD ui_openssl = {
201{
202 "OpenSSL default user interface", 200 "OpenSSL default user interface",
203 open_console, 201 open_console,
204 write_string, 202 write_string,
@@ -217,12 +215,12 @@ UI_OpenSSL(void)
217 215
218/* The following function makes sure that info and error strings are printed 216/* The following function makes sure that info and error strings are printed
219 before any prompt. */ 217 before any prompt. */
220static int 218static int
221write_string(UI * ui, UI_STRING * uis) 219write_string(UI *ui, UI_STRING *uis)
222{ 220{
223 switch (UI_get_string_type(uis)) { 221 switch (UI_get_string_type(uis)) {
224 case UIT_ERROR: 222 case UIT_ERROR:
225 case UIT_INFO: 223 case UIT_INFO:
226 fputs(UI_get0_output_string(uis), tty_out); 224 fputs(UI_get0_output_string(uis), tty_out);
227 fflush(tty_out); 225 fflush(tty_out);
228 break; 226 break;
@@ -232,8 +230,8 @@ write_string(UI * ui, UI_STRING * uis)
232 return 1; 230 return 1;
233} 231}
234 232
235static int 233static int
236read_string(UI * ui, UI_STRING * uis) 234read_string(UI *ui, UI_STRING *uis)
237{ 235{
238 int ok = 0; 236 int ok = 0;
239 237
@@ -257,7 +255,7 @@ read_string(UI * ui, UI_STRING * uis)
257 UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1)) <= 0) 255 UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1)) <= 0)
258 return ok; 256 return ok;
259 if (strcmp(UI_get0_result_string(uis), 257 if (strcmp(UI_get0_result_string(uis),
260 UI_get0_test_string(uis)) != 0) { 258 UI_get0_test_string(uis)) != 0) {
261 fprintf(tty_out, "Verify failure\n"); 259 fprintf(tty_out, "Verify failure\n");
262 fflush(tty_out); 260 fflush(tty_out);
263 return 0; 261 return 0;
@@ -271,8 +269,8 @@ read_string(UI * ui, UI_STRING * uis)
271 269
272 270
273/* Internal functions to read a string without echoing */ 271/* Internal functions to read a string without echoing */
274static int 272static int
275read_till_nl(FILE * in) 273read_till_nl(FILE *in)
276{ 274{
277#define SIZE 4 275#define SIZE 4
278 char buf[SIZE + 1]; 276 char buf[SIZE + 1];
@@ -286,8 +284,8 @@ read_till_nl(FILE * in)
286 284
287static volatile sig_atomic_t intr_signal; 285static volatile sig_atomic_t intr_signal;
288 286
289static int 287static int
290read_string_inner(UI * ui, UI_STRING * uis, int echo, int strip_nl) 288read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
291{ 289{
292 static int ps; 290 static int ps;
293 int ok; 291 int ok;
@@ -339,8 +337,8 @@ error:
339 337
340 338
341/* Internal functions to open, handle and close a channel to the console. */ 339/* Internal functions to open, handle and close a channel to the console. */
342static int 340static int
343open_console(UI * ui) 341open_console(UI *ui)
344{ 342{
345 CRYPTO_w_lock(CRYPTO_LOCK_UI); 343 CRYPTO_w_lock(CRYPTO_LOCK_UI);
346 is_a_tty = 1; 344 is_a_tty = 1;
@@ -361,8 +359,8 @@ open_console(UI * ui)
361 * solaris can return EINVAL instead. This should be 359 * solaris can return EINVAL instead. This should be
362 * ok 360 * ok
363 */ 361 */
364 if (errno == EINVAL) 362 if (errno == EINVAL)
365 is_a_tty = 0; 363 is_a_tty = 0;
366 else 364 else
367 return 0; 365 return 0;
368 } 366 }
@@ -370,8 +368,8 @@ open_console(UI * ui)
370 return 1; 368 return 1;
371} 369}
372 370
373static int 371static int
374noecho_console(UI * ui) 372noecho_console(UI *ui)
375{ 373{
376#ifdef TTY_FLAGS 374#ifdef TTY_FLAGS
377 memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); 375 memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig));
@@ -385,8 +383,8 @@ noecho_console(UI * ui)
385 return 1; 383 return 1;
386} 384}
387 385
388static int 386static int
389echo_console(UI * ui) 387echo_console(UI *ui)
390{ 388{
391#if defined(TTY_set) 389#if defined(TTY_set)
392 memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); 390 memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig));
@@ -400,8 +398,8 @@ echo_console(UI * ui)
400 return 1; 398 return 1;
401} 399}
402 400
403static int 401static int
404close_console(UI * ui) 402close_console(UI *ui)
405{ 403{
406 if (tty_in != stdin) 404 if (tty_in != stdin)
407 fclose(tty_in); 405 fclose(tty_in);
@@ -414,7 +412,7 @@ close_console(UI * ui)
414 412
415 413
416/* Internal functions to handle signals and act on them */ 414/* Internal functions to handle signals and act on them */
417static void 415static void
418pushsig(void) 416pushsig(void)
419{ 417{
420 int i; 418 int i;
@@ -450,7 +448,7 @@ pushsig(void)
450#endif 448#endif
451} 449}
452 450
453static void 451static void
454popsig(void) 452popsig(void)
455{ 453{
456 int i; 454 int i;
@@ -467,7 +465,7 @@ popsig(void)
467 } 465 }
468} 466}
469 467
470static void 468static void
471recsig(int i) 469recsig(int i)
472{ 470{
473 intr_signal = i; 471 intr_signal = i;
diff --git a/src/lib/libcrypto/ui/ui_util.c b/src/lib/libcrypto/ui/ui_util.c
index af50451403..81c5a079a6 100644
--- a/src/lib/libcrypto/ui/ui_util.c
+++ b/src/lib/libcrypto/ui/ui_util.c
@@ -56,18 +56,19 @@
56#include <string.h> 56#include <string.h>
57#include "ui_locl.h" 57#include "ui_locl.h"
58 58
59int 59int
60UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify) 60UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify)
61{ 61{
62 char buff[BUFSIZ]; 62 char buff[BUFSIZ];
63 int ret; 63 int ret;
64 64
65 ret = UI_UTIL_read_pw(buf, buff, (length > BUFSIZ) ? BUFSIZ : length, prompt, verify); 65 ret = UI_UTIL_read_pw(buf, buff, (length > BUFSIZ) ? BUFSIZ : length,
66 prompt, verify);
66 OPENSSL_cleanse(buff, BUFSIZ); 67 OPENSSL_cleanse(buff, BUFSIZ);
67 return (ret); 68 return (ret);
68} 69}
69 70
70int 71int
71UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify) 72UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify)
72{ 73{
73 int ok = 0; 74 int ok = 0;
@@ -80,8 +81,8 @@ UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify)
80 if (ui) { 81 if (ui) {
81 ok = UI_add_input_string(ui, prompt, 0, buf, 0, size - 1); 82 ok = UI_add_input_string(ui, prompt, 0, buf, 0, size - 1);
82 if (ok >= 0 && verify) 83 if (ok >= 0 && verify)
83 ok = UI_add_verify_string(ui, prompt, 0, buff, 0, size - 1, 84 ok = UI_add_verify_string(ui, prompt, 0, buff, 0,
84 buf); 85 size - 1, buf);
85 if (ok >= 0) 86 if (ok >= 0)
86 ok = UI_process(ui); 87 ok = UI_process(ui);
87 UI_free(ui); 88 UI_free(ui);
diff --git a/src/lib/libssl/src/crypto/ui/ui.h b/src/lib/libssl/src/crypto/ui/ui.h
index ed35e50eb4..7970f893d6 100644
--- a/src/lib/libssl/src/crypto/ui/ui.h
+++ b/src/lib/libssl/src/crypto/ui/ui.h
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -128,19 +128,19 @@ void UI_free(UI *ui);
128 On success, the all return an index of the added information. That index 128 On success, the all return an index of the added information. That index
129 is usefull when retrieving results with UI_get0_result(). */ 129 is usefull when retrieving results with UI_get0_result(). */
130int UI_add_input_string(UI *ui, const char *prompt, int flags, 130int UI_add_input_string(UI *ui, const char *prompt, int flags,
131 char *result_buf, int minsize, int maxsize); 131 char *result_buf, int minsize, int maxsize);
132int UI_dup_input_string(UI *ui, const char *prompt, int flags, 132int UI_dup_input_string(UI *ui, const char *prompt, int flags,
133 char *result_buf, int minsize, int maxsize); 133 char *result_buf, int minsize, int maxsize);
134int UI_add_verify_string(UI *ui, const char *prompt, int flags, 134int UI_add_verify_string(UI *ui, const char *prompt, int flags,
135 char *result_buf, int minsize, int maxsize, const char *test_buf); 135 char *result_buf, int minsize, int maxsize, const char *test_buf);
136int UI_dup_verify_string(UI *ui, const char *prompt, int flags, 136int UI_dup_verify_string(UI *ui, const char *prompt, int flags,
137 char *result_buf, int minsize, int maxsize, const char *test_buf); 137 char *result_buf, int minsize, int maxsize, const char *test_buf);
138int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, 138int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
139 const char *ok_chars, const char *cancel_chars, 139 const char *ok_chars, const char *cancel_chars,
140 int flags, char *result_buf); 140 int flags, char *result_buf);
141int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, 141int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
142 const char *ok_chars, const char *cancel_chars, 142 const char *ok_chars, const char *cancel_chars,
143 int flags, char *result_buf); 143 int flags, char *result_buf);
144int UI_add_info_string(UI *ui, const char *text); 144int UI_add_info_string(UI *ui, const char *text);
145int UI_dup_info_string(UI *ui, const char *text); 145int UI_dup_info_string(UI *ui, const char *text);
146int UI_add_error_string(UI *ui, const char *text); 146int UI_add_error_string(UI *ui, const char *text);
@@ -185,8 +185,8 @@ int UI_dup_error_string(UI *ui, const char *text);
185 185
186 "Enter pass phrase for foo.key:" 186 "Enter pass phrase for foo.key:"
187*/ 187*/
188char *UI_construct_prompt(UI *ui_method, 188char *UI_construct_prompt(UI *ui_method, const char *object_desc,
189 const char *object_desc, const char *object_name); 189 const char *object_name);
190 190
191 191
192/* The following function is used to store a pointer to user-specific data. 192/* The following function is used to store a pointer to user-specific data.
@@ -228,8 +228,8 @@ int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)(void));
228#define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg) 228#define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg)
229#define UI_get_app_data(s) UI_get_ex_data(s,0) 229#define UI_get_app_data(s) UI_get_ex_data(s,0)
230int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 230int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
231 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); 231 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
232int UI_set_ex_data(UI *r,int idx,void *arg); 232int UI_set_ex_data(UI *r, int idx, void *arg);
233void *UI_get_ex_data(UI *r, int idx); 233void *UI_get_ex_data(UI *r, int idx);
234 234
235/* Use specific methods instead of the built-in one */ 235/* Use specific methods instead of the built-in one */
@@ -292,15 +292,14 @@ DECLARE_STACK_OF(UI_STRING)
292 292
293/* The different types of strings that are currently supported. 293/* The different types of strings that are currently supported.
294 This is only needed by method authors. */ 294 This is only needed by method authors. */
295enum UI_string_types 295enum UI_string_types {
296 { 296 UIT_NONE = 0,
297 UIT_NONE=0,
298 UIT_PROMPT, /* Prompt for a string */ 297 UIT_PROMPT, /* Prompt for a string */
299 UIT_VERIFY, /* Prompt for a string and verify */ 298 UIT_VERIFY, /* Prompt for a string and verify */
300 UIT_BOOLEAN, /* Prompt for a yes/no response */ 299 UIT_BOOLEAN, /* Prompt for a yes/no response */
301 UIT_INFO, /* Send info to the user */ 300 UIT_INFO, /* Send info to the user */
302 UIT_ERROR /* Send an error message to the user */ 301 UIT_ERROR /* Send an error message to the user */
303 }; 302};
304 303
305/* Create and manipulate methods */ 304/* Create and manipulate methods */
306UI_METHOD *UI_create_method(char *name); 305UI_METHOD *UI_create_method(char *name);
@@ -312,9 +311,9 @@ int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis
312int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)); 311int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui));
313int UI_method_set_prompt_constructor(UI_METHOD *method, char *(*prompt_constructor)(UI* ui, const char* object_desc, const char* object_name)); 312int UI_method_set_prompt_constructor(UI_METHOD *method, char *(*prompt_constructor)(UI* ui, const char* object_desc, const char* object_name));
314int (*UI_method_get_opener(UI_METHOD *method))(UI*); 313int (*UI_method_get_opener(UI_METHOD *method))(UI*);
315int (*UI_method_get_writer(UI_METHOD *method))(UI*,UI_STRING*); 314int (*UI_method_get_writer(UI_METHOD *method))(UI*, UI_STRING*);
316int (*UI_method_get_flusher(UI_METHOD *method))(UI*); 315int (*UI_method_get_flusher(UI_METHOD *method))(UI*);
317int (*UI_method_get_reader(UI_METHOD *method))(UI*,UI_STRING*); 316int (*UI_method_get_reader(UI_METHOD *method))(UI*, UI_STRING*);
318int (*UI_method_get_closer(UI_METHOD *method))(UI*); 317int (*UI_method_get_closer(UI_METHOD *method))(UI*);
319char * (*UI_method_get_prompt_constructor(UI_METHOD *method))(UI*, const char*, const char*); 318char * (*UI_method_get_prompt_constructor(UI_METHOD *method))(UI*, const char*, const char*);
320 319
@@ -342,8 +341,8 @@ int UI_set_result(UI *ui, UI_STRING *uis, const char *result);
342 341
343 342
344/* A couple of popular utility functions */ 343/* A couple of popular utility functions */
345int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify); 344int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify);
346int UI_UTIL_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); 345int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify);
347 346
348 347
349/* BEGIN ERROR CODES */ 348/* BEGIN ERROR CODES */
diff --git a/src/lib/libssl/src/crypto/ui/ui_compat.c b/src/lib/libssl/src/crypto/ui/ui_compat.c
index 2c5ee4dcee..416e035bdf 100644
--- a/src/lib/libssl/src/crypto/ui/ui_compat.c
+++ b/src/lib/libssl/src/crypto/ui/ui_compat.c
@@ -56,13 +56,13 @@
56#include <string.h> 56#include <string.h>
57#include <openssl/ui_compat.h> 57#include <openssl/ui_compat.h>
58 58
59int 59int
60_ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, int verify) 60_ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, int verify)
61{ 61{
62 return UI_UTIL_read_pw_string(buf, length, prompt, verify); 62 return UI_UTIL_read_pw_string(buf, length, prompt, verify);
63} 63}
64 64
65int 65int
66_ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify) 66_ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify)
67{ 67{
68 return UI_UTIL_read_pw(buf, buff, size, prompt, verify); 68 return UI_UTIL_read_pw(buf, buff, size, prompt, verify);
diff --git a/src/lib/libssl/src/crypto/ui/ui_compat.h b/src/lib/libssl/src/crypto/ui/ui_compat.h
index b35c9bb7fd..75c2ae1ef9 100644
--- a/src/lib/libssl/src/crypto/ui/ui_compat.h
+++ b/src/lib/libssl/src/crypto/ui/ui_compat.h
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -74,8 +74,8 @@ extern "C" {
74#define des_read_pw(b,bf,s,p,v) \ 74#define des_read_pw(b,bf,s,p,v) \
75 _ossl_old_des_read_pw((b),(bf),(s),(p),(v)) 75 _ossl_old_des_read_pw((b),(bf),(s),(p),(v))
76 76
77int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify); 77int _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, int verify);
78int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); 78int _ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify);
79 79
80#ifdef __cplusplus 80#ifdef __cplusplus
81} 81}
diff --git a/src/lib/libssl/src/crypto/ui/ui_err.c b/src/lib/libssl/src/crypto/ui/ui_err.c
index a9b22e2e57..e8b841eb0d 100644
--- a/src/lib/libssl/src/crypto/ui/ui_err.c
+++ b/src/lib/libssl/src/crypto/ui/ui_err.c
@@ -68,8 +68,7 @@
68#define ERR_FUNC(func) ERR_PACK(ERR_LIB_UI,func,0) 68#define ERR_FUNC(func) ERR_PACK(ERR_LIB_UI,func,0)
69#define ERR_REASON(reason) ERR_PACK(ERR_LIB_UI,0,reason) 69#define ERR_REASON(reason) ERR_PACK(ERR_LIB_UI,0,reason)
70 70
71static ERR_STRING_DATA UI_str_functs[] = 71static ERR_STRING_DATA UI_str_functs[] = {
72{
73 {ERR_FUNC(UI_F_GENERAL_ALLOCATE_BOOLEAN), "GENERAL_ALLOCATE_BOOLEAN"}, 72 {ERR_FUNC(UI_F_GENERAL_ALLOCATE_BOOLEAN), "GENERAL_ALLOCATE_BOOLEAN"},
74 {ERR_FUNC(UI_F_GENERAL_ALLOCATE_PROMPT), "GENERAL_ALLOCATE_PROMPT"}, 73 {ERR_FUNC(UI_F_GENERAL_ALLOCATE_PROMPT), "GENERAL_ALLOCATE_PROMPT"},
75 {ERR_FUNC(UI_F_GENERAL_ALLOCATE_STRING), "GENERAL_ALLOCATE_STRING"}, 74 {ERR_FUNC(UI_F_GENERAL_ALLOCATE_STRING), "GENERAL_ALLOCATE_STRING"},
@@ -85,8 +84,7 @@ static ERR_STRING_DATA UI_str_functs[] =
85 {0, NULL} 84 {0, NULL}
86}; 85};
87 86
88static ERR_STRING_DATA UI_str_reasons[] = 87static ERR_STRING_DATA UI_str_reasons[] = {
89{
90 {ERR_REASON(UI_R_COMMON_OK_AND_CANCEL_CHARACTERS), "common ok and cancel characters"}, 88 {ERR_REASON(UI_R_COMMON_OK_AND_CANCEL_CHARACTERS), "common ok and cancel characters"},
91 {ERR_REASON(UI_R_INDEX_TOO_LARGE), "index too large"}, 89 {ERR_REASON(UI_R_INDEX_TOO_LARGE), "index too large"},
92 {ERR_REASON(UI_R_INDEX_TOO_SMALL), "index too small"}, 90 {ERR_REASON(UI_R_INDEX_TOO_SMALL), "index too small"},
@@ -99,11 +97,10 @@ static ERR_STRING_DATA UI_str_reasons[] =
99 97
100#endif 98#endif
101 99
102void 100void
103ERR_load_UI_strings(void) 101ERR_load_UI_strings(void)
104{ 102{
105#ifndef OPENSSL_NO_ERR 103#ifndef OPENSSL_NO_ERR
106
107 if (ERR_func_error_string(UI_str_functs[0].error) == NULL) { 104 if (ERR_func_error_string(UI_str_functs[0].error) == NULL) {
108 ERR_load_strings(0, UI_str_functs); 105 ERR_load_strings(0, UI_str_functs);
109 ERR_load_strings(0, UI_str_reasons); 106 ERR_load_strings(0, UI_str_reasons);
diff --git a/src/lib/libssl/src/crypto/ui/ui_lib.c b/src/lib/libssl/src/crypto/ui/ui_lib.c
index 32fb9d7dbb..fc03d9b7d4 100644
--- a/src/lib/libssl/src/crypto/ui/ui_lib.c
+++ b/src/lib/libssl/src/crypto/ui/ui_lib.c
@@ -64,16 +64,16 @@
64#include <openssl/err.h> 64#include <openssl/err.h>
65#include "ui_locl.h" 65#include "ui_locl.h"
66 66
67IMPLEMENT_STACK_OF(UI_STRING_ST) 67IMPLEMENT_STACK_OF(UI_STRING_ST) static const UI_METHOD *default_UI_meth = NULL;
68 static const UI_METHOD *default_UI_meth = NULL;
69 68
70 UI *UI_new(void) 69UI *
70UI_new(void)
71{ 71{
72 return (UI_new_method(NULL)); 72 return (UI_new_method(NULL));
73} 73}
74 74
75UI * 75UI *
76UI_new_method(const UI_METHOD * method) 76UI_new_method(const UI_METHOD *method)
77{ 77{
78 UI *ret; 78 UI *ret;
79 79
@@ -94,16 +94,16 @@ UI_new_method(const UI_METHOD * method)
94 return ret; 94 return ret;
95} 95}
96 96
97static void 97static void
98free_string(UI_STRING * uis) 98free_string(UI_STRING *uis)
99{ 99{
100 if (uis->flags & OUT_STRING_FREEABLE) { 100 if (uis->flags & OUT_STRING_FREEABLE) {
101 free((char *) uis->out_string); 101 free((char *) uis->out_string);
102 switch (uis->type) { 102 switch (uis->type) {
103 case UIT_BOOLEAN: 103 case UIT_BOOLEAN:
104 free((char *) uis->_.boolean_data.action_desc); 104 free((char *)uis->_.boolean_data.action_desc);
105 free((char *) uis->_.boolean_data.ok_chars); 105 free((char *)uis->_.boolean_data.ok_chars);
106 free((char *) uis->_.boolean_data.cancel_chars); 106 free((char *)uis->_.boolean_data.cancel_chars);
107 break; 107 break;
108 default: 108 default:
109 break; 109 break;
@@ -112,8 +112,8 @@ free_string(UI_STRING * uis)
112 free(uis); 112 free(uis);
113} 113}
114 114
115void 115void
116UI_free(UI * ui) 116UI_free(UI *ui)
117{ 117{
118 if (ui == NULL) 118 if (ui == NULL)
119 return; 119 return;
@@ -122,8 +122,8 @@ UI_free(UI * ui)
122 free(ui); 122 free(ui);
123} 123}
124 124
125static int 125static int
126allocate_string_stack(UI * ui) 126allocate_string_stack(UI *ui)
127{ 127{
128 if (ui->strings == NULL) { 128 if (ui->strings == NULL) {
129 ui->strings = sk_UI_STRING_new_null(); 129 ui->strings = sk_UI_STRING_new_null();
@@ -135,7 +135,7 @@ allocate_string_stack(UI * ui)
135} 135}
136 136
137static UI_STRING * 137static UI_STRING *
138general_allocate_prompt(UI * ui, const char *prompt, 138general_allocate_prompt(UI *ui, const char *prompt,
139 int prompt_freeable, enum UI_string_types type, int input_flags, 139 int prompt_freeable, enum UI_string_types type, int input_flags,
140 char *result_buf) 140 char *result_buf)
141{ 141{
@@ -143,8 +143,8 @@ general_allocate_prompt(UI * ui, const char *prompt,
143 143
144 if (prompt == NULL) { 144 if (prompt == NULL) {
145 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, ERR_R_PASSED_NULL_PARAMETER); 145 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, ERR_R_PASSED_NULL_PARAMETER);
146 } else if ((type == UIT_PROMPT || type == UIT_VERIFY 146 } else if ((type == UIT_PROMPT || type == UIT_VERIFY ||
147 || type == UIT_BOOLEAN) && result_buf == NULL) { 147 type == UIT_BOOLEAN) && result_buf == NULL) {
148 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER); 148 UIerr(UI_F_GENERAL_ALLOCATE_PROMPT, UI_R_NO_RESULT_BUFFER);
149 } else if ((ret = (UI_STRING *) malloc(sizeof(UI_STRING)))) { 149 } else if ((ret = (UI_STRING *) malloc(sizeof(UI_STRING)))) {
150 ret->out_string = prompt; 150 ret->out_string = prompt;
@@ -156,8 +156,8 @@ general_allocate_prompt(UI * ui, const char *prompt,
156 return ret; 156 return ret;
157} 157}
158 158
159static int 159static int
160general_allocate_string(UI * ui, const char *prompt, 160general_allocate_string(UI *ui, const char *prompt,
161 int prompt_freeable, enum UI_string_types type, int input_flags, 161 int prompt_freeable, enum UI_string_types type, int input_flags,
162 char *result_buf, int minsize, int maxsize, const char *test_buf) 162 char *result_buf, int minsize, int maxsize, const char *test_buf)
163{ 163{
@@ -180,8 +180,8 @@ general_allocate_string(UI * ui, const char *prompt,
180 return ret; 180 return ret;
181} 181}
182 182
183static int 183static int
184general_allocate_boolean(UI * ui, 184general_allocate_boolean(UI *ui,
185 const char *prompt, const char *action_desc, 185 const char *prompt, const char *action_desc,
186 const char *ok_chars, const char *cancel_chars, 186 const char *ok_chars, const char *cancel_chars,
187 int prompt_freeable, enum UI_string_types type, int input_flags, 187 int prompt_freeable, enum UI_string_types type, int input_flags,
@@ -227,8 +227,8 @@ general_allocate_boolean(UI * ui,
227 227
228/* Returns the index to the place in the stack or -1 for error. Uses a 228/* Returns the index to the place in the stack or -1 for error. Uses a
229 direct reference to the prompt. */ 229 direct reference to the prompt. */
230int 230int
231UI_add_input_string(UI * ui, const char *prompt, int flags, 231UI_add_input_string(UI *ui, const char *prompt, int flags,
232 char *result_buf, int minsize, int maxsize) 232 char *result_buf, int minsize, int maxsize)
233{ 233{
234 return general_allocate_string(ui, prompt, 0, 234 return general_allocate_string(ui, prompt, 0,
@@ -236,8 +236,8 @@ UI_add_input_string(UI * ui, const char *prompt, int flags,
236} 236}
237 237
238/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */ 238/* Same as UI_add_input_string(), excepts it takes a copy of the prompt */
239int 239int
240UI_dup_input_string(UI * ui, const char *prompt, int flags, 240UI_dup_input_string(UI *ui, const char *prompt, int flags,
241 char *result_buf, int minsize, int maxsize) 241 char *result_buf, int minsize, int maxsize)
242{ 242{
243 char *prompt_copy = NULL; 243 char *prompt_copy = NULL;
@@ -253,16 +253,16 @@ UI_dup_input_string(UI * ui, const char *prompt, int flags,
253 UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); 253 UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL);
254} 254}
255 255
256int 256int
257UI_add_verify_string(UI * ui, const char *prompt, int flags, 257UI_add_verify_string(UI *ui, const char *prompt, int flags,
258 char *result_buf, int minsize, int maxsize, const char *test_buf) 258 char *result_buf, int minsize, int maxsize, const char *test_buf)
259{ 259{
260 return general_allocate_string(ui, prompt, 0, 260 return general_allocate_string(ui, prompt, 0,
261 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); 261 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf);
262} 262}
263 263
264int 264int
265UI_dup_verify_string(UI * ui, const char *prompt, int flags, 265UI_dup_verify_string(UI *ui, const char *prompt, int flags,
266 char *result_buf, int minsize, int maxsize, const char *test_buf) 266 char *result_buf, int minsize, int maxsize, const char *test_buf)
267{ 267{
268 char *prompt_copy = NULL; 268 char *prompt_copy = NULL;
@@ -278,8 +278,8 @@ UI_dup_verify_string(UI * ui, const char *prompt, int flags,
278 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); 278 UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf);
279} 279}
280 280
281int 281int
282UI_add_input_boolean(UI * ui, const char *prompt, const char *action_desc, 282UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,
283 const char *ok_chars, const char *cancel_chars, 283 const char *ok_chars, const char *cancel_chars,
284 int flags, char *result_buf) 284 int flags, char *result_buf)
285{ 285{
@@ -287,8 +287,8 @@ UI_add_input_boolean(UI * ui, const char *prompt, const char *action_desc,
287 ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf); 287 ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf);
288} 288}
289 289
290int 290int
291UI_dup_input_boolean(UI * ui, const char *prompt, const char *action_desc, 291UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,
292 const char *ok_chars, const char *cancel_chars, 292 const char *ok_chars, const char *cancel_chars,
293 int flags, char *result_buf) 293 int flags, char *result_buf)
294{ 294{
@@ -328,6 +328,7 @@ UI_dup_input_boolean(UI * ui, const char *prompt, const char *action_desc,
328 return general_allocate_boolean(ui, prompt_copy, action_desc_copy, 328 return general_allocate_boolean(ui, prompt_copy, action_desc_copy,
329 ok_chars_copy, cancel_chars_copy, 1, UIT_BOOLEAN, flags, 329 ok_chars_copy, cancel_chars_copy, 1, UIT_BOOLEAN, flags,
330 result_buf); 330 result_buf);
331
331err: 332err:
332 if (prompt_copy) 333 if (prompt_copy)
333 free(prompt_copy); 334 free(prompt_copy);
@@ -340,15 +341,15 @@ err:
340 return -1; 341 return -1;
341} 342}
342 343
343int 344int
344UI_add_info_string(UI * ui, const char *text) 345UI_add_info_string(UI *ui, const char *text)
345{ 346{
346 return general_allocate_string(ui, text, 0, UIT_INFO, 0, NULL, 0, 0, 347 return general_allocate_string(ui, text, 0, UIT_INFO, 0, NULL, 0, 0,
347 NULL); 348 NULL);
348} 349}
349 350
350int 351int
351UI_dup_info_string(UI * ui, const char *text) 352UI_dup_info_string(UI *ui, const char *text)
352{ 353{
353 char *text_copy = NULL; 354 char *text_copy = NULL;
354 355
@@ -363,15 +364,15 @@ UI_dup_info_string(UI * ui, const char *text)
363 0, 0, NULL); 364 0, 0, NULL);
364} 365}
365 366
366int 367int
367UI_add_error_string(UI * ui, const char *text) 368UI_add_error_string(UI *ui, const char *text)
368{ 369{
369 return general_allocate_string(ui, text, 0, UIT_ERROR, 0, NULL, 0, 0, 370 return general_allocate_string(ui, text, 0, UIT_ERROR, 0, NULL, 0, 0,
370 NULL); 371 NULL);
371} 372}
372 373
373int 374int
374UI_dup_error_string(UI * ui, const char *text) 375UI_dup_error_string(UI *ui, const char *text)
375{ 376{
376 char *text_copy = NULL; 377 char *text_copy = NULL;
377 378
@@ -387,8 +388,7 @@ UI_dup_error_string(UI * ui, const char *text)
387} 388}
388 389
389char * 390char *
390UI_construct_prompt(UI * ui, const char *object_desc, 391UI_construct_prompt(UI *ui, const char *object_desc, const char *object_name)
391 const char *object_name)
392{ 392{
393 char *prompt = NULL; 393 char *prompt = NULL;
394 394
@@ -408,7 +408,7 @@ UI_construct_prompt(UI * ui, const char *object_desc,
408 len += sizeof(prompt2) - 1 + strlen(object_name); 408 len += sizeof(prompt2) - 1 + strlen(object_name);
409 len += sizeof(prompt3) - 1; 409 len += sizeof(prompt3) - 1;
410 410
411 prompt = (char *) malloc(len + 1); 411 prompt = (char *)malloc(len + 1);
412 BUF_strlcpy(prompt, prompt1, len + 1); 412 BUF_strlcpy(prompt, prompt1, len + 1);
413 BUF_strlcat(prompt, object_desc, len + 1); 413 BUF_strlcat(prompt, object_desc, len + 1);
414 if (object_name) { 414 if (object_name) {
@@ -421,7 +421,7 @@ UI_construct_prompt(UI * ui, const char *object_desc,
421} 421}
422 422
423void * 423void *
424UI_add_user_data(UI * ui, void *user_data) 424UI_add_user_data(UI *ui, void *user_data)
425{ 425{
426 void *old_data = ui->user_data; 426 void *old_data = ui->user_data;
427 ui->user_data = user_data; 427 ui->user_data = user_data;
@@ -429,13 +429,13 @@ UI_add_user_data(UI * ui, void *user_data)
429} 429}
430 430
431void * 431void *
432UI_get0_user_data(UI * ui) 432UI_get0_user_data(UI *ui)
433{ 433{
434 return ui->user_data; 434 return ui->user_data;
435} 435}
436 436
437const char * 437const char *
438UI_get0_result(UI * ui, int i) 438UI_get0_result(UI *ui, int i)
439{ 439{
440 if (i < 0) { 440 if (i < 0) {
441 UIerr(UI_F_UI_GET0_RESULT, UI_R_INDEX_TOO_SMALL); 441 UIerr(UI_F_UI_GET0_RESULT, UI_R_INDEX_TOO_SMALL);
@@ -448,8 +448,8 @@ UI_get0_result(UI * ui, int i)
448 return UI_get0_result_string(sk_UI_STRING_value(ui->strings, i)); 448 return UI_get0_result_string(sk_UI_STRING_value(ui->strings, i));
449} 449}
450 450
451static int 451static int
452print_error(const char *str, size_t len, UI * ui) 452print_error(const char *str, size_t len, UI *ui)
453{ 453{
454 UI_STRING uis; 454 UI_STRING uis;
455 455
@@ -457,14 +457,14 @@ print_error(const char *str, size_t len, UI * ui)
457 uis.type = UIT_ERROR; 457 uis.type = UIT_ERROR;
458 uis.out_string = str; 458 uis.out_string = str;
459 459
460 if (ui->meth->ui_write_string 460 if (ui->meth->ui_write_string &&
461 && !ui->meth->ui_write_string(ui, &uis)) 461 !ui->meth->ui_write_string(ui, &uis))
462 return -1; 462 return -1;
463 return 0; 463 return 0;
464} 464}
465 465
466int 466int
467UI_process(UI * ui) 467UI_process(UI *ui)
468{ 468{
469 int i, ok = 0; 469 int i, ok = 0;
470 470
@@ -473,12 +473,12 @@ UI_process(UI * ui)
473 473
474 if (ui->flags & UI_FLAG_PRINT_ERRORS) 474 if (ui->flags & UI_FLAG_PRINT_ERRORS)
475 ERR_print_errors_cb( 475 ERR_print_errors_cb(
476 (int (*) (const char *, size_t, void *)) print_error, 476 (int (*)(const char *, size_t, void *)) print_error,
477 (void *) ui); 477 (void *)ui);
478 478
479 for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) { 479 for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) {
480 if (ui->meth->ui_write_string 480 if (ui->meth->ui_write_string &&
481 && !ui->meth->ui_write_string(ui, 481 !ui->meth->ui_write_string(ui,
482 sk_UI_STRING_value(ui->strings, i))) { 482 sk_UI_STRING_value(ui->strings, i))) {
483 ok = -1; 483 ok = -1;
484 goto err; 484 goto err;
@@ -490,7 +490,7 @@ UI_process(UI * ui)
490 case -1: /* Interrupt/Cancel/something... */ 490 case -1: /* Interrupt/Cancel/something... */
491 ok = -2; 491 ok = -2;
492 goto err; 492 goto err;
493 case 0: /* Errors */ 493 case 0: /* Errors */
494 ok = -1; 494 ok = -1;
495 goto err; 495 goto err;
496 default: /* Success */ 496 default: /* Success */
@@ -501,11 +501,11 @@ UI_process(UI * ui)
501 for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) { 501 for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) {
502 if (ui->meth->ui_read_string) { 502 if (ui->meth->ui_read_string) {
503 switch (ui->meth->ui_read_string(ui, 503 switch (ui->meth->ui_read_string(ui,
504 sk_UI_STRING_value(ui->strings, i))) { 504 sk_UI_STRING_value(ui->strings, i))) {
505 case -1: /* Interrupt/Cancel/something... */ 505 case -1: /* Interrupt/Cancel/something... */
506 ok = -2; 506 ok = -2;
507 goto err; 507 goto err;
508 case 0:/* Errors */ 508 case 0: /* Errors */
509 ok = -1; 509 ok = -1;
510 goto err; 510 goto err;
511 default: /* Success */ 511 default: /* Success */
@@ -520,8 +520,8 @@ err:
520 return ok; 520 return ok;
521} 521}
522 522
523int 523int
524UI_ctrl(UI * ui, int cmd, long i, void *p, void (*f) (void)) 524UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void))
525{ 525{
526 if (ui == NULL) { 526 if (ui == NULL) {
527 UIerr(UI_F_UI_CTRL, ERR_R_PASSED_NULL_PARAMETER); 527 UIerr(UI_F_UI_CTRL, ERR_R_PASSED_NULL_PARAMETER);
@@ -546,28 +546,28 @@ UI_ctrl(UI * ui, int cmd, long i, void *p, void (*f) (void))
546 return -1; 546 return -1;
547} 547}
548 548
549int 549int
550UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new * new_func, 550UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
551 CRYPTO_EX_dup * dup_func, CRYPTO_EX_free * free_func) 551 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
552{ 552{
553 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, argl, argp, 553 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, argl, argp,
554 new_func, dup_func, free_func); 554 new_func, dup_func, free_func);
555} 555}
556 556
557int 557int
558UI_set_ex_data(UI * r, int idx, void *arg) 558UI_set_ex_data(UI *r, int idx, void *arg)
559{ 559{
560 return (CRYPTO_set_ex_data(&r->ex_data, idx, arg)); 560 return (CRYPTO_set_ex_data(&r->ex_data, idx, arg));
561} 561}
562 562
563void * 563void *
564UI_get_ex_data(UI * r, int idx) 564UI_get_ex_data(UI *r, int idx)
565{ 565{
566 return (CRYPTO_get_ex_data(&r->ex_data, idx)); 566 return (CRYPTO_get_ex_data(&r->ex_data, idx));
567} 567}
568 568
569void 569void
570UI_set_default_method(const UI_METHOD * meth) 570UI_set_default_method(const UI_METHOD *meth)
571{ 571{
572 default_UI_meth = meth; 572 default_UI_meth = meth;
573} 573}
@@ -582,13 +582,13 @@ UI_get_default_method(void)
582} 582}
583 583
584const UI_METHOD * 584const UI_METHOD *
585UI_get_method(UI * ui) 585UI_get_method(UI *ui)
586{ 586{
587 return ui->meth; 587 return ui->meth;
588} 588}
589 589
590const UI_METHOD * 590const UI_METHOD *
591UI_set_method(UI * ui, const UI_METHOD * meth) 591UI_set_method(UI *ui, const UI_METHOD *meth)
592{ 592{
593 ui->meth = meth; 593 ui->meth = meth;
594 return ui->meth; 594 return ui->meth;
@@ -610,16 +610,16 @@ UI_create_method(char *name)
610/* BIG FSCKING WARNING!!!! If you use this on a statically allocated method 610/* BIG FSCKING WARNING!!!! If you use this on a statically allocated method
611 (that is, it hasn't been allocated using UI_create_method(), you deserve 611 (that is, it hasn't been allocated using UI_create_method(), you deserve
612 anything Murphy can throw at you and more! You have been warned. */ 612 anything Murphy can throw at you and more! You have been warned. */
613void 613void
614UI_destroy_method(UI_METHOD * ui_method) 614UI_destroy_method(UI_METHOD *ui_method)
615{ 615{
616 free(ui_method->name); 616 free(ui_method->name);
617 ui_method->name = NULL; 617 ui_method->name = NULL;
618 free(ui_method); 618 free(ui_method);
619} 619}
620 620
621int 621int
622UI_method_set_opener(UI_METHOD * method, int (*opener) (UI * ui)) 622UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui))
623{ 623{
624 if (method) { 624 if (method) {
625 method->ui_open_session = opener; 625 method->ui_open_session = opener;
@@ -628,8 +628,8 @@ UI_method_set_opener(UI_METHOD * method, int (*opener) (UI * ui))
628 return -1; 628 return -1;
629} 629}
630 630
631int 631int
632UI_method_set_writer(UI_METHOD * method, int (*writer) (UI * ui, UI_STRING * uis)) 632UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis))
633{ 633{
634 if (method) { 634 if (method) {
635 method->ui_write_string = writer; 635 method->ui_write_string = writer;
@@ -638,8 +638,8 @@ UI_method_set_writer(UI_METHOD * method, int (*writer) (UI * ui, UI_STRING * uis
638 return -1; 638 return -1;
639} 639}
640 640
641int 641int
642UI_method_set_flusher(UI_METHOD * method, int (*flusher) (UI * ui)) 642UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui))
643{ 643{
644 if (method) { 644 if (method) {
645 method->ui_flush = flusher; 645 method->ui_flush = flusher;
@@ -648,8 +648,8 @@ UI_method_set_flusher(UI_METHOD * method, int (*flusher) (UI * ui))
648 return -1; 648 return -1;
649} 649}
650 650
651int 651int
652UI_method_set_reader(UI_METHOD * method, int (*reader) (UI * ui, UI_STRING * uis)) 652UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis))
653{ 653{
654 if (method) { 654 if (method) {
655 method->ui_read_string = reader; 655 method->ui_read_string = reader;
@@ -658,8 +658,8 @@ UI_method_set_reader(UI_METHOD * method, int (*reader) (UI * ui, UI_STRING * uis
658 return -1; 658 return -1;
659} 659}
660 660
661int 661int
662UI_method_set_closer(UI_METHOD * method, int (*closer) (UI * ui)) 662UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui))
663{ 663{
664 if (method) { 664 if (method) {
665 method->ui_close_session = closer; 665 method->ui_close_session = closer;
@@ -668,8 +668,10 @@ UI_method_set_closer(UI_METHOD * method, int (*closer) (UI * ui))
668 return -1; 668 return -1;
669} 669}
670 670
671int 671int
672UI_method_set_prompt_constructor(UI_METHOD * method, char *(*prompt_constructor) (UI * ui, const char *object_desc, const char *object_name)) 672UI_method_set_prompt_constructor(UI_METHOD *method,
673 char *(*prompt_constructor)(UI *ui, const char *object_desc,
674 const char *object_name))
673{ 675{
674 if (method) { 676 if (method) {
675 method->ui_construct_prompt = prompt_constructor; 677 method->ui_construct_prompt = prompt_constructor;
@@ -678,8 +680,8 @@ UI_method_set_prompt_constructor(UI_METHOD * method, char *(*prompt_constructor)
678 return -1; 680 return -1;
679} 681}
680 682
681int (* 683int
682 UI_method_get_opener(UI_METHOD * method)) (UI *) 684(*UI_method_get_opener(UI_METHOD * method))(UI *)
683{ 685{
684 if (method) 686 if (method)
685 return method->ui_open_session; 687 return method->ui_open_session;
@@ -687,8 +689,8 @@ int (*
687 return NULL; 689 return NULL;
688} 690}
689 691
690int (* 692int
691 UI_method_get_writer(UI_METHOD * method)) (UI *, UI_STRING *) 693(*UI_method_get_writer(UI_METHOD *method))(UI *, UI_STRING *)
692{ 694{
693 if (method) 695 if (method)
694 return method->ui_write_string; 696 return method->ui_write_string;
@@ -696,8 +698,8 @@ int (*
696 return NULL; 698 return NULL;
697} 699}
698 700
699int (* 701int
700 UI_method_get_flusher(UI_METHOD * method)) (UI *) 702(*UI_method_get_flusher(UI_METHOD *method)) (UI *)
701{ 703{
702 if (method) 704 if (method)
703 return method->ui_flush; 705 return method->ui_flush;
@@ -705,8 +707,8 @@ int (*
705 return NULL; 707 return NULL;
706} 708}
707 709
708int (* 710int
709 UI_method_get_reader(UI_METHOD * method)) (UI *, UI_STRING *) 711(*UI_method_get_reader(UI_METHOD *method))(UI *, UI_STRING *)
710{ 712{
711 if (method) 713 if (method)
712 return method->ui_read_string; 714 return method->ui_read_string;
@@ -714,8 +716,8 @@ int (*
714 return NULL; 716 return NULL;
715} 717}
716 718
717int (* 719int
718 UI_method_get_closer(UI_METHOD * method)) (UI *) 720(*UI_method_get_closer(UI_METHOD *method))(UI *)
719{ 721{
720 if (method) 722 if (method)
721 return method->ui_close_session; 723 return method->ui_close_session;
@@ -723,8 +725,9 @@ int (*
723 return NULL; 725 return NULL;
724} 726}
725 727
726char *(* 728char *
727 UI_method_get_prompt_constructor(UI_METHOD * method)) (UI *, const char *, const char *) 729(*UI_method_get_prompt_constructor(UI_METHOD *method))(UI *, const char *,
730 const char *)
728{ 731{
729 if (method) 732 if (method)
730 return method->ui_construct_prompt; 733 return method->ui_construct_prompt;
@@ -732,16 +735,16 @@ char *(*
732 return NULL; 735 return NULL;
733} 736}
734 737
735enum UI_string_types 738enum UI_string_types
736UI_get_string_type(UI_STRING * uis) 739UI_get_string_type(UI_STRING *uis)
737{ 740{
738 if (!uis) 741 if (!uis)
739 return UIT_NONE; 742 return UIT_NONE;
740 return uis->type; 743 return uis->type;
741} 744}
742 745
743int 746int
744UI_get_input_flags(UI_STRING * uis) 747UI_get_input_flags(UI_STRING *uis)
745{ 748{
746 if (!uis) 749 if (!uis)
747 return 0; 750 return 0;
@@ -749,7 +752,7 @@ UI_get_input_flags(UI_STRING * uis)
749} 752}
750 753
751const char * 754const char *
752UI_get0_output_string(UI_STRING * uis) 755UI_get0_output_string(UI_STRING *uis)
753{ 756{
754 if (!uis) 757 if (!uis)
755 return NULL; 758 return NULL;
@@ -757,7 +760,7 @@ UI_get0_output_string(UI_STRING * uis)
757} 760}
758 761
759const char * 762const char *
760UI_get0_action_string(UI_STRING * uis) 763UI_get0_action_string(UI_STRING *uis)
761{ 764{
762 if (!uis) 765 if (!uis)
763 return NULL; 766 return NULL;
@@ -771,7 +774,7 @@ UI_get0_action_string(UI_STRING * uis)
771} 774}
772 775
773const char * 776const char *
774UI_get0_result_string(UI_STRING * uis) 777UI_get0_result_string(UI_STRING *uis)
775{ 778{
776 if (!uis) 779 if (!uis)
777 return NULL; 780 return NULL;
@@ -785,7 +788,7 @@ UI_get0_result_string(UI_STRING * uis)
785} 788}
786 789
787const char * 790const char *
788UI_get0_test_string(UI_STRING * uis) 791UI_get0_test_string(UI_STRING *uis)
789{ 792{
790 if (!uis) 793 if (!uis)
791 return NULL; 794 return NULL;
@@ -797,8 +800,8 @@ UI_get0_test_string(UI_STRING * uis)
797 } 800 }
798} 801}
799 802
800int 803int
801UI_get_result_minsize(UI_STRING * uis) 804UI_get_result_minsize(UI_STRING *uis)
802{ 805{
803 if (!uis) 806 if (!uis)
804 return -1; 807 return -1;
@@ -811,8 +814,8 @@ UI_get_result_minsize(UI_STRING * uis)
811 } 814 }
812} 815}
813 816
814int 817int
815UI_get_result_maxsize(UI_STRING * uis) 818UI_get_result_maxsize(UI_STRING *uis)
816{ 819{
817 if (!uis) 820 if (!uis)
818 return -1; 821 return -1;
@@ -825,8 +828,8 @@ UI_get_result_maxsize(UI_STRING * uis)
825 } 828 }
826} 829}
827 830
828int 831int
829UI_set_result(UI * ui, UI_STRING * uis, const char *result) 832UI_set_result(UI *ui, UI_STRING *uis, const char *result)
830{ 833{
831 int l = strlen(result); 834 int l = strlen(result);
832 835
@@ -890,7 +893,7 @@ UI_set_result(UI * ui, UI_STRING * uis, const char *result)
890 break; 893 break;
891 } 894 }
892 } 895 }
893 default: 896 default:
894 break; 897 break;
895 } 898 }
896 } 899 }
diff --git a/src/lib/libssl/src/crypto/ui/ui_locl.h b/src/lib/libssl/src/crypto/ui/ui_locl.h
index 39789e2638..d6c4e26192 100644
--- a/src/lib/libssl/src/crypto/ui/ui_locl.h
+++ b/src/lib/libssl/src/crypto/ui/ui_locl.h
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -66,8 +66,7 @@
66#undef _ 66#undef _
67#endif 67#endif
68 68
69struct ui_method_st 69struct ui_method_st {
70 {
71 char *name; 70 char *name;
72 71
73 /* All the functions return 1 or non-NULL for success and 0 or NULL 72 /* All the functions return 1 or non-NULL for success and 0 or NULL
@@ -96,11 +95,10 @@ struct ui_method_st
96 The returned string shall always be allocated on the heap with 95 The returned string shall always be allocated on the heap with
97 malloc(), and need to be free'd with free(). */ 96 malloc(), and need to be free'd with free(). */
98 char *(*ui_construct_prompt)(UI *ui, const char *object_desc, 97 char *(*ui_construct_prompt)(UI *ui, const char *object_desc,
99 const char *object_name); 98 const char *object_name);
100 }; 99};
101 100
102struct ui_string_st 101struct ui_string_st {
103 {
104 enum UI_string_types type; /* Input */ 102 enum UI_string_types type; /* Input */
105 const char *out_string; /* Input */ 103 const char *out_string; /* Input */
106 int input_flags; /* Flags from the user */ 104 int input_flags; /* Flags from the user */
@@ -111,10 +109,8 @@ struct ui_string_st
111 with size in result_maxsize. Otherwise, it 109 with size in result_maxsize. Otherwise, it
112 may be allocated by the UI routine, meaning 110 may be allocated by the UI routine, meaning
113 result_minsize is going to be overwritten.*/ 111 result_minsize is going to be overwritten.*/
114 union 112 union {
115 { 113 struct {
116 struct
117 {
118 int result_minsize; /* Input: minimum required 114 int result_minsize; /* Input: minimum required
119 size of the result. 115 size of the result.
120 */ 116 */
@@ -123,21 +119,19 @@ struct ui_string_st
123 119
124 const char *test_buf; /* Input: test string to verify 120 const char *test_buf; /* Input: test string to verify
125 against */ 121 against */
126 } string_data; 122 } string_data;
127 struct 123 struct {
128 {
129 const char *action_desc; /* Input */ 124 const char *action_desc; /* Input */
130 const char *ok_chars; /* Input */ 125 const char *ok_chars; /* Input */
131 const char *cancel_chars; /* Input */ 126 const char *cancel_chars; /* Input */
132 } boolean_data; 127 } boolean_data;
133 } _; 128 } _;
134 129
135#define OUT_STRING_FREEABLE 0x01 130#define OUT_STRING_FREEABLE 0x01
136 int flags; /* flags for internal use */ 131 int flags; /* flags for internal use */
137 }; 132};
138 133
139struct ui_st 134struct ui_st {
140 {
141 const UI_METHOD *meth; 135 const UI_METHOD *meth;
142 STACK_OF(UI_STRING) *strings; /* We might want to prompt for more 136 STACK_OF(UI_STRING) *strings; /* We might want to prompt for more
143 than one thing at a time, and 137 than one thing at a time, and
@@ -148,6 +142,6 @@ struct ui_st
148#define UI_FLAG_REDOABLE 0x0001 142#define UI_FLAG_REDOABLE 0x0001
149#define UI_FLAG_PRINT_ERRORS 0x0100 143#define UI_FLAG_PRINT_ERRORS 0x0100
150 int flags; 144 int flags;
151 }; 145};
152 146
153#endif 147#endif
diff --git a/src/lib/libssl/src/crypto/ui/ui_openssl.c b/src/lib/libssl/src/crypto/ui/ui_openssl.c
index 94a999baa8..ef483352ea 100644
--- a/src/lib/libssl/src/crypto/ui/ui_openssl.c
+++ b/src/lib/libssl/src/crypto/ui/ui_openssl.c
@@ -114,7 +114,6 @@
114 * [including the GNU Public Licence.] 114 * [including the GNU Public Licence.]
115 */ 115 */
116 116
117
118#include <openssl/e_os2.h> 117#include <openssl/e_os2.h>
119 118
120#include <signal.h> 119#include <signal.h>
@@ -187,18 +186,17 @@ static int read_till_nl(FILE *);
187static void recsig(int); 186static void recsig(int);
188static void pushsig(void); 187static void pushsig(void);
189static void popsig(void); 188static void popsig(void);
190static int read_string_inner(UI * ui, UI_STRING * uis, int echo, int strip_nl); 189static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl);
191 190
192static int read_string(UI * ui, UI_STRING * uis); 191static int read_string(UI *ui, UI_STRING *uis);
193static int write_string(UI * ui, UI_STRING * uis); 192static int write_string(UI *ui, UI_STRING *uis);
194 193
195static int open_console(UI * ui); 194static int open_console(UI *ui);
196static int echo_console(UI * ui); 195static int echo_console(UI *ui);
197static int noecho_console(UI * ui); 196static int noecho_console(UI *ui);
198static int close_console(UI * ui); 197static int close_console(UI *ui);
199 198
200static UI_METHOD ui_openssl = 199static UI_METHOD ui_openssl = {
201{
202 "OpenSSL default user interface", 200 "OpenSSL default user interface",
203 open_console, 201 open_console,
204 write_string, 202 write_string,
@@ -217,12 +215,12 @@ UI_OpenSSL(void)
217 215
218/* The following function makes sure that info and error strings are printed 216/* The following function makes sure that info and error strings are printed
219 before any prompt. */ 217 before any prompt. */
220static int 218static int
221write_string(UI * ui, UI_STRING * uis) 219write_string(UI *ui, UI_STRING *uis)
222{ 220{
223 switch (UI_get_string_type(uis)) { 221 switch (UI_get_string_type(uis)) {
224 case UIT_ERROR: 222 case UIT_ERROR:
225 case UIT_INFO: 223 case UIT_INFO:
226 fputs(UI_get0_output_string(uis), tty_out); 224 fputs(UI_get0_output_string(uis), tty_out);
227 fflush(tty_out); 225 fflush(tty_out);
228 break; 226 break;
@@ -232,8 +230,8 @@ write_string(UI * ui, UI_STRING * uis)
232 return 1; 230 return 1;
233} 231}
234 232
235static int 233static int
236read_string(UI * ui, UI_STRING * uis) 234read_string(UI *ui, UI_STRING *uis)
237{ 235{
238 int ok = 0; 236 int ok = 0;
239 237
@@ -257,7 +255,7 @@ read_string(UI * ui, UI_STRING * uis)
257 UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1)) <= 0) 255 UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1)) <= 0)
258 return ok; 256 return ok;
259 if (strcmp(UI_get0_result_string(uis), 257 if (strcmp(UI_get0_result_string(uis),
260 UI_get0_test_string(uis)) != 0) { 258 UI_get0_test_string(uis)) != 0) {
261 fprintf(tty_out, "Verify failure\n"); 259 fprintf(tty_out, "Verify failure\n");
262 fflush(tty_out); 260 fflush(tty_out);
263 return 0; 261 return 0;
@@ -271,8 +269,8 @@ read_string(UI * ui, UI_STRING * uis)
271 269
272 270
273/* Internal functions to read a string without echoing */ 271/* Internal functions to read a string without echoing */
274static int 272static int
275read_till_nl(FILE * in) 273read_till_nl(FILE *in)
276{ 274{
277#define SIZE 4 275#define SIZE 4
278 char buf[SIZE + 1]; 276 char buf[SIZE + 1];
@@ -286,8 +284,8 @@ read_till_nl(FILE * in)
286 284
287static volatile sig_atomic_t intr_signal; 285static volatile sig_atomic_t intr_signal;
288 286
289static int 287static int
290read_string_inner(UI * ui, UI_STRING * uis, int echo, int strip_nl) 288read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
291{ 289{
292 static int ps; 290 static int ps;
293 int ok; 291 int ok;
@@ -339,8 +337,8 @@ error:
339 337
340 338
341/* Internal functions to open, handle and close a channel to the console. */ 339/* Internal functions to open, handle and close a channel to the console. */
342static int 340static int
343open_console(UI * ui) 341open_console(UI *ui)
344{ 342{
345 CRYPTO_w_lock(CRYPTO_LOCK_UI); 343 CRYPTO_w_lock(CRYPTO_LOCK_UI);
346 is_a_tty = 1; 344 is_a_tty = 1;
@@ -361,8 +359,8 @@ open_console(UI * ui)
361 * solaris can return EINVAL instead. This should be 359 * solaris can return EINVAL instead. This should be
362 * ok 360 * ok
363 */ 361 */
364 if (errno == EINVAL) 362 if (errno == EINVAL)
365 is_a_tty = 0; 363 is_a_tty = 0;
366 else 364 else
367 return 0; 365 return 0;
368 } 366 }
@@ -370,8 +368,8 @@ open_console(UI * ui)
370 return 1; 368 return 1;
371} 369}
372 370
373static int 371static int
374noecho_console(UI * ui) 372noecho_console(UI *ui)
375{ 373{
376#ifdef TTY_FLAGS 374#ifdef TTY_FLAGS
377 memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); 375 memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig));
@@ -385,8 +383,8 @@ noecho_console(UI * ui)
385 return 1; 383 return 1;
386} 384}
387 385
388static int 386static int
389echo_console(UI * ui) 387echo_console(UI *ui)
390{ 388{
391#if defined(TTY_set) 389#if defined(TTY_set)
392 memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); 390 memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig));
@@ -400,8 +398,8 @@ echo_console(UI * ui)
400 return 1; 398 return 1;
401} 399}
402 400
403static int 401static int
404close_console(UI * ui) 402close_console(UI *ui)
405{ 403{
406 if (tty_in != stdin) 404 if (tty_in != stdin)
407 fclose(tty_in); 405 fclose(tty_in);
@@ -414,7 +412,7 @@ close_console(UI * ui)
414 412
415 413
416/* Internal functions to handle signals and act on them */ 414/* Internal functions to handle signals and act on them */
417static void 415static void
418pushsig(void) 416pushsig(void)
419{ 417{
420 int i; 418 int i;
@@ -450,7 +448,7 @@ pushsig(void)
450#endif 448#endif
451} 449}
452 450
453static void 451static void
454popsig(void) 452popsig(void)
455{ 453{
456 int i; 454 int i;
@@ -467,7 +465,7 @@ popsig(void)
467 } 465 }
468} 466}
469 467
470static void 468static void
471recsig(int i) 469recsig(int i)
472{ 470{
473 intr_signal = i; 471 intr_signal = i;
diff --git a/src/lib/libssl/src/crypto/ui/ui_util.c b/src/lib/libssl/src/crypto/ui/ui_util.c
index af50451403..81c5a079a6 100644
--- a/src/lib/libssl/src/crypto/ui/ui_util.c
+++ b/src/lib/libssl/src/crypto/ui/ui_util.c
@@ -56,18 +56,19 @@
56#include <string.h> 56#include <string.h>
57#include "ui_locl.h" 57#include "ui_locl.h"
58 58
59int 59int
60UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify) 60UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify)
61{ 61{
62 char buff[BUFSIZ]; 62 char buff[BUFSIZ];
63 int ret; 63 int ret;
64 64
65 ret = UI_UTIL_read_pw(buf, buff, (length > BUFSIZ) ? BUFSIZ : length, prompt, verify); 65 ret = UI_UTIL_read_pw(buf, buff, (length > BUFSIZ) ? BUFSIZ : length,
66 prompt, verify);
66 OPENSSL_cleanse(buff, BUFSIZ); 67 OPENSSL_cleanse(buff, BUFSIZ);
67 return (ret); 68 return (ret);
68} 69}
69 70
70int 71int
71UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify) 72UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify)
72{ 73{
73 int ok = 0; 74 int ok = 0;
@@ -80,8 +81,8 @@ UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify)
80 if (ui) { 81 if (ui) {
81 ok = UI_add_input_string(ui, prompt, 0, buf, 0, size - 1); 82 ok = UI_add_input_string(ui, prompt, 0, buf, 0, size - 1);
82 if (ok >= 0 && verify) 83 if (ok >= 0 && verify)
83 ok = UI_add_verify_string(ui, prompt, 0, buff, 0, size - 1, 84 ok = UI_add_verify_string(ui, prompt, 0, buff, 0,
84 buf); 85 size - 1, buf);
85 if (ok >= 0) 86 if (ok >= 0)
86 ok = UI_process(ui); 87 ok = UI_process(ui);
87 UI_free(ui); 88 UI_free(ui);