From 216028eef6b1dd26ceaa0140261c882a9fba67f8 Mon Sep 17 00:00:00 2001 From: beck Date: Sat, 12 Nov 2022 13:16:10 +0000 Subject: [PATCH] Hide symbols in libcrypto/ui ok jsing@ --- lib/libcrypto/Symbols.namespace | 52 +++++++++++++++++++++ lib/libcrypto/hidden/openssl/ui.h | 78 +++++++++++++++++++++++++++++++ lib/libcrypto/ui/ui_err.c | 3 +- lib/libcrypto/ui/ui_lib.c | 51 +++++++++++++++++++- lib/libcrypto/ui/ui_openssl.c | 3 +- lib/libcrypto/ui/ui_util.c | 4 +- 6 files changed, 187 insertions(+), 4 deletions(-) create mode 100644 lib/libcrypto/hidden/openssl/ui.h diff --git a/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index 0d524d4732c..270be2262af 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/lib/libcrypto/Symbols.namespace @@ -205,3 +205,55 @@ _libre_d2i_PKCS12_bio _libre_d2i_PKCS12_fp _libre_PKCS12_newpass _libre_ERR_load_PKCS12_strings +_libre_UI_new +_libre_UI_new_method +_libre_UI_free +_libre_UI_add_input_string +_libre_UI_dup_input_string +_libre_UI_add_verify_string +_libre_UI_dup_verify_string +_libre_UI_add_input_boolean +_libre_UI_dup_input_boolean +_libre_UI_add_info_string +_libre_UI_dup_info_string +_libre_UI_add_error_string +_libre_UI_dup_error_string +_libre_UI_construct_prompt +_libre_UI_add_user_data +_libre_UI_get0_user_data +_libre_UI_get0_result +_libre_UI_process +_libre_UI_ctrl +_libre_UI_get_ex_new_index +_libre_UI_set_ex_data +_libre_UI_get_ex_data +_libre_UI_set_default_method +_libre_UI_get_default_method +_libre_UI_get_method +_libre_UI_set_method +_libre_UI_OpenSSL +_libre_UI_create_method +_libre_UI_destroy_method +_libre_UI_method_set_opener +_libre_UI_method_set_writer +_libre_UI_method_set_flusher +_libre_UI_method_set_reader +_libre_UI_method_set_closer +_libre_UI_method_set_prompt_constructor +_libre_UI_method_get_opener +_libre_UI_method_get_writer +_libre_UI_method_get_flusher +_libre_UI_method_get_reader +_libre_UI_method_get_closer +_libre_UI_get_string_type +_libre_UI_get_input_flags +_libre_UI_get0_output_string +_libre_UI_get0_action_string +_libre_UI_get0_result_string +_libre_UI_get0_test_string +_libre_UI_get_result_minsize +_libre_UI_get_result_maxsize +_libre_UI_set_result +_libre_UI_UTIL_read_pw_string +_libre_UI_UTIL_read_pw +_libre_ERR_load_UI_strings diff --git a/lib/libcrypto/hidden/openssl/ui.h b/lib/libcrypto/hidden/openssl/ui.h new file mode 100644 index 00000000000..7ad9ca0285c --- /dev/null +++ b/lib/libcrypto/hidden/openssl/ui.h @@ -0,0 +1,78 @@ +/* $OpenBSD: ui.h,v 1.1 2022/11/12 13:16:10 beck Exp $ */ +/* + * Copyright (c) 2022 Bob Beck + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_UI_H +#define _LIBCRYPTO_UI_H + +#include_next +#include "crypto_namespace.h" + +LCRYPTO_USED(UI_new); +LCRYPTO_USED(UI_new_method); +LCRYPTO_USED(UI_free); +LCRYPTO_USED(UI_add_input_string); +LCRYPTO_USED(UI_dup_input_string); +LCRYPTO_USED(UI_add_verify_string); +LCRYPTO_USED(UI_dup_verify_string); +LCRYPTO_USED(UI_add_input_boolean); +LCRYPTO_USED(UI_dup_input_boolean); +LCRYPTO_USED(UI_add_info_string); +LCRYPTO_USED(UI_dup_info_string); +LCRYPTO_USED(UI_add_error_string); +LCRYPTO_USED(UI_dup_error_string); +LCRYPTO_USED(UI_construct_prompt); +LCRYPTO_USED(UI_add_user_data); +LCRYPTO_USED(UI_get0_user_data); +LCRYPTO_USED(UI_get0_result); +LCRYPTO_USED(UI_process); +LCRYPTO_USED(UI_ctrl); +LCRYPTO_USED(UI_get_ex_new_index); +LCRYPTO_USED(UI_set_ex_data); +LCRYPTO_USED(UI_get_ex_data); +LCRYPTO_USED(UI_set_default_method); +LCRYPTO_USED(UI_get_default_method); +LCRYPTO_USED(UI_get_method); +LCRYPTO_USED(UI_set_method); +LCRYPTO_USED(UI_OpenSSL); +LCRYPTO_USED(UI_create_method); +LCRYPTO_USED(UI_destroy_method); +LCRYPTO_USED(UI_method_set_opener); +LCRYPTO_USED(UI_method_set_writer); +LCRYPTO_USED(UI_method_set_flusher); +LCRYPTO_USED(UI_method_set_reader); +LCRYPTO_USED(UI_method_set_closer); +LCRYPTO_USED(UI_method_set_prompt_constructor); +LCRYPTO_USED(UI_method_get_opener); +LCRYPTO_USED(UI_method_get_writer); +LCRYPTO_USED(UI_method_get_flusher); +LCRYPTO_USED(UI_method_get_reader); +LCRYPTO_USED(UI_method_get_closer); +LCRYPTO_USED(UI_get_string_type); +LCRYPTO_USED(UI_get_input_flags); +LCRYPTO_USED(UI_get0_output_string); +LCRYPTO_USED(UI_get0_action_string); +LCRYPTO_USED(UI_get0_result_string); +LCRYPTO_USED(UI_get0_test_string); +LCRYPTO_USED(UI_get_result_minsize); +LCRYPTO_USED(UI_get_result_maxsize); +LCRYPTO_USED(UI_set_result); +LCRYPTO_USED(UI_UTIL_read_pw_string); +LCRYPTO_USED(UI_UTIL_read_pw); +LCRYPTO_USED(ERR_load_UI_strings); +LCRYPTO_USED(UI_method_get_prompt_constructor); + +#endif /* _LIBCRYPTO_UI_H */ diff --git a/lib/libcrypto/ui/ui_err.c b/lib/libcrypto/ui/ui_err.c index 691403aff6a..a1207fb0c38 100644 --- a/lib/libcrypto/ui/ui_err.c +++ b/lib/libcrypto/ui/ui_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_err.c,v 1.10 2022/07/12 14:42:50 kn Exp $ */ +/* $OpenBSD: ui_err.c,v 1.11 2022/11/12 13:16:10 beck Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * @@ -93,3 +93,4 @@ ERR_load_UI_strings(void) } #endif } +LCRYPTO_ALIAS(ERR_load_UI_strings) diff --git a/lib/libcrypto/ui/ui_lib.c b/lib/libcrypto/ui/ui_lib.c index 09522e716c2..0a0e11784d1 100644 --- a/lib/libcrypto/ui/ui_lib.c +++ b/lib/libcrypto/ui/ui_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_lib.c,v 1.44 2020/09/25 11:25:31 tb Exp $ */ +/* $OpenBSD: ui_lib.c,v 1.45 2022/11/12 13:16:10 beck Exp $ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2001. */ @@ -73,6 +73,7 @@ UI_new(void) { return (UI_new_method(NULL)); } +LCRYPTO_ALIAS(UI_new) UI * UI_new_method(const UI_METHOD *method) @@ -89,6 +90,7 @@ UI_new_method(const UI_METHOD *method) return ret; } +LCRYPTO_ALIAS(UI_new_method) static void free_string(UI_STRING *uis) @@ -119,6 +121,7 @@ UI_free(UI *ui) CRYPTO_free_ex_data(CRYPTO_EX_INDEX_UI, ui, &ui->ex_data); free(ui); } +LCRYPTO_ALIAS(UI_free) static int allocate_string_stack(UI *ui) @@ -265,6 +268,7 @@ UI_add_input_string(UI *ui, const char *prompt, int flags, char *result_buf, return general_allocate_string(ui, prompt, 0, UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); } +LCRYPTO_ALIAS(UI_add_input_string) /* Same as UI_add_input_string(), excepts it takes a copy of the prompt. */ int @@ -274,6 +278,7 @@ UI_dup_input_string(UI *ui, const char *prompt, int flags, char *result_buf, return general_allocate_string(ui, prompt, 1, UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); } +LCRYPTO_ALIAS(UI_dup_input_string) int UI_add_verify_string(UI *ui, const char *prompt, int flags, char *result_buf, @@ -282,6 +287,7 @@ UI_add_verify_string(UI *ui, const char *prompt, int flags, char *result_buf, return general_allocate_string(ui, prompt, 0, UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); } +LCRYPTO_ALIAS(UI_add_verify_string) int UI_dup_verify_string(UI *ui, const char *prompt, int flags, @@ -290,6 +296,7 @@ UI_dup_verify_string(UI *ui, const char *prompt, int flags, return general_allocate_string(ui, prompt, 1, UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); } +LCRYPTO_ALIAS(UI_dup_verify_string) int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, @@ -298,6 +305,7 @@ UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, return general_allocate_boolean(ui, prompt, action_desc, ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf); } +LCRYPTO_ALIAS(UI_add_input_boolean) int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, @@ -306,6 +314,7 @@ UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, return general_allocate_boolean(ui, prompt, action_desc, ok_chars, cancel_chars, 1, UIT_BOOLEAN, flags, result_buf); } +LCRYPTO_ALIAS(UI_dup_input_boolean) int UI_add_info_string(UI *ui, const char *text) @@ -313,6 +322,7 @@ UI_add_info_string(UI *ui, const char *text) return general_allocate_string(ui, text, 0, UIT_INFO, 0, NULL, 0, 0, NULL); } +LCRYPTO_ALIAS(UI_add_info_string) int UI_dup_info_string(UI *ui, const char *text) @@ -320,6 +330,7 @@ UI_dup_info_string(UI *ui, const char *text) return general_allocate_string(ui, text, 1, UIT_INFO, 0, NULL, 0, 0, NULL); } +LCRYPTO_ALIAS(UI_dup_info_string) int UI_add_error_string(UI *ui, const char *text) @@ -327,6 +338,7 @@ UI_add_error_string(UI *ui, const char *text) return general_allocate_string(ui, text, 0, UIT_ERROR, 0, NULL, 0, 0, NULL); } +LCRYPTO_ALIAS(UI_add_error_string) int UI_dup_error_string(UI *ui, const char *text) @@ -334,6 +346,7 @@ UI_dup_error_string(UI *ui, const char *text) return general_allocate_string(ui, text, 1, UIT_ERROR, 0, NULL, 0, 0, NULL); } +LCRYPTO_ALIAS(UI_dup_error_string) char * UI_construct_prompt(UI *ui, const char *object_desc, const char *object_name) @@ -358,6 +371,7 @@ UI_construct_prompt(UI *ui, const char *object_desc, const char *object_name) return prompt; } +LCRYPTO_ALIAS(UI_construct_prompt) void * UI_add_user_data(UI *ui, void *user_data) @@ -367,12 +381,14 @@ UI_add_user_data(UI *ui, void *user_data) ui->user_data = user_data; return old_data; } +LCRYPTO_ALIAS(UI_add_user_data) void * UI_get0_user_data(UI *ui) { return ui->user_data; } +LCRYPTO_ALIAS(UI_get0_user_data) const char * UI_get0_result(UI *ui, int i) @@ -387,6 +403,7 @@ UI_get0_result(UI *ui, int i) } return UI_get0_result_string(sk_UI_STRING_value(ui->strings, i)); } +LCRYPTO_ALIAS(UI_get0_result) static int print_error(const char *str, size_t len, void *arg) @@ -460,6 +477,7 @@ UI_process(UI *ui) return -1; return ok; } +LCRYPTO_ALIAS(UI_process) int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void)) @@ -486,6 +504,7 @@ UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void)) UIerror(UI_R_UNKNOWN_CONTROL_COMMAND); return -1; } +LCRYPTO_ALIAS(UI_ctrl) int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, @@ -494,24 +513,28 @@ UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, argl, argp, new_func, dup_func, free_func); } +LCRYPTO_ALIAS(UI_get_ex_new_index) int UI_set_ex_data(UI *r, int idx, void *arg) { return (CRYPTO_set_ex_data(&r->ex_data, idx, arg)); } +LCRYPTO_ALIAS(UI_set_ex_data) void * UI_get_ex_data(UI *r, int idx) { return (CRYPTO_get_ex_data(&r->ex_data, idx)); } +LCRYPTO_ALIAS(UI_get_ex_data) void UI_set_default_method(const UI_METHOD *meth) { default_UI_meth = meth; } +LCRYPTO_ALIAS(UI_set_default_method) const UI_METHOD * UI_get_default_method(void) @@ -521,12 +544,14 @@ UI_get_default_method(void) } return default_UI_meth; } +LCRYPTO_ALIAS(UI_get_default_method) const UI_METHOD * UI_get_method(UI *ui) { return ui->meth; } +LCRYPTO_ALIAS(UI_get_method) const UI_METHOD * UI_set_method(UI *ui, const UI_METHOD *meth) @@ -534,6 +559,7 @@ UI_set_method(UI *ui, const UI_METHOD *meth) ui->meth = meth; return ui->meth; } +LCRYPTO_ALIAS(UI_set_method) UI_METHOD * @@ -546,6 +572,7 @@ UI_create_method(const char *name) return ui_method; } +LCRYPTO_ALIAS(UI_create_method) /* * BIG FSCKING WARNING!!!! If you use this on a statically allocated method @@ -559,6 +586,7 @@ UI_destroy_method(UI_METHOD *ui_method) ui_method->name = NULL; free(ui_method); } +LCRYPTO_ALIAS(UI_destroy_method) int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui)) @@ -569,6 +597,7 @@ UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui)) } return -1; } +LCRYPTO_ALIAS(UI_method_set_opener) int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis)) @@ -579,6 +608,7 @@ UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis)) } return -1; } +LCRYPTO_ALIAS(UI_method_set_writer) int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)) @@ -589,6 +619,7 @@ UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)) } return -1; } +LCRYPTO_ALIAS(UI_method_set_flusher) int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)) @@ -599,6 +630,7 @@ UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)) } return -1; } +LCRYPTO_ALIAS(UI_method_set_reader) int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)) @@ -609,6 +641,7 @@ UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)) } return -1; } +LCRYPTO_ALIAS(UI_method_set_closer) int UI_method_set_prompt_constructor(UI_METHOD *method, @@ -621,6 +654,7 @@ UI_method_set_prompt_constructor(UI_METHOD *method, } return -1; } +LCRYPTO_ALIAS(UI_method_set_prompt_constructor) int (*UI_method_get_opener(const UI_METHOD * method))(UI *) @@ -629,6 +663,7 @@ int return method->ui_open_session; return NULL; } +LCRYPTO_ALIAS(UI_method_get_opener) int (*UI_method_get_writer(const UI_METHOD *method))(UI *, UI_STRING *) @@ -637,6 +672,7 @@ int return method->ui_write_string; return NULL; } +LCRYPTO_ALIAS(UI_method_get_writer) int (*UI_method_get_flusher(const UI_METHOD *method)) (UI *) @@ -645,6 +681,7 @@ int return method->ui_flush; return NULL; } +LCRYPTO_ALIAS(UI_method_get_flusher) int (*UI_method_get_reader(const UI_METHOD *method))(UI *, UI_STRING *) @@ -653,6 +690,7 @@ int return method->ui_read_string; return NULL; } +LCRYPTO_ALIAS(UI_method_get_reader) int (*UI_method_get_closer(const UI_METHOD *method))(UI *) @@ -661,6 +699,7 @@ int return method->ui_close_session; return NULL; } +LCRYPTO_ALIAS(UI_method_get_closer) char * (*UI_method_get_prompt_constructor(const UI_METHOD *method))(UI *, const char *, @@ -670,6 +709,7 @@ char * return method->ui_construct_prompt; return NULL; } +LCRYPTO_ALIAS(UI_method_get_prompt_constructor) enum UI_string_types UI_get_string_type(UI_STRING *uis) @@ -678,6 +718,7 @@ UI_get_string_type(UI_STRING *uis) return UIT_NONE; return uis->type; } +LCRYPTO_ALIAS(UI_get_string_type) int UI_get_input_flags(UI_STRING *uis) @@ -686,6 +727,7 @@ UI_get_input_flags(UI_STRING *uis) return 0; return uis->input_flags; } +LCRYPTO_ALIAS(UI_get_input_flags) const char * UI_get0_output_string(UI_STRING *uis) @@ -694,6 +736,7 @@ UI_get0_output_string(UI_STRING *uis) return NULL; return uis->out_string; } +LCRYPTO_ALIAS(UI_get0_output_string) const char * UI_get0_action_string(UI_STRING *uis) @@ -708,6 +751,7 @@ UI_get0_action_string(UI_STRING *uis) return NULL; } } +LCRYPTO_ALIAS(UI_get0_action_string) const char * UI_get0_result_string(UI_STRING *uis) @@ -722,6 +766,7 @@ UI_get0_result_string(UI_STRING *uis) return NULL; } } +LCRYPTO_ALIAS(UI_get0_result_string) const char * UI_get0_test_string(UI_STRING *uis) @@ -735,6 +780,7 @@ UI_get0_test_string(UI_STRING *uis) return NULL; } } +LCRYPTO_ALIAS(UI_get0_test_string) int UI_get_result_minsize(UI_STRING *uis) @@ -749,6 +795,7 @@ UI_get_result_minsize(UI_STRING *uis) return -1; } } +LCRYPTO_ALIAS(UI_get_result_minsize) int UI_get_result_maxsize(UI_STRING *uis) @@ -763,6 +810,7 @@ UI_get_result_maxsize(UI_STRING *uis) return -1; } } +LCRYPTO_ALIAS(UI_get_result_maxsize) int UI_set_result(UI *ui, UI_STRING *uis, const char *result) @@ -825,3 +873,4 @@ UI_set_result(UI *ui, UI_STRING *uis, const char *result) } return 0; } +LCRYPTO_ALIAS(UI_set_result) diff --git a/lib/libcrypto/ui/ui_openssl.c b/lib/libcrypto/ui/ui_openssl.c index 9562c2c937a..81d7b8de1c2 100644 --- a/lib/libcrypto/ui/ui_openssl.c +++ b/lib/libcrypto/ui/ui_openssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_openssl.c,v 1.25 2015/09/10 15:56:26 jsing Exp $ */ +/* $OpenBSD: ui_openssl.c,v 1.26 2022/11/12 13:16:10 beck Exp $ */ /* Written by Richard Levitte (richard@levitte.org) and others * for the OpenSSL project 2001. */ @@ -167,6 +167,7 @@ UI_OpenSSL(void) { return &ui_openssl; } +LCRYPTO_ALIAS(UI_OpenSSL) /* The following function makes sure that info and error strings are printed before any prompt. */ diff --git a/lib/libcrypto/ui/ui_util.c b/lib/libcrypto/ui/ui_util.c index d1040c9826a..808b294d766 100644 --- a/lib/libcrypto/ui/ui_util.c +++ b/lib/libcrypto/ui/ui_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_util.c,v 1.10 2015/09/10 15:56:26 jsing Exp $ */ +/* $OpenBSD: ui_util.c,v 1.11 2022/11/12 13:16:10 beck Exp $ */ /* ==================================================================== * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved. * @@ -70,6 +70,7 @@ UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify) explicit_bzero(buff, BUFSIZ); return (ret); } +LCRYPTO_ALIAS(UI_UTIL_read_pw_string) int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify) @@ -94,6 +95,7 @@ UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify) ok = 0; return (ok); } +LCRYPTO_ALIAS(UI_UTIL_read_pw) /* * Old compatibility glue - see comment in ui_compat.h. -- 2.20.1