Commit 54681f6e5b for openssl.org
commit 54681f6e5b689299bada4363adc2edc46a1d67b4
Author: Richard Levitte <levitte@openssl.org>
Date: Mon Oct 27 20:47:44 2025 +0100
Set the 'tmp' flag BN_FLG_FIXED_TOP in bn_mod_exp_mont_fixed_top()
If not set, bn_check_top() trips when BN_DEBUG is defined
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28801)
diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c
index 1dda2e017f..ae6d9a2100 100644
--- a/crypto/bn/bn_exp.c
+++ b/crypto/bn/bn_exp.c
@@ -766,6 +766,7 @@ int bn_mod_exp_mont_fixed_top(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
for (i = 1; i < top; i++)
tmp.d[i] = (~m->d[i]) & BN_MASK2;
tmp.top = top;
+ tmp.flags |= BN_FLG_FIXED_TOP;
} else
#endif
if (!bn_to_mont_fixed_top(&tmp, BN_value_one(), mont, ctx))