]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Set the 'tmp' flag BN_FLG_FIXED_TOP in bn_mod_exp_mont_fixed_top()
authorRichard Levitte <levitte@openssl.org>
Mon, 27 Oct 2025 19:47:44 +0000 (20:47 +0100)
committerTomas Mraz <tomas@openssl.org>
Tue, 4 Nov 2025 09:21:29 +0000 (10:21 +0100)
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)

crypto/bn/bn_exp.c

index 1dda2e017f1b93a1c27e00317e43aa1f9a84569e..ae6d9a2100518ea5559e7f7878bf1ce3ef5ef6d3 100644 (file)
@@ -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))