diff options
author | jsing <> | 2023-01-11 04:39:42 +0000 |
---|---|---|
committer | jsing <> | 2023-01-11 04:39:42 +0000 |
commit | 74f1269e0cf9abe4f2b70a0ba26461fafac75cd2 (patch) | |
tree | 5fe3fd82569c7f9e8a9a1295ec3fda45956a6144 /src/lib/libcrypto/dsa/dsa_gen.c | |
parent | e4eca83b70194cd4d7b511bbdb16dec48f17bf00 (diff) | |
download | openbsd-74f1269e0cf9abe4f2b70a0ba26461fafac75cd2.tar.gz openbsd-74f1269e0cf9abe4f2b70a0ba26461fafac75cd2.tar.bz2 openbsd-74f1269e0cf9abe4f2b70a0ba26461fafac75cd2.zip |
Clean up and simplify BIGNUM handling in DSA code.
This adds missing BN_CTX_start()/BN_CTX_end() calls, removes NULL checks
before BN_CTX_end()/BN_CTX_free() (since they're NULL safe) and calls
BN_free() instead of BN_clear_free() (which does the same thing).
Also replace stack allocated BIGNUMs with calls to BN_CTX_get(), using the
BN_CTX that is already available.
ok tb@
Diffstat (limited to 'src/lib/libcrypto/dsa/dsa_gen.c')
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_gen.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_gen.c b/src/lib/libcrypto/dsa/dsa_gen.c index 9c2b9cfd70..1f91894100 100644 --- a/src/lib/libcrypto/dsa/dsa_gen.c +++ b/src/lib/libcrypto/dsa/dsa_gen.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dsa_gen.c,v 1.26 2022/11/26 16:08:52 tb Exp $ */ | 1 | /* $OpenBSD: dsa_gen.c,v 1.27 2023/01/11 04:39:42 jsing 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 | * |
@@ -142,11 +142,12 @@ dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, const EVP_MD *evpmd, | |||
142 | else if (seed_len != 0) | 142 | else if (seed_len != 0) |
143 | goto err; | 143 | goto err; |
144 | 144 | ||
145 | if ((mont=BN_MONT_CTX_new()) == NULL) | 145 | if ((mont = BN_MONT_CTX_new()) == NULL) |
146 | goto err; | 146 | goto err; |
147 | 147 | ||
148 | if ((ctx=BN_CTX_new()) == NULL) | 148 | if ((ctx = BN_CTX_new()) == NULL) |
149 | goto err; | 149 | goto err; |
150 | |||
150 | BN_CTX_start(ctx); | 151 | BN_CTX_start(ctx); |
151 | 152 | ||
152 | if ((r0 = BN_CTX_get(ctx)) == NULL) | 153 | if ((r0 = BN_CTX_get(ctx)) == NULL) |
@@ -348,11 +349,10 @@ err: | |||
348 | if (seed_out != NULL) | 349 | if (seed_out != NULL) |
349 | memcpy(seed_out, seed, qsize); | 350 | memcpy(seed_out, seed, qsize); |
350 | } | 351 | } |
351 | if (ctx) { | 352 | BN_CTX_end(ctx); |
352 | BN_CTX_end(ctx); | 353 | BN_CTX_free(ctx); |
353 | BN_CTX_free(ctx); | ||
354 | } | ||
355 | BN_MONT_CTX_free(mont); | 354 | BN_MONT_CTX_free(mont); |
355 | |||
356 | return ok; | 356 | return ok; |
357 | } | 357 | } |
358 | #endif | 358 | #endif |