summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2024-03-27 01:26:30 +0000
committertb <>2024-03-27 01:26:30 +0000
commitefa9d2333ae33cbad7579ecb053433a2a93d1d5b (patch)
treecd55a6bfa91ef5f5520977f545fb7dc464a9183b /src/lib
parentd63e16568602c2845543acd93bc322272a7ab788 (diff)
downloadopenbsd-efa9d2333ae33cbad7579ecb053433a2a93d1d5b.tar.gz
openbsd-efa9d2333ae33cbad7579ecb053433a2a93d1d5b.tar.bz2
openbsd-efa9d2333ae33cbad7579ecb053433a2a93d1d5b.zip
Use dh for DH function arguments.
No need for a variety of r, d, ...
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/dh/dh_lib.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c
index 98cc6e77ba..86503bc4e0 100644
--- a/src/lib/libcrypto/dh/dh_lib.c
+++ b/src/lib/libcrypto/dh/dh_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_lib.c,v 1.44 2024/03/27 01:22:30 tb Exp $ */ 1/* $OpenBSD: dh_lib.c,v 1.45 2024/03/27 01:26:30 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -140,37 +140,35 @@ DH_new_method(ENGINE *engine)
140LCRYPTO_ALIAS(DH_new_method); 140LCRYPTO_ALIAS(DH_new_method);
141 141
142void 142void
143DH_free(DH *r) 143DH_free(DH *dh)
144{ 144{
145 int i; 145 if (dh == NULL)
146
147 if (r == NULL)
148 return; 146 return;
149 i = CRYPTO_add(&r->references, -1, CRYPTO_LOCK_DH); 147
150 if (i > 0) 148 if (CRYPTO_add(&dh->references, -1, CRYPTO_LOCK_DH) > 0)
151 return; 149 return;
152 150
153 if (r->meth != NULL && r->meth->finish != NULL) 151 if (dh->meth != NULL && dh->meth->finish != NULL)
154 r->meth->finish(r); 152 dh->meth->finish(dh);
155 153
156 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data); 154 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, dh, &dh->ex_data);
157 155
158 BN_free(r->p); 156 BN_free(dh->p);
159 BN_free(r->g); 157 BN_free(dh->g);
160 BN_free(r->q); 158 BN_free(dh->q);
161 BN_free(r->j); 159 BN_free(dh->j);
162 free(r->seed); 160 free(dh->seed);
163 BN_free(r->counter); 161 BN_free(dh->counter);
164 BN_free(r->pub_key); 162 BN_free(dh->pub_key);
165 BN_free(r->priv_key); 163 BN_free(dh->priv_key);
166 free(r); 164 free(dh);
167} 165}
168LCRYPTO_ALIAS(DH_free); 166LCRYPTO_ALIAS(DH_free);
169 167
170int 168int
171DH_up_ref(DH *r) 169DH_up_ref(DH *dh)
172{ 170{
173 return CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DH) > 1; 171 return CRYPTO_add(&dh->references, 1, CRYPTO_LOCK_DH) > 1;
174} 172}
175LCRYPTO_ALIAS(DH_up_ref); 173LCRYPTO_ALIAS(DH_up_ref);
176 174
@@ -184,16 +182,16 @@ DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
184LCRYPTO_ALIAS(DH_get_ex_new_index); 182LCRYPTO_ALIAS(DH_get_ex_new_index);
185 183
186int 184int
187DH_set_ex_data(DH *d, int idx, void *arg) 185DH_set_ex_data(DH *dh, int idx, void *arg)
188{ 186{
189 return CRYPTO_set_ex_data(&d->ex_data, idx, arg); 187 return CRYPTO_set_ex_data(&dh->ex_data, idx, arg);
190} 188}
191LCRYPTO_ALIAS(DH_set_ex_data); 189LCRYPTO_ALIAS(DH_set_ex_data);
192 190
193void * 191void *
194DH_get_ex_data(DH *d, int idx) 192DH_get_ex_data(DH *dh, int idx)
195{ 193{
196 return CRYPTO_get_ex_data(&d->ex_data, idx); 194 return CRYPTO_get_ex_data(&dh->ex_data, idx);
197} 195}
198LCRYPTO_ALIAS(DH_get_ex_data); 196LCRYPTO_ALIAS(DH_get_ex_data);
199 197