From b7cb70902c58c927b969ecac46828718a5ff0497 Mon Sep 17 00:00:00 2001 From: guenther <> Date: Tue, 8 Nov 2016 01:40:22 +0000 Subject: Reduce the ternary operator abuse ok miod@ --- src/lib/libcrypto/bn/bn_sqrt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/bn/bn_sqrt.c b/src/lib/libcrypto/bn/bn_sqrt.c index f94fa41094..e5231d2a95 100644 --- a/src/lib/libcrypto/bn/bn_sqrt.c +++ b/src/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 * 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)) -- cgit v1.2.3-55-g6feb