summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn_sqrt.c11
1 files changed, 8 insertions, 3 deletions
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 @@
1/* $OpenBSD: bn_sqrt.c,v 1.6 2015/02/09 15:49:22 jsing Exp $ */ 1/* $OpenBSD: bn_sqrt.c,v 1.7 2016/11/08 01:40:22 guenther Exp $ */
2/* Written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> 2/* Written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * and Bodo Moeller for the OpenSSL project. */ 3 * and Bodo Moeller for the OpenSSL project. */
4/* ==================================================================== 4/* ====================================================================
@@ -231,8 +231,13 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
231 if (!BN_pseudo_rand(y, BN_num_bits(p), 0, 0)) 231 if (!BN_pseudo_rand(y, BN_num_bits(p), 0, 0))
232 goto end; 232 goto end;
233 if (BN_ucmp(y, p) >= 0) { 233 if (BN_ucmp(y, p) >= 0) {
234 if (!(p->neg ? BN_add : BN_sub)(y, y, p)) 234 if (p->neg) {
235 goto end; 235 if (!BN_add(y, y, p))
236 goto end;
237 } else {
238 if (!BN_sub(y, y, p))
239 goto end;
240 }
236 } 241 }
237 /* now 0 <= y < |p| */ 242 /* now 0 <= y < |p| */
238 if (BN_is_zero(y)) 243 if (BN_is_zero(y))