diff --git a/wolfcrypt/src/sp_arm32.c b/wolfcrypt/src/sp_arm32.c index e2841500bd..52bde53a81 100644 --- a/wolfcrypt/src/sp_arm32.c +++ b/wolfcrypt/src/sp_arm32.c @@ -8517,7 +8517,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, y = (int)(n >> c); n <<= 32 - c; } - sp_2048_lshift_64(r, norm, y); + sp_2048_lshift_64(r, norm, (byte)y); for (; i>=0 || c>=5; ) { if (c == 0) { n = e[i--]; @@ -8545,7 +8545,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, sp_2048_mont_sqr_64(r, r, m, mp); sp_2048_mont_sqr_64(r, r, m, mp); - sp_2048_lshift_64(r, r, y); + sp_2048_lshift_64(r, r, (byte)y); sp_2048_mul_d_64(tmp, norm, r[64]); r[64] = 0; o = sp_2048_add_64(r, r, tmp); @@ -20406,7 +20406,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits, y = (int)(n >> c); n <<= 32 - c; } - sp_3072_lshift_96(r, norm, y); + sp_3072_lshift_96(r, norm, (byte)y); for (; i>=0 || c>=5; ) { if (c == 0) { n = e[i--]; @@ -20434,7 +20434,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits, sp_3072_mont_sqr_96(r, r, m, mp); sp_3072_mont_sqr_96(r, r, m, mp); - sp_3072_lshift_96(r, r, y); + sp_3072_lshift_96(r, r, (byte)y); sp_3072_mul_d_96(tmp, norm, r[96]); r[96] = 0; o = sp_3072_add_96(r, r, tmp); @@ -28700,7 +28700,7 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits, y = (int)(n >> c); n <<= 32 - c; } - sp_4096_lshift_128(r, norm, y); + sp_4096_lshift_128(r, norm, (byte)y); for (; i>=0 || c>=5; ) { if (c == 0) { n = e[i--]; @@ -28728,7 +28728,7 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits, sp_4096_mont_sqr_128(r, r, m, mp); sp_4096_mont_sqr_128(r, r, m, mp); - sp_4096_lshift_128(r, r, y); + sp_4096_lshift_128(r, r, (byte)y); sp_4096_mul_d_128(tmp, norm, r[128]); r[128] = 0; o = sp_4096_add_128(r, r, tmp); @@ -32708,7 +32708,7 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, y = 0; for (j=0,x=63; j<4; j++,x+=64) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -32723,7 +32723,7 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, for (i=62; i>=0; i--) { y = 0; for (j=0,x=i; j<4; j++,x+=64) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } sp_256_proj_point_dbl_8(rt, rt, t); @@ -33080,7 +33080,7 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, y = 0; for (j=0,x=31; j<8; j++,x+=32) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -33095,7 +33095,7 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, for (i=30; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=32) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } sp_256_proj_point_dbl_8(rt, rt, t); @@ -42396,7 +42396,7 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, y = 0; for (j=0,x=95; j<4; j++,x+=96) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -42411,7 +42411,7 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, for (i=94; i>=0; i--) { y = 0; for (j=0,x=i; j<4; j++,x+=96) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } sp_384_proj_point_dbl_12(rt, rt, t); @@ -42784,7 +42784,7 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, y = 0; for (j=0,x=47; j<8; j++,x+=48) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -42799,7 +42799,7 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, for (i=46; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=48) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } sp_384_proj_point_dbl_12(rt, rt, t); diff --git a/wolfcrypt/src/sp_arm64.c b/wolfcrypt/src/sp_arm64.c index e79150d82d..741ba88957 100644 --- a/wolfcrypt/src/sp_arm64.c +++ b/wolfcrypt/src/sp_arm64.c @@ -5718,7 +5718,7 @@ static int sp_2048_mod_exp_2_32(sp_digit* r, const sp_digit* e, int bits, y = (int)(n >> c); n <<= 64 - c; } - sp_2048_lshift_32(r, norm, y); + sp_2048_lshift_32(r, norm, (byte)y); for (; i>=0 || c>=6; ) { if (c == 0) { n = e[i--]; @@ -5747,7 +5747,7 @@ static int sp_2048_mod_exp_2_32(sp_digit* r, const sp_digit* e, int bits, sp_2048_mont_sqr_32(r, r, m, mp); sp_2048_mont_sqr_32(r, r, m, mp); - sp_2048_lshift_32(r, r, y); + sp_2048_lshift_32(r, r, (byte)y); sp_2048_mul_d_32(tmp, norm, r[32]); r[32] = 0; o = sp_2048_add_32(r, r, tmp); @@ -13610,7 +13610,7 @@ static int sp_3072_mod_exp_2_48(sp_digit* r, const sp_digit* e, int bits, y = (int)(n >> c); n <<= 64 - c; } - sp_3072_lshift_48(r, norm, y); + sp_3072_lshift_48(r, norm, (byte)y); for (; i>=0 || c>=6; ) { if (c == 0) { n = e[i--]; @@ -13639,7 +13639,7 @@ static int sp_3072_mod_exp_2_48(sp_digit* r, const sp_digit* e, int bits, sp_3072_mont_sqr_48(r, r, m, mp); sp_3072_mont_sqr_48(r, r, m, mp); - sp_3072_lshift_48(r, r, y); + sp_3072_lshift_48(r, r, (byte)y); sp_3072_mul_d_48(tmp, norm, r[48]); r[48] = 0; o = sp_3072_add_48(r, r, tmp); @@ -18701,7 +18701,7 @@ static int sp_4096_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, y = (int)(n >> c); n <<= 64 - c; } - sp_4096_lshift_64(r, norm, y); + sp_4096_lshift_64(r, norm, (byte)y); for (; i>=0 || c>=6; ) { if (c == 0) { n = e[i--]; @@ -18730,7 +18730,7 @@ static int sp_4096_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, sp_4096_mont_sqr_64(r, r, m, mp); sp_4096_mont_sqr_64(r, r, m, mp); - sp_4096_lshift_64(r, r, y); + sp_4096_lshift_64(r, r, (byte)y); sp_4096_mul_d_64(tmp, norm, r[64]); r[64] = 0; o = sp_4096_add_64(r, r, tmp); @@ -21075,7 +21075,7 @@ static void sp_256_ecc_recode_6_4(const sp_digit* k, ecc_recode_256* v) n = k[j]; o = 0; for (i=0; i<43; i++) { - y = n; + y = (int8_t)n; if (o + 6 < 64) { y &= 0x3f; n >>= 6; @@ -21089,12 +21089,12 @@ static void sp_256_ecc_recode_6_4(const sp_digit* k, ecc_recode_256* v) } else if (++j < 4) { n = k[j]; - y |= (n << (64 - o)) & 0x3f; + y |= (uint8_t)((n << (64 - o)) & 0x3f); o -= 58; n >>= o; } - y += carry; + y += (uint8_t)carry; v[i].i = recode_index_4_6[y]; v[i].neg = recode_neg_4_6[y]; carry = (y >> 6) + v[i].neg; @@ -21577,7 +21577,7 @@ static int sp_256_ecc_mulmod_stripe_4(sp_point_256* r, const sp_point_256* g, y = 0; for (j=0,x=42; j<6 && x<256; j++,x+=43) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -21592,7 +21592,7 @@ static int sp_256_ecc_mulmod_stripe_4(sp_point_256* r, const sp_point_256* g, for (i=41; i>=0; i--) { y = 0; for (j=0,x=i; j<6 && x<256; j++,x+=43) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } sp_256_proj_point_dbl_4(rt, rt, t); @@ -21937,7 +21937,7 @@ static int sp_256_ecc_mulmod_stripe_4(sp_point_256* r, const sp_point_256* g, y = 0; for (j=0,x=31; j<8; j++,x+=32) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -21952,7 +21952,7 @@ static int sp_256_ecc_mulmod_stripe_4(sp_point_256* r, const sp_point_256* g, for (i=30; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=32) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } sp_256_proj_point_dbl_4(rt, rt, t); @@ -23858,7 +23858,7 @@ static void sp_256_ecc_recode_7_4(const sp_digit* k, ecc_recode_256* v) n = k[j]; o = 0; for (i=0; i<37; i++) { - y = n; + y = (int8_t)n; if (o + 7 < 64) { y &= 0x7f; n >>= 7; @@ -23872,12 +23872,12 @@ static void sp_256_ecc_recode_7_4(const sp_digit* k, ecc_recode_256* v) } else if (++j < 4) { n = k[j]; - y |= (n << (64 - o)) & 0x7f; + y |= (uint8_t)((n << (64 - o)) & 0x7f); o -= 57; n >>= o; } - y += carry; + y += (uint8_t)carry; v[i].i = recode_index_4_7[y]; v[i].neg = recode_neg_4_7[y]; carry = (y >> 7) + v[i].neg; @@ -40642,7 +40642,7 @@ static void sp_384_ecc_recode_6_6(const sp_digit* k, ecc_recode_384* v) n = k[j]; o = 0; for (i=0; i<65; i++) { - y = n; + y = (int8_t)n; if (o + 6 < 64) { y &= 0x3f; n >>= 6; @@ -40656,12 +40656,12 @@ static void sp_384_ecc_recode_6_6(const sp_digit* k, ecc_recode_384* v) } else if (++j < 6) { n = k[j]; - y |= (n << (64 - o)) & 0x3f; + y |= (uint8_t)((n << (64 - o)) & 0x3f); o -= 58; n >>= o; } - y += carry; + y += (uint8_t)carry; v[i].i = recode_index_6_6[y]; v[i].neg = recode_neg_6_6[y]; carry = (y >> 6) + v[i].neg; @@ -41162,7 +41162,7 @@ static int sp_384_ecc_mulmod_stripe_6(sp_point_384* r, const sp_point_384* g, y = 0; for (j=0,x=47; j<8; j++,x+=48) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -41177,7 +41177,7 @@ static int sp_384_ecc_mulmod_stripe_6(sp_point_384* r, const sp_point_384* g, for (i=46; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=48) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } sp_384_proj_point_dbl_6(rt, rt, t); diff --git a/wolfcrypt/src/sp_armthumb.c b/wolfcrypt/src/sp_armthumb.c index d15e2f89c4..dde994630d 100644 --- a/wolfcrypt/src/sp_armthumb.c +++ b/wolfcrypt/src/sp_armthumb.c @@ -5223,7 +5223,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, y = (int)(n >> c); n <<= 32 - c; } - sp_2048_lshift_64(r, norm, y); + sp_2048_lshift_64(r, norm, (byte)y); for (; i>=0 || c>=5; ) { if (c == 0) { n = e[i--]; @@ -5251,7 +5251,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, sp_2048_mont_sqr_64(r, r, m, mp); sp_2048_mont_sqr_64(r, r, m, mp); - sp_2048_lshift_64(r, r, y); + sp_2048_lshift_64(r, r, (byte)y); sp_2048_mul_d_64(tmp, norm, r[64]); r[64] = 0; o = sp_2048_add_64(r, r, tmp); @@ -11285,7 +11285,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits, y = (int)(n >> c); n <<= 32 - c; } - sp_3072_lshift_96(r, norm, y); + sp_3072_lshift_96(r, norm, (byte)y); for (; i>=0 || c>=5; ) { if (c == 0) { n = e[i--]; @@ -11313,7 +11313,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits, sp_3072_mont_sqr_96(r, r, m, mp); sp_3072_mont_sqr_96(r, r, m, mp); - sp_3072_lshift_96(r, r, y); + sp_3072_lshift_96(r, r, (byte)y); sp_3072_mul_d_96(tmp, norm, r[96]); r[96] = 0; o = sp_3072_add_96(r, r, tmp); @@ -15404,7 +15404,7 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits, y = (int)(n >> c); n <<= 32 - c; } - sp_4096_lshift_128(r, norm, y); + sp_4096_lshift_128(r, norm, (byte)y); for (; i>=0 || c>=5; ) { if (c == 0) { n = e[i--]; @@ -15432,7 +15432,7 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits, sp_4096_mont_sqr_128(r, r, m, mp); sp_4096_mont_sqr_128(r, r, m, mp); - sp_4096_lshift_128(r, r, y); + sp_4096_lshift_128(r, r, (byte)y); sp_4096_mul_d_128(tmp, norm, r[128]); r[128] = 0; o = sp_4096_add_128(r, r, tmp); @@ -18429,7 +18429,7 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, y = 0; for (j=0,x=63; j<4; j++,x+=64) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -18444,7 +18444,7 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, for (i=62; i>=0; i--) { y = 0; for (j=0,x=i; j<4; j++,x+=64) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } sp_256_proj_point_dbl_8(rt, rt, t); @@ -18801,7 +18801,7 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, y = 0; for (j=0,x=31; j<8; j++,x+=32) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -18816,7 +18816,7 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, for (i=30; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=32) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } sp_256_proj_point_dbl_8(rt, rt, t); @@ -25231,7 +25231,7 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, y = 0; for (j=0,x=95; j<4; j++,x+=96) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -25246,7 +25246,7 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, for (i=94; i>=0; i--) { y = 0; for (j=0,x=i; j<4; j++,x+=96) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } sp_384_proj_point_dbl_12(rt, rt, t); @@ -25619,7 +25619,7 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, y = 0; for (j=0,x=47; j<8; j++,x+=48) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -25634,7 +25634,7 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, for (i=46; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=48) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } sp_384_proj_point_dbl_12(rt, rt, t); diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index 1e9297ece2..edcff60454 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -1254,7 +1254,7 @@ SP_NOINLINE static void sp_2048_mul_d_90(sp_digit* r, const sp_digit* a, for (i = 0; i < 90; i++) { t += tb * a[i]; - r[i] = t & 0x7fffff; + r[i] = (sp_digit)(t & 0x7fffff); t >>= 23; } r[90] = (sp_digit)t; @@ -1273,27 +1273,27 @@ SP_NOINLINE static void sp_2048_mul_d_90(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x7fffff; t >>= 23; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x7fffff; t >>= 23; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x7fffff; t >>= 23; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x7fffff; t >>= 23; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } t += tb * a[88]; - r[88] = t & 0x7fffff; + r[88] = (sp_digit)(t & 0x7fffff); t >>= 23; t += tb * a[89]; - r[89] = t & 0x7fffff; + r[89] = (sp_digit)(t & 0x7fffff); t >>= 23; - r[90] = t & 0x7fffff; + r[90] = (sp_digit)(t & 0x7fffff); #endif /* WOLFSSL_SP_SMALL */ } @@ -1629,7 +1629,7 @@ SP_NOINLINE static void sp_2048_mul_d_45(sp_digit* r, const sp_digit* a, for (i = 0; i < 45; i++) { t += tb * a[i]; - r[i] = t & 0x7fffff; + r[i] = (sp_digit)(t & 0x7fffff); t >>= 23; } r[45] = (sp_digit)t; @@ -1648,24 +1648,24 @@ SP_NOINLINE static void sp_2048_mul_d_45(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x7fffff; t >>= 23; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x7fffff; t >>= 23; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x7fffff; t >>= 23; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x7fffff; t >>= 23; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } t += tb * a[44]; - r[44] = t & 0x7fffff; + r[44] = (sp_digit)(t & 0x7fffff); t >>= 23; - r[45] = t & 0x7fffff; + r[45] = (sp_digit)(t & 0x7fffff); #endif /* WOLFSSL_SP_SMALL */ } @@ -1975,7 +1975,7 @@ static int sp_2048_mod_exp_45(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 23; } - y = (n >> 22) & 1; + y = (int)((n >> 22) & 1); n <<= 1; sp_2048_mont_mul_45(t[y^1], t[0], t[1], m, mp); @@ -2066,7 +2066,7 @@ static int sp_2048_mod_exp_45(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 23; } - y = (n >> 22) & 1; + y = (int)((n >> 22) & 1); n <<= 1; sp_2048_mont_mul_45(t[y^1], t[0], t[1], m, mp); @@ -2194,7 +2194,7 @@ static int sp_2048_mod_exp_45(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (9 - c); c += 23; } - y = (n >> 27) & 0x1f; + y = (int)((n >> 27) & 0x1f); n <<= 5; c -= 5; XMEMCPY(rt, t[y], sizeof(sp_digit) * 90); @@ -2203,7 +2203,7 @@ static int sp_2048_mod_exp_45(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (9 - c); c += 23; } - y = (n >> 27) & 0x1f; + y = (int)((n >> 27) & 0x1f); n <<= 5; c -= 5; @@ -2570,7 +2570,7 @@ SP_NOINLINE static void sp_2048_mul_d_180(sp_digit* r, const sp_digit* a, for (i = 0; i < 180; i++) { t += tb * a[i]; - r[i] = t & 0x7fffff; + r[i] = (sp_digit)(t & 0x7fffff); t >>= 23; } r[180] = (sp_digit)t; @@ -2589,21 +2589,21 @@ SP_NOINLINE static void sp_2048_mul_d_180(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x7fffff; t >>= 23; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x7fffff; t >>= 23; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x7fffff; t >>= 23; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x7fffff; t >>= 23; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } - r[180] = t & 0x7fffff; + r[180] = (sp_digit)(t & 0x7fffff); #endif /* WOLFSSL_SP_SMALL */ } @@ -2929,7 +2929,7 @@ static int sp_2048_mod_exp_90(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 23; } - y = (n >> 22) & 1; + y = (int)((n >> 22) & 1); n <<= 1; sp_2048_mont_mul_90(t[y^1], t[0], t[1], m, mp); @@ -3020,7 +3020,7 @@ static int sp_2048_mod_exp_90(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 23; } - y = (n >> 22) & 1; + y = (int)((n >> 22) & 1); n <<= 1; sp_2048_mont_mul_90(t[y^1], t[0], t[1], m, mp); @@ -3148,7 +3148,7 @@ static int sp_2048_mod_exp_90(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (9 - c); c += 23; } - y = (n >> 27) & 0x1f; + y = (int)((n >> 27) & 0x1f); n <<= 5; c -= 5; XMEMCPY(rt, t[y], sizeof(sp_digit) * 180); @@ -3157,7 +3157,7 @@ static int sp_2048_mod_exp_90(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (9 - c); c += 23; } - y = (n >> 27) & 0x1f; + y = (int)((n >> 27) & 0x1f); n <<= 5; c -= 5; @@ -4156,16 +4156,16 @@ static int sp_2048_mod_exp_2_90(sp_digit* r, const sp_digit* e, int bits, const n |= e[i--] << (9 - c); c += 23; } - y = (n >> 28) & 0xf; + y = (int)((n >> 28) & 0xf); n <<= 4; c -= 4; - sp_2048_lshift_90(r, norm, y); + sp_2048_lshift_90(r, norm, (byte)y); for (; i>=0 || c>=4; ) { if (c < 4) { n |= e[i--] << (9 - c); c += 23; } - y = (n >> 28) & 0xf; + y = (int)((n >> 28) & 0xf); n <<= 4; c -= 4; @@ -4174,7 +4174,7 @@ static int sp_2048_mod_exp_2_90(sp_digit* r, const sp_digit* e, int bits, const sp_2048_mont_sqr_90(r, r, m, mp); sp_2048_mont_sqr_90(r, r, m, mp); - sp_2048_lshift_90(r, r, y); + sp_2048_lshift_90(r, r, (byte)y); sp_2048_mul_d_90(tmp, norm, (r[90] << 22) + (r[89] >> 1)); r[90] = 0; r[89] &= 0x1L; @@ -5149,7 +5149,7 @@ SP_NOINLINE static void sp_3072_mul_d_134(sp_digit* r, const sp_digit* a, for (i = 0; i < 134; i++) { t += tb * a[i]; - r[i] = t & 0x7fffff; + r[i] = (sp_digit)(t & 0x7fffff); t >>= 23; } r[134] = (sp_digit)t; @@ -5168,27 +5168,27 @@ SP_NOINLINE static void sp_3072_mul_d_134(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x7fffff; t >>= 23; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x7fffff; t >>= 23; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x7fffff; t >>= 23; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x7fffff; t >>= 23; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } t += tb * a[132]; - r[132] = t & 0x7fffff; + r[132] = (sp_digit)(t & 0x7fffff); t >>= 23; t += tb * a[133]; - r[133] = t & 0x7fffff; + r[133] = (sp_digit)(t & 0x7fffff); t >>= 23; - r[134] = t & 0x7fffff; + r[134] = (sp_digit)(t & 0x7fffff); #endif /* WOLFSSL_SP_SMALL */ } @@ -5516,7 +5516,7 @@ SP_NOINLINE static void sp_3072_mul_d_67(sp_digit* r, const sp_digit* a, for (i = 0; i < 67; i++) { t += tb * a[i]; - r[i] = t & 0x7fffff; + r[i] = (sp_digit)(t & 0x7fffff); t >>= 23; } r[67] = (sp_digit)t; @@ -5535,30 +5535,30 @@ SP_NOINLINE static void sp_3072_mul_d_67(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x7fffff; t >>= 23; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x7fffff; t >>= 23; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x7fffff; t >>= 23; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x7fffff; t >>= 23; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } t += tb * a[64]; - r[64] = t & 0x7fffff; + r[64] = (sp_digit)(t & 0x7fffff); t >>= 23; t += tb * a[65]; - r[65] = t & 0x7fffff; + r[65] = (sp_digit)(t & 0x7fffff); t >>= 23; t += tb * a[66]; - r[66] = t & 0x7fffff; + r[66] = (sp_digit)(t & 0x7fffff); t >>= 23; - r[67] = t & 0x7fffff; + r[67] = (sp_digit)(t & 0x7fffff); #endif /* WOLFSSL_SP_SMALL */ } @@ -5830,7 +5830,7 @@ static int sp_3072_mod_exp_67(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 23; } - y = (n >> 22) & 1; + y = (int)((n >> 22) & 1); n <<= 1; sp_3072_mont_mul_67(t[y^1], t[0], t[1], m, mp); @@ -5921,7 +5921,7 @@ static int sp_3072_mod_exp_67(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 23; } - y = (n >> 22) & 1; + y = (int)((n >> 22) & 1); n <<= 1; sp_3072_mont_mul_67(t[y^1], t[0], t[1], m, mp); @@ -6049,7 +6049,7 @@ static int sp_3072_mod_exp_67(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (9 - c); c += 23; } - y = (n >> 27) & 0x1f; + y = (int)((n >> 27) & 0x1f); n <<= 5; c -= 5; XMEMCPY(rt, t[y], sizeof(sp_digit) * 134); @@ -6058,7 +6058,7 @@ static int sp_3072_mod_exp_67(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (9 - c); c += 23; } - y = (n >> 27) & 0x1f; + y = (int)((n >> 27) & 0x1f); n <<= 5; c -= 5; @@ -6453,7 +6453,7 @@ SP_NOINLINE static void sp_3072_mul_d_268(sp_digit* r, const sp_digit* a, for (i = 0; i < 268; i++) { t += tb * a[i]; - r[i] = t & 0x7fffff; + r[i] = (sp_digit)(t & 0x7fffff); t >>= 23; } r[268] = (sp_digit)t; @@ -6472,21 +6472,21 @@ SP_NOINLINE static void sp_3072_mul_d_268(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x7fffff; t >>= 23; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x7fffff; t >>= 23; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x7fffff; t >>= 23; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x7fffff; t >>= 23; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } - r[268] = t & 0x7fffff; + r[268] = (sp_digit)(t & 0x7fffff); #endif /* WOLFSSL_SP_SMALL */ } @@ -6820,7 +6820,7 @@ static int sp_3072_mod_exp_134(sp_digit* r, const sp_digit* a, const sp_digit* e c = 23; } - y = (n >> 22) & 1; + y = (int)((n >> 22) & 1); n <<= 1; sp_3072_mont_mul_134(t[y^1], t[0], t[1], m, mp); @@ -6911,7 +6911,7 @@ static int sp_3072_mod_exp_134(sp_digit* r, const sp_digit* a, const sp_digit* e c = 23; } - y = (n >> 22) & 1; + y = (int)((n >> 22) & 1); n <<= 1; sp_3072_mont_mul_134(t[y^1], t[0], t[1], m, mp); @@ -7039,7 +7039,7 @@ static int sp_3072_mod_exp_134(sp_digit* r, const sp_digit* a, const sp_digit* e n |= e[i--] << (9 - c); c += 23; } - y = (n >> 27) & 0x1f; + y = (int)((n >> 27) & 0x1f); n <<= 5; c -= 5; XMEMCPY(rt, t[y], sizeof(sp_digit) * 268); @@ -7048,7 +7048,7 @@ static int sp_3072_mod_exp_134(sp_digit* r, const sp_digit* a, const sp_digit* e n |= e[i--] << (9 - c); c += 23; } - y = (n >> 27) & 0x1f; + y = (int)((n >> 27) & 0x1f); n <<= 5; c -= 5; @@ -8135,16 +8135,16 @@ static int sp_3072_mod_exp_2_134(sp_digit* r, const sp_digit* e, int bits, const n |= e[i--] << (9 - c); c += 23; } - y = (n >> 28) & 0xf; + y = (int)((n >> 28) & 0xf); n <<= 4; c -= 4; - sp_3072_lshift_134(r, norm, y); + sp_3072_lshift_134(r, norm, (byte)y); for (; i>=0 || c>=4; ) { if (c < 4) { n |= e[i--] << (9 - c); c += 23; } - y = (n >> 28) & 0xf; + y = (int)((n >> 28) & 0xf); n <<= 4; c -= 4; @@ -8153,7 +8153,7 @@ static int sp_3072_mod_exp_2_134(sp_digit* r, const sp_digit* e, int bits, const sp_3072_mont_sqr_134(r, r, m, mp); sp_3072_mont_sqr_134(r, r, m, mp); - sp_3072_lshift_134(r, r, y); + sp_3072_lshift_134(r, r, (byte)y); sp_3072_mul_d_134(tmp, norm, (r[134] << 10) + (r[133] >> 13)); r[134] = 0; r[133] &= 0x1fffL; @@ -9193,7 +9193,7 @@ SP_NOINLINE static void sp_4096_mul_d_196(sp_digit* r, const sp_digit* a, for (i = 0; i < 196; i++) { t += tb * a[i]; - r[i] = t & 0x1fffff; + r[i] = (sp_digit)(t & 0x1fffff); t >>= 21; } r[196] = (sp_digit)t; @@ -9212,21 +9212,21 @@ SP_NOINLINE static void sp_4096_mul_d_196(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x1fffff; t >>= 21; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x1fffff; t >>= 21; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x1fffff; t >>= 21; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x1fffff; t >>= 21; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } - r[196] = t & 0x1fffff; + r[196] = (sp_digit)(t & 0x1fffff); #endif /* WOLFSSL_SP_SMALL */ } @@ -9542,7 +9542,7 @@ SP_NOINLINE static void sp_4096_mul_d_98(sp_digit* r, const sp_digit* a, for (i = 0; i < 98; i++) { t += tb * a[i]; - r[i] = t & 0x1fffff; + r[i] = (sp_digit)(t & 0x1fffff); t >>= 21; } r[98] = (sp_digit)t; @@ -9561,27 +9561,27 @@ SP_NOINLINE static void sp_4096_mul_d_98(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x1fffff; t >>= 21; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x1fffff; t >>= 21; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x1fffff; t >>= 21; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x1fffff; t >>= 21; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } t += tb * a[96]; - r[96] = t & 0x1fffff; + r[96] = (sp_digit)(t & 0x1fffff); t >>= 21; t += tb * a[97]; - r[97] = t & 0x1fffff; + r[97] = (sp_digit)(t & 0x1fffff); t >>= 21; - r[98] = t & 0x1fffff; + r[98] = (sp_digit)(t & 0x1fffff); #endif /* WOLFSSL_SP_SMALL */ } @@ -9905,7 +9905,7 @@ static int sp_4096_mod_exp_98(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 21; } - y = (n >> 20) & 1; + y = (int)((n >> 20) & 1); n <<= 1; sp_4096_mont_mul_98(t[y^1], t[0], t[1], m, mp); @@ -9996,7 +9996,7 @@ static int sp_4096_mod_exp_98(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 21; } - y = (n >> 20) & 1; + y = (int)((n >> 20) & 1); n <<= 1; sp_4096_mont_mul_98(t[y^1], t[0], t[1], m, mp); @@ -10124,7 +10124,7 @@ static int sp_4096_mod_exp_98(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (11 - c); c += 21; } - y = (n >> 27) & 0x1f; + y = (int)((n >> 27) & 0x1f); n <<= 5; c -= 5; XMEMCPY(rt, t[y], sizeof(sp_digit) * 196); @@ -10133,7 +10133,7 @@ static int sp_4096_mod_exp_98(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (11 - c); c += 21; } - y = (n >> 27) & 0x1f; + y = (int)((n >> 27) & 0x1f); n <<= 5; c -= 5; @@ -10515,7 +10515,7 @@ SP_NOINLINE static void sp_4096_mul_d_392(sp_digit* r, const sp_digit* a, for (i = 0; i < 392; i++) { t += tb * a[i]; - r[i] = t & 0x1fffff; + r[i] = (sp_digit)(t & 0x1fffff); t >>= 21; } r[392] = (sp_digit)t; @@ -10534,21 +10534,21 @@ SP_NOINLINE static void sp_4096_mul_d_392(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x1fffff; t >>= 21; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x1fffff; t >>= 21; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x1fffff; t >>= 21; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x1fffff; t >>= 21; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } - r[392] = t & 0x1fffff; + r[392] = (sp_digit)(t & 0x1fffff); #endif /* WOLFSSL_SP_SMALL */ } @@ -10878,7 +10878,7 @@ static int sp_4096_mod_exp_196(sp_digit* r, const sp_digit* a, const sp_digit* e c = 21; } - y = (n >> 20) & 1; + y = (int)((n >> 20) & 1); n <<= 1; sp_4096_mont_mul_196(t[y^1], t[0], t[1], m, mp); @@ -10969,7 +10969,7 @@ static int sp_4096_mod_exp_196(sp_digit* r, const sp_digit* a, const sp_digit* e c = 21; } - y = (n >> 20) & 1; + y = (int)((n >> 20) & 1); n <<= 1; sp_4096_mont_mul_196(t[y^1], t[0], t[1], m, mp); @@ -11097,7 +11097,7 @@ static int sp_4096_mod_exp_196(sp_digit* r, const sp_digit* a, const sp_digit* e n |= e[i--] << (11 - c); c += 21; } - y = (n >> 27) & 0x1f; + y = (int)((n >> 27) & 0x1f); n <<= 5; c -= 5; XMEMCPY(rt, t[y], sizeof(sp_digit) * 392); @@ -11106,7 +11106,7 @@ static int sp_4096_mod_exp_196(sp_digit* r, const sp_digit* a, const sp_digit* e n |= e[i--] << (11 - c); c += 21; } - y = (n >> 27) & 0x1f; + y = (int)((n >> 27) & 0x1f); n <<= 5; c -= 5; @@ -12317,16 +12317,16 @@ static int sp_4096_mod_exp_2_196(sp_digit* r, const sp_digit* e, int bits, const n |= e[i--] << (11 - c); c += 21; } - y = (n >> 28) & 0xf; + y = (int)((n >> 28) & 0xf); n <<= 4; c -= 4; - sp_4096_lshift_196(r, norm, y); + sp_4096_lshift_196(r, norm, (byte)y); for (; i>=0 || c>=4; ) { if (c < 4) { n |= e[i--] << (11 - c); c += 21; } - y = (n >> 28) & 0xf; + y = (int)((n >> 28) & 0xf); n <<= 4; c -= 4; @@ -12335,7 +12335,7 @@ static int sp_4096_mod_exp_2_196(sp_digit* r, const sp_digit* e, int bits, const sp_4096_mont_sqr_196(r, r, m, mp); sp_4096_mont_sqr_196(r, r, m, mp); - sp_4096_lshift_196(r, r, y); + sp_4096_lshift_196(r, r, (byte)y); sp_4096_mul_d_196(tmp, norm, (r[196] << 20) + (r[195] >> 1)); r[196] = 0; r[195] &= 0x1L; @@ -14947,7 +14947,7 @@ static void sp_256_ecc_recode_6_10(const sp_digit* k, ecc_recode_256* v) n = k[j]; o = 0; for (i=0; i<43; i++) { - y = n; + y = (int8_t)n; if (o + 6 < 26) { y &= 0x3f; n >>= 6; @@ -14961,12 +14961,12 @@ static void sp_256_ecc_recode_6_10(const sp_digit* k, ecc_recode_256* v) } else if (++j < 10) { n = k[j]; - y |= (n << (26 - o)) & 0x3f; + y |= (uint8_t)((n << (26 - o)) & 0x3f); o -= 20; n >>= o; } - y += carry; + y += (uint8_t)carry; v[i].i = recode_index_10_6[y]; v[i].neg = recode_neg_10_6[y]; carry = (y >> 6) + v[i].neg; @@ -15501,7 +15501,7 @@ static int sp_256_ecc_mulmod_stripe_10(sp_point_256* r, const sp_point_256* g, y = 0; for (j=0,x=31; j<8; j++,x+=32) { - y |= ((k[x / 26] >> (x % 26)) & 1) << j; + y |= (int)(((k[x / 26] >> (x % 26)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -15516,7 +15516,7 @@ static int sp_256_ecc_mulmod_stripe_10(sp_point_256* r, const sp_point_256* g, for (i=30; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=32) { - y |= ((k[x / 26] >> (x % 26)) & 1) << j; + y |= (int)(((k[x / 26] >> (x % 26)) & 1) << j); } sp_256_proj_point_dbl_10(rt, rt, t); @@ -17397,7 +17397,7 @@ SP_NOINLINE static void sp_256_mul_d_10(sp_digit* r, const sp_digit* a, for (i = 0; i < 10; i++) { t += tb * a[i]; - r[i] = t & 0x3ffffff; + r[i] = (sp_digit)(t & 0x3ffffff); t >>= 26; } r[10] = (sp_digit)t; @@ -17415,17 +17415,17 @@ SP_NOINLINE static void sp_256_mul_d_10(sp_digit* r, const sp_digit* a, t[ 7] = tb * a[ 7]; t[ 8] = tb * a[ 8]; t[ 9] = tb * a[ 9]; - r[ 0] = (t[ 0] & 0x3ffffff); - r[ 1] = (sp_digit)(t[ 0] >> 26) + (t[ 1] & 0x3ffffff); - r[ 2] = (sp_digit)(t[ 1] >> 26) + (t[ 2] & 0x3ffffff); - r[ 3] = (sp_digit)(t[ 2] >> 26) + (t[ 3] & 0x3ffffff); - r[ 4] = (sp_digit)(t[ 3] >> 26) + (t[ 4] & 0x3ffffff); - r[ 5] = (sp_digit)(t[ 4] >> 26) + (t[ 5] & 0x3ffffff); - r[ 6] = (sp_digit)(t[ 5] >> 26) + (t[ 6] & 0x3ffffff); - r[ 7] = (sp_digit)(t[ 6] >> 26) + (t[ 7] & 0x3ffffff); - r[ 8] = (sp_digit)(t[ 7] >> 26) + (t[ 8] & 0x3ffffff); - r[ 9] = (sp_digit)(t[ 8] >> 26) + (t[ 9] & 0x3ffffff); - r[10] = (sp_digit)(t[ 9] >> 26); + r[ 0] = (sp_digit) (t[ 0] & 0x3ffffff); + r[ 1] = (sp_digit)((t[ 0] >> 26) + (t[ 1] & 0x3ffffff)); + r[ 2] = (sp_digit)((t[ 1] >> 26) + (t[ 2] & 0x3ffffff)); + r[ 3] = (sp_digit)((t[ 2] >> 26) + (t[ 3] & 0x3ffffff)); + r[ 4] = (sp_digit)((t[ 3] >> 26) + (t[ 4] & 0x3ffffff)); + r[ 5] = (sp_digit)((t[ 4] >> 26) + (t[ 5] & 0x3ffffff)); + r[ 6] = (sp_digit)((t[ 5] >> 26) + (t[ 6] & 0x3ffffff)); + r[ 7] = (sp_digit)((t[ 6] >> 26) + (t[ 7] & 0x3ffffff)); + r[ 8] = (sp_digit)((t[ 7] >> 26) + (t[ 8] & 0x3ffffff)); + r[ 9] = (sp_digit)((t[ 8] >> 26) + (t[ 9] & 0x3ffffff)); + r[10] = (sp_digit) (t[ 9] >> 26); #endif /* WOLFSSL_SP_SMALL */ } @@ -21739,7 +21739,7 @@ static void sp_384_ecc_recode_6_15(const sp_digit* k, ecc_recode_384* v) n = k[j]; o = 0; for (i=0; i<65; i++) { - y = n; + y = (int8_t)n; if (o + 6 < 26) { y &= 0x3f; n >>= 6; @@ -21753,12 +21753,12 @@ static void sp_384_ecc_recode_6_15(const sp_digit* k, ecc_recode_384* v) } else if (++j < 15) { n = k[j]; - y |= (n << (26 - o)) & 0x3f; + y |= (uint8_t)((n << (26 - o)) & 0x3f); o -= 20; n >>= o; } - y += carry; + y += (uint8_t)carry; v[i].i = recode_index_15_6[y]; v[i].neg = recode_neg_15_6[y]; carry = (y >> 6) + v[i].neg; @@ -22343,7 +22343,7 @@ static int sp_384_ecc_mulmod_stripe_15(sp_point_384* r, const sp_point_384* g, y = 0; for (j=0,x=47; j<8; j++,x+=48) { - y |= ((k[x / 26] >> (x % 26)) & 1) << j; + y |= (int)(((k[x / 26] >> (x % 26)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -22358,7 +22358,7 @@ static int sp_384_ecc_mulmod_stripe_15(sp_point_384* r, const sp_point_384* g, for (i=46; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=48) { - y |= ((k[x / 26] >> (x % 26)) & 1) << j; + y |= (int)(((k[x / 26] >> (x % 26)) & 1) << j); } sp_384_proj_point_dbl_15(rt, rt, t); @@ -24749,7 +24749,7 @@ SP_NOINLINE static void sp_384_mul_d_15(sp_digit* r, const sp_digit* a, for (i = 0; i < 15; i++) { t += tb * a[i]; - r[i] = t & 0x3ffffff; + r[i] = (sp_digit)(t & 0x3ffffff); t >>= 26; } r[15] = (sp_digit)t; @@ -24772,22 +24772,22 @@ SP_NOINLINE static void sp_384_mul_d_15(sp_digit* r, const sp_digit* a, t[12] = tb * a[12]; t[13] = tb * a[13]; t[14] = tb * a[14]; - r[ 0] = (t[ 0] & 0x3ffffff); - r[ 1] = (sp_digit)(t[ 0] >> 26) + (t[ 1] & 0x3ffffff); - r[ 2] = (sp_digit)(t[ 1] >> 26) + (t[ 2] & 0x3ffffff); - r[ 3] = (sp_digit)(t[ 2] >> 26) + (t[ 3] & 0x3ffffff); - r[ 4] = (sp_digit)(t[ 3] >> 26) + (t[ 4] & 0x3ffffff); - r[ 5] = (sp_digit)(t[ 4] >> 26) + (t[ 5] & 0x3ffffff); - r[ 6] = (sp_digit)(t[ 5] >> 26) + (t[ 6] & 0x3ffffff); - r[ 7] = (sp_digit)(t[ 6] >> 26) + (t[ 7] & 0x3ffffff); - r[ 8] = (sp_digit)(t[ 7] >> 26) + (t[ 8] & 0x3ffffff); - r[ 9] = (sp_digit)(t[ 8] >> 26) + (t[ 9] & 0x3ffffff); - r[10] = (sp_digit)(t[ 9] >> 26) + (t[10] & 0x3ffffff); - r[11] = (sp_digit)(t[10] >> 26) + (t[11] & 0x3ffffff); - r[12] = (sp_digit)(t[11] >> 26) + (t[12] & 0x3ffffff); - r[13] = (sp_digit)(t[12] >> 26) + (t[13] & 0x3ffffff); - r[14] = (sp_digit)(t[13] >> 26) + (t[14] & 0x3ffffff); - r[15] = (sp_digit)(t[14] >> 26); + r[ 0] = (sp_digit) (t[ 0] & 0x3ffffff); + r[ 1] = (sp_digit)((t[ 0] >> 26) + (t[ 1] & 0x3ffffff)); + r[ 2] = (sp_digit)((t[ 1] >> 26) + (t[ 2] & 0x3ffffff)); + r[ 3] = (sp_digit)((t[ 2] >> 26) + (t[ 3] & 0x3ffffff)); + r[ 4] = (sp_digit)((t[ 3] >> 26) + (t[ 4] & 0x3ffffff)); + r[ 5] = (sp_digit)((t[ 4] >> 26) + (t[ 5] & 0x3ffffff)); + r[ 6] = (sp_digit)((t[ 5] >> 26) + (t[ 6] & 0x3ffffff)); + r[ 7] = (sp_digit)((t[ 6] >> 26) + (t[ 7] & 0x3ffffff)); + r[ 8] = (sp_digit)((t[ 7] >> 26) + (t[ 8] & 0x3ffffff)); + r[ 9] = (sp_digit)((t[ 8] >> 26) + (t[ 9] & 0x3ffffff)); + r[10] = (sp_digit)((t[ 9] >> 26) + (t[10] & 0x3ffffff)); + r[11] = (sp_digit)((t[10] >> 26) + (t[11] & 0x3ffffff)); + r[12] = (sp_digit)((t[11] >> 26) + (t[12] & 0x3ffffff)); + r[13] = (sp_digit)((t[12] >> 26) + (t[13] & 0x3ffffff)); + r[14] = (sp_digit)((t[13] >> 26) + (t[14] & 0x3ffffff)); + r[15] = (sp_digit) (t[14] >> 26); #endif /* WOLFSSL_SP_SMALL */ } diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index 978fce2d72..bf698f244b 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -893,7 +893,7 @@ SP_NOINLINE static void sp_2048_mul_d_36(sp_digit* r, const sp_digit* a, for (i = 0; i < 36; i++) { t += tb * a[i]; - r[i] = t & 0x1ffffffffffffffL; + r[i] = (sp_digit)(t & 0x1ffffffffffffffL); t >>= 57; } r[36] = (sp_digit)t; @@ -912,21 +912,21 @@ SP_NOINLINE static void sp_2048_mul_d_36(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } - r[36] = t & 0x1ffffffffffffffL; + r[36] = (sp_digit)(t & 0x1ffffffffffffffL); #endif /* WOLFSSL_SP_SMALL */ } @@ -1236,7 +1236,7 @@ SP_NOINLINE static void sp_2048_mul_d_18(sp_digit* r, const sp_digit* a, for (i = 0; i < 18; i++) { t += tb * a[i]; - r[i] = t & 0x1ffffffffffffffL; + r[i] = (sp_digit)(t & 0x1ffffffffffffffL); t >>= 57; } r[18] = (sp_digit)t; @@ -1255,27 +1255,27 @@ SP_NOINLINE static void sp_2048_mul_d_18(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } t += tb * a[16]; - r[16] = t & 0x1ffffffffffffffL; + r[16] = (sp_digit)(t & 0x1ffffffffffffffL); t >>= 57; t += tb * a[17]; - r[17] = t & 0x1ffffffffffffffL; + r[17] = (sp_digit)(t & 0x1ffffffffffffffL); t >>= 57; - r[18] = t & 0x1ffffffffffffffL; + r[18] = (sp_digit)(t & 0x1ffffffffffffffL); #endif /* WOLFSSL_SP_SMALL */ } @@ -1622,7 +1622,7 @@ static int sp_2048_mod_exp_18(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 57; } - y = (n >> 56) & 1; + y = (int)((n >> 56) & 1); n <<= 1; sp_2048_mont_mul_18(t[y^1], t[0], t[1], m, mp); @@ -1713,7 +1713,7 @@ static int sp_2048_mod_exp_18(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 57; } - y = (n >> 56) & 1; + y = (int)((n >> 56) & 1); n <<= 1; sp_2048_mont_mul_18(t[y^1], t[0], t[1], m, mp); @@ -1841,7 +1841,7 @@ static int sp_2048_mod_exp_18(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (7 - c); c += 57; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; XMEMCPY(rt, t[y], sizeof(sp_digit) * 36); @@ -1850,7 +1850,7 @@ static int sp_2048_mod_exp_18(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (7 - c); c += 57; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; @@ -2569,7 +2569,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 57; } - y = (n >> 56) & 1; + y = (int)((n >> 56) & 1); n <<= 1; sp_2048_mont_mul_36(t[y^1], t[0], t[1], m, mp); @@ -2660,7 +2660,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 57; } - y = (n >> 56) & 1; + y = (int)((n >> 56) & 1); n <<= 1; sp_2048_mont_mul_36(t[y^1], t[0], t[1], m, mp); @@ -2788,7 +2788,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (7 - c); c += 57; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; XMEMCPY(rt, t[y], sizeof(sp_digit) * 72); @@ -2797,7 +2797,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (7 - c); c += 57; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; @@ -3688,16 +3688,16 @@ static int sp_2048_mod_exp_2_36(sp_digit* r, const sp_digit* e, int bits, const n |= e[i--] << (7 - c); c += 57; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; - sp_2048_lshift_36(r, norm, y); + sp_2048_lshift_36(r, norm, (byte)y); for (; i>=0 || c>=5; ) { if (c < 5) { n |= e[i--] << (7 - c); c += 57; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; @@ -3707,7 +3707,7 @@ static int sp_2048_mod_exp_2_36(sp_digit* r, const sp_digit* e, int bits, const sp_2048_mont_sqr_36(r, r, m, mp); sp_2048_mont_sqr_36(r, r, m, mp); - sp_2048_lshift_36(r, r, y); + sp_2048_lshift_36(r, r, (byte)y); sp_2048_mul_d_36(tmp, norm, (r[36] << 4) + (r[35] >> 53)); r[36] = 0; r[35] &= 0x1fffffffffffffL; @@ -5100,7 +5100,7 @@ SP_NOINLINE static void sp_3072_mul_d_54(sp_digit* r, const sp_digit* a, for (i = 0; i < 54; i++) { t += tb * a[i]; - r[i] = t & 0x1ffffffffffffffL; + r[i] = (sp_digit)(t & 0x1ffffffffffffffL); t >>= 57; } r[54] = (sp_digit)t; @@ -5119,27 +5119,27 @@ SP_NOINLINE static void sp_3072_mul_d_54(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } t += tb * a[52]; - r[52] = t & 0x1ffffffffffffffL; + r[52] = (sp_digit)(t & 0x1ffffffffffffffL); t >>= 57; t += tb * a[53]; - r[53] = t & 0x1ffffffffffffffL; + r[53] = (sp_digit)(t & 0x1ffffffffffffffL); t >>= 57; - r[54] = t & 0x1ffffffffffffffL; + r[54] = (sp_digit)(t & 0x1ffffffffffffffL); #endif /* WOLFSSL_SP_SMALL */ } @@ -5467,7 +5467,7 @@ SP_NOINLINE static void sp_3072_mul_d_27(sp_digit* r, const sp_digit* a, for (i = 0; i < 27; i++) { t += tb * a[i]; - r[i] = t & 0x1ffffffffffffffL; + r[i] = (sp_digit)(t & 0x1ffffffffffffffL); t >>= 57; } r[27] = (sp_digit)t; @@ -5486,30 +5486,30 @@ SP_NOINLINE static void sp_3072_mul_d_27(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x1ffffffffffffffL; t >>= 57; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } t += tb * a[24]; - r[24] = t & 0x1ffffffffffffffL; + r[24] = (sp_digit)(t & 0x1ffffffffffffffL); t >>= 57; t += tb * a[25]; - r[25] = t & 0x1ffffffffffffffL; + r[25] = (sp_digit)(t & 0x1ffffffffffffffL); t >>= 57; t += tb * a[26]; - r[26] = t & 0x1ffffffffffffffL; + r[26] = (sp_digit)(t & 0x1ffffffffffffffL); t >>= 57; - r[27] = t & 0x1ffffffffffffffL; + r[27] = (sp_digit)(t & 0x1ffffffffffffffL); #endif /* WOLFSSL_SP_SMALL */ } @@ -5818,7 +5818,7 @@ static int sp_3072_mod_exp_27(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 57; } - y = (n >> 56) & 1; + y = (int)((n >> 56) & 1); n <<= 1; sp_3072_mont_mul_27(t[y^1], t[0], t[1], m, mp); @@ -5909,7 +5909,7 @@ static int sp_3072_mod_exp_27(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 57; } - y = (n >> 56) & 1; + y = (int)((n >> 56) & 1); n <<= 1; sp_3072_mont_mul_27(t[y^1], t[0], t[1], m, mp); @@ -6037,7 +6037,7 @@ static int sp_3072_mod_exp_27(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (7 - c); c += 57; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; XMEMCPY(rt, t[y], sizeof(sp_digit) * 54); @@ -6046,7 +6046,7 @@ static int sp_3072_mod_exp_27(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (7 - c); c += 57; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; @@ -6735,7 +6735,7 @@ static int sp_3072_mod_exp_54(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 57; } - y = (n >> 56) & 1; + y = (int)((n >> 56) & 1); n <<= 1; sp_3072_mont_mul_54(t[y^1], t[0], t[1], m, mp); @@ -6826,7 +6826,7 @@ static int sp_3072_mod_exp_54(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 57; } - y = (n >> 56) & 1; + y = (int)((n >> 56) & 1); n <<= 1; sp_3072_mont_mul_54(t[y^1], t[0], t[1], m, mp); @@ -6954,7 +6954,7 @@ static int sp_3072_mod_exp_54(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (7 - c); c += 57; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; XMEMCPY(rt, t[y], sizeof(sp_digit) * 108); @@ -6963,7 +6963,7 @@ static int sp_3072_mod_exp_54(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (7 - c); c += 57; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; @@ -7890,16 +7890,16 @@ static int sp_3072_mod_exp_2_54(sp_digit* r, const sp_digit* e, int bits, const n |= e[i--] << (7 - c); c += 57; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; - sp_3072_lshift_54(r, norm, y); + sp_3072_lshift_54(r, norm, (byte)y); for (; i>=0 || c>=5; ) { if (c < 5) { n |= e[i--] << (7 - c); c += 57; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; @@ -7909,7 +7909,7 @@ static int sp_3072_mod_exp_2_54(sp_digit* r, const sp_digit* e, int bits, const sp_3072_mont_sqr_54(r, r, m, mp); sp_3072_mont_sqr_54(r, r, m, mp); - sp_3072_lshift_54(r, r, y); + sp_3072_lshift_54(r, r, (byte)y); sp_3072_mul_d_54(tmp, norm, (r[54] << 6) + (r[53] >> 51)); r[54] = 0; r[53] &= 0x7ffffffffffffL; @@ -9352,7 +9352,7 @@ SP_NOINLINE static void sp_4096_mul_d_78(sp_digit* r, const sp_digit* a, for (i = 0; i < 78; i++) { t += tb * a[i]; - r[i] = t & 0x1fffffffffffffL; + r[i] = (sp_digit)(t & 0x1fffffffffffffL); t >>= 53; } r[78] = (sp_digit)t; @@ -9371,27 +9371,27 @@ SP_NOINLINE static void sp_4096_mul_d_78(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x1fffffffffffffL; t >>= 53; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x1fffffffffffffL; t >>= 53; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x1fffffffffffffL; t >>= 53; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x1fffffffffffffL; t >>= 53; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } t += tb * a[76]; - r[76] = t & 0x1fffffffffffffL; + r[76] = (sp_digit)(t & 0x1fffffffffffffL); t >>= 53; t += tb * a[77]; - r[77] = t & 0x1fffffffffffffL; + r[77] = (sp_digit)(t & 0x1fffffffffffffL); t >>= 53; - r[78] = t & 0x1fffffffffffffL; + r[78] = (sp_digit)(t & 0x1fffffffffffffL); #endif /* WOLFSSL_SP_SMALL */ } @@ -9742,7 +9742,7 @@ SP_NOINLINE static void sp_4096_mul_d_39(sp_digit* r, const sp_digit* a, for (i = 0; i < 39; i++) { t += tb * a[i]; - r[i] = t & 0x1fffffffffffffL; + r[i] = (sp_digit)(t & 0x1fffffffffffffL); t >>= 53; } r[39] = (sp_digit)t; @@ -9761,30 +9761,30 @@ SP_NOINLINE static void sp_4096_mul_d_39(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x1fffffffffffffL; t >>= 53; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x1fffffffffffffL; t >>= 53; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x1fffffffffffffL; t >>= 53; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x1fffffffffffffL; t >>= 53; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } t += tb * a[36]; - r[36] = t & 0x1fffffffffffffL; + r[36] = (sp_digit)(t & 0x1fffffffffffffL); t >>= 53; t += tb * a[37]; - r[37] = t & 0x1fffffffffffffL; + r[37] = (sp_digit)(t & 0x1fffffffffffffL); t >>= 53; t += tb * a[38]; - r[38] = t & 0x1fffffffffffffL; + r[38] = (sp_digit)(t & 0x1fffffffffffffL); t >>= 53; - r[39] = t & 0x1fffffffffffffL; + r[39] = (sp_digit)(t & 0x1fffffffffffffL); #endif /* WOLFSSL_SP_SMALL */ } @@ -10122,7 +10122,7 @@ static int sp_4096_mod_exp_39(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 53; } - y = (n >> 52) & 1; + y = (int)((n >> 52) & 1); n <<= 1; sp_4096_mont_mul_39(t[y^1], t[0], t[1], m, mp); @@ -10213,7 +10213,7 @@ static int sp_4096_mod_exp_39(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 53; } - y = (n >> 52) & 1; + y = (int)((n >> 52) & 1); n <<= 1; sp_4096_mont_mul_39(t[y^1], t[0], t[1], m, mp); @@ -10341,7 +10341,7 @@ static int sp_4096_mod_exp_39(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (11 - c); c += 53; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; XMEMCPY(rt, t[y], sizeof(sp_digit) * 78); @@ -10350,7 +10350,7 @@ static int sp_4096_mod_exp_39(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (11 - c); c += 53; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; @@ -10746,7 +10746,7 @@ SP_NOINLINE static void sp_4096_mul_d_156(sp_digit* r, const sp_digit* a, for (i = 0; i < 156; i++) { t += tb * a[i]; - r[i] = t & 0x1fffffffffffffL; + r[i] = (sp_digit)(t & 0x1fffffffffffffL); t >>= 53; } r[156] = (sp_digit)t; @@ -10765,21 +10765,21 @@ SP_NOINLINE static void sp_4096_mul_d_156(sp_digit* r, const sp_digit* a, t += p[0]; t2 = t & 0x1fffffffffffffL; t >>= 53; - r[i + 0] = t2; + r[i + 0] = (sp_digit)t2; t += p[1]; t2 = t & 0x1fffffffffffffL; t >>= 53; - r[i + 1] = t2; + r[i + 1] = (sp_digit)t2; t += p[2]; t2 = t & 0x1fffffffffffffL; t >>= 53; - r[i + 2] = t2; + r[i + 2] = (sp_digit)t2; t += p[3]; t2 = t & 0x1fffffffffffffL; t >>= 53; - r[i + 3] = t2; + r[i + 3] = (sp_digit)t2; } - r[156] = t & 0x1fffffffffffffL; + r[156] = (sp_digit)(t & 0x1fffffffffffffL); #endif /* WOLFSSL_SP_SMALL */ } @@ -11137,7 +11137,7 @@ static int sp_4096_mod_exp_78(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 53; } - y = (n >> 52) & 1; + y = (int)((n >> 52) & 1); n <<= 1; sp_4096_mont_mul_78(t[y^1], t[0], t[1], m, mp); @@ -11228,7 +11228,7 @@ static int sp_4096_mod_exp_78(sp_digit* r, const sp_digit* a, const sp_digit* e, c = 53; } - y = (n >> 52) & 1; + y = (int)((n >> 52) & 1); n <<= 1; sp_4096_mont_mul_78(t[y^1], t[0], t[1], m, mp); @@ -11356,7 +11356,7 @@ static int sp_4096_mod_exp_78(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (11 - c); c += 53; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; XMEMCPY(rt, t[y], sizeof(sp_digit) * 156); @@ -11365,7 +11365,7 @@ static int sp_4096_mod_exp_78(sp_digit* r, const sp_digit* a, const sp_digit* e, n |= e[i--] << (11 - c); c += 53; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; @@ -12340,16 +12340,16 @@ static int sp_4096_mod_exp_2_78(sp_digit* r, const sp_digit* e, int bits, const n |= e[i--] << (11 - c); c += 53; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; - sp_4096_lshift_78(r, norm, y); + sp_4096_lshift_78(r, norm, (byte)y); for (; i>=0 || c>=5; ) { if (c < 5) { n |= e[i--] << (11 - c); c += 53; } - y = (n >> 59) & 0x1f; + y = (int)((n >> 59) & 0x1f); n <<= 5; c -= 5; @@ -12359,7 +12359,7 @@ static int sp_4096_mod_exp_2_78(sp_digit* r, const sp_digit* e, int bits, const sp_4096_mont_sqr_78(r, r, m, mp); sp_4096_mont_sqr_78(r, r, m, mp); - sp_4096_lshift_78(r, r, y); + sp_4096_lshift_78(r, r, (byte)y); sp_4096_mul_d_78(tmp, norm, (r[78] << 38) + (r[77] >> 15)); r[78] = 0; r[77] &= 0x7fffL; @@ -14747,7 +14747,7 @@ static void sp_256_ecc_recode_6_5(const sp_digit* k, ecc_recode_256* v) n = k[j]; o = 0; for (i=0; i<43; i++) { - y = n; + y = (int8_t)n; if (o + 6 < 52) { y &= 0x3f; n >>= 6; @@ -14761,12 +14761,12 @@ static void sp_256_ecc_recode_6_5(const sp_digit* k, ecc_recode_256* v) } else if (++j < 5) { n = k[j]; - y |= (n << (52 - o)) & 0x3f; + y |= (uint8_t)((n << (52 - o)) & 0x3f); o -= 46; n >>= o; } - y += carry; + y += (uint8_t)carry; v[i].i = recode_index_5_6[y]; v[i].neg = recode_neg_5_6[y]; carry = (y >> 6) + v[i].neg; @@ -15251,7 +15251,7 @@ static int sp_256_ecc_mulmod_stripe_5(sp_point_256* r, const sp_point_256* g, y = 0; for (j=0,x=31; j<8; j++,x+=32) { - y |= ((k[x / 52] >> (x % 52)) & 1) << j; + y |= (int)(((k[x / 52] >> (x % 52)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -15266,7 +15266,7 @@ static int sp_256_ecc_mulmod_stripe_5(sp_point_256* r, const sp_point_256* g, for (i=30; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=32) { - y |= ((k[x / 52] >> (x % 52)) & 1) << j; + y |= (int)(((k[x / 52] >> (x % 52)) & 1) << j); } sp_256_proj_point_dbl_5(rt, rt, t); @@ -17146,7 +17146,7 @@ SP_NOINLINE static void sp_256_mul_d_5(sp_digit* r, const sp_digit* a, for (i = 0; i < 5; i++) { t += tb * a[i]; - r[i] = t & 0xfffffffffffffL; + r[i] = (sp_digit)(t & 0xfffffffffffffL); t >>= 52; } r[5] = (sp_digit)t; @@ -17159,12 +17159,12 @@ SP_NOINLINE static void sp_256_mul_d_5(sp_digit* r, const sp_digit* a, t[ 2] = tb * a[ 2]; t[ 3] = tb * a[ 3]; t[ 4] = tb * a[ 4]; - r[ 0] = (t[ 0] & 0xfffffffffffffL); - r[ 1] = (sp_digit)(t[ 0] >> 52) + (t[ 1] & 0xfffffffffffffL); - r[ 2] = (sp_digit)(t[ 1] >> 52) + (t[ 2] & 0xfffffffffffffL); - r[ 3] = (sp_digit)(t[ 2] >> 52) + (t[ 3] & 0xfffffffffffffL); - r[ 4] = (sp_digit)(t[ 3] >> 52) + (t[ 4] & 0xfffffffffffffL); - r[ 5] = (sp_digit)(t[ 4] >> 52); + r[ 0] = (sp_digit) (t[ 0] & 0xfffffffffffffL); + r[ 1] = (sp_digit)((t[ 0] >> 52) + (t[ 1] & 0xfffffffffffffL)); + r[ 2] = (sp_digit)((t[ 1] >> 52) + (t[ 2] & 0xfffffffffffffL)); + r[ 3] = (sp_digit)((t[ 2] >> 52) + (t[ 3] & 0xfffffffffffffL)); + r[ 4] = (sp_digit)((t[ 3] >> 52) + (t[ 4] & 0xfffffffffffffL)); + r[ 5] = (sp_digit) (t[ 4] >> 52); #endif /* WOLFSSL_SP_SMALL */ } @@ -21033,7 +21033,7 @@ static void sp_384_ecc_recode_6_7(const sp_digit* k, ecc_recode_384* v) n = k[j]; o = 0; for (i=0; i<65; i++) { - y = n; + y = (int8_t)n; if (o + 6 < 55) { y &= 0x3f; n >>= 6; @@ -21047,12 +21047,12 @@ static void sp_384_ecc_recode_6_7(const sp_digit* k, ecc_recode_384* v) } else if (++j < 7) { n = k[j]; - y |= (n << (55 - o)) & 0x3f; + y |= (uint8_t)((n << (55 - o)) & 0x3f); o -= 49; n >>= o; } - y += carry; + y += (uint8_t)carry; v[i].i = recode_index_7_6[y]; v[i].neg = recode_neg_7_6[y]; carry = (y >> 6) + v[i].neg; @@ -21557,7 +21557,7 @@ static int sp_384_ecc_mulmod_stripe_7(sp_point_384* r, const sp_point_384* g, y = 0; for (j=0,x=47; j<8; j++,x+=48) { - y |= ((k[x / 55] >> (x % 55)) & 1) << j; + y |= (int)(((k[x / 55] >> (x % 55)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -21572,7 +21572,7 @@ static int sp_384_ecc_mulmod_stripe_7(sp_point_384* r, const sp_point_384* g, for (i=46; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=48) { - y |= ((k[x / 55] >> (x % 55)) & 1) << j; + y |= (int)(((k[x / 55] >> (x % 55)) & 1) << j); } sp_384_proj_point_dbl_7(rt, rt, t); @@ -23962,7 +23962,7 @@ SP_NOINLINE static void sp_384_mul_d_7(sp_digit* r, const sp_digit* a, for (i = 0; i < 7; i++) { t += tb * a[i]; - r[i] = t & 0x7fffffffffffffL; + r[i] = (sp_digit)(t & 0x7fffffffffffffL); t >>= 55; } r[7] = (sp_digit)t; @@ -23977,14 +23977,14 @@ SP_NOINLINE static void sp_384_mul_d_7(sp_digit* r, const sp_digit* a, t[ 4] = tb * a[ 4]; t[ 5] = tb * a[ 5]; t[ 6] = tb * a[ 6]; - r[ 0] = (t[ 0] & 0x7fffffffffffffL); - r[ 1] = (sp_digit)(t[ 0] >> 55) + (t[ 1] & 0x7fffffffffffffL); - r[ 2] = (sp_digit)(t[ 1] >> 55) + (t[ 2] & 0x7fffffffffffffL); - r[ 3] = (sp_digit)(t[ 2] >> 55) + (t[ 3] & 0x7fffffffffffffL); - r[ 4] = (sp_digit)(t[ 3] >> 55) + (t[ 4] & 0x7fffffffffffffL); - r[ 5] = (sp_digit)(t[ 4] >> 55) + (t[ 5] & 0x7fffffffffffffL); - r[ 6] = (sp_digit)(t[ 5] >> 55) + (t[ 6] & 0x7fffffffffffffL); - r[ 7] = (sp_digit)(t[ 6] >> 55); + r[ 0] = (sp_digit) (t[ 0] & 0x7fffffffffffffL); + r[ 1] = (sp_digit)((t[ 0] >> 55) + (t[ 1] & 0x7fffffffffffffL)); + r[ 2] = (sp_digit)((t[ 1] >> 55) + (t[ 2] & 0x7fffffffffffffL)); + r[ 3] = (sp_digit)((t[ 2] >> 55) + (t[ 3] & 0x7fffffffffffffL)); + r[ 4] = (sp_digit)((t[ 3] >> 55) + (t[ 4] & 0x7fffffffffffffL)); + r[ 5] = (sp_digit)((t[ 4] >> 55) + (t[ 5] & 0x7fffffffffffffL)); + r[ 6] = (sp_digit)((t[ 5] >> 55) + (t[ 6] & 0x7fffffffffffffL)); + r[ 7] = (sp_digit) (t[ 6] >> 55); #endif /* WOLFSSL_SP_SMALL */ } diff --git a/wolfcrypt/src/sp_cortexm.c b/wolfcrypt/src/sp_cortexm.c index 348a35b2c9..18d0562cfc 100644 --- a/wolfcrypt/src/sp_cortexm.c +++ b/wolfcrypt/src/sp_cortexm.c @@ -5119,7 +5119,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, y = (int)(n >> c); n <<= 32 - c; } - sp_2048_lshift_64(r, norm, y); + sp_2048_lshift_64(r, norm, (byte)y); for (; i>=0 || c>=5; ) { if (c == 0) { n = e[i--]; @@ -5147,7 +5147,7 @@ static int sp_2048_mod_exp_2_64(sp_digit* r, const sp_digit* e, int bits, sp_2048_mont_sqr_64(r, r, m, mp); sp_2048_mont_sqr_64(r, r, m, mp); - sp_2048_lshift_64(r, r, y); + sp_2048_lshift_64(r, r, (byte)y); sp_2048_mul_d_64(tmp, norm, r[64]); r[64] = 0; o = sp_2048_add_64(r, r, tmp); @@ -10211,7 +10211,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits, y = (int)(n >> c); n <<= 32 - c; } - sp_3072_lshift_96(r, norm, y); + sp_3072_lshift_96(r, norm, (byte)y); for (; i>=0 || c>=5; ) { if (c == 0) { n = e[i--]; @@ -10239,7 +10239,7 @@ static int sp_3072_mod_exp_2_96(sp_digit* r, const sp_digit* e, int bits, sp_3072_mont_sqr_96(r, r, m, mp); sp_3072_mont_sqr_96(r, r, m, mp); - sp_3072_lshift_96(r, r, y); + sp_3072_lshift_96(r, r, (byte)y); sp_3072_mul_d_96(tmp, norm, r[96]); r[96] = 0; o = sp_3072_add_96(r, r, tmp); @@ -13723,7 +13723,7 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits, y = (int)(n >> c); n <<= 32 - c; } - sp_4096_lshift_128(r, norm, y); + sp_4096_lshift_128(r, norm, (byte)y); for (; i>=0 || c>=5; ) { if (c == 0) { n = e[i--]; @@ -13751,7 +13751,7 @@ static int sp_4096_mod_exp_2_128(sp_digit* r, const sp_digit* e, int bits, sp_4096_mont_sqr_128(r, r, m, mp); sp_4096_mont_sqr_128(r, r, m, mp); - sp_4096_lshift_128(r, r, y); + sp_4096_lshift_128(r, r, (byte)y); sp_4096_mul_d_128(tmp, norm, r[128]); r[128] = 0; o = sp_4096_add_128(r, r, tmp); @@ -17699,7 +17699,7 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, y = 0; for (j=0,x=63; j<4; j++,x+=64) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -17714,7 +17714,7 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, for (i=62; i>=0; i--) { y = 0; for (j=0,x=i; j<4; j++,x+=64) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } sp_256_proj_point_dbl_8(rt, rt, t); @@ -18071,7 +18071,7 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, y = 0; for (j=0,x=31; j<8; j++,x+=32) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -18086,7 +18086,7 @@ static int sp_256_ecc_mulmod_stripe_8(sp_point_256* r, const sp_point_256* g, for (i=30; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=32) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } sp_256_proj_point_dbl_8(rt, rt, t); @@ -25157,7 +25157,7 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, y = 0; for (j=0,x=95; j<4; j++,x+=96) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -25172,7 +25172,7 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, for (i=94; i>=0; i--) { y = 0; for (j=0,x=i; j<4; j++,x+=96) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } sp_384_proj_point_dbl_12(rt, rt, t); @@ -25545,7 +25545,7 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, y = 0; for (j=0,x=47; j<8; j++,x+=48) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -25560,7 +25560,7 @@ static int sp_384_ecc_mulmod_stripe_12(sp_point_384* r, const sp_point_384* g, for (i=46; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=48) { - y |= ((k[x / 32] >> (x % 32)) & 1) << j; + y |= (int)(((k[x / 32] >> (x % 32)) & 1) << j); } sp_384_proj_point_dbl_12(rt, rt, t); diff --git a/wolfcrypt/src/sp_x86_64.c b/wolfcrypt/src/sp_x86_64.c index 45ebdf815c..bf7411efb8 100644 --- a/wolfcrypt/src/sp_x86_64.c +++ b/wolfcrypt/src/sp_x86_64.c @@ -7555,7 +7555,7 @@ static void sp_256_ecc_recode_6_4(const sp_digit* k, ecc_recode_256* v) n = k[j]; o = 0; for (i=0; i<43; i++) { - y = n; + y = (int8_t)n; if (o + 6 < 64) { y &= 0x3f; n >>= 6; @@ -7569,12 +7569,12 @@ static void sp_256_ecc_recode_6_4(const sp_digit* k, ecc_recode_256* v) } else if (++j < 4) { n = k[j]; - y |= (n << (64 - o)) & 0x3f; + y |= (uint8_t)((n << (64 - o)) & 0x3f); o -= 58; n >>= o; } - y += carry; + y += (uint8_t)carry; v[i].i = recode_index_4_6[y]; v[i].neg = recode_neg_4_6[y]; carry = (y >> 6) + v[i].neg; @@ -8993,7 +8993,7 @@ static int sp_256_ecc_mulmod_stripe_4(sp_point_256* r, const sp_point_256* g, y = 0; for (j=0,x=42; j<6 && x<256; j++,x+=43) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -9008,7 +9008,7 @@ static int sp_256_ecc_mulmod_stripe_4(sp_point_256* r, const sp_point_256* g, for (i=41; i>=0; i--) { y = 0; for (j=0,x=i; j<6 && x<256; j++,x+=43) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } sp_256_proj_point_dbl_4(rt, rt, t); @@ -9423,7 +9423,7 @@ static int sp_256_ecc_mulmod_stripe_avx2_4(sp_point_256* r, const sp_point_256* y = 0; for (j=0,x=42; j<6 && x<256; j++,x+=43) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -9438,7 +9438,7 @@ static int sp_256_ecc_mulmod_stripe_avx2_4(sp_point_256* r, const sp_point_256* for (i=41; i>=0; i--) { y = 0; for (j=0,x=i; j<6 && x<256; j++,x+=43) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } sp_256_proj_point_dbl_avx2_4(rt, rt, t); @@ -9992,7 +9992,7 @@ static void sp_256_ecc_recode_7_4(const sp_digit* k, ecc_recode_256* v) n = k[j]; o = 0; for (i=0; i<37; i++) { - y = n; + y = (int8_t)n; if (o + 7 < 64) { y &= 0x7f; n >>= 7; @@ -10006,12 +10006,12 @@ static void sp_256_ecc_recode_7_4(const sp_digit* k, ecc_recode_256* v) } else if (++j < 4) { n = k[j]; - y |= (n << (64 - o)) & 0x7f; + y |= (uint8_t)((n << (64 - o)) & 0x7f); o -= 57; n >>= o; } - y += carry; + y += (uint8_t)carry; v[i].i = recode_index_4_7[y]; v[i].neg = recode_neg_4_7[y]; carry = (y >> 7) + v[i].neg; @@ -25889,7 +25889,7 @@ static void sp_384_ecc_recode_6_6(const sp_digit* k, ecc_recode_384* v) n = k[j]; o = 0; for (i=0; i<65; i++) { - y = n; + y = (int8_t)n; if (o + 6 < 64) { y &= 0x3f; n >>= 6; @@ -25903,12 +25903,12 @@ static void sp_384_ecc_recode_6_6(const sp_digit* k, ecc_recode_384* v) } else if (++j < 6) { n = k[j]; - y |= (n << (64 - o)) & 0x3f; + y |= (uint8_t)((n << (64 - o)) & 0x3f); o -= 58; n >>= o; } - y += carry; + y += (uint8_t)carry; v[i].i = recode_index_6_6[y]; v[i].neg = recode_neg_6_6[y]; carry = (y >> 6) + v[i].neg; @@ -27378,7 +27378,7 @@ static int sp_384_ecc_mulmod_stripe_6(sp_point_384* r, const sp_point_384* g, y = 0; for (j=0,x=47; j<8; j++,x+=48) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -27393,7 +27393,7 @@ static int sp_384_ecc_mulmod_stripe_6(sp_point_384* r, const sp_point_384* g, for (i=46; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=48) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } sp_384_proj_point_dbl_6(rt, rt, t); @@ -27806,7 +27806,7 @@ static int sp_384_ecc_mulmod_stripe_avx2_6(sp_point_384* r, const sp_point_384* y = 0; for (j=0,x=47; j<8; j++,x+=48) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } #ifndef WC_NO_CACHE_RESISTANT if (ct) { @@ -27821,7 +27821,7 @@ static int sp_384_ecc_mulmod_stripe_avx2_6(sp_point_384* r, const sp_point_384* for (i=46; i>=0; i--) { y = 0; for (j=0,x=i; j<8; j++,x+=48) { - y |= ((k[x / 64] >> (x % 64)) & 1) << j; + y |= (int)(((k[x / 64] >> (x % 64)) & 1) << j); } sp_384_proj_point_dbl_avx2_6(rt, rt, t);