summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_key.c
diff options
context:
space:
mode:
authortb <>2023-06-25 18:52:27 +0000
committertb <>2023-06-25 18:52:27 +0000
commit70d8987d04d28fe256835167778ab28f3e6bdd3c (patch)
tree0df2834b9d3887c87ec022222f74c206da81e21c /src/lib/libcrypto/ec/ec_key.c
parent1f1e97550126828f07750399c2a4acd3af28df1b (diff)
downloadopenbsd-70d8987d04d28fe256835167778ab28f3e6bdd3c.tar.gz
openbsd-70d8987d04d28fe256835167778ab28f3e6bdd3c.tar.bz2
openbsd-70d8987d04d28fe256835167778ab28f3e6bdd3c.zip
Remove EC_EXTRA_DATA
With the ecdh_check() and ecdsa_check() abominations gone, we can finally get rid of EC_EXTRA_DATA and EC_KEY_{get,insert}_key_method_data(). The EC_EX_DATA_*() handlers, (which fortunately have always had "'package' level visibility") join the ride to the great bit bucket in the sky. Thanks to op for making this possible. ok jsing
Diffstat (limited to 'src/lib/libcrypto/ec/ec_key.c')
-rw-r--r--src/lib/libcrypto/ec/ec_key.c50
1 files changed, 1 insertions, 49 deletions
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c
index 2f9f05cc56..4127352523 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.32 2023/03/27 10:25:02 tb Exp $ */ 1/* $OpenBSD: ec_key.c,v 1.33 2023/06/25 18:52:27 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -122,16 +122,12 @@ EC_KEY_free(EC_KEY *r)
122 EC_POINT_free(r->pub_key); 122 EC_POINT_free(r->pub_key);
123 BN_free(r->priv_key); 123 BN_free(r->priv_key);
124 124
125 EC_EX_DATA_free_all_data(&r->method_data);
126
127 freezero(r, sizeof(EC_KEY)); 125 freezero(r, sizeof(EC_KEY));
128} 126}
129 127
130EC_KEY * 128EC_KEY *
131EC_KEY_copy(EC_KEY *dest, const EC_KEY *src) 129EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
132{ 130{
133 EC_EXTRA_DATA *d;
134
135 if (dest == NULL || src == NULL) { 131 if (dest == NULL || src == NULL) {
136 ECerror(ERR_R_PASSED_NULL_PARAMETER); 132 ECerror(ERR_R_PASSED_NULL_PARAMETER);
137 return NULL; 133 return NULL;
@@ -175,18 +171,6 @@ EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
175 if (!bn_copy(dest->priv_key, src->priv_key)) 171 if (!bn_copy(dest->priv_key, src->priv_key))
176 return NULL; 172 return NULL;
177 } 173 }
178 /* copy method/extra data */
179 EC_EX_DATA_free_all_data(&dest->method_data);
180
181 for (d = src->method_data; d != NULL; d = d->next) {
182 void *t = d->dup_func(d->data);
183
184 if (t == NULL)
185 return 0;
186 if (!EC_EX_DATA_set_data(&dest->method_data, t, d->dup_func,
187 d->free_func, d->clear_free_func))
188 return 0;
189 }
190 174
191 /* copy the rest */ 175 /* copy the rest */
192 dest->enc_flag = src->enc_flag; 176 dest->enc_flag = src->enc_flag;
@@ -526,38 +510,6 @@ EC_KEY_set_conv_form(EC_KEY *key, point_conversion_form_t cform)
526 EC_GROUP_set_point_conversion_form(key->group, cform); 510 EC_GROUP_set_point_conversion_form(key->group, cform);
527} 511}
528 512
529void *
530EC_KEY_get_key_method_data(EC_KEY *key,
531 void *(*dup_func) (void *),
532 void (*free_func) (void *),
533 void (*clear_free_func) (void *))
534{
535 void *ret;
536
537 CRYPTO_r_lock(CRYPTO_LOCK_EC);
538 ret = EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func);
539 CRYPTO_r_unlock(CRYPTO_LOCK_EC);
540
541 return ret;
542}
543
544void *
545EC_KEY_insert_key_method_data(EC_KEY *key, void *data,
546 void *(*dup_func) (void *),
547 void (*free_func) (void *),
548 void (*clear_free_func) (void *))
549{
550 EC_EXTRA_DATA *ex_data;
551
552 CRYPTO_w_lock(CRYPTO_LOCK_EC);
553 ex_data = EC_EX_DATA_get_data(key->method_data, dup_func, free_func, clear_free_func);
554 if (ex_data == NULL)
555 EC_EX_DATA_set_data(&key->method_data, data, dup_func, free_func, clear_free_func);
556 CRYPTO_w_unlock(CRYPTO_LOCK_EC);
557
558 return ex_data;
559}
560
561void 513void
562EC_KEY_set_asn1_flag(EC_KEY *key, int flag) 514EC_KEY_set_asn1_flag(EC_KEY *key, int flag)
563{ 515{