diff options
author | tb <> | 2018-11-05 23:50:05 +0000 |
---|---|---|
committer | tb <> | 2018-11-05 23:50:05 +0000 |
commit | bcef8f9f7589db87fc5979bf8a77f81275c574a2 (patch) | |
tree | 1e04cc34be4d65b95be7fd1dc42660ff4e7b6580 /src/lib/libcrypto/dsa | |
parent | b7d5fcfa073d6408fd2af787acdc717bb412fd8f (diff) | |
download | openbsd-bcef8f9f7589db87fc5979bf8a77f81275c574a2.tar.gz openbsd-bcef8f9f7589db87fc5979bf8a77f81275c574a2.tar.bz2 openbsd-bcef8f9f7589db87fc5979bf8a77f81275c574a2.zip |
Eliminate a few "} else" branches, a few unneeded NULL checks before
freeing and indent nearby labels.
ok beck jsing
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_key.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_key.c b/src/lib/libcrypto/dsa/dsa_key.c index b2d08e5e0c..520b980983 100644 --- a/src/lib/libcrypto/dsa/dsa_key.c +++ b/src/lib/libcrypto/dsa/dsa_key.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dsa_key.c,v 1.24 2018/11/05 23:46:16 tb Exp $ */ | 1 | /* $OpenBSD: dsa_key.c,v 1.25 2018/11/05 23:50:05 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 | * |
@@ -82,27 +82,25 @@ dsa_builtin_keygen(DSA *dsa) | |||
82 | { | 82 | { |
83 | int ok = 0; | 83 | int ok = 0; |
84 | BN_CTX *ctx = NULL; | 84 | BN_CTX *ctx = NULL; |
85 | BIGNUM *pub_key = NULL, *priv_key = NULL; | 85 | BIGNUM *pub_key = dsa->pub_key, *priv_key = dsa->priv_key; |
86 | 86 | ||
87 | if ((ctx = BN_CTX_new()) == NULL) | 87 | if ((ctx = BN_CTX_new()) == NULL) |
88 | goto err; | 88 | goto err; |
89 | 89 | ||
90 | if (dsa->priv_key == NULL) { | 90 | if (priv_key == NULL) { |
91 | if ((priv_key = BN_new()) == NULL) | 91 | if ((priv_key = BN_new()) == NULL) |
92 | goto err; | 92 | goto err; |
93 | } else | 93 | } |
94 | priv_key=dsa->priv_key; | ||
95 | 94 | ||
96 | do { | 95 | do { |
97 | if (!BN_rand_range(priv_key, dsa->q)) | 96 | if (!BN_rand_range(priv_key, dsa->q)) |
98 | goto err; | 97 | goto err; |
99 | } while (BN_is_zero(priv_key)); | 98 | } while (BN_is_zero(priv_key)); |
100 | 99 | ||
101 | if (dsa->pub_key == NULL) { | 100 | if (pub_key == NULL) { |
102 | if ((pub_key = BN_new()) == NULL) | 101 | if ((pub_key = BN_new()) == NULL) |
103 | goto err; | 102 | goto err; |
104 | } else | 103 | } |
105 | pub_key=dsa->pub_key; | ||
106 | 104 | ||
107 | if (!BN_mod_exp_ct(pub_key, dsa->g, priv_key, dsa->p, ctx)) | 105 | if (!BN_mod_exp_ct(pub_key, dsa->g, priv_key, dsa->p, ctx)) |
108 | goto err; | 106 | goto err; |
@@ -111,10 +109,10 @@ dsa_builtin_keygen(DSA *dsa) | |||
111 | dsa->pub_key = pub_key; | 109 | dsa->pub_key = pub_key; |
112 | ok = 1; | 110 | ok = 1; |
113 | 111 | ||
114 | err: | 112 | err: |
115 | if (pub_key != NULL && dsa->pub_key == NULL) | 113 | if (dsa->pub_key == NULL) |
116 | BN_free(pub_key); | 114 | BN_free(pub_key); |
117 | if (priv_key != NULL && dsa->priv_key == NULL) | 115 | if (dsa->priv_key == NULL) |
118 | BN_free(priv_key); | 116 | BN_free(priv_key); |
119 | BN_CTX_free(ctx); | 117 | BN_CTX_free(ctx); |
120 | return ok; | 118 | return ok; |