From: tb Date: Sat, 2 Mar 2024 11:37:13 +0000 (+0000) Subject: Make CRYPTO_THREADID opaque X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=463a61a11aa548f944148b4ebde7cb2d8914603b;p=openbsd Make CRYPTO_THREADID opaque With ERR_STATE out of the way, we can make CRYPTO_THREADID opaque. The type is still accessed by used public API, but some of the public API can also go away. ok jsing --- diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index f9ef997e307..846bd5ce839 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -623,11 +623,7 @@ CONF_set_nconf CRL_DIST_POINTS_free CRL_DIST_POINTS_it CRL_DIST_POINTS_new -CRYPTO_THREADID_cmp -CRYPTO_THREADID_cpy -CRYPTO_THREADID_current CRYPTO_THREADID_get_callback -CRYPTO_THREADID_hash CRYPTO_THREADID_set_callback CRYPTO_THREADID_set_numeric CRYPTO_THREADID_set_pointer diff --git a/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index 489c618ec58..95b2a33720b 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/lib/libcrypto/Symbols.namespace @@ -1855,10 +1855,6 @@ _libre_CRYPTO_get_ex_data _libre_CRYPTO_cleanup_all_ex_data _libre_CRYPTO_lock _libre_CRYPTO_add_lock -_libre_CRYPTO_THREADID_current -_libre_CRYPTO_THREADID_cmp -_libre_CRYPTO_THREADID_cpy -_libre_CRYPTO_THREADID_hash _libre_CRYPTO_set_mem_functions _libre_CRYPTO_set_locked_mem_functions _libre_CRYPTO_set_mem_ex_functions diff --git a/lib/libcrypto/cryptlib.c b/lib/libcrypto/cryptlib.c index 28b50c2c173..abf11594006 100644 --- a/lib/libcrypto/cryptlib.c +++ b/lib/libcrypto/cryptlib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptlib.c,v 1.47 2023/12/14 15:31:22 tb Exp $ */ +/* $OpenBSD: cryptlib.c,v 1.48 2024/03/02 11:37:13 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * @@ -124,6 +124,8 @@ #include #include +#include "crypto_local.h" + static void (*locking_callback)(int mode, int type, const char *file, int line) = NULL; static int (*add_lock_callback)(int *pointer, int amount, diff --git a/lib/libcrypto/crypto.h b/lib/libcrypto/crypto.h index 382d40a3505..01359c42975 100644 --- a/lib/libcrypto/crypto.h +++ b/lib/libcrypto/crypto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.h,v 1.68 2024/03/02 11:35:09 tb Exp $ */ +/* $OpenBSD: crypto.h,v 1.69 2024/03/02 11:37:13 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * @@ -313,14 +313,7 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file, int line); /* Don't use this structure directly. */ -typedef struct crypto_threadid_st { - void *ptr; - unsigned long val; -} CRYPTO_THREADID; -void CRYPTO_THREADID_current(CRYPTO_THREADID *id); -int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b); -void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src); -unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id); +typedef struct crypto_threadid_st CRYPTO_THREADID; #ifndef LIBRESSL_INTERNAL /* These functions are deprecated no-op stubs */ diff --git a/lib/libcrypto/crypto_local.h b/lib/libcrypto/crypto_local.h new file mode 100644 index 00000000000..970a7846603 --- /dev/null +++ b/lib/libcrypto/crypto_local.h @@ -0,0 +1,138 @@ +/* $OpenBSD: crypto_local.h,v 1.1 2024/03/02 11:37:13 tb Exp $ */ +/* ==================================================================== + * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +/* ==================================================================== + * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. + * ECDH support in OpenSSL originally developed by + * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. + */ + +#include +#include +#include + +#ifndef HEADER_CRYPTO_LOCAL_H +#define HEADER_CRYPTO_LOCAL_H + +__BEGIN_HIDDEN_DECLS + +struct crypto_threadid_st { + void *ptr; + unsigned long val; +} /* CRYPTO_THREADID */; + +void CRYPTO_THREADID_current(CRYPTO_THREADID *id); +int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b); +void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src); +unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id); + +__END_HIDDEN_DECLS + +#endif diff --git a/lib/libcrypto/err/err.c b/lib/libcrypto/err/err.c index acbcda76cc9..a7b13a54042 100644 --- a/lib/libcrypto/err/err.c +++ b/lib/libcrypto/err/err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: err.c,v 1.59 2024/03/02 10:30:48 tb Exp $ */ +/* $OpenBSD: err.c,v 1.60 2024/03/02 11:37:13 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -122,6 +122,8 @@ #include #include +#include "crypto_local.h" + DECLARE_LHASH_OF(ERR_STRING_DATA); DECLARE_LHASH_OF(ERR_STATE); diff --git a/lib/libcrypto/err/err_prn.c b/lib/libcrypto/err/err_prn.c index 61f4dad5749..fb6e19c54c0 100644 --- a/lib/libcrypto/err/err_prn.c +++ b/lib/libcrypto/err/err_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: err_prn.c,v 1.22 2024/01/10 14:23:37 tb Exp $ */ +/* $OpenBSD: err_prn.c,v 1.23 2024/03/02 11:37:13 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,6 +66,7 @@ #include #include "bio_local.h" +#include "crypto_local.h" void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), void *u) diff --git a/lib/libcrypto/hidden/openssl/crypto.h b/lib/libcrypto/hidden/openssl/crypto.h index 3e8f3dc7a80..10daf41f574 100644 --- a/lib/libcrypto/hidden/openssl/crypto.h +++ b/lib/libcrypto/hidden/openssl/crypto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.h,v 1.5 2024/03/02 11:32:31 tb Exp $ */ +/* $OpenBSD: crypto.h,v 1.6 2024/03/02 11:37:13 tb Exp $ */ /* * Copyright (c) 2023 Bob Beck * @@ -38,10 +38,6 @@ LCRYPTO_USED(CRYPTO_get_ex_data); LCRYPTO_USED(CRYPTO_cleanup_all_ex_data); LCRYPTO_USED(CRYPTO_lock); LCRYPTO_USED(CRYPTO_add_lock); -LCRYPTO_USED(CRYPTO_THREADID_current); -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_mem_ex_functions); LCRYPTO_USED(OpenSSLDie);