Set flags to 0 before calling BN_with_flags()
authorPascal Cuoq <cuoq@trust-in-soft.com>
Wed, 6 May 2015 09:31:27 +0000 (11:31 +0200)
committerKurt Roeckx <kurt@roeckx.be>
Wed, 7 Oct 2015 18:36:34 +0000 (20:36 +0200)
BN_with_flags() will read the dest->flags to keep the BN_FLG_MALLOCED but
overwrites everything else.

Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>
MR #1231

(cherry picked from commit f92768e6f5259069bd21dbed2b98b3423c1dfca4)

crypto/bn/bn_gcd.c

index 97c55ab72098159b2f883353ba27ac2aeb26b2ff..ce59fe701f9db1d87003f1739357275a9a257008 100644 (file)
@@ -583,6 +583,7 @@ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in,
          * BN_div_no_branch will be called eventually.
          */
         pB = &local_B;
+        local_B.flags = 0;
         BN_with_flags(pB, B, BN_FLG_CONSTTIME);
         if (!BN_nnmod(B, pB, A, ctx))
             goto err;
@@ -610,6 +611,7 @@ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in,
          * BN_div_no_branch will be called eventually.
          */
         pA = &local_A;
+        local_A.flags = 0;
         BN_with_flags(pA, A, BN_FLG_CONSTTIME);
 
         /* (D, M) := (A/B, A%B) ... */