]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Avoid warning about zero extending unsigned int on Windows
authorTomas Mraz <tomas@openssl.org>
Wed, 3 Dec 2025 11:17:13 +0000 (12:17 +0100)
committerTomas Mraz <tomas@openssl.org>
Wed, 3 Dec 2025 14:25:20 +0000 (15:25 +0100)
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29300)

crypto/bn/bn_gcd.c

index 6a763b09543ff03c1dcde3cd6f72d53f5d80e742..e09b6a3d723ae9556c9bc5da99ca13af6203ae33 100644 (file)
@@ -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);