summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2026-03-18 08:02:40 +0000
committertb <>2026-03-18 08:02:40 +0000
commite1991105df8fe12032795b7f34ed61fd9272e525 (patch)
tree2c5c9a04e08f3ba3f5c6e0bec7c4f26c2bab6e8e /src/lib
parentec0894d4cccd2b2d88759796071c3ed1afd3a475 (diff)
downloadopenbsd-e1991105df8fe12032795b7f34ed61fd9272e525.tar.gz
openbsd-e1991105df8fe12032795b7f34ed61fd9272e525.tar.bz2
openbsd-e1991105df8fe12032795b7f34ed61fd9272e525.zip
libcrypto: prefix EC_KEY methods with ec_key_
We received reports that the too generic internal ecdsa_{sign,verify}() symbol names clash in some static links. The naming here is annoying because the EC_KEY_METHOD amalgamated the no longer existing ECDH and ECDSA methods which themselves had poorly chosen method names, still reflected in public API. There are various messes here. The ECDSA verify methods are declared in ec_local.h, whereas the ECDSA sign methods are in ecdsa_local.h (which is itself pretty useless and really only about EC_KEY_METHOD). I therefore merged the ECDSA method declarations into ec_local.h and deleted ecdsa_local.h since I see no real benefit to the latter. ecdsa.c needs ec_local.h anyway. Having the method declarations next to EC_KEY_METHOD seems sensible. I left the order as it was, matching ecdsa.c. The eckey_compute_pubkey() prototype should probably be moved down. With one exception I just added an ec_key_ prefix. This leads to a a repetition of 'key' in ec_key_ecdh_compute_key() which I chose to live with because it matches the public ECDH_compute_key() (mostly used by SSH implementations). The exception is ec_key_generate_key() where I expanded the gen() leading to another _key repetition but this then matches EC_KEY_generate_key(). Thanks to Rosen Penev for reporting and sending an initial diff. See also https://github.com/gsliepen/tinc/issues/478 ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/ec/ec_key.c19
-rw-r--r--src/lib/libcrypto/ec/ec_local.h16
-rw-r--r--src/lib/libcrypto/ecdh/ecdh.c6
-rw-r--r--src/lib/libcrypto/ecdsa/ecdsa.c14
-rw-r--r--src/lib/libcrypto/ecdsa/ecdsa_local.h76
5 files changed, 31 insertions, 100 deletions
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c
index e9777019c8..a32533ec73 100644
--- a/src/lib/libcrypto/ec/ec_key.c
+++ b/src/lib/libcrypto/ec/ec_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_key.c,v 1.52 2025/05/10 05:54:38 tb Exp $ */ 1/* $OpenBSD: ec_key.c,v 1.53 2026/03/18 08:02:40 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -69,7 +69,6 @@
69 69
70#include "bn_local.h" 70#include "bn_local.h"
71#include "ec_local.h" 71#include "ec_local.h"
72#include "ecdsa_local.h"
73#include "err_local.h" 72#include "err_local.h"
74 73
75EC_KEY * 74EC_KEY *
@@ -236,7 +235,7 @@ EC_KEY_generate_key(EC_KEY *eckey)
236LCRYPTO_ALIAS(EC_KEY_generate_key); 235LCRYPTO_ALIAS(EC_KEY_generate_key);
237 236
238static int 237static int
239ec_key_gen(EC_KEY *eckey) 238ec_key_generate_key(EC_KEY *eckey)
240{ 239{
241 BIGNUM *priv_key = NULL; 240 BIGNUM *priv_key = NULL;
242 EC_POINT *pub_key = NULL; 241 EC_POINT *pub_key = NULL;
@@ -771,15 +770,15 @@ static const EC_KEY_METHOD openssl_ec_key_method = {
771 .set_private = NULL, 770 .set_private = NULL,
772 .set_public = NULL, 771 .set_public = NULL,
773 772
774 .keygen = ec_key_gen, 773 .keygen = ec_key_generate_key,
775 .compute_key = ecdh_compute_key, 774 .compute_key = ec_key_ecdh_compute_key,
776 775
777 .sign = ecdsa_sign, 776 .sign = ec_key_ecdsa_sign,
778 .sign_setup = ecdsa_sign_setup, 777 .sign_setup = ec_key_ecdsa_sign_setup,
779 .sign_sig = ecdsa_sign_sig, 778 .sign_sig = ec_key_ecdsa_sign_sig,
780 779
781 .verify = ecdsa_verify, 780 .verify = ec_key_ecdsa_verify,
782 .verify_sig = ecdsa_verify_sig, 781 .verify_sig = ec_key_ecdsa_verify_sig,
783}; 782};
784 783
785const EC_KEY_METHOD * 784const EC_KEY_METHOD *
diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h
index d84e92767c..cb7612b39f 100644
--- a/src/lib/libcrypto/ec/ec_local.h
+++ b/src/lib/libcrypto/ec/ec_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_local.h,v 1.73 2025/12/26 18:42:33 tb Exp $ */ 1/* $OpenBSD: ec_local.h,v 1.74 2026/03/18 08:02:40 tb Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller for the OpenSSL project. 3 * Originally written by Bodo Moeller for the OpenSSL project.
4 */ 4 */
@@ -256,11 +256,19 @@ struct ec_key_st {
256} /* EC_KEY */; 256} /* EC_KEY */;
257 257
258int eckey_compute_pubkey(EC_KEY *eckey); 258int eckey_compute_pubkey(EC_KEY *eckey);
259int ecdh_compute_key(unsigned char **out, size_t *out_len, 259
260int ec_key_ecdh_compute_key(unsigned char **out, size_t *out_len,
260 const EC_POINT *pub_key, const EC_KEY *ecdh); 261 const EC_POINT *pub_key, const EC_KEY *ecdh);
261int ecdsa_verify(int type, const unsigned char *dgst, int dgst_len, 262int ec_key_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *in_ctx, BIGNUM **out_kinv,
263 BIGNUM **out_r);
264int ec_key_ecdsa_sign(int type, const unsigned char *digest, int digest_len,
265 unsigned char *signature, unsigned int *signature_len, const BIGNUM *kinv,
266 const BIGNUM *r, EC_KEY *eckey);
267ECDSA_SIG *ec_key_ecdsa_sign_sig(const unsigned char *digest, int digest_len,
268 const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *eckey);
269int ec_key_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len,
262 const unsigned char *sigbuf, int sig_len, EC_KEY *eckey); 270 const unsigned char *sigbuf, int sig_len, EC_KEY *eckey);
263int ecdsa_verify_sig(const unsigned char *dgst, int dgst_len, 271int ec_key_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len,
264 const ECDSA_SIG *sig, EC_KEY *eckey); 272 const ECDSA_SIG *sig, EC_KEY *eckey);
265 273
266/* 274/*
diff --git a/src/lib/libcrypto/ecdh/ecdh.c b/src/lib/libcrypto/ecdh/ecdh.c
index c3affed682..f970db7750 100644
--- a/src/lib/libcrypto/ecdh/ecdh.c
+++ b/src/lib/libcrypto/ecdh/ecdh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecdh.c,v 1.12 2025/05/10 05:54:38 tb Exp $ */ 1/* $OpenBSD: ecdh.c,v 1.13 2026/03/18 08:02:40 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -143,8 +143,8 @@ ecdh_KDF_X9_63(unsigned char *out, size_t outlen, const unsigned char *Z,
143 * Based on the ECKAS-DH1 and ECSVDP-DH primitives in the IEEE 1363 standard. 143 * Based on the ECKAS-DH1 and ECSVDP-DH primitives in the IEEE 1363 standard.
144 */ 144 */
145int 145int
146ecdh_compute_key(unsigned char **out, size_t *out_len, const EC_POINT *pub_key, 146ec_key_ecdh_compute_key(unsigned char **out, size_t *out_len,
147 const EC_KEY *ecdh) 147 const EC_POINT *pub_key, const EC_KEY *ecdh)
148{ 148{
149 BN_CTX *ctx; 149 BN_CTX *ctx;
150 BIGNUM *x; 150 BIGNUM *x;
diff --git a/src/lib/libcrypto/ecdsa/ecdsa.c b/src/lib/libcrypto/ecdsa/ecdsa.c
index 1be139a695..735b165568 100644
--- a/src/lib/libcrypto/ecdsa/ecdsa.c
+++ b/src/lib/libcrypto/ecdsa/ecdsa.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecdsa.c,v 1.21 2026/03/16 22:19:32 tb Exp $ */ 1/* $OpenBSD: ecdsa.c,v 1.22 2026/03/18 08:02:40 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -64,7 +64,6 @@
64 64
65#include "bn_local.h" 65#include "bn_local.h"
66#include "ec_local.h" 66#include "ec_local.h"
67#include "ecdsa_local.h"
68#include "err_local.h" 67#include "err_local.h"
69 68
70struct ECDSA_SIG_st { 69struct ECDSA_SIG_st {
@@ -222,7 +221,7 @@ ecdsa_prepare_digest(const unsigned char *digest, int digest_len,
222} 221}
223 222
224int 223int
225ecdsa_sign(int type, const unsigned char *digest, int digest_len, 224ec_key_ecdsa_sign(int type, const unsigned char *digest, int digest_len,
226 unsigned char *signature, unsigned int *signature_len, const BIGNUM *kinv, 225 unsigned char *signature, unsigned int *signature_len, const BIGNUM *kinv,
227 const BIGNUM *r, EC_KEY *key) 226 const BIGNUM *r, EC_KEY *key)
228{ 227{
@@ -271,7 +270,8 @@ LCRYPTO_ALIAS(ECDSA_sign);
271 */ 270 */
272 271
273int 272int
274ecdsa_sign_setup(EC_KEY *key, BN_CTX *in_ctx, BIGNUM **out_kinv, BIGNUM **out_r) 273ec_key_ecdsa_sign_setup(EC_KEY *key, BN_CTX *in_ctx, BIGNUM **out_kinv,
274 BIGNUM **out_r)
275{ 275{
276 const EC_GROUP *group; 276 const EC_GROUP *group;
277 EC_POINT *point = NULL; 277 EC_POINT *point = NULL;
@@ -522,7 +522,7 @@ ecdsa_compute_s(BIGNUM **out_s, const BIGNUM *e, const BIGNUM *kinv,
522 */ 522 */
523 523
524ECDSA_SIG * 524ECDSA_SIG *
525ecdsa_sign_sig(const unsigned char *digest, int digest_len, 525ec_key_ecdsa_sign_sig(const unsigned char *digest, int digest_len,
526 const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *key) 526 const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *key)
527{ 527{
528 BN_CTX *ctx = NULL; 528 BN_CTX *ctx = NULL;
@@ -605,7 +605,7 @@ ECDSA_do_sign(const unsigned char *digest, int digest_len, EC_KEY *key)
605LCRYPTO_ALIAS(ECDSA_do_sign); 605LCRYPTO_ALIAS(ECDSA_do_sign);
606 606
607int 607int
608ecdsa_verify(int type, const unsigned char *digest, int digest_len, 608ec_key_ecdsa_verify(int type, const unsigned char *digest, int digest_len,
609 const unsigned char *sigbuf, int sig_len, EC_KEY *key) 609 const unsigned char *sigbuf, int sig_len, EC_KEY *key)
610{ 610{
611 ECDSA_SIG *s; 611 ECDSA_SIG *s;
@@ -654,7 +654,7 @@ LCRYPTO_ALIAS(ECDSA_verify);
654 */ 654 */
655 655
656int 656int
657ecdsa_verify_sig(const unsigned char *digest, int digest_len, 657ec_key_ecdsa_verify_sig(const unsigned char *digest, int digest_len,
658 const ECDSA_SIG *sig, EC_KEY *key) 658 const ECDSA_SIG *sig, EC_KEY *key)
659{ 659{
660 const EC_GROUP *group; 660 const EC_GROUP *group;
diff --git a/src/lib/libcrypto/ecdsa/ecdsa_local.h b/src/lib/libcrypto/ecdsa/ecdsa_local.h
deleted file mode 100644
index f254d39323..0000000000
--- a/src/lib/libcrypto/ecdsa/ecdsa_local.h
+++ /dev/null
@@ -1,76 +0,0 @@
1/* $OpenBSD: ecdsa_local.h,v 1.3 2026/03/16 22:19:32 tb Exp $ */
2/*
3 * Written by Nils Larsch for the OpenSSL project
4 */
5/* ====================================================================
6 * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#ifndef HEADER_ECS_LOCAL_H
60#define HEADER_ECS_LOCAL_H
61
62#include <openssl/ec.h>
63
64__BEGIN_HIDDEN_DECLS
65
66int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *in_ctx, BIGNUM **out_kinv,
67 BIGNUM **out_r);
68int ecdsa_sign(int type, const unsigned char *digest, int digest_len,
69 unsigned char *signature, unsigned int *signature_len, const BIGNUM *kinv,
70 const BIGNUM *r, EC_KEY *eckey);
71ECDSA_SIG *ecdsa_sign_sig(const unsigned char *digest, int digest_len,
72 const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *eckey);
73
74__END_HIDDEN_DECLS
75
76#endif /* !HEADER_ECS_LOCAL_H */