summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2023-07-28 09:22:26 +0000
committertb <>2023-07-28 09:22:26 +0000
commitf15cd04d37436407bfd863b507fcd73ca66e3976 (patch)
tree4eb57ae2fdd0f6dff20d00655e0d117dcf61415d
parente5c3cb1fc9513740908e7dc235cee9871623b942 (diff)
downloadopenbsd-f15cd04d37436407bfd863b507fcd73ca66e3976.tar.gz
openbsd-f15cd04d37436407bfd863b507fcd73ca66e3976.tar.bz2
openbsd-f15cd04d37436407bfd863b507fcd73ca66e3976.zip
Excise ECDH_METHOD
Unlike ECDSA_METHOD, this has been unused forever but kind of needed to stay for symmetry with ECDSA_METHOD. Now we can finally take it behind the barn and remove its tendrils into ENGINE. ok jsing
-rw-r--r--src/lib/libcrypto/Makefile4
-rw-r--r--src/lib/libcrypto/Symbols.list14
-rw-r--r--src/lib/libcrypto/Symbols.namespace7
-rw-r--r--src/lib/libcrypto/ecdh/ecdh.h13
-rw-r--r--src/lib/libcrypto/ecdh/ech_lib.c147
-rw-r--r--src/lib/libcrypto/engine/eng_fat.c11
-rw-r--r--src/lib/libcrypto/engine/eng_int.h3
-rw-r--r--src/lib/libcrypto/engine/eng_list.c5
-rw-r--r--src/lib/libcrypto/engine/eng_openssl.c5
-rw-r--r--src/lib/libcrypto/engine/engine.h14
-rw-r--r--src/lib/libcrypto/engine/tb_ecdh.c141
-rw-r--r--src/lib/libcrypto/hidden/openssl/ecdh.h10
-rw-r--r--src/lib/libcrypto/ossl_typ.h4
13 files changed, 9 insertions, 369 deletions
diff --git a/src/lib/libcrypto/Makefile b/src/lib/libcrypto/Makefile
index 030efb14c1..5018157934 100644
--- a/src/lib/libcrypto/Makefile
+++ b/src/lib/libcrypto/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.142 2023/07/28 09:19:58 tb Exp $ 1# $OpenBSD: Makefile,v 1.143 2023/07/28 09:22:26 tb Exp $
2 2
3LIB= crypto 3LIB= crypto
4LIBREBUILD=y 4LIBREBUILD=y
@@ -353,7 +353,6 @@ SRCS+= ecx_methods.c
353 353
354# ecdh/ 354# ecdh/
355SRCS+= ecdh.c 355SRCS+= ecdh.c
356SRCS+= ech_lib.c
357 356
358# ecdsa/ 357# ecdsa/
359SRCS+= ecdsa.c 358SRCS+= ecdsa.c
@@ -377,7 +376,6 @@ SRCS+= tb_cipher.c
377SRCS+= tb_dh.c 376SRCS+= tb_dh.c
378SRCS+= tb_digest.c 377SRCS+= tb_digest.c
379SRCS+= tb_dsa.c 378SRCS+= tb_dsa.c
380SRCS+= tb_ecdh.c
381SRCS+= tb_eckey.c 379SRCS+= tb_eckey.c
382SRCS+= tb_pkmeth.c 380SRCS+= tb_pkmeth.c
383SRCS+= tb_rand.c 381SRCS+= tb_rand.c
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list
index b9338fee67..c16a178cf7 100644
--- a/src/lib/libcrypto/Symbols.list
+++ b/src/lib/libcrypto/Symbols.list
@@ -1010,14 +1010,7 @@ DSO_set_filename
1010DSO_set_method 1010DSO_set_method
1011DSO_set_name_converter 1011DSO_set_name_converter
1012DSO_up_ref 1012DSO_up_ref
1013ECDH_OpenSSL
1014ECDH_compute_key 1013ECDH_compute_key
1015ECDH_get_default_method
1016ECDH_get_ex_data
1017ECDH_get_ex_new_index
1018ECDH_set_default_method
1019ECDH_set_ex_data
1020ECDH_set_method
1021ECDH_size 1014ECDH_size
1022ECDSA_SIG_free 1015ECDSA_SIG_free
1023ECDSA_SIG_get0 1016ECDSA_SIG_get0
@@ -1180,7 +1173,6 @@ ENGINE_free
1180ENGINE_get_DH 1173ENGINE_get_DH
1181ENGINE_get_DSA 1174ENGINE_get_DSA
1182ENGINE_get_EC 1175ENGINE_get_EC
1183ENGINE_get_ECDH
1184ENGINE_get_RAND 1176ENGINE_get_RAND
1185ENGINE_get_RSA 1177ENGINE_get_RSA
1186ENGINE_get_STORE 1178ENGINE_get_STORE
@@ -1192,7 +1184,6 @@ ENGINE_get_ctrl_function
1192ENGINE_get_default_DH 1184ENGINE_get_default_DH
1193ENGINE_get_default_DSA 1185ENGINE_get_default_DSA
1194ENGINE_get_default_EC 1186ENGINE_get_default_EC
1195ENGINE_get_default_ECDH
1196ENGINE_get_default_RAND 1187ENGINE_get_default_RAND
1197ENGINE_get_default_RSA 1188ENGINE_get_default_RSA
1198ENGINE_get_destroy_function 1189ENGINE_get_destroy_function
@@ -1234,14 +1225,12 @@ ENGINE_pkey_asn1_find_str
1234ENGINE_register_DH 1225ENGINE_register_DH
1235ENGINE_register_DSA 1226ENGINE_register_DSA
1236ENGINE_register_EC 1227ENGINE_register_EC
1237ENGINE_register_ECDH
1238ENGINE_register_RAND 1228ENGINE_register_RAND
1239ENGINE_register_RSA 1229ENGINE_register_RSA
1240ENGINE_register_STORE 1230ENGINE_register_STORE
1241ENGINE_register_all_DH 1231ENGINE_register_all_DH
1242ENGINE_register_all_DSA 1232ENGINE_register_all_DSA
1243ENGINE_register_all_EC 1233ENGINE_register_all_EC
1244ENGINE_register_all_ECDH
1245ENGINE_register_all_RAND 1234ENGINE_register_all_RAND
1246ENGINE_register_all_RSA 1235ENGINE_register_all_RSA
1247ENGINE_register_all_STORE 1236ENGINE_register_all_STORE
@@ -1259,7 +1248,6 @@ ENGINE_remove
1259ENGINE_set_DH 1248ENGINE_set_DH
1260ENGINE_set_DSA 1249ENGINE_set_DSA
1261ENGINE_set_EC 1250ENGINE_set_EC
1262ENGINE_set_ECDH
1263ENGINE_set_RAND 1251ENGINE_set_RAND
1264ENGINE_set_RSA 1252ENGINE_set_RSA
1265ENGINE_set_STORE 1253ENGINE_set_STORE
@@ -1270,7 +1258,6 @@ ENGINE_set_default
1270ENGINE_set_default_DH 1258ENGINE_set_default_DH
1271ENGINE_set_default_DSA 1259ENGINE_set_default_DSA
1272ENGINE_set_default_EC 1260ENGINE_set_default_EC
1273ENGINE_set_default_ECDH
1274ENGINE_set_default_RAND 1261ENGINE_set_default_RAND
1275ENGINE_set_default_RSA 1262ENGINE_set_default_RSA
1276ENGINE_set_default_ciphers 1263ENGINE_set_default_ciphers
@@ -1295,7 +1282,6 @@ ENGINE_set_table_flags
1295ENGINE_unregister_DH 1282ENGINE_unregister_DH
1296ENGINE_unregister_DSA 1283ENGINE_unregister_DSA
1297ENGINE_unregister_EC 1284ENGINE_unregister_EC
1298ENGINE_unregister_ECDH
1299ENGINE_unregister_RAND 1285ENGINE_unregister_RAND
1300ENGINE_unregister_RSA 1286ENGINE_unregister_RSA
1301ENGINE_unregister_STORE 1287ENGINE_unregister_STORE
diff --git a/src/lib/libcrypto/Symbols.namespace b/src/lib/libcrypto/Symbols.namespace
index 9ad2aa2c21..9dd16a93f2 100644
--- a/src/lib/libcrypto/Symbols.namespace
+++ b/src/lib/libcrypto/Symbols.namespace
@@ -1636,15 +1636,8 @@ _libre_SM4_encrypt
1636_libre_CRYPTO_poly1305_init 1636_libre_CRYPTO_poly1305_init
1637_libre_CRYPTO_poly1305_update 1637_libre_CRYPTO_poly1305_update
1638_libre_CRYPTO_poly1305_finish 1638_libre_CRYPTO_poly1305_finish
1639_libre_ECDH_OpenSSL
1640_libre_ECDH_set_default_method
1641_libre_ECDH_get_default_method
1642_libre_ECDH_set_method
1643_libre_ECDH_size 1639_libre_ECDH_size
1644_libre_ECDH_compute_key 1640_libre_ECDH_compute_key
1645_libre_ECDH_get_ex_new_index
1646_libre_ECDH_set_ex_data
1647_libre_ECDH_get_ex_data
1648_libre_PEM_get_EVP_CIPHER_INFO 1641_libre_PEM_get_EVP_CIPHER_INFO
1649_libre_PEM_do_header 1642_libre_PEM_do_header
1650_libre_PEM_read_bio 1643_libre_PEM_read_bio
diff --git a/src/lib/libcrypto/ecdh/ecdh.h b/src/lib/libcrypto/ecdh/ecdh.h
index a5e32bea48..3163b9ea2e 100644
--- a/src/lib/libcrypto/ecdh/ecdh.h
+++ b/src/lib/libcrypto/ecdh/ecdh.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecdh.h,v 1.8 2023/07/28 09:19:59 tb Exp $ */ 1/* $OpenBSD: ecdh.h,v 1.9 2023/07/28 09:22:26 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -83,22 +83,11 @@
83extern "C" { 83extern "C" {
84#endif 84#endif
85 85
86const ECDH_METHOD *ECDH_OpenSSL(void);
87
88void ECDH_set_default_method(const ECDH_METHOD *);
89const ECDH_METHOD *ECDH_get_default_method(void);
90int ECDH_set_method(EC_KEY *, const ECDH_METHOD *);
91
92int ECDH_size(const EC_KEY *ecdh); 86int ECDH_size(const EC_KEY *ecdh);
93int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, 87int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
94 EC_KEY *ecdh, 88 EC_KEY *ecdh,
95 void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); 89 void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen));
96 90
97int ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new
98*new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
99int ECDH_set_ex_data(EC_KEY *d, int idx, void *arg);
100void *ECDH_get_ex_data(EC_KEY *d, int idx);
101
102#ifdef __cplusplus 91#ifdef __cplusplus
103} 92}
104#endif 93#endif
diff --git a/src/lib/libcrypto/ecdh/ech_lib.c b/src/lib/libcrypto/ecdh/ech_lib.c
deleted file mode 100644
index c8e5744c0a..0000000000
--- a/src/lib/libcrypto/ecdh/ech_lib.c
+++ /dev/null
@@ -1,147 +0,0 @@
1/* $OpenBSD: ech_lib.c,v 1.24 2023/07/07 13:54:45 beck Exp $ */
2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 *
5 * The Elliptic Curve Public-Key Crypto Library (ECC Code) included
6 * herein is developed by SUN MICROSYSTEMS, INC., and is contributed
7 * to the OpenSSL project.
8 *
9 * The ECC Code is licensed pursuant to the OpenSSL open source
10 * license provided below.
11 *
12 * The ECDH software is originally written by Douglas Stebila of
13 * Sun Microsystems Laboratories.
14 *
15 */
16/* ====================================================================
17 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions
21 * are met:
22 *
23 * 1. Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 *
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in
28 * the documentation and/or other materials provided with the
29 * distribution.
30 *
31 * 3. All advertising materials mentioning features or use of this
32 * software must display the following acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
35 *
36 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
37 * endorse or promote products derived from this software without
38 * prior written permission. For written permission, please contact
39 * openssl-core@OpenSSL.org.
40 *
41 * 5. Products derived from this software may not be called "OpenSSL"
42 * nor may "OpenSSL" appear in their names without prior written
43 * permission of the OpenSSL Project.
44 *
45 * 6. Redistributions of any form whatsoever must retain the following
46 * acknowledgment:
47 * "This product includes software developed by the OpenSSL Project
48 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
51 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
53 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
54 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
56 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
57 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
59 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
60 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
61 * OF THE POSSIBILITY OF SUCH DAMAGE.
62 * ====================================================================
63 *
64 * This product includes cryptographic software written by Eric Young
65 * (eay@cryptsoft.com). This product includes software written by Tim
66 * Hudson (tjh@cryptsoft.com).
67 *
68 */
69
70#include <string.h>
71
72#include <openssl/opensslconf.h>
73
74#ifndef OPENSSL_NO_ENGINE
75#include <openssl/engine.h>
76#endif
77#include <openssl/err.h>
78
79#include "ec_local.h"
80
81struct ecdh_method {
82 const char *name;
83 int (*compute_key)(void *key, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh,
84 void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen));
85 int flags;
86 char *app_data;
87};
88
89static const ECDH_METHOD *default_ECDH_method = NULL;
90
91static const ECDH_METHOD openssl_ecdh_meth = {
92 .name = "OpenSSL ECDH method",
93 .compute_key = ecdh_compute_key,
94};
95
96const ECDH_METHOD *
97ECDH_OpenSSL(void)
98{
99 return &openssl_ecdh_meth;
100}
101LCRYPTO_ALIAS(ECDH_OpenSSL);
102
103void
104ECDH_set_default_method(const ECDH_METHOD *meth)
105{
106 default_ECDH_method = meth;
107}
108LCRYPTO_ALIAS(ECDH_set_default_method);
109
110const ECDH_METHOD *
111ECDH_get_default_method(void)
112{
113 if (!default_ECDH_method) {
114 default_ECDH_method = ECDH_OpenSSL();
115 }
116 return default_ECDH_method;
117}
118LCRYPTO_ALIAS(ECDH_get_default_method);
119
120int
121ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth)
122{
123 return 0;
124}
125LCRYPTO_ALIAS(ECDH_set_method);
126
127int
128ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
129 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
130{
131 return -1;
132}
133LCRYPTO_ALIAS(ECDH_get_ex_new_index);
134
135int
136ECDH_set_ex_data(EC_KEY *d, int idx, void *arg)
137{
138 return 0;
139}
140LCRYPTO_ALIAS(ECDH_set_ex_data);
141
142void *
143ECDH_get_ex_data(EC_KEY *d, int idx)
144{
145 return NULL;
146}
147LCRYPTO_ALIAS(ECDH_get_ex_data);
diff --git a/src/lib/libcrypto/engine/eng_fat.c b/src/lib/libcrypto/engine/eng_fat.c
index cf49c99bb4..f0b57722ff 100644
--- a/src/lib/libcrypto/engine/eng_fat.c
+++ b/src/lib/libcrypto/engine/eng_fat.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: eng_fat.c,v 1.18 2023/07/28 09:08:31 tb Exp $ */ 1/* $OpenBSD: eng_fat.c,v 1.19 2023/07/28 09:22:26 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -85,10 +85,6 @@ ENGINE_set_default(ENGINE *e, unsigned int flags)
85 if ((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e)) 85 if ((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e))
86 return 0; 86 return 0;
87#endif 87#endif
88#ifndef OPENSSL_NO_ECDH
89 if ((flags & ENGINE_METHOD_ECDH) && !ENGINE_set_default_ECDH(e))
90 return 0;
91#endif
92#ifndef OPENSSL_NO_EC 88#ifndef OPENSSL_NO_EC
93 if ((flags & ENGINE_METHOD_EC) && !ENGINE_set_default_EC(e)) 89 if ((flags & ENGINE_METHOD_EC) && !ENGINE_set_default_EC(e))
94 return 0; 90 return 0;
@@ -117,8 +113,6 @@ int_def_cb(const char *alg, int len, void *arg)
117 *pflags |= ENGINE_METHOD_RSA; 113 *pflags |= ENGINE_METHOD_RSA;
118 else if (!strncmp(alg, "DSA", len)) 114 else if (!strncmp(alg, "DSA", len))
119 *pflags |= ENGINE_METHOD_DSA; 115 *pflags |= ENGINE_METHOD_DSA;
120 else if (!strncmp(alg, "ECDH", len))
121 *pflags |= ENGINE_METHOD_ECDH;
122 else if (!strncmp(alg, "DH", len)) 116 else if (!strncmp(alg, "DH", len))
123 *pflags |= ENGINE_METHOD_DH; 117 *pflags |= ENGINE_METHOD_DH;
124 else if (strncmp(alg, "EC", len) == 0) 118 else if (strncmp(alg, "EC", len) == 0)
@@ -168,9 +162,6 @@ ENGINE_register_complete(ENGINE *e)
168#ifndef OPENSSL_NO_DH 162#ifndef OPENSSL_NO_DH
169 ENGINE_register_DH(e); 163 ENGINE_register_DH(e);
170#endif 164#endif
171#ifndef OPENSSL_NO_ECDH
172 ENGINE_register_ECDH(e);
173#endif
174#ifndef OPENSSL_NO_EC 165#ifndef OPENSSL_NO_EC
175 ENGINE_register_EC(e); 166 ENGINE_register_EC(e);
176#endif 167#endif
diff --git a/src/lib/libcrypto/engine/eng_int.h b/src/lib/libcrypto/engine/eng_int.h
index ad504a5a2b..2b0ba22aaf 100644
--- a/src/lib/libcrypto/engine/eng_int.h
+++ b/src/lib/libcrypto/engine/eng_int.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: eng_int.h,v 1.11 2023/07/28 09:08:31 tb Exp $ */ 1/* $OpenBSD: eng_int.h,v 1.12 2023/07/28 09:22:26 tb Exp $ */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL 2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -157,7 +157,6 @@ struct engine_st {
157 const RSA_METHOD *rsa_meth; 157 const RSA_METHOD *rsa_meth;
158 const DSA_METHOD *dsa_meth; 158 const DSA_METHOD *dsa_meth;
159 const DH_METHOD *dh_meth; 159 const DH_METHOD *dh_meth;
160 const ECDH_METHOD *ecdh_meth;
161 const EC_KEY_METHOD *ec_meth; 160 const EC_KEY_METHOD *ec_meth;
162 const RAND_METHOD *rand_meth; 161 const RAND_METHOD *rand_meth;
163 const STORE_METHOD *store_meth; 162 const STORE_METHOD *store_meth;
diff --git a/src/lib/libcrypto/engine/eng_list.c b/src/lib/libcrypto/engine/eng_list.c
index e460e71136..eaa0d228f9 100644
--- a/src/lib/libcrypto/engine/eng_list.c
+++ b/src/lib/libcrypto/engine/eng_list.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: eng_list.c,v 1.26 2023/07/28 09:08:31 tb Exp $ */ 1/* $OpenBSD: eng_list.c,v 1.27 2023/07/28 09:22:26 tb Exp $ */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL 2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -310,9 +310,6 @@ engine_cpy(ENGINE *dest, const ENGINE *src)
310#ifndef OPENSSL_NO_DH 310#ifndef OPENSSL_NO_DH
311 dest->dh_meth = src->dh_meth; 311 dest->dh_meth = src->dh_meth;
312#endif 312#endif
313#ifndef OPENSSL_NO_ECDH
314 dest->ecdh_meth = src->ecdh_meth;
315#endif
316#ifndef OPENSSL_NO_EC 313#ifndef OPENSSL_NO_EC
317 dest->ec_meth = src->ec_meth; 314 dest->ec_meth = src->ec_meth;
318#endif 315#endif
diff --git a/src/lib/libcrypto/engine/eng_openssl.c b/src/lib/libcrypto/engine/eng_openssl.c
index 7abb6114bc..6162b715f0 100644
--- a/src/lib/libcrypto/engine/eng_openssl.c
+++ b/src/lib/libcrypto/engine/eng_openssl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: eng_openssl.c,v 1.18 2023/07/28 09:08:31 tb Exp $ */ 1/* $OpenBSD: eng_openssl.c,v 1.19 2023/07/28 09:22:26 tb Exp $ */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL 2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -146,9 +146,6 @@ bind_helper(ENGINE *e)
146#ifndef OPENSSL_NO_DSA 146#ifndef OPENSSL_NO_DSA
147 || !ENGINE_set_DSA(e, DSA_get_default_method()) 147 || !ENGINE_set_DSA(e, DSA_get_default_method())
148#endif 148#endif
149#ifndef OPENSSL_NO_ECDH
150 || !ENGINE_set_ECDH(e, ECDH_OpenSSL())
151#endif
152#ifndef OPENSSL_NO_DH 149#ifndef OPENSSL_NO_DH
153 || !ENGINE_set_DH(e, DH_get_default_method()) 150 || !ENGINE_set_DH(e, DH_get_default_method())
154#endif 151#endif
diff --git a/src/lib/libcrypto/engine/engine.h b/src/lib/libcrypto/engine/engine.h
index dbc3718dca..ef5878a5d3 100644
--- a/src/lib/libcrypto/engine/engine.h
+++ b/src/lib/libcrypto/engine/engine.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: engine.h,v 1.40 2023/07/28 09:08:31 tb Exp $ */ 1/* $OpenBSD: engine.h,v 1.41 2023/07/28 09:22:26 tb Exp $ */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL 2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -76,9 +76,6 @@
76#ifndef OPENSSL_NO_EC 76#ifndef OPENSSL_NO_EC
77#include <openssl/ec.h> 77#include <openssl/ec.h>
78#endif 78#endif
79#ifndef OPENSSL_NO_ECDH
80#include <openssl/ecdh.h>
81#endif
82#include <openssl/err.h> 79#include <openssl/err.h>
83#ifndef OPENSSL_NO_RSA 80#ifndef OPENSSL_NO_RSA
84#include <openssl/rsa.h> 81#include <openssl/rsa.h>
@@ -98,7 +95,6 @@ extern "C" {
98#define ENGINE_METHOD_DSA (unsigned int)0x0002 95#define ENGINE_METHOD_DSA (unsigned int)0x0002
99#define ENGINE_METHOD_DH (unsigned int)0x0004 96#define ENGINE_METHOD_DH (unsigned int)0x0004
100#define ENGINE_METHOD_RAND (unsigned int)0x0008 97#define ENGINE_METHOD_RAND (unsigned int)0x0008
101#define ENGINE_METHOD_ECDH (unsigned int)0x0010
102#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 98#define ENGINE_METHOD_CIPHERS (unsigned int)0x0040
103#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 99#define ENGINE_METHOD_DIGESTS (unsigned int)0x0080
104#define ENGINE_METHOD_STORE (unsigned int)0x0100 100#define ENGINE_METHOD_STORE (unsigned int)0x0100
@@ -375,10 +371,6 @@ int ENGINE_register_DSA(ENGINE *e);
375void ENGINE_unregister_DSA(ENGINE *e); 371void ENGINE_unregister_DSA(ENGINE *e);
376void ENGINE_register_all_DSA(void); 372void ENGINE_register_all_DSA(void);
377 373
378int ENGINE_register_ECDH(ENGINE *e);
379void ENGINE_unregister_ECDH(ENGINE *e);
380void ENGINE_register_all_ECDH(void);
381
382int ENGINE_register_EC(ENGINE *e); 374int ENGINE_register_EC(ENGINE *e);
383void ENGINE_unregister_EC(ENGINE *e); 375void ENGINE_unregister_EC(ENGINE *e);
384void ENGINE_register_all_EC(void); 376void ENGINE_register_all_EC(void);
@@ -475,7 +467,6 @@ int ENGINE_set_id(ENGINE *e, const char *id);
475int ENGINE_set_name(ENGINE *e, const char *name); 467int ENGINE_set_name(ENGINE *e, const char *name);
476int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); 468int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
477int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); 469int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);
478int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth);
479int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ec_meth); 470int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ec_meth);
480int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); 471int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);
481int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); 472int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
@@ -514,7 +505,6 @@ const char *ENGINE_get_id(const ENGINE *e);
514const char *ENGINE_get_name(const ENGINE *e); 505const char *ENGINE_get_name(const ENGINE *e);
515const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); 506const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);
516const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); 507const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);
517const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e);
518const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e); 508const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e);
519const DH_METHOD *ENGINE_get_DH(const ENGINE *e); 509const DH_METHOD *ENGINE_get_DH(const ENGINE *e);
520const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); 510const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);
@@ -581,7 +571,6 @@ int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,
581ENGINE *ENGINE_get_default_RSA(void); 571ENGINE *ENGINE_get_default_RSA(void);
582/* Same for the other "methods" */ 572/* Same for the other "methods" */
583ENGINE *ENGINE_get_default_DSA(void); 573ENGINE *ENGINE_get_default_DSA(void);
584ENGINE *ENGINE_get_default_ECDH(void);
585ENGINE *ENGINE_get_default_EC(void); 574ENGINE *ENGINE_get_default_EC(void);
586ENGINE *ENGINE_get_default_DH(void); 575ENGINE *ENGINE_get_default_DH(void);
587ENGINE *ENGINE_get_default_RAND(void); 576ENGINE *ENGINE_get_default_RAND(void);
@@ -600,7 +589,6 @@ int ENGINE_set_default_RSA(ENGINE *e);
600int ENGINE_set_default_string(ENGINE *e, const char *def_list); 589int ENGINE_set_default_string(ENGINE *e, const char *def_list);
601/* Same for the other "methods" */ 590/* Same for the other "methods" */
602int ENGINE_set_default_DSA(ENGINE *e); 591int ENGINE_set_default_DSA(ENGINE *e);
603int ENGINE_set_default_ECDH(ENGINE *e);
604int ENGINE_set_default_EC(ENGINE *e); 592int ENGINE_set_default_EC(ENGINE *e);
605int ENGINE_set_default_DH(ENGINE *e); 593int ENGINE_set_default_DH(ENGINE *e);
606int ENGINE_set_default_RAND(ENGINE *e); 594int ENGINE_set_default_RAND(ENGINE *e);
diff --git a/src/lib/libcrypto/engine/tb_ecdh.c b/src/lib/libcrypto/engine/tb_ecdh.c
deleted file mode 100644
index a67877addd..0000000000
--- a/src/lib/libcrypto/engine/tb_ecdh.c
+++ /dev/null
@@ -1,141 +0,0 @@
1/* $OpenBSD: tb_ecdh.c,v 1.4 2014/06/12 15:49:29 deraadt Exp $ */
2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 *
5 * The Elliptic Curve Public-Key Crypto Library (ECC Code) included
6 * herein is developed by SUN MICROSYSTEMS, INC., and is contributed
7 * to the OpenSSL project.
8 *
9 * The ECC Code is licensed pursuant to the OpenSSL open source
10 * license provided below.
11 *
12 * The ECDH engine software is originally written by Nils Gura and
13 * Douglas Stebila of Sun Microsystems Laboratories.
14 *
15 */
16/* ====================================================================
17 * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved.
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions
21 * are met:
22 *
23 * 1. Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 *
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in
28 * the documentation and/or other materials provided with the
29 * distribution.
30 *
31 * 3. All advertising materials mentioning features or use of this
32 * software must display the following acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
35 *
36 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
37 * endorse or promote products derived from this software without
38 * prior written permission. For written permission, please contact
39 * licensing@OpenSSL.org.
40 *
41 * 5. Products derived from this software may not be called "OpenSSL"
42 * nor may "OpenSSL" appear in their names without prior written
43 * permission of the OpenSSL Project.
44 *
45 * 6. Redistributions of any form whatsoever must retain the following
46 * acknowledgment:
47 * "This product includes software developed by the OpenSSL Project
48 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
51 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
53 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
54 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
56 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
57 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
59 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
60 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
61 * OF THE POSSIBILITY OF SUCH DAMAGE.
62 * ====================================================================
63 *
64 * This product includes cryptographic software written by Eric Young
65 * (eay@cryptsoft.com). This product includes software written by Tim
66 * Hudson (tjh@cryptsoft.com).
67 *
68 */
69
70#include "eng_int.h"
71
72/* If this symbol is defined then ENGINE_get_default_ECDH(), the function that is
73 * used by ECDH to hook in implementation code and cache defaults (etc), will
74 * display brief debugging summaries to stderr with the 'nid'. */
75/* #define ENGINE_ECDH_DEBUG */
76
77static ENGINE_TABLE *ecdh_table = NULL;
78static const int dummy_nid = 1;
79
80void
81ENGINE_unregister_ECDH(ENGINE *e)
82{
83 engine_table_unregister(&ecdh_table, e);
84}
85
86static void
87engine_unregister_all_ECDH(void)
88{
89 engine_table_cleanup(&ecdh_table);
90}
91
92int
93ENGINE_register_ECDH(ENGINE *e)
94{
95 if (e->ecdh_meth)
96 return engine_table_register(&ecdh_table,
97 engine_unregister_all_ECDH, e, &dummy_nid, 1, 0);
98 return 1;
99}
100
101void
102ENGINE_register_all_ECDH(void)
103{
104 ENGINE *e;
105
106 for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
107 ENGINE_register_ECDH(e);
108}
109
110int
111ENGINE_set_default_ECDH(ENGINE *e)
112{
113 if (e->ecdh_meth)
114 return engine_table_register(&ecdh_table,
115 engine_unregister_all_ECDH, e, &dummy_nid, 1, 1);
116 return 1;
117}
118
119/* Exposed API function to get a functional reference from the implementation
120 * table (ie. try to get a functional reference from the tabled structural
121 * references). */
122ENGINE *
123ENGINE_get_default_ECDH(void)
124{
125 return engine_table_select(&ecdh_table, dummy_nid);
126}
127
128/* Obtains an ECDH implementation from an ENGINE functional reference */
129const ECDH_METHOD *
130ENGINE_get_ECDH(const ENGINE *e)
131{
132 return e->ecdh_meth;
133}
134
135/* Sets an ECDH implementation in an ENGINE structure */
136int
137ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth)
138{
139 e->ecdh_meth = ecdh_meth;
140 return 1;
141}
diff --git a/src/lib/libcrypto/hidden/openssl/ecdh.h b/src/lib/libcrypto/hidden/openssl/ecdh.h
index db56f8a588..aff95893f0 100644
--- a/src/lib/libcrypto/hidden/openssl/ecdh.h
+++ b/src/lib/libcrypto/hidden/openssl/ecdh.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecdh.h,v 1.1 2023/07/08 06:04:33 beck Exp $ */ 1/* $OpenBSD: ecdh.h,v 1.2 2023/07/28 09:22:26 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2023 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -25,15 +25,7 @@
25#endif 25#endif
26#include "crypto_namespace.h" 26#include "crypto_namespace.h"
27 27
28LCRYPTO_USED(ECDH_OpenSSL);
29LCRYPTO_USED(ECDH_set_default_method);
30LCRYPTO_USED(ECDH_get_default_method);
31LCRYPTO_USED(ECDH_set_method);
32LCRYPTO_USED(ECDH_size); 28LCRYPTO_USED(ECDH_size);
33LCRYPTO_USED(ECDH_compute_key); 29LCRYPTO_USED(ECDH_compute_key);
34LCRYPTO_USED(ECDH_get_ex_new_index);
35LCRYPTO_USED(ECDH_set_ex_data);
36LCRYPTO_USED(ECDH_get_ex_data);
37LCRYPTO_USED(ERR_load_ECDH_strings);
38 30
39#endif /* _LIBCRYPTO_ECDH_H */ 31#endif /* _LIBCRYPTO_ECDH_H */
diff --git a/src/lib/libcrypto/ossl_typ.h b/src/lib/libcrypto/ossl_typ.h
index 8ff3779636..b58888de3b 100644
--- a/src/lib/libcrypto/ossl_typ.h
+++ b/src/lib/libcrypto/ossl_typ.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ossl_typ.h,v 1.26 2023/07/28 09:08:31 tb Exp $ */ 1/* $OpenBSD: ossl_typ.h,v 1.27 2023/07/28 09:22:26 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -124,8 +124,6 @@ typedef struct rsa_pss_params_st RSA_PSS_PARAMS;
124 124
125typedef struct rand_meth_st RAND_METHOD; 125typedef struct rand_meth_st RAND_METHOD;
126 126
127typedef struct ecdh_method ECDH_METHOD;
128
129typedef struct x509_st X509; 127typedef struct x509_st X509;
130typedef struct X509_algor_st X509_ALGOR; 128typedef struct X509_algor_st X509_ALGOR;
131typedef struct X509_crl_st X509_CRL; 129typedef struct X509_crl_st X509_CRL;