Commit 575d9bac4b961176e4c847b122e74370f17c16b1

Tom St Denis 2015-10-30T18:08:42

Add error check to mp_sqrtmod_prime() Signed-off-by: Tom St Denis <tstdenis82@gmail.com>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/bn_mp_sqrtmod_prime.c b/bn_mp_sqrtmod_prime.c
index b1a0441..2f1b7a7 100644
--- a/bn_mp_sqrtmod_prime.c
+++ b/bn_mp_sqrtmod_prime.c
@@ -30,7 +30,9 @@ int mp_sqrtmod_prime(mp_int *n, mp_int *prime, mp_int *ret)
   if ((res = mp_jacobi(n, prime, &legendre)) != MP_OKAY)        return res;
   if (legendre == -1)                                           return MP_VAL; /* quadratic non-residue mod prime */
 
-  mp_init_multi(&t1, &C, &Q, &S, &Z, &M, &T, &R, &two, NULL);
+  if ((res = mp_init_multi(&t1, &C, &Q, &S, &Z, &M, &T, &R, &two, NULL)) != MP_OKAY) {
+	return res;
+  }
 
   /* SPECIAL CASE: if prime mod 4 == 3
    * compute directly: res = n^(prime+1)/4 mod prime