summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-06-25 18:45:56 +0000
committertb <>2023-06-25 18:45:56 +0000
commit1f1e97550126828f07750399c2a4acd3af28df1b (patch)
tree827bc6c6e367e27b583030a88f63ac80be6f976b /src
parent5119a6bbd2e88876fc335ff3b50913e87b9d734f (diff)
downloadopenbsd-1f1e97550126828f07750399c2a4acd3af28df1b.tar.gz
openbsd-1f1e97550126828f07750399c2a4acd3af28df1b.tar.bz2
openbsd-1f1e97550126828f07750399c2a4acd3af28df1b.zip
Remove {ecdh,ecdsa}_check() and {ECDH,ECDSA}_DATA
This is now unused code. Removing it will free us up to remove some other ugliness in the ec directory. ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/ecdh/ech_lib.c97
-rw-r--r--src/lib/libcrypto/ecdh/ech_local.h14
-rw-r--r--src/lib/libcrypto/ecdsa/ecs_lib.c96
-rw-r--r--src/lib/libcrypto/ecdsa/ecs_local.h20
4 files changed, 4 insertions, 223 deletions
diff --git a/src/lib/libcrypto/ecdh/ech_lib.c b/src/lib/libcrypto/ecdh/ech_lib.c
index 6e12126034..f062ec3fdc 100644
--- a/src/lib/libcrypto/ecdh/ech_lib.c
+++ b/src/lib/libcrypto/ecdh/ech_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ech_lib.c,v 1.18 2023/06/25 18:27:38 tb Exp $ */ 1/* $OpenBSD: ech_lib.c,v 1.19 2023/06/25 18:45:56 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -81,10 +81,6 @@
81 81
82static const ECDH_METHOD *default_ECDH_method = NULL; 82static const ECDH_METHOD *default_ECDH_method = NULL;
83 83
84static void *ecdh_data_new(void);
85static void *ecdh_data_dup(void *);
86static void ecdh_data_free(void *);
87
88void 84void
89ECDH_set_default_method(const ECDH_METHOD *meth) 85ECDH_set_default_method(const ECDH_METHOD *meth)
90{ 86{
@@ -106,97 +102,6 @@ ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth)
106 return 0; 102 return 0;
107} 103}
108 104
109static ECDH_DATA *
110ECDH_DATA_new_method(ENGINE *engine)
111{
112 ECDH_DATA *ret;
113
114 ret = malloc(sizeof(ECDH_DATA));
115 if (ret == NULL) {
116 ECDHerror(ERR_R_MALLOC_FAILURE);
117 return (NULL);
118 }
119
120 ret->init = NULL;
121
122 ret->meth = ECDH_get_default_method();
123 ret->engine = engine;
124#ifndef OPENSSL_NO_ENGINE
125 if (!ret->engine)
126 ret->engine = ENGINE_get_default_ECDH();
127 if (ret->engine) {
128 ret->meth = ENGINE_get_ECDH(ret->engine);
129 if (ret->meth == NULL) {
130 ECDHerror(ERR_R_ENGINE_LIB);
131 ENGINE_finish(ret->engine);
132 free(ret);
133 return NULL;
134 }
135 }
136#endif
137
138 ret->flags = ret->meth->flags;
139 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDH, ret, &ret->ex_data);
140 return (ret);
141}
142
143static void *
144ecdh_data_new(void)
145{
146 return (void *)ECDH_DATA_new_method(NULL);
147}
148
149static void *
150ecdh_data_dup(void *data)
151{
152 ECDH_DATA *r = (ECDH_DATA *)data;
153
154 /* XXX: dummy operation */
155 if (r == NULL)
156 return NULL;
157
158 return (void *)ecdh_data_new();
159}
160
161void
162ecdh_data_free(void *data)
163{
164 ECDH_DATA *r = (ECDH_DATA *)data;
165
166#ifndef OPENSSL_NO_ENGINE
167 ENGINE_finish(r->engine);
168#endif
169
170 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDH, r, &r->ex_data);
171
172 freezero(r, sizeof(ECDH_DATA));
173}
174
175ECDH_DATA *
176ecdh_check(EC_KEY *key)
177{
178 ECDH_DATA *ecdh_data;
179
180 void *data = EC_KEY_get_key_method_data(key, ecdh_data_dup,
181 ecdh_data_free, ecdh_data_free);
182 if (data == NULL) {
183 ecdh_data = (ECDH_DATA *)ecdh_data_new();
184 if (ecdh_data == NULL)
185 return NULL;
186 data = EC_KEY_insert_key_method_data(key, (void *)ecdh_data,
187 ecdh_data_dup, ecdh_data_free, ecdh_data_free);
188 if (data != NULL) {
189 /* Another thread raced us to install the key_method
190 * data and won. */
191 ecdh_data_free(ecdh_data);
192 ecdh_data = (ECDH_DATA *)data;
193 }
194 } else
195 ecdh_data = (ECDH_DATA *)data;
196
197 return ecdh_data;
198}
199
200int 105int
201ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 106ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
202 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) 107 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
diff --git a/src/lib/libcrypto/ecdh/ech_local.h b/src/lib/libcrypto/ecdh/ech_local.h
index c8cb518249..fefa817b1c 100644
--- a/src/lib/libcrypto/ecdh/ech_local.h
+++ b/src/lib/libcrypto/ecdh/ech_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ech_local.h,v 1.3 2023/06/25 08:12:23 tb Exp $ */ 1/* $OpenBSD: ech_local.h,v 1.4 2023/06/25 18:45:56 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -68,18 +68,6 @@ struct ecdh_method {
68 char *app_data; 68 char *app_data;
69}; 69};
70 70
71typedef struct ecdh_data_st {
72 /* EC_KEY_METH_DATA part */
73 int (*init)(EC_KEY *);
74 /* method specific part */
75 ENGINE *engine;
76 int flags;
77 const ECDH_METHOD *meth;
78 CRYPTO_EX_DATA ex_data;
79} ECDH_DATA;
80
81ECDH_DATA *ecdh_check(EC_KEY *);
82
83/* 71/*
84 * ECDH Key Derivation Function as defined in ANSI X9.63. 72 * ECDH Key Derivation Function as defined in ANSI X9.63.
85 */ 73 */
diff --git a/src/lib/libcrypto/ecdsa/ecs_lib.c b/src/lib/libcrypto/ecdsa/ecs_lib.c
index 9ba5db2fca..11e707dd55 100644
--- a/src/lib/libcrypto/ecdsa/ecs_lib.c
+++ b/src/lib/libcrypto/ecdsa/ecs_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecs_lib.c,v 1.19 2023/06/25 18:27:38 tb Exp $ */ 1/* $OpenBSD: ecs_lib.c,v 1.20 2023/06/25 18:45:56 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -68,10 +68,6 @@
68 68
69static const ECDSA_METHOD *default_ECDSA_method = NULL; 69static const ECDSA_METHOD *default_ECDSA_method = NULL;
70 70
71static void *ecdsa_data_new(void);
72static void *ecdsa_data_dup(void *);
73static void ecdsa_data_free(void *);
74
75void 71void
76ECDSA_set_default_method(const ECDSA_METHOD *meth) 72ECDSA_set_default_method(const ECDSA_METHOD *meth)
77{ 73{
@@ -93,96 +89,6 @@ ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth)
93 return 0; 89 return 0;
94} 90}
95 91
96static ECDSA_DATA *
97ECDSA_DATA_new_method(ENGINE *engine)
98{
99 ECDSA_DATA *ret;
100
101 ret = malloc(sizeof(ECDSA_DATA));
102 if (ret == NULL) {
103 ECDSAerror(ERR_R_MALLOC_FAILURE);
104 return (NULL);
105 }
106
107 ret->init = NULL;
108
109 ret->meth = ECDSA_get_default_method();
110 ret->engine = engine;
111#ifndef OPENSSL_NO_ENGINE
112 if (!ret->engine)
113 ret->engine = ENGINE_get_default_ECDSA();
114 if (ret->engine) {
115 ret->meth = ENGINE_get_ECDSA(ret->engine);
116 if (ret->meth == NULL) {
117 ECDSAerror(ERR_R_ENGINE_LIB);
118 ENGINE_finish(ret->engine);
119 free(ret);
120 return NULL;
121 }
122 }
123#endif
124
125 ret->flags = ret->meth->flags;
126 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDSA, ret, &ret->ex_data);
127 return (ret);
128}
129
130static void *
131ecdsa_data_new(void)
132{
133 return (void *)ECDSA_DATA_new_method(NULL);
134}
135
136static void *
137ecdsa_data_dup(void *data)
138{
139 ECDSA_DATA *r = (ECDSA_DATA *)data;
140
141 /* XXX: dummy operation */
142 if (r == NULL)
143 return NULL;
144
145 return ecdsa_data_new();
146}
147
148static void
149ecdsa_data_free(void *data)
150{
151 ECDSA_DATA *r = (ECDSA_DATA *)data;
152
153#ifndef OPENSSL_NO_ENGINE
154 ENGINE_finish(r->engine);
155#endif
156 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDSA, r, &r->ex_data);
157
158 freezero(r, sizeof(ECDSA_DATA));
159}
160
161ECDSA_DATA *
162ecdsa_check(EC_KEY *key)
163{
164 ECDSA_DATA *ecdsa_data;
165
166 void *data = EC_KEY_get_key_method_data(key, ecdsa_data_dup,
167 ecdsa_data_free, ecdsa_data_free);
168 if (data == NULL) {
169 ecdsa_data = (ECDSA_DATA *)ecdsa_data_new();
170 if (ecdsa_data == NULL)
171 return NULL;
172 data = EC_KEY_insert_key_method_data(key, (void *)ecdsa_data,
173 ecdsa_data_dup, ecdsa_data_free, ecdsa_data_free);
174 if (data != NULL) {
175 /* Another thread raced us to install the key_method
176 * data and won. */
177 ecdsa_data_free(ecdsa_data);
178 ecdsa_data = (ECDSA_DATA *)data;
179 }
180 } else
181 ecdsa_data = (ECDSA_DATA *)data;
182
183 return ecdsa_data;
184}
185
186int 92int
187ECDSA_size(const EC_KEY *r) 93ECDSA_size(const EC_KEY *r)
188{ 94{
diff --git a/src/lib/libcrypto/ecdsa/ecs_local.h b/src/lib/libcrypto/ecdsa/ecs_local.h
index 5cdf264557..20ad0c246e 100644
--- a/src/lib/libcrypto/ecdsa/ecs_local.h
+++ b/src/lib/libcrypto/ecdsa/ecs_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecs_local.h,v 1.2 2022/11/26 17:23:17 tb Exp $ */ 1/* $OpenBSD: ecs_local.h,v 1.3 2023/06/25 18:45:56 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project 3 * Written by Nils Larsch for the OpenSSL project
4 */ 4 */
@@ -63,29 +63,11 @@
63 63
64__BEGIN_HIDDEN_DECLS 64__BEGIN_HIDDEN_DECLS
65 65
66typedef struct ecdsa_data_st {
67 /* EC_KEY_METH_DATA part */
68 int (*init)(EC_KEY *);
69 /* method (ECDSA) specific part */
70 ENGINE *engine;
71 int flags;
72 const ECDSA_METHOD *meth;
73 CRYPTO_EX_DATA ex_data;
74} ECDSA_DATA;
75
76struct ECDSA_SIG_st { 66struct ECDSA_SIG_st {
77 BIGNUM *r; 67 BIGNUM *r;
78 BIGNUM *s; 68 BIGNUM *s;
79}; 69};
80 70
81/** ecdsa_check
82 * checks whether ECKEY->meth_data is a pointer to a ECDSA_DATA structure
83 * and if not it removes the old meth_data and creates a ECDSA_DATA structure.
84 * \param eckey pointer to a EC_KEY object
85 * \return pointer to a ECDSA_DATA structure
86 */
87ECDSA_DATA *ecdsa_check(EC_KEY *eckey);
88
89int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, 71int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,
90 BIGNUM **rp); 72 BIGNUM **rp);
91int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen, 73int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen,