summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ecdsa
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/lib/libcrypto/ecdsa
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/lib/libcrypto/ecdsa')
-rw-r--r--src/lib/libcrypto/ecdsa/ecs_lib.c96
-rw-r--r--src/lib/libcrypto/ecdsa/ecs_local.h20
2 files changed, 2 insertions, 114 deletions
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,