diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2024-03-02 11:28:47 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2024-03-02 11:28:47 +0000 |
commit | 6ba078d0373805d7e5135b2c3307917db5d1919a (patch) | |
tree | 47de99077d34d6fd2a543b954facdb9e18c6aecc /lib | |
parent | 343a9fe1988a06148dfb6c4578b27e075dd017b8 (diff) |
Remove a bunch of CRYPTO memory API
This was neutered early on in the fork and has been rotting ever since.
Some parts of the API are still used, but it's easier to clean up when
most of the mess is gone.
ok jsing
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/Symbols.list | 24 | ||||
-rw-r--r-- | lib/libcrypto/Symbols.namespace | 14 | ||||
-rw-r--r-- | lib/libcrypto/crypto.h | 80 | ||||
-rw-r--r-- | lib/libcrypto/hidden/openssl/crypto.h | 22 | ||||
-rw-r--r-- | lib/libcrypto/malloc-wrapper.c | 150 | ||||
-rw-r--r-- | lib/libcrypto/mem_dbg.c | 68 |
6 files changed, 4 insertions, 354 deletions
diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index 5a1fe7be48e..26170084e5b 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -649,16 +649,10 @@ CRYPTO_chacha_20 CRYPTO_cleanup_all_ex_data CRYPTO_ctr128_encrypt CRYPTO_ctr128_encrypt_ctr32 -CRYPTO_dbg_free -CRYPTO_dbg_get_options -CRYPTO_dbg_malloc -CRYPTO_dbg_realloc -CRYPTO_dbg_set_options CRYPTO_destroy_dynlockid CRYPTO_dup_ex_data CRYPTO_free CRYPTO_free_ex_data -CRYPTO_free_locked CRYPTO_gcm128_aad CRYPTO_gcm128_decrypt CRYPTO_gcm128_decrypt_ctr32 @@ -679,24 +673,13 @@ CRYPTO_get_ex_data CRYPTO_get_ex_new_index CRYPTO_get_id_callback CRYPTO_get_lock_name -CRYPTO_get_locked_mem_ex_functions -CRYPTO_get_locked_mem_functions CRYPTO_get_locking_callback -CRYPTO_get_mem_debug_functions -CRYPTO_get_mem_debug_options -CRYPTO_get_mem_ex_functions -CRYPTO_get_mem_functions CRYPTO_get_new_dynlockid CRYPTO_get_new_lockid CRYPTO_hchacha_20 -CRYPTO_is_mem_check_on CRYPTO_lock CRYPTO_malloc -CRYPTO_malloc_locked CRYPTO_mem_ctrl -CRYPTO_mem_leaks -CRYPTO_mem_leaks_cb -CRYPTO_mem_leaks_fp CRYPTO_memcmp CRYPTO_new_ex_data CRYPTO_num_locks @@ -706,9 +689,6 @@ CRYPTO_poly1305_init CRYPTO_poly1305_update CRYPTO_pop_info CRYPTO_push_info_ -CRYPTO_realloc -CRYPTO_realloc_clean -CRYPTO_remalloc CRYPTO_remove_all_info CRYPTO_set_add_lock_callback CRYPTO_set_dynlock_create_callback @@ -716,11 +696,7 @@ CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_lock_callback CRYPTO_set_ex_data CRYPTO_set_id_callback -CRYPTO_set_locked_mem_ex_functions -CRYPTO_set_locked_mem_functions CRYPTO_set_locking_callback -CRYPTO_set_mem_debug_functions -CRYPTO_set_mem_debug_options CRYPTO_set_mem_ex_functions CRYPTO_set_mem_functions CRYPTO_strdup diff --git a/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index b673042f029..ff6e6492e22 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/lib/libcrypto/Symbols.namespace @@ -1864,26 +1864,12 @@ _libre_CRYPTO_set_locked_mem_functions _libre_CRYPTO_set_mem_ex_functions _libre_CRYPTO_set_locked_mem_ex_functions _libre_CRYPTO_set_mem_debug_functions -_libre_CRYPTO_get_mem_functions -_libre_CRYPTO_get_locked_mem_functions -_libre_CRYPTO_get_mem_ex_functions -_libre_CRYPTO_get_locked_mem_ex_functions -_libre_CRYPTO_get_mem_debug_functions _libre_CRYPTO_realloc_clean _libre_CRYPTO_remalloc _libre_CRYPTO_set_mem_debug_options -_libre_CRYPTO_get_mem_debug_options _libre_CRYPTO_push_info_ _libre_CRYPTO_pop_info _libre_CRYPTO_remove_all_info -_libre_CRYPTO_dbg_malloc -_libre_CRYPTO_dbg_realloc -_libre_CRYPTO_dbg_free -_libre_CRYPTO_dbg_set_options -_libre_CRYPTO_dbg_get_options -_libre_CRYPTO_mem_leaks_fp -_libre_CRYPTO_mem_leaks -_libre_CRYPTO_mem_leaks_cb _libre_OpenSSLDie _libre_OPENSSL_cpu_caps _libre_OPENSSL_init_crypto diff --git a/lib/libcrypto/crypto.h b/lib/libcrypto/crypto.h index f37ec3106df..19732ced327 100644 --- a/lib/libcrypto/crypto.h +++ b/lib/libcrypto/crypto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.h,v 1.65 2024/03/02 09:15:03 tb Exp $ */ +/* $OpenBSD: crypto.h,v 1.66 2024/03/02 11:28:46 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * @@ -272,26 +272,10 @@ DECLARE_STACK_OF(void) #endif int CRYPTO_mem_ctrl(int mode); -int CRYPTO_is_mem_check_on(void); - -/* for applications */ -#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) -#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) #define OPENSSL_malloc(num) CRYPTO_malloc((int)num,NULL,0) #define OPENSSL_strdup(str) CRYPTO_strdup((str),NULL,0) -#define OPENSSL_realloc(addr,num) \ - CRYPTO_realloc((char *)addr,(int)num,NULL,0) -#define OPENSSL_realloc_clean(addr,old_num,num) \ - CRYPTO_realloc_clean(addr,old_num,num,NULL,0) -#define OPENSSL_remalloc(addr,num) \ - CRYPTO_remalloc((char **)addr,(int)num,NULL,0) -#define OPENSSL_freeFunc CRYPTO_free #define OPENSSL_free(addr) CRYPTO_free(addr) - -#define OPENSSL_malloc_locked(num) \ - CRYPTO_malloc_locked((int)num,NULL,0) -#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr) #endif const char *OpenSSL_version(int type); @@ -376,87 +360,25 @@ void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l /* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- * call the latter last if you need different functions */ int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t), void (*f)(void *)); -int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *)); int CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int), void *(*r)(void *, size_t, const char *, int), void (*f)(void *)); -int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int), - void (*free_func)(void *)); -int CRYPTO_set_mem_debug_functions( - void (*m)(void *, int, const char *, int, int), - void (*r)(void *, void *, int, const char *, int, int), - void (*f)(void *, int), void (*so)(long), long (*go)(void)); -void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t), - void (**f)(void *)); -void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); -void CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int), - void *(**r)(void *, size_t, const char *, int), void (**f)(void *)); -void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int), - void (**f)(void *)); -void CRYPTO_get_mem_debug_functions( - void (**m)(void *, int, const char *, int, int), - void (**r)(void *, void *, int, const char *, int, int), - void (**f)(void *, int), void (**so)(long), long (**go)(void)); #ifndef LIBRESSL_INTERNAL -void *CRYPTO_malloc_locked(int num, const char *file, int line); -void CRYPTO_free_locked(void *ptr); void *CRYPTO_malloc(int num, const char *file, int line); char *CRYPTO_strdup(const char *str, const char *file, int line); void CRYPTO_free(void *ptr); -void *CRYPTO_realloc(void *addr, int num, const char *file, int line); #endif -void *CRYPTO_realloc_clean(void *addr, int old_num, int num, - const char *file, int line); -void *CRYPTO_remalloc(void *addr, int num, const char *file, int line); - #ifndef LIBRESSL_INTERNAL void OPENSSL_cleanse(void *ptr, size_t len); #endif -void CRYPTO_set_mem_debug_options(long bits); -long CRYPTO_get_mem_debug_options(void); - #define CRYPTO_push_info(info) \ CRYPTO_push_info_(info, NULL, 0); int CRYPTO_push_info_(const char *info, const char *file, int line); int CRYPTO_pop_info(void); int CRYPTO_remove_all_info(void); - -/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro; - * used as default in CRYPTO_MDEBUG compilations): */ -/* The last argument has the following significance: - * - * 0: called before the actual memory allocation has taken place - * 1: called after the actual memory allocation has taken place - */ -void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line, int before_p) - __attribute__ ((deprecated)); -void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file, int line, int before_p) - __attribute__ ((deprecated)); -void CRYPTO_dbg_free(void *addr, int before_p) - __attribute__ ((deprecated)); -/* Tell the debugging code about options. By default, the following values - * apply: - * - * 0: Clear all options. - * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option. - * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option. - * V_CRYPTO_MDEBUG_ALL (3): 1 + 2 - */ -void CRYPTO_dbg_set_options(long bits) - __attribute__ ((deprecated)); -long CRYPTO_dbg_get_options(void) - __attribute__ ((deprecated)); - - -int CRYPTO_mem_leaks_fp(FILE *); -int CRYPTO_mem_leaks(struct bio_st *bio); -/* unsigned long order, char *file, int line, int num_bytes, char *addr */ -typedef int *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); -int CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); - /* * Because this is a public header, use a portable method of indicating the * function does not return, rather than __dead. diff --git a/lib/libcrypto/hidden/openssl/crypto.h b/lib/libcrypto/hidden/openssl/crypto.h index 083d156d148..efbcca975f4 100644 --- a/lib/libcrypto/hidden/openssl/crypto.h +++ b/lib/libcrypto/hidden/openssl/crypto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.h,v 1.3 2024/03/01 07:38:33 tb Exp $ */ +/* $OpenBSD: crypto.h,v 1.4 2024/03/02 11:28:46 tb Exp $ */ /* * Copyright (c) 2023 Bob Beck <beck@openbsd.org> * @@ -43,30 +43,10 @@ LCRYPTO_USED(CRYPTO_THREADID_cmp); LCRYPTO_USED(CRYPTO_THREADID_cpy); LCRYPTO_USED(CRYPTO_THREADID_hash); LCRYPTO_USED(CRYPTO_set_mem_functions); -LCRYPTO_USED(CRYPTO_set_locked_mem_functions); LCRYPTO_USED(CRYPTO_set_mem_ex_functions); -LCRYPTO_USED(CRYPTO_set_locked_mem_ex_functions); -LCRYPTO_USED(CRYPTO_set_mem_debug_functions); -LCRYPTO_USED(CRYPTO_get_mem_functions); -LCRYPTO_USED(CRYPTO_get_locked_mem_functions); -LCRYPTO_USED(CRYPTO_get_mem_ex_functions); -LCRYPTO_USED(CRYPTO_get_locked_mem_ex_functions); -LCRYPTO_USED(CRYPTO_get_mem_debug_functions); -LCRYPTO_USED(CRYPTO_realloc_clean); -LCRYPTO_USED(CRYPTO_remalloc); -LCRYPTO_USED(CRYPTO_set_mem_debug_options); -LCRYPTO_USED(CRYPTO_get_mem_debug_options); LCRYPTO_USED(CRYPTO_push_info_); LCRYPTO_USED(CRYPTO_pop_info); LCRYPTO_USED(CRYPTO_remove_all_info); -LCRYPTO_USED(CRYPTO_dbg_malloc); -LCRYPTO_USED(CRYPTO_dbg_realloc); -LCRYPTO_USED(CRYPTO_dbg_free); -LCRYPTO_USED(CRYPTO_dbg_set_options); -LCRYPTO_USED(CRYPTO_dbg_get_options); -LCRYPTO_USED(CRYPTO_mem_leaks_fp); -LCRYPTO_USED(CRYPTO_mem_leaks); -LCRYPTO_USED(CRYPTO_mem_leaks_cb); LCRYPTO_USED(OpenSSLDie); LCRYPTO_USED(OPENSSL_cpu_caps); LCRYPTO_USED(OPENSSL_init_crypto); diff --git a/lib/libcrypto/malloc-wrapper.c b/lib/libcrypto/malloc-wrapper.c index 4d57f00b23b..e13cc233739 100644 --- a/lib/libcrypto/malloc-wrapper.c +++ b/lib/libcrypto/malloc-wrapper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc-wrapper.c,v 1.8 2023/07/08 08:28:23 beck Exp $ */ +/* $OpenBSD: malloc-wrapper.c,v 1.9 2024/03/02 11:28:46 tb Exp $ */ /* * Copyright (c) 2014 Bob Beck * @@ -36,111 +36,6 @@ CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int), } LCRYPTO_ALIAS(CRYPTO_set_mem_ex_functions); -int -CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *)) -{ - return 0; -} -LCRYPTO_ALIAS(CRYPTO_set_locked_mem_functions); - -int -CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int), - void (*f)(void *)) -{ - return 0; -} -LCRYPTO_ALIAS(CRYPTO_set_locked_mem_ex_functions); - -int -CRYPTO_set_mem_debug_functions(void (*m)(void *, int, const char *, int, int), - void (*r)(void *, void *, int, const char *, int, int), - void (*f)(void *, int), void (*so)(long), long (*go)(void)) -{ - return 0; -} -LCRYPTO_ALIAS(CRYPTO_set_mem_debug_functions); - - -void -CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t), - void (**f)(void *)) -{ - if (m != NULL) - *m = malloc; - if (r != NULL) - *r = realloc; - if (f != NULL) - *f = free; -} -LCRYPTO_ALIAS(CRYPTO_get_mem_functions); - -void -CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int), - void *(**r)(void *, size_t, const char *, int), void (**f)(void *)) -{ - if (m != NULL) - *m = NULL; - if (r != NULL) - *r = NULL; - if (f != NULL) - *f = free; -} -LCRYPTO_ALIAS(CRYPTO_get_mem_ex_functions); - -void -CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)) -{ - if (m != NULL) - *m = malloc; - if (f != NULL) - *f = free; -} -LCRYPTO_ALIAS(CRYPTO_get_locked_mem_functions); - -void -CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int), - void (**f)(void *)) -{ - if (m != NULL) - *m = NULL; - if (f != NULL) - *f = free; -} -LCRYPTO_ALIAS(CRYPTO_get_locked_mem_ex_functions); - -void -CRYPTO_get_mem_debug_functions(void (**m)(void *, int, const char *, int, int), - void (**r)(void *, void *, int, const char *, int, int), - void (**f)(void *, int), void (**so)(long), long (**go)(void)) -{ - if (m != NULL) - *m = NULL; - if (r != NULL) - *r = NULL; - if (f != NULL) - *f = NULL; - if (so != NULL) - *so = NULL; - if (go != NULL) - *go = NULL; -} -LCRYPTO_ALIAS(CRYPTO_get_mem_debug_functions); - - -void * -CRYPTO_malloc_locked(int num, const char *file, int line) -{ - if (num <= 0) - return NULL; - return malloc(num); -} - -void -CRYPTO_free_locked(void *ptr) -{ - free(ptr); -} - void * CRYPTO_malloc(int num, const char *file, int line) { @@ -155,51 +50,8 @@ CRYPTO_strdup(const char *str, const char *file, int line) return strdup(str); } -void * -CRYPTO_realloc(void *ptr, int num, const char *file, int line) -{ - if (num <= 0) - return NULL; - return realloc(ptr, num); -} - -void * -CRYPTO_realloc_clean(void *ptr, int old_len, int num, const char *file, - int line) -{ - if (num <= 0) - return NULL; - /* Original does not support shrinking. */ - if (num < old_len) - return NULL; - return recallocarray(ptr, old_len, num, 1); -} -LCRYPTO_ALIAS(CRYPTO_realloc_clean); - void CRYPTO_free(void *ptr) { free(ptr); } - -void * -CRYPTO_remalloc(void *a, int num, const char *file, int line) -{ - free(a); - return malloc(num); -} -LCRYPTO_ALIAS(CRYPTO_remalloc); - -void -CRYPTO_set_mem_debug_options(long bits) -{ - return; -} -LCRYPTO_ALIAS(CRYPTO_set_mem_debug_options); - -long -CRYPTO_get_mem_debug_options(void) -{ - return 0; -} -LCRYPTO_ALIAS(CRYPTO_get_mem_debug_options); diff --git a/lib/libcrypto/mem_dbg.c b/lib/libcrypto/mem_dbg.c index e2eacebe19b..bfdd9c171bf 100644 --- a/lib/libcrypto/mem_dbg.c +++ b/lib/libcrypto/mem_dbg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem_dbg.c,v 1.25 2023/07/08 08:28:23 beck Exp $ */ +/* $OpenBSD: mem_dbg.c,v 1.26 2024/03/02 11:28:46 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -122,27 +122,6 @@ CRYPTO_mem_ctrl(int mode) } int -CRYPTO_is_mem_check_on(void) -{ - return (0); -} - - -void -CRYPTO_dbg_set_options(long bits) -{ - return; -} -LCRYPTO_ALIAS(CRYPTO_dbg_set_options); - -long -CRYPTO_dbg_get_options(void) -{ - return (0); -} -LCRYPTO_ALIAS(CRYPTO_dbg_get_options); - -int CRYPTO_push_info_(const char *info, const char *file, int line) { return (0); @@ -162,48 +141,3 @@ CRYPTO_remove_all_info(void) return (0); } LCRYPTO_ALIAS(CRYPTO_remove_all_info); - -void -CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line, - int before_p) -{ - OPENSSL_assert("CRYPTO_dbg_malloc is no longer permitted"); -} -LCRYPTO_ALIAS(CRYPTO_dbg_malloc); - -void -CRYPTO_dbg_free(void *addr, int before_p) -{ - OPENSSL_assert("CRYPTO_dbg_free is no longer permitted"); -} -LCRYPTO_ALIAS(CRYPTO_dbg_free); - -void -CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, - const char *file, int line, int before_p) -{ - OPENSSL_assert("CRYPTO_dbg_realloc is no longer permitted"); -} -LCRYPTO_ALIAS(CRYPTO_dbg_realloc); - -int -CRYPTO_mem_leaks(BIO *b) -{ - return -1; -} -LCRYPTO_ALIAS(CRYPTO_mem_leaks); - -int -CRYPTO_mem_leaks_fp(FILE *fp) -{ - return -1; -} -LCRYPTO_ALIAS(CRYPTO_mem_leaks_fp); - - -int -CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb) -{ - return -1; -} -LCRYPTO_ALIAS(CRYPTO_mem_leaks_cb); |