summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2016-11-08 01:40:22 +0000
committerguenther <guenther@openbsd.org>2016-11-08 01:40:22 +0000
commit8f7517009ad465c53b192276eb71f3a65d5c0bea (patch)
tree24707d542aa8606dfe3737c3c2a04b9eaa2db4fa
parentrename some types and functions to make the code easier to read. (diff)
downloadwireguard-openbsd-8f7517009ad465c53b192276eb71f3a65d5c0bea.tar.xz
wireguard-openbsd-8f7517009ad465c53b192276eb71f3a65d5c0bea.zip
Reduce the ternary operator abuse
ok miod@
-rw-r--r--lib/libcrypto/bn/bn_sqrt.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/libcrypto/bn/bn_sqrt.c b/lib/libcrypto/bn/bn_sqrt.c
index f94fa410941..e5231d2a952 100644
--- a/lib/libcrypto/bn/bn_sqrt.c
+++ b/lib/libcrypto/bn/bn_sqrt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bn_sqrt.c,v 1.6 2015/02/09 15:49:22 jsing Exp $ */
+/* $OpenBSD: bn_sqrt.c,v 1.7 2016/11/08 01:40:22 guenther Exp $ */
/* Written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
* and Bodo Moeller for the OpenSSL project. */
/* ====================================================================
@@ -231,8 +231,13 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
if (!BN_pseudo_rand(y, BN_num_bits(p), 0, 0))
goto end;
if (BN_ucmp(y, p) >= 0) {
- if (!(p->neg ? BN_add : BN_sub)(y, y, p))
- goto end;
+ if (p->neg) {
+ if (!BN_add(y, y, p))
+ goto end;
+ } else {
+ if (!BN_sub(y, y, p))
+ goto end;
+ }
}
/* now 0 <= y < |p| */
if (BN_is_zero(y))