Commit 209c91c320 for openssl.org

commit 209c91c320460b676869427ea463b330aed119eb
Author: Tomas Mraz <tomas@openssl.org>
Date:   Wed Dec 3 12:17:13 2025 +0100

    Avoid warning about zero extending unsigned int on Windows

    Reviewed-by: Neil Horman <nhorman@openssl.org>
    Reviewed-by: Norbert Pocs <norbertp@openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/29300)

diff --git a/crypto/bn/bn_gcd.c b/crypto/bn/bn_gcd.c
index 6a763b0954..e09b6a3d72 100644
--- a/crypto/bn/bn_gcd.c
+++ b/crypto/bn/bn_gcd.c
@@ -654,7 +654,8 @@ int BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx)

     for (i = 0; i < m; i++) {
         /* conditionally flip signs if delta is positive and g is odd */
-        cond = ((unsigned int)-delta >> (8 * sizeof(delta) - 1)) & g->d[0] & 1
+        cond = ((unsigned int)-delta >> (8 * sizeof(delta) - 1))
+            & (unsigned int)g->d[0] & 1
             /* make sure g->top > 0 (i.e. if top == 0 then g == 0 always) */
             & (~((unsigned int)(g->top - 1) >> (sizeof(g->top) * 8 - 1)));
         delta = (-cond & -delta) | ((cond - 1) & delta);
@@ -666,7 +667,7 @@ int BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx)
         delta++;
         if (!BN_add(temp, g, r))
             goto err;
-        BN_consttime_swap(g->d[0] & 1 /* g is odd */
+        BN_consttime_swap((unsigned int)g->d[0] & 1 /* g is odd */
                 /* make sure g->top > 0 (i.e. if top == 0 then g == 0 always) */
                 & (~((unsigned int)(g->top - 1) >> (sizeof(g->top) * 8 - 1))),
                 g, temp, top);