summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2023-12-28 22:11:26 +0000
committertb <>2023-12-28 22:11:26 +0000
commit93ff5806b4e95e427cc6b51725af8512138ee762 (patch)
treed6f28d7845a4cfc9a2cf3126b71cd4b7b4804fb8
parentd038647e3a4f1ef5e7535103a39d0cdc628ed9e0 (diff)
downloadopenbsd-93ff5806b4e95e427cc6b51725af8512138ee762.tar.gz
openbsd-93ff5806b4e95e427cc6b51725af8512138ee762.tar.bz2
openbsd-93ff5806b4e95e427cc6b51725af8512138ee762.zip
Rework pkey_das_paramgen()
Another copy-paste-then-tweak-and-diverge version of the same old thing. Fix it the same way as pkey_rsa_paramgen() and pkey_dh_paramgen(). The callbacks are initialized at the top and the weird error checking is turned into something much simpler. ok jsing
-rw-r--r--src/lib/libcrypto/dsa/dsa_pmeth.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_pmeth.c b/src/lib/libcrypto/dsa/dsa_pmeth.c
index dff47ed348..001bdec201 100644
--- a/src/lib/libcrypto/dsa/dsa_pmeth.c
+++ b/src/lib/libcrypto/dsa/dsa_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_pmeth.c,v 1.18 2023/12/28 22:07:23 tb Exp $ */ 1/* $OpenBSD: dsa_pmeth.c,v 1.19 2023/12/28 22:11:26 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -288,25 +288,30 @@ out_of_range:
288static int 288static int
289pkey_dsa_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) 289pkey_dsa_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
290{ 290{
291 DSA *dsa = NULL; 291 DSA *dsa;
292 DSA_PKEY_CTX *dctx = ctx->data; 292 DSA_PKEY_CTX *dctx = ctx->data;
293 BN_GENCB *pcb, cb; 293 BN_GENCB *pcb = NULL;
294 int ret; 294 BN_GENCB cb = {0};
295 int ret = 0;
295 296
296 if (ctx->pkey_gencb) { 297 if ((dsa = DSA_new()) == NULL)
298 goto err;
299 if (ctx->pkey_gencb != NULL) {
297 pcb = &cb; 300 pcb = &cb;
298 evp_pkey_set_cb_translate(pcb, ctx); 301 evp_pkey_set_cb_translate(pcb, ctx);
299 } else 302 }
300 pcb = NULL; 303 if (!dsa_builtin_paramgen(dsa, dctx->nbits, dctx->qbits, dctx->pmd,
301 dsa = DSA_new(); 304 NULL, 0, NULL, NULL, NULL, pcb))
302 if (!dsa) 305 goto err;
303 return 0; 306 if (!EVP_PKEY_assign_DSA(pkey, dsa))
304 ret = dsa_builtin_paramgen(dsa, dctx->nbits, dctx->qbits, dctx->pmd, 307 goto err;
305 NULL, 0, NULL, NULL, NULL, pcb); 308 dsa = NULL;
306 if (ret) 309
307 EVP_PKEY_assign_DSA(pkey, dsa); 310 ret = 1;
308 else 311
309 DSA_free(dsa); 312 err:
313 DSA_free(dsa);
314
310 return ret; 315 return ret;
311} 316}
312 317