diff options
author | 2014-07-09 10:16:24 +0000 | |
---|---|---|
committer | 2014-07-09 10:16:24 +0000 | |
commit | e85b1b814f1a1df4b8b146b5d663297f415d0ca8 (patch) | |
tree | 6c3a88d6caf2c126ae5221ae811a71a3d9d59e17 /lib/libssl/src/crypto/dsa/dsa_key.c | |
parent | config parser improvements: (diff) | |
download | wireguard-openbsd-e85b1b814f1a1df4b8b146b5d663297f415d0ca8.tar.xz wireguard-openbsd-e85b1b814f1a1df4b8b146b5d663297f415d0ca8.zip |
KNF
Diffstat (limited to 'lib/libssl/src/crypto/dsa/dsa_key.c')
-rw-r--r-- | lib/libssl/src/crypto/dsa/dsa_key.c | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/lib/libssl/src/crypto/dsa/dsa_key.c b/lib/libssl/src/crypto/dsa/dsa_key.c index 7747ed14164..2d11f59107e 100644 --- a/lib/libssl/src/crypto/dsa/dsa_key.c +++ b/lib/libssl/src/crypto/dsa/dsa_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_key.c,v 1.15 2014/06/12 15:49:28 deraadt Exp $ */ +/* $OpenBSD: dsa_key.c,v 1.16 2014/07/09 10:16:24 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,63 +66,67 @@ static int dsa_builtin_keygen(DSA *dsa); -int DSA_generate_key(DSA *dsa) - { - if(dsa->meth->dsa_keygen) +int +DSA_generate_key(DSA *dsa) +{ + if (dsa->meth->dsa_keygen) return dsa->meth->dsa_keygen(dsa); return dsa_builtin_keygen(dsa); - } +} -static int dsa_builtin_keygen(DSA *dsa) - { - int ok=0; - BN_CTX *ctx=NULL; - BIGNUM *pub_key=NULL,*priv_key=NULL; +static int +dsa_builtin_keygen(DSA *dsa) +{ + int ok = 0; + BN_CTX *ctx = NULL; + BIGNUM *pub_key = NULL, *priv_key = NULL; - if ((ctx=BN_CTX_new()) == NULL) goto err; + if ((ctx = BN_CTX_new()) == NULL) + goto err; - if (dsa->priv_key == NULL) - { - if ((priv_key=BN_new()) == NULL) goto err; - } - else + if (dsa->priv_key == NULL) { + if ((priv_key = BN_new()) == NULL) + goto err; + } else priv_key=dsa->priv_key; - do - if (!BN_rand_range(priv_key,dsa->q)) goto err; - while (BN_is_zero(priv_key)); + do { + if (!BN_rand_range(priv_key, dsa->q)) + goto err; + } while (BN_is_zero(priv_key)); - if (dsa->pub_key == NULL) - { - if ((pub_key=BN_new()) == NULL) goto err; - } - else + if (dsa->pub_key == NULL) { + if ((pub_key = BN_new()) == NULL) + goto err; + } else pub_key=dsa->pub_key; { BIGNUM local_prk; BIGNUM *prk; - if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) - { + if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) { BN_init(&local_prk); prk = &local_prk; BN_with_flags(prk, priv_key, BN_FLG_CONSTTIME); - } - else + } else prk = priv_key; - if (!BN_mod_exp(pub_key,dsa->g,prk,dsa->p,ctx)) goto err; + if (!BN_mod_exp(pub_key, dsa->g, prk, dsa->p, ctx)) + goto err; } - dsa->priv_key=priv_key; - dsa->pub_key=pub_key; - ok=1; + dsa->priv_key = priv_key; + dsa->pub_key = pub_key; + ok = 1; err: - if ((pub_key != NULL) && (dsa->pub_key == NULL)) BN_free(pub_key); - if ((priv_key != NULL) && (dsa->priv_key == NULL)) BN_free(priv_key); - if (ctx != NULL) BN_CTX_free(ctx); - return(ok); - } + if (pub_key != NULL && dsa->pub_key == NULL) + BN_free(pub_key); + if (priv_key != NULL && dsa->priv_key == NULL) + BN_free(priv_key); + if (ctx != NULL) + BN_CTX_free(ctx); + return ok; +} #endif |