diff options
-rw-r--r-- | src/lib/libcrypto/Makefile | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/Symbols.list | 1 | ||||
-rw-r--r-- | src/lib/libcrypto/conf/conf_api.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/hidden/openssl/lhash.h | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/lhash/lhash.c | 11 | ||||
-rw-r--r-- | src/lib/libcrypto/lhash/lhash.h | 48 | ||||
-rw-r--r-- | src/lib/libcrypto/lhash/lhash_local.h | 105 | ||||
-rw-r--r-- | src/lib/libcrypto/objects/obj_dat.c | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/stack/safestack.h | 23 | ||||
-rw-r--r-- | src/lib/libcrypto/stack/stack.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/stack/stack.h | 11 | ||||
-rw-r--r-- | src/lib/libcrypto/stack/stack_local.h | 71 | ||||
-rw-r--r-- | src/lib/libcrypto/x509/x509_policy.c | 3 |
13 files changed, 211 insertions, 80 deletions
diff --git a/src/lib/libcrypto/Makefile b/src/lib/libcrypto/Makefile index cc56c53591..0e4c783d9e 100644 --- a/src/lib/libcrypto/Makefile +++ b/src/lib/libcrypto/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.171 2024/03/02 11:04:51 tb Exp $ | 1 | # $OpenBSD: Makefile,v 1.172 2024/03/02 11:11:11 tb Exp $ |
2 | 2 | ||
3 | LIB= crypto | 3 | LIB= crypto |
4 | LIBREBUILD=y | 4 | LIBREBUILD=y |
@@ -40,11 +40,13 @@ CFLAGS+= -I${LCRYPTO_SRC}/evp | |||
40 | CFLAGS+= -I${LCRYPTO_SRC}/hidden | 40 | CFLAGS+= -I${LCRYPTO_SRC}/hidden |
41 | CFLAGS+= -I${LCRYPTO_SRC}/hmac | 41 | CFLAGS+= -I${LCRYPTO_SRC}/hmac |
42 | CFLAGS+= -I${LCRYPTO_SRC}/kdf | 42 | CFLAGS+= -I${LCRYPTO_SRC}/kdf |
43 | CFLAGS+= -I${LCRYPTO_SRC}/lhash | ||
43 | CFLAGS+= -I${LCRYPTO_SRC}/modes | 44 | CFLAGS+= -I${LCRYPTO_SRC}/modes |
44 | CFLAGS+= -I${LCRYPTO_SRC}/ocsp | 45 | CFLAGS+= -I${LCRYPTO_SRC}/ocsp |
45 | CFLAGS+= -I${LCRYPTO_SRC}/pkcs12 | 46 | CFLAGS+= -I${LCRYPTO_SRC}/pkcs12 |
46 | CFLAGS+= -I${LCRYPTO_SRC}/rsa | 47 | CFLAGS+= -I${LCRYPTO_SRC}/rsa |
47 | CFLAGS+= -I${LCRYPTO_SRC}/sha | 48 | CFLAGS+= -I${LCRYPTO_SRC}/sha |
49 | CFLAGS+= -I${LCRYPTO_SRC}/stack | ||
48 | CFLAGS+= -I${LCRYPTO_SRC}/ts | 50 | CFLAGS+= -I${LCRYPTO_SRC}/ts |
49 | CFLAGS+= -I${LCRYPTO_SRC}/x509 | 51 | CFLAGS+= -I${LCRYPTO_SRC}/x509 |
50 | 52 | ||
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index 644797f655..f14233f649 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list | |||
@@ -3434,6 +3434,7 @@ idea_set_encrypt_key | |||
3434 | lh_delete | 3434 | lh_delete |
3435 | lh_doall | 3435 | lh_doall |
3436 | lh_doall_arg | 3436 | lh_doall_arg |
3437 | lh_error | ||
3437 | lh_free | 3438 | lh_free |
3438 | lh_insert | 3439 | lh_insert |
3439 | lh_new | 3440 | lh_new |
diff --git a/src/lib/libcrypto/conf/conf_api.c b/src/lib/libcrypto/conf/conf_api.c index 464edcd4ff..b78bd50c2c 100644 --- a/src/lib/libcrypto/conf/conf_api.c +++ b/src/lib/libcrypto/conf/conf_api.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: conf_api.c,v 1.17 2024/01/24 14:05:10 jsing Exp $ */ | 1 | /* $OpenBSD: conf_api.c,v 1.18 2024/03/02 11:11:11 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -69,6 +69,8 @@ | |||
69 | #include <openssl/conf.h> | 69 | #include <openssl/conf.h> |
70 | #include <openssl/conf_api.h> | 70 | #include <openssl/conf_api.h> |
71 | 71 | ||
72 | #include "lhash_local.h" | ||
73 | |||
72 | static void value_free_hash_doall_arg(CONF_VALUE *a, | 74 | static void value_free_hash_doall_arg(CONF_VALUE *a, |
73 | LHASH_OF(CONF_VALUE) *conf); | 75 | LHASH_OF(CONF_VALUE) *conf); |
74 | static void value_free_stack_doall(CONF_VALUE *a); | 76 | static void value_free_stack_doall(CONF_VALUE *a); |
diff --git a/src/lib/libcrypto/hidden/openssl/lhash.h b/src/lib/libcrypto/hidden/openssl/lhash.h index eee272cf46..2cf5b2dc5a 100644 --- a/src/lib/libcrypto/hidden/openssl/lhash.h +++ b/src/lib/libcrypto/hidden/openssl/lhash.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: lhash.h,v 1.3 2024/03/02 11:04:51 tb Exp $ */ | 1 | /* $OpenBSD: lhash.h,v 1.4 2024/03/02 11:11:11 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2023 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2023 Bob Beck <beck@openbsd.org> |
4 | * | 4 | * |
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | LCRYPTO_USED(lh_new); | 28 | LCRYPTO_USED(lh_new); |
29 | LCRYPTO_USED(lh_free); | 29 | LCRYPTO_USED(lh_free); |
30 | LCRYPTO_USED(lh_error); | ||
30 | LCRYPTO_USED(lh_insert); | 31 | LCRYPTO_USED(lh_insert); |
31 | LCRYPTO_USED(lh_delete); | 32 | LCRYPTO_USED(lh_delete); |
32 | LCRYPTO_USED(lh_retrieve); | 33 | LCRYPTO_USED(lh_retrieve); |
diff --git a/src/lib/libcrypto/lhash/lhash.c b/src/lib/libcrypto/lhash/lhash.c index 81660419c7..cd69f6fec1 100644 --- a/src/lib/libcrypto/lhash/lhash.c +++ b/src/lib/libcrypto/lhash/lhash.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: lhash.c,v 1.21 2024/01/24 14:02:52 jsing Exp $ */ | 1 | /* $OpenBSD: lhash.c,v 1.22 2024/03/02 11:11:11 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -103,6 +103,8 @@ | |||
103 | #include <openssl/crypto.h> | 103 | #include <openssl/crypto.h> |
104 | #include <openssl/lhash.h> | 104 | #include <openssl/lhash.h> |
105 | 105 | ||
106 | #include "lhash_local.h" | ||
107 | |||
106 | #undef MIN_NODES | 108 | #undef MIN_NODES |
107 | #define MIN_NODES 16 | 109 | #define MIN_NODES 16 |
108 | #define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */ | 110 | #define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */ |
@@ -157,6 +159,13 @@ lh_free(_LHASH *lh) | |||
157 | } | 159 | } |
158 | LCRYPTO_ALIAS(lh_free); | 160 | LCRYPTO_ALIAS(lh_free); |
159 | 161 | ||
162 | int | ||
163 | lh_error(_LHASH *lh) | ||
164 | { | ||
165 | return lh->error; | ||
166 | } | ||
167 | LCRYPTO_ALIAS(lh_error); | ||
168 | |||
160 | void * | 169 | void * |
161 | lh_insert(_LHASH *lh, void *data) | 170 | lh_insert(_LHASH *lh, void *data) |
162 | { | 171 | { |
diff --git a/src/lib/libcrypto/lhash/lhash.h b/src/lib/libcrypto/lhash/lhash.h index 8db0174a61..86d05544a0 100644 --- a/src/lib/libcrypto/lhash/lhash.h +++ b/src/lib/libcrypto/lhash/lhash.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: lhash.h,v 1.13 2024/03/02 11:04:51 tb Exp $ */ | 1 | /* $OpenBSD: lhash.h,v 1.14 2024/03/02 11:11:11 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -75,14 +75,6 @@ | |||
75 | extern "C" { | 75 | extern "C" { |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | typedef struct lhash_node_st { | ||
79 | void *data; | ||
80 | struct lhash_node_st *next; | ||
81 | #ifndef OPENSSL_NO_HASH_COMP | ||
82 | unsigned long hash; | ||
83 | #endif | ||
84 | } LHASH_NODE; | ||
85 | |||
86 | typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *); | 78 | typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *); |
87 | typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *); | 79 | typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *); |
88 | typedef void (*LHASH_DOALL_FN_TYPE)(void *); | 80 | typedef void (*LHASH_DOALL_FN_TYPE)(void *); |
@@ -133,44 +125,13 @@ typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *); | |||
133 | name##_doall_arg(a, b); } | 125 | name##_doall_arg(a, b); } |
134 | #define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG | 126 | #define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG |
135 | 127 | ||
136 | typedef struct lhash_st { | 128 | typedef struct lhash_st _LHASH; |
137 | LHASH_NODE **b; | ||
138 | LHASH_COMP_FN_TYPE comp; | ||
139 | LHASH_HASH_FN_TYPE hash; | ||
140 | unsigned int num_nodes; | ||
141 | unsigned int num_alloc_nodes; | ||
142 | unsigned int p; | ||
143 | unsigned int pmax; | ||
144 | unsigned long up_load; /* load times 256 */ | ||
145 | unsigned long down_load; /* load times 256 */ | ||
146 | unsigned long num_items; | ||
147 | |||
148 | unsigned long num_expands; | ||
149 | unsigned long num_expand_reallocs; | ||
150 | unsigned long num_contracts; | ||
151 | unsigned long num_contract_reallocs; | ||
152 | unsigned long num_hash_calls; | ||
153 | unsigned long num_comp_calls; | ||
154 | unsigned long num_insert; | ||
155 | unsigned long num_replace; | ||
156 | unsigned long num_delete; | ||
157 | unsigned long num_no_delete; | ||
158 | unsigned long num_retrieve; | ||
159 | unsigned long num_retrieve_miss; | ||
160 | unsigned long num_hash_comps; | ||
161 | |||
162 | int error; | ||
163 | } _LHASH; /* Do not use _LHASH directly, use LHASH_OF | ||
164 | * and friends */ | ||
165 | 129 | ||
166 | #define LH_LOAD_MULT 256 | 130 | #define LH_LOAD_MULT 256 |
167 | 131 | ||
168 | /* Indicates a malloc() error in the last call, this is only bad | ||
169 | * in lh_insert(). */ | ||
170 | #define lh_error(lh) ((lh)->error) | ||
171 | |||
172 | _LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c); | 132 | _LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c); |
173 | void lh_free(_LHASH *lh); | 133 | void lh_free(_LHASH *lh); |
134 | int lh_error(_LHASH *lh); | ||
174 | void *lh_insert(_LHASH *lh, void *data); | 135 | void *lh_insert(_LHASH *lh, void *data); |
175 | void *lh_delete(_LHASH *lh, const void *data); | 136 | void *lh_delete(_LHASH *lh, const void *data); |
176 | void *lh_retrieve(_LHASH *lh, const void *data); | 137 | void *lh_retrieve(_LHASH *lh, const void *data); |
@@ -183,7 +144,7 @@ unsigned long lh_num_items(const _LHASH *lh); | |||
183 | 144 | ||
184 | #define LHASH_OF(type) struct lhash_st_##type | 145 | #define LHASH_OF(type) struct lhash_st_##type |
185 | 146 | ||
186 | #define DECLARE_LHASH_OF(type) LHASH_OF(type) { int dummy; } | 147 | #define DECLARE_LHASH_OF(type) LHASH_OF(type) |
187 | 148 | ||
188 | #define CHECKED_LHASH_OF(type,lh) \ | 149 | #define CHECKED_LHASH_OF(type,lh) \ |
189 | ((_LHASH *)CHECKED_PTR_OF(LHASH_OF(type),lh)) | 150 | ((_LHASH *)CHECKED_PTR_OF(LHASH_OF(type),lh)) |
@@ -206,7 +167,6 @@ unsigned long lh_num_items(const _LHASH *lh); | |||
206 | #define LHM_lh_doall_arg(type, lh, fn, arg_type, arg) \ | 167 | #define LHM_lh_doall_arg(type, lh, fn, arg_type, arg) \ |
207 | lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg)) | 168 | lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg)) |
208 | #define LHM_lh_num_items(type, lh) lh_num_items(CHECKED_LHASH_OF(type, lh)) | 169 | #define LHM_lh_num_items(type, lh) lh_num_items(CHECKED_LHASH_OF(type, lh)) |
209 | #define LHM_lh_down_load(type, lh) (CHECKED_LHASH_OF(type, lh)->down_load) | ||
210 | #define LHM_lh_free(type, lh) lh_free(CHECKED_LHASH_OF(type, lh)) | 170 | #define LHM_lh_free(type, lh) lh_free(CHECKED_LHASH_OF(type, lh)) |
211 | 171 | ||
212 | DECLARE_LHASH_OF(OPENSSL_STRING); | 172 | DECLARE_LHASH_OF(OPENSSL_STRING); |
diff --git a/src/lib/libcrypto/lhash/lhash_local.h b/src/lib/libcrypto/lhash/lhash_local.h new file mode 100644 index 0000000000..5466e554e7 --- /dev/null +++ b/src/lib/libcrypto/lhash/lhash_local.h | |||
@@ -0,0 +1,105 @@ | |||
1 | /* $OpenBSD: lhash_local.h,v 1.1 2024/03/02 11:11:11 tb Exp $ */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | /* Header for dynamic hash table routines | ||
60 | * Author - Eric Young | ||
61 | */ | ||
62 | |||
63 | #include <openssl/opensslconf.h> | ||
64 | |||
65 | #ifndef HEADER_LHASH_LOCAL_H | ||
66 | #define HEADER_LHASH_LOCAL_H | ||
67 | |||
68 | typedef struct lhash_node_st { | ||
69 | void *data; | ||
70 | struct lhash_node_st *next; | ||
71 | #ifndef OPENSSL_NO_HASH_COMP | ||
72 | unsigned long hash; | ||
73 | #endif | ||
74 | } LHASH_NODE; | ||
75 | |||
76 | struct lhash_st { | ||
77 | LHASH_NODE **b; | ||
78 | LHASH_COMP_FN_TYPE comp; | ||
79 | LHASH_HASH_FN_TYPE hash; | ||
80 | unsigned int num_nodes; | ||
81 | unsigned int num_alloc_nodes; | ||
82 | unsigned int p; | ||
83 | unsigned int pmax; | ||
84 | unsigned long up_load; /* load times 256 */ | ||
85 | unsigned long down_load; /* load times 256 */ | ||
86 | unsigned long num_items; | ||
87 | |||
88 | unsigned long num_expands; | ||
89 | unsigned long num_expand_reallocs; | ||
90 | unsigned long num_contracts; | ||
91 | unsigned long num_contract_reallocs; | ||
92 | unsigned long num_hash_calls; | ||
93 | unsigned long num_comp_calls; | ||
94 | unsigned long num_insert; | ||
95 | unsigned long num_replace; | ||
96 | unsigned long num_delete; | ||
97 | unsigned long num_no_delete; | ||
98 | unsigned long num_retrieve; | ||
99 | unsigned long num_retrieve_miss; | ||
100 | unsigned long num_hash_comps; | ||
101 | |||
102 | int error; | ||
103 | } /* _LHASH */; | ||
104 | |||
105 | #endif | ||
diff --git a/src/lib/libcrypto/objects/obj_dat.c b/src/lib/libcrypto/objects/obj_dat.c index 626036264f..b90c80316c 100644 --- a/src/lib/libcrypto/objects/obj_dat.c +++ b/src/lib/libcrypto/objects/obj_dat.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: obj_dat.c,v 1.88 2024/03/02 09:49:45 tb Exp $ */ | 1 | /* $OpenBSD: obj_dat.c,v 1.89 2024/03/02 11:11:11 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -71,6 +71,7 @@ | |||
71 | #include <openssl/objects.h> | 71 | #include <openssl/objects.h> |
72 | 72 | ||
73 | #include "asn1_local.h" | 73 | #include "asn1_local.h" |
74 | #include "lhash_local.h" | ||
74 | 75 | ||
75 | /* obj_dat.h is generated from objects.h by obj_dat.pl */ | 76 | /* obj_dat.h is generated from objects.h by obj_dat.pl */ |
76 | #include "obj_dat.h" | 77 | #include "obj_dat.h" |
diff --git a/src/lib/libcrypto/stack/safestack.h b/src/lib/libcrypto/stack/safestack.h index b64b865dc8..61770ef36f 100644 --- a/src/lib/libcrypto/stack/safestack.h +++ b/src/lib/libcrypto/stack/safestack.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: safestack.h,v 1.30 2024/03/02 11:04:52 tb Exp $ */ | 1 | /* $OpenBSD: safestack.h,v 1.31 2024/03/02 11:11:11 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -84,16 +84,8 @@ | |||
84 | #define STACK_OF(type) struct stack_st_##type | 84 | #define STACK_OF(type) struct stack_st_##type |
85 | #define PREDECLARE_STACK_OF(type) STACK_OF(type); | 85 | #define PREDECLARE_STACK_OF(type) STACK_OF(type); |
86 | 86 | ||
87 | #define DECLARE_STACK_OF(type) \ | 87 | #define DECLARE_STACK_OF(type) STACK_OF(type); |
88 | STACK_OF(type) \ | 88 | #define DECLARE_SPECIAL_STACK_OF(type, type2) STACK_OF(type); |
89 | { \ | ||
90 | _STACK stack; \ | ||
91 | }; | ||
92 | #define DECLARE_SPECIAL_STACK_OF(type, type2) \ | ||
93 | STACK_OF(type) \ | ||
94 | { \ | ||
95 | _STACK stack; \ | ||
96 | }; | ||
97 | 89 | ||
98 | #define IMPLEMENT_STACK_OF(type) /* nada (obsolete in new safestack approach)*/ | 90 | #define IMPLEMENT_STACK_OF(type) /* nada (obsolete in new safestack approach)*/ |
99 | 91 | ||
@@ -1815,7 +1807,6 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char) | |||
1815 | LHM_lh_doall_arg(ADDED_OBJ,lh,fn,arg_type,arg) | 1807 | LHM_lh_doall_arg(ADDED_OBJ,lh,fn,arg_type,arg) |
1816 | #define lh_ADDED_OBJ_error(lh) LHM_lh_error(ADDED_OBJ,lh) | 1808 | #define lh_ADDED_OBJ_error(lh) LHM_lh_error(ADDED_OBJ,lh) |
1817 | #define lh_ADDED_OBJ_num_items(lh) LHM_lh_num_items(ADDED_OBJ,lh) | 1809 | #define lh_ADDED_OBJ_num_items(lh) LHM_lh_num_items(ADDED_OBJ,lh) |
1818 | #define lh_ADDED_OBJ_down_load(lh) LHM_lh_down_load(ADDED_OBJ,lh) | ||
1819 | #define lh_ADDED_OBJ_free(lh) LHM_lh_free(ADDED_OBJ,lh) | 1810 | #define lh_ADDED_OBJ_free(lh) LHM_lh_free(ADDED_OBJ,lh) |
1820 | 1811 | ||
1821 | #define lh_CONF_VALUE_new() LHM_lh_new(CONF_VALUE,conf_value) | 1812 | #define lh_CONF_VALUE_new() LHM_lh_new(CONF_VALUE,conf_value) |
@@ -1827,7 +1818,6 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char) | |||
1827 | LHM_lh_doall_arg(CONF_VALUE,lh,fn,arg_type,arg) | 1818 | LHM_lh_doall_arg(CONF_VALUE,lh,fn,arg_type,arg) |
1828 | #define lh_CONF_VALUE_error(lh) LHM_lh_error(CONF_VALUE,lh) | 1819 | #define lh_CONF_VALUE_error(lh) LHM_lh_error(CONF_VALUE,lh) |
1829 | #define lh_CONF_VALUE_num_items(lh) LHM_lh_num_items(CONF_VALUE,lh) | 1820 | #define lh_CONF_VALUE_num_items(lh) LHM_lh_num_items(CONF_VALUE,lh) |
1830 | #define lh_CONF_VALUE_down_load(lh) LHM_lh_down_load(CONF_VALUE,lh) | ||
1831 | #define lh_CONF_VALUE_free(lh) LHM_lh_free(CONF_VALUE,lh) | 1821 | #define lh_CONF_VALUE_free(lh) LHM_lh_free(CONF_VALUE,lh) |
1832 | 1822 | ||
1833 | #define lh_ERR_STATE_new() LHM_lh_new(ERR_STATE,err_state) | 1823 | #define lh_ERR_STATE_new() LHM_lh_new(ERR_STATE,err_state) |
@@ -1839,7 +1829,6 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char) | |||
1839 | LHM_lh_doall_arg(ERR_STATE,lh,fn,arg_type,arg) | 1829 | LHM_lh_doall_arg(ERR_STATE,lh,fn,arg_type,arg) |
1840 | #define lh_ERR_STATE_error(lh) LHM_lh_error(ERR_STATE,lh) | 1830 | #define lh_ERR_STATE_error(lh) LHM_lh_error(ERR_STATE,lh) |
1841 | #define lh_ERR_STATE_num_items(lh) LHM_lh_num_items(ERR_STATE,lh) | 1831 | #define lh_ERR_STATE_num_items(lh) LHM_lh_num_items(ERR_STATE,lh) |
1842 | #define lh_ERR_STATE_down_load(lh) LHM_lh_down_load(ERR_STATE,lh) | ||
1843 | #define lh_ERR_STATE_free(lh) LHM_lh_free(ERR_STATE,lh) | 1832 | #define lh_ERR_STATE_free(lh) LHM_lh_free(ERR_STATE,lh) |
1844 | 1833 | ||
1845 | #define lh_ERR_STRING_DATA_new() LHM_lh_new(ERR_STRING_DATA,err_string_data) | 1834 | #define lh_ERR_STRING_DATA_new() LHM_lh_new(ERR_STRING_DATA,err_string_data) |
@@ -1851,7 +1840,6 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char) | |||
1851 | LHM_lh_doall_arg(ERR_STRING_DATA,lh,fn,arg_type,arg) | 1840 | LHM_lh_doall_arg(ERR_STRING_DATA,lh,fn,arg_type,arg) |
1852 | #define lh_ERR_STRING_DATA_error(lh) LHM_lh_error(ERR_STRING_DATA,lh) | 1841 | #define lh_ERR_STRING_DATA_error(lh) LHM_lh_error(ERR_STRING_DATA,lh) |
1853 | #define lh_ERR_STRING_DATA_num_items(lh) LHM_lh_num_items(ERR_STRING_DATA,lh) | 1842 | #define lh_ERR_STRING_DATA_num_items(lh) LHM_lh_num_items(ERR_STRING_DATA,lh) |
1854 | #define lh_ERR_STRING_DATA_down_load(lh) LHM_lh_down_load(ERR_STRING_DATA,lh) | ||
1855 | #define lh_ERR_STRING_DATA_free(lh) LHM_lh_free(ERR_STRING_DATA,lh) | 1843 | #define lh_ERR_STRING_DATA_free(lh) LHM_lh_free(ERR_STRING_DATA,lh) |
1856 | 1844 | ||
1857 | #define lh_EX_CLASS_ITEM_new() LHM_lh_new(EX_CLASS_ITEM,ex_class_item) | 1845 | #define lh_EX_CLASS_ITEM_new() LHM_lh_new(EX_CLASS_ITEM,ex_class_item) |
@@ -1863,7 +1851,6 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char) | |||
1863 | LHM_lh_doall_arg(EX_CLASS_ITEM,lh,fn,arg_type,arg) | 1851 | LHM_lh_doall_arg(EX_CLASS_ITEM,lh,fn,arg_type,arg) |
1864 | #define lh_EX_CLASS_ITEM_error(lh) LHM_lh_error(EX_CLASS_ITEM,lh) | 1852 | #define lh_EX_CLASS_ITEM_error(lh) LHM_lh_error(EX_CLASS_ITEM,lh) |
1865 | #define lh_EX_CLASS_ITEM_num_items(lh) LHM_lh_num_items(EX_CLASS_ITEM,lh) | 1853 | #define lh_EX_CLASS_ITEM_num_items(lh) LHM_lh_num_items(EX_CLASS_ITEM,lh) |
1866 | #define lh_EX_CLASS_ITEM_down_load(lh) LHM_lh_down_load(EX_CLASS_ITEM,lh) | ||
1867 | #define lh_EX_CLASS_ITEM_free(lh) LHM_lh_free(EX_CLASS_ITEM,lh) | 1854 | #define lh_EX_CLASS_ITEM_free(lh) LHM_lh_free(EX_CLASS_ITEM,lh) |
1868 | 1855 | ||
1869 | #define lh_FUNCTION_new() LHM_lh_new(FUNCTION,function) | 1856 | #define lh_FUNCTION_new() LHM_lh_new(FUNCTION,function) |
@@ -1875,7 +1862,6 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char) | |||
1875 | LHM_lh_doall_arg(FUNCTION,lh,fn,arg_type,arg) | 1862 | LHM_lh_doall_arg(FUNCTION,lh,fn,arg_type,arg) |
1876 | #define lh_FUNCTION_error(lh) LHM_lh_error(FUNCTION,lh) | 1863 | #define lh_FUNCTION_error(lh) LHM_lh_error(FUNCTION,lh) |
1877 | #define lh_FUNCTION_num_items(lh) LHM_lh_num_items(FUNCTION,lh) | 1864 | #define lh_FUNCTION_num_items(lh) LHM_lh_num_items(FUNCTION,lh) |
1878 | #define lh_FUNCTION_down_load(lh) LHM_lh_down_load(FUNCTION,lh) | ||
1879 | #define lh_FUNCTION_free(lh) LHM_lh_free(FUNCTION,lh) | 1865 | #define lh_FUNCTION_free(lh) LHM_lh_free(FUNCTION,lh) |
1880 | 1866 | ||
1881 | #define lh_OBJ_NAME_new() LHM_lh_new(OBJ_NAME,obj_name) | 1867 | #define lh_OBJ_NAME_new() LHM_lh_new(OBJ_NAME,obj_name) |
@@ -1887,7 +1873,6 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char) | |||
1887 | LHM_lh_doall_arg(OBJ_NAME,lh,fn,arg_type,arg) | 1873 | LHM_lh_doall_arg(OBJ_NAME,lh,fn,arg_type,arg) |
1888 | #define lh_OBJ_NAME_error(lh) LHM_lh_error(OBJ_NAME,lh) | 1874 | #define lh_OBJ_NAME_error(lh) LHM_lh_error(OBJ_NAME,lh) |
1889 | #define lh_OBJ_NAME_num_items(lh) LHM_lh_num_items(OBJ_NAME,lh) | 1875 | #define lh_OBJ_NAME_num_items(lh) LHM_lh_num_items(OBJ_NAME,lh) |
1890 | #define lh_OBJ_NAME_down_load(lh) LHM_lh_down_load(OBJ_NAME,lh) | ||
1891 | #define lh_OBJ_NAME_free(lh) LHM_lh_free(OBJ_NAME,lh) | 1876 | #define lh_OBJ_NAME_free(lh) LHM_lh_free(OBJ_NAME,lh) |
1892 | 1877 | ||
1893 | #define lh_OPENSSL_STRING_new() LHM_lh_new(OPENSSL_STRING,openssl_string) | 1878 | #define lh_OPENSSL_STRING_new() LHM_lh_new(OPENSSL_STRING,openssl_string) |
@@ -1899,7 +1884,6 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char) | |||
1899 | LHM_lh_doall_arg(OPENSSL_STRING,lh,fn,arg_type,arg) | 1884 | LHM_lh_doall_arg(OPENSSL_STRING,lh,fn,arg_type,arg) |
1900 | #define lh_OPENSSL_STRING_error(lh) LHM_lh_error(OPENSSL_STRING,lh) | 1885 | #define lh_OPENSSL_STRING_error(lh) LHM_lh_error(OPENSSL_STRING,lh) |
1901 | #define lh_OPENSSL_STRING_num_items(lh) LHM_lh_num_items(OPENSSL_STRING,lh) | 1886 | #define lh_OPENSSL_STRING_num_items(lh) LHM_lh_num_items(OPENSSL_STRING,lh) |
1902 | #define lh_OPENSSL_STRING_down_load(lh) LHM_lh_down_load(OPENSSL_STRING,lh) | ||
1903 | #define lh_OPENSSL_STRING_free(lh) LHM_lh_free(OPENSSL_STRING,lh) | 1887 | #define lh_OPENSSL_STRING_free(lh) LHM_lh_free(OPENSSL_STRING,lh) |
1904 | 1888 | ||
1905 | #define lh_SSL_SESSION_new() LHM_lh_new(SSL_SESSION,ssl_session) | 1889 | #define lh_SSL_SESSION_new() LHM_lh_new(SSL_SESSION,ssl_session) |
@@ -1911,7 +1895,6 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char) | |||
1911 | LHM_lh_doall_arg(SSL_SESSION,lh,fn,arg_type,arg) | 1895 | LHM_lh_doall_arg(SSL_SESSION,lh,fn,arg_type,arg) |
1912 | #define lh_SSL_SESSION_error(lh) LHM_lh_error(SSL_SESSION,lh) | 1896 | #define lh_SSL_SESSION_error(lh) LHM_lh_error(SSL_SESSION,lh) |
1913 | #define lh_SSL_SESSION_num_items(lh) LHM_lh_num_items(SSL_SESSION,lh) | 1897 | #define lh_SSL_SESSION_num_items(lh) LHM_lh_num_items(SSL_SESSION,lh) |
1914 | #define lh_SSL_SESSION_down_load(lh) LHM_lh_down_load(SSL_SESSION,lh) | ||
1915 | #define lh_SSL_SESSION_free(lh) LHM_lh_free(SSL_SESSION,lh) | 1898 | #define lh_SSL_SESSION_free(lh) LHM_lh_free(SSL_SESSION,lh) |
1916 | 1899 | ||
1917 | #endif /* !defined HEADER_SAFESTACK_H */ | 1900 | #endif /* !defined HEADER_SAFESTACK_H */ |
diff --git a/src/lib/libcrypto/stack/stack.c b/src/lib/libcrypto/stack/stack.c index 86117f07a7..99bb52dcfa 100644 --- a/src/lib/libcrypto/stack/stack.c +++ b/src/lib/libcrypto/stack/stack.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: stack.c,v 1.26 2024/03/02 09:47:16 tb Exp $ */ | 1 | /* $OpenBSD: stack.c,v 1.27 2024/03/02 11:11:11 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -63,6 +63,8 @@ | |||
63 | #include <openssl/objects.h> | 63 | #include <openssl/objects.h> |
64 | #include <openssl/stack.h> | 64 | #include <openssl/stack.h> |
65 | 65 | ||
66 | #include "stack_local.h" | ||
67 | |||
66 | #undef MIN_NODES | 68 | #undef MIN_NODES |
67 | #define MIN_NODES 4 | 69 | #define MIN_NODES 4 |
68 | 70 | ||
diff --git a/src/lib/libcrypto/stack/stack.h b/src/lib/libcrypto/stack/stack.h index 6bea6348f2..8b490c7225 100644 --- a/src/lib/libcrypto/stack/stack.h +++ b/src/lib/libcrypto/stack/stack.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: stack.h,v 1.9 2014/06/12 15:49:30 deraadt Exp $ */ | 1 | /* $OpenBSD: stack.h,v 1.10 2024/03/02 11:11:11 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -63,14 +63,7 @@ | |||
63 | extern "C" { | 63 | extern "C" { |
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | typedef struct stack_st { | 66 | typedef struct stack_st _STACK; |
67 | int num; | ||
68 | char **data; | ||
69 | int sorted; | ||
70 | |||
71 | int num_alloc; | ||
72 | int (*comp)(const void *, const void *); | ||
73 | } _STACK; /* Use STACK_OF(...) instead */ | ||
74 | 67 | ||
75 | #define M_sk_num(sk) ((sk) ? (sk)->num:-1) | 68 | #define M_sk_num(sk) ((sk) ? (sk)->num:-1) |
76 | #define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL) | 69 | #define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL) |
diff --git a/src/lib/libcrypto/stack/stack_local.h b/src/lib/libcrypto/stack/stack_local.h new file mode 100644 index 0000000000..a330707192 --- /dev/null +++ b/src/lib/libcrypto/stack/stack_local.h | |||
@@ -0,0 +1,71 @@ | |||
1 | /* $OpenBSD: stack_local.h,v 1.1 2024/03/02 11:11:11 tb Exp $ */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #ifndef HEADER_STACK_LOCAL_H | ||
60 | #define HEADER_STACK_LOCAL_H | ||
61 | |||
62 | struct stack_st { | ||
63 | int num; | ||
64 | char **data; | ||
65 | int sorted; | ||
66 | |||
67 | int num_alloc; | ||
68 | int (*comp)(const void *, const void *); | ||
69 | } /* _STACK */; | ||
70 | |||
71 | #endif | ||
diff --git a/src/lib/libcrypto/x509/x509_policy.c b/src/lib/libcrypto/x509/x509_policy.c index 73f7154f51..ec9be8d927 100644 --- a/src/lib/libcrypto/x509/x509_policy.c +++ b/src/lib/libcrypto/x509/x509_policy.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_policy.c,v 1.25 2023/04/28 16:30:14 tb Exp $ */ | 1 | /* $OpenBSD: x509_policy.c,v 1.26 2024/03/02 11:11:11 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2022, Google Inc. | 3 | * Copyright (c) 2022, Google Inc. |
4 | * | 4 | * |
@@ -23,6 +23,7 @@ | |||
23 | #include <openssl/x509.h> | 23 | #include <openssl/x509.h> |
24 | #include <openssl/x509v3.h> | 24 | #include <openssl/x509v3.h> |
25 | 25 | ||
26 | #include "stack_local.h" | ||
26 | #include "x509_internal.h" | 27 | #include "x509_internal.h" |
27 | #include "x509_local.h" | 28 | #include "x509_local.h" |
28 | 29 | ||