From: Pascal Cuoq Date: Wed, 6 May 2015 09:31:27 +0000 (+0200) Subject: Set flags to 0 before calling BN_with_flags() X-Git-Tag: OpenSSL_1_1_0-pre1~456 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f92768e6f5259069bd21dbed2b98b3423c1dfca4;p=openssl Set flags to 0 before calling BN_with_flags() BN_with_flags() will read the dest->flags to keep the BN_FLG_MALLOCED but overwrites everything else. Signed-off-by: Kurt Roeckx Reviewed-by: Rich Salz MR #1231 --- diff --git a/crypto/bn/bn_gcd.c b/crypto/bn/bn_gcd.c index 17c6cf5ce3..02643190ef 100644 --- a/crypto/bn/bn_gcd.c +++ b/crypto/bn/bn_gcd.c @@ -599,6 +599,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; @@ -626,6 +627,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) ... */