@@ -1884,17 +1884,17 @@ static void dilithium_decode_gamma1_c(const byte* s, int bits, sword32* z)
18841884 #endif
18851885 #else
18861886 z [i + 0 ] = DILITHIUM_GAMMA1_17 -
1887- ( s [ 0 ] | ((sword32 )( s [ 1 ] << 8 ) |
1887+ ( ( sword32 ) s [ 0 ] | ((( sword32 )s [ 1 ] << 8 ) |
18881888 (sword32 )(s [ 2 ] & 0x03 ) << 16 ));
18891889 z [i + 1 ] = DILITHIUM_GAMMA1_17 -
1890- ((s [ 2 ] >> 2 ) | ((sword32 )( s [ 3 ] << 6 ) |
1890+ ((( sword32 ) s [ 2 ] >> 2 ) | ((( sword32 )s [ 3 ] << 6 ) |
18911891 (sword32 )(s [ 4 ] & 0x0f ) << 14 ));
18921892 z [i + 2 ] = DILITHIUM_GAMMA1_17 -
1893- ((s [ 4 ] >> 4 ) | ((sword32 )( s [ 5 ] << 4 ) |
1893+ ((( sword32 ) s [ 4 ] >> 4 ) | ((( sword32 )s [ 5 ] << 4 ) |
18941894 (sword32 )(s [ 6 ] & 0x3f ) << 12 ));
18951895 z [i + 3 ] = DILITHIUM_GAMMA1_17 -
1896- ((s [ 6 ] >> 6 ) | ((sword32 )( s [ 7 ] << 2 ) |
1897- (sword32 )( s [ 8 ] ) << 10 ));
1896+ ((( sword32 ) s [ 6 ] >> 6 ) | ((( sword32 )s [ 7 ] << 2 ) |
1897+ (( sword32 )s [ 8 ] ) << 10 ));
18981898 #endif
18991899 /* Move to next place to decode from. */
19001900 s += DILITHIUM_GAMMA1_17_ENC_BITS / 2 ;
@@ -1948,29 +1948,29 @@ static void dilithium_decode_gamma1_c(const byte* s, int bits, sword32* z)
19481948 #endif
19491949 #else
19501950 z [i + 0 ] = (sword32 )((word32 )DILITHIUM_GAMMA1_17 -
1951- ( s [ 0 ] | ((sword32 )( s [ 1 ] << 8 ) |
1952- (sword32 )( s [ 2 ] & 0x03 ) << 16 )));
1951+ ( ( sword32 ) s [ 0 ] | ((( sword32 )s [ 1 ] << 8 ) |
1952+ (( sword32 )s [ 2 ] & 0x03 ) << 16 )));
19531953 z [i + 1 ] = (sword32 )((word32 )DILITHIUM_GAMMA1_17 -
1954- ((s [ 2 ] >> 2 ) | ((sword32 )( s [ 3 ] << 6 ) |
1955- (sword32 )( s [ 4 ] & 0x0f ) << 14 )));
1954+ ((( sword32 ) s [ 2 ] >> 2 ) | ((( sword32 )s [ 3 ] << 6 ) |
1955+ (( sword32 )s [ 4 ] & 0x0f ) << 14 )));
19561956 z [i + 2 ] = (sword32 )((word32 )DILITHIUM_GAMMA1_17 -
1957- ((s [ 4 ] >> 4 ) | ((sword32 )( s [ 5 ] << 4 ) |
1958- (sword32 )( s [ 6 ] & 0x3f ) << 12 )));
1957+ ((( sword32 ) s [ 4 ] >> 4 ) | ((( sword32 )s [ 5 ] << 4 ) |
1958+ (( sword32 )s [ 6 ] & 0x3f ) << 12 )));
19591959 z [i + 3 ] = (sword32 )((word32 )DILITHIUM_GAMMA1_17 -
1960- ((s [ 6 ] >> 6 ) | ((sword32 )( s [ 7 ] << 2 ) |
1961- (sword32 )( s [ 8 ] ) << 10 )));
1960+ ((( sword32 ) s [ 6 ] >> 6 ) | ((( sword32 )s [ 7 ] << 2 ) |
1961+ (( sword32 )s [ 8 ] ) << 10 )));
19621962 z [i + 4 ] = (sword32 )((word32 )DILITHIUM_GAMMA1_17 -
1963- ( s [ 9 ] | ((sword32 )( s [10 ] << 8 ) |
1964- (sword32 )( s [11 ] & 0x03 ) << 16 )));
1963+ ( ( sword32 ) s [ 9 ] | ((( sword32 )s [10 ] << 8 ) |
1964+ (( sword32 )s [11 ] & 0x03 ) << 16 )));
19651965 z [i + 5 ] = (sword32 )((word32 )DILITHIUM_GAMMA1_17 -
1966- ((s [11 ] >> 2 ) | ((sword32 )( s [12 ] << 6 ) |
1967- (sword32 )( s [13 ] & 0x0f ) << 14 )));
1966+ ((( sword32 ) s [11 ] >> 2 ) | ((( sword32 )s [12 ] << 6 ) |
1967+ (( sword32 )s [13 ] & 0x0f ) << 14 )));
19681968 z [i + 6 ] = (sword32 )((word32 )DILITHIUM_GAMMA1_17 -
1969- ((s [13 ] >> 4 ) | ((sword32 )( s [14 ] << 4 ) |
1970- (sword32 )( s [15 ] & 0x3f ) << 12 )));
1969+ ((( sword32 ) s [13 ] >> 4 ) | ((( sword32 )s [14 ] << 4 ) |
1970+ (( sword32 )s [15 ] & 0x3f ) << 12 )));
19711971 z [i + 7 ] = (sword32 )((word32 )DILITHIUM_GAMMA1_17 -
1972- ((s [15 ] >> 6 ) | ((sword32 )( s [16 ] << 2 ) |
1973- (sword32 )( s [17 ] ) << 10 )));
1972+ ((( sword32 ) s [15 ] >> 6 ) | ((( sword32 )s [16 ] << 2 ) |
1973+ (( sword32 )s [17 ] ) << 10 )));
19741974 #endif
19751975 /* Move to next place to decode from. */
19761976 s += DILITHIUM_GAMMA1_17_ENC_BITS ;
@@ -2005,14 +2005,18 @@ static void dilithium_decode_gamma1_c(const byte* s, int bits, sword32* z)
20052005 ((sword32 )s16_0 << 4 ));
20062006 #endif
20072007 #else
2008- z [i + 0 ] = DILITHIUM_GAMMA1_19 - ( s [0 ] | ((sword32 )s [1 ] << 8 ) |
2009- ((sword32 )(s [2 ] & 0x0f ) << 16 ));
2010- z [i + 1 ] = DILITHIUM_GAMMA1_19 - ((s [2 ] >> 4 ) | ((sword32 )s [3 ] << 4 ) |
2011- ((sword32 )(s [4 ] ) << 12 ));
2012- z [i + 2 ] = DILITHIUM_GAMMA1_19 - ( s [5 ] | ((sword32 )s [6 ] << 8 ) |
2013- ((sword32 )(s [7 ] & 0x0f ) << 16 ));
2014- z [i + 3 ] = DILITHIUM_GAMMA1_19 - ((s [7 ] >> 4 ) | ((sword32 )s [8 ] << 4 ) |
2015- ((sword32 )(s [9 ] ) << 12 ));
2008+ z [i + 0 ] = DILITHIUM_GAMMA1_19 -
2009+ ( (sword32 )s [0 ] | ((sword32 )s [1 ] << 8 ) |
2010+ (((sword32 )s [2 ] & 0x0f ) << 16 ));
2011+ z [i + 1 ] = DILITHIUM_GAMMA1_19 -
2012+ (((sword32 )s [2 ] >> 4 ) | ((sword32 )s [3 ] << 4 ) |
2013+ (((sword32 )s [4 ] ) << 12 ));
2014+ z [i + 2 ] = DILITHIUM_GAMMA1_19 -
2015+ ( (sword32 )s [5 ] | ((sword32 )s [6 ] << 8 ) |
2016+ (((sword32 )s [7 ] & 0x0f ) << 16 ));
2017+ z [i + 3 ] = DILITHIUM_GAMMA1_19 -
2018+ (((sword32 )s [7 ] >> 4 ) | ((sword32 )s [8 ] << 4 ) |
2019+ (((sword32 )s [9 ] ) << 12 ));
20162020 #endif
20172021 /* Move to next place to decode from. */
20182022 s += DILITHIUM_GAMMA1_19_ENC_BITS / 2 ;
@@ -2065,30 +2069,38 @@ static void dilithium_decode_gamma1_c(const byte* s, int bits, sword32* z)
20652069 ((sword32 )s16_1 << 4 ));
20662070 #endif
20672071 #else
2068- z [i + 0 ] = DILITHIUM_GAMMA1_19 - ( s [ 0 ] |
2069- ((sword32 )s [ 1 ] << 8 ) |
2070- ((sword32 )(s [ 2 ] & 0x0f ) << 16 ));
2071- z [i + 1 ] = DILITHIUM_GAMMA1_19 - ((s [ 2 ] >> 4 ) |
2072- ((sword32 ) s [ 3 ] << 4 ) |
2073- ((sword32 )(s [ 4 ] ) << 12 ));
2074- z [i + 2 ] = DILITHIUM_GAMMA1_19 - ( s [ 5 ] |
2075- ((sword32 ) s [ 6 ] << 8 ) |
2076- ((sword32 )(s [ 7 ] & 0x0f ) << 16 ));
2077- z [i + 3 ] = DILITHIUM_GAMMA1_19 - ((s [ 7 ] >> 4 ) |
2078- ((sword32 ) s [ 8 ] << 4 ) |
2079- ((sword32 )(s [ 9 ] ) << 12 ));
2080- z [i + 4 ] = DILITHIUM_GAMMA1_19 - ( s [10 ] |
2081- ((sword32 ) s [11 ] << 8 ) |
2082- ((sword32 )(s [12 ] & 0x0f ) << 16 ));
2083- z [i + 5 ] = DILITHIUM_GAMMA1_19 - ((s [12 ] >> 4 ) |
2084- ((sword32 ) s [13 ] << 4 ) |
2085- ((sword32 )(s [14 ] ) << 12 ));
2086- z [i + 6 ] = DILITHIUM_GAMMA1_19 - ( s [15 ] |
2087- ((sword32 ) s [16 ] << 8 ) |
2088- ((sword32 )(s [17 ] & 0x0f ) << 16 ));
2089- z [i + 7 ] = DILITHIUM_GAMMA1_19 - ((s [17 ] >> 4 ) |
2090- ((sword32 ) s [18 ] << 4 ) |
2091- ((sword32 )(s [19 ] ) << 12 ));
2072+ z [i + 0 ] = DILITHIUM_GAMMA1_19 -
2073+ ( (sword32 )s [ 0 ] |
2074+ ( (sword32 )s [ 1 ] << 8 ) |
2075+ (((sword32 )s [ 2 ] & 0x0f ) << 16 ));
2076+ z [i + 1 ] = DILITHIUM_GAMMA1_19 -
2077+ (((sword32 )s [ 2 ] >> 4 ) |
2078+ ( (sword32 )s [ 3 ] << 4 ) |
2079+ (((sword32 )s [ 4 ] ) << 12 ));
2080+ z [i + 2 ] = DILITHIUM_GAMMA1_19 -
2081+ ( (sword32 )s [ 5 ] |
2082+ ( (sword32 )s [ 6 ] << 8 ) |
2083+ (((sword32 )s [ 7 ] & 0x0f ) << 16 ));
2084+ z [i + 3 ] = DILITHIUM_GAMMA1_19 -
2085+ ( ((sword32 )s [ 7 ] >> 4 ) |
2086+ ( (sword32 )s [ 8 ] << 4 ) |
2087+ (((sword32 )s [ 9 ] ) << 12 ));
2088+ z [i + 4 ] = DILITHIUM_GAMMA1_19 -
2089+ ( (sword32 )s [10 ] |
2090+ ( (sword32 )s [11 ] << 8 ) |
2091+ (((sword32 )s [12 ] & 0x0f ) << 16 ));
2092+ z [i + 5 ] = DILITHIUM_GAMMA1_19 -
2093+ ( ((sword32 )s [12 ] >> 4 ) |
2094+ ( (sword32 )s [13 ] << 4 ) |
2095+ (((sword32 )s [14 ] ) << 12 ));
2096+ z [i + 6 ] = DILITHIUM_GAMMA1_19 -
2097+ ( (sword32 )s [15 ] |
2098+ ( (sword32 )s [16 ] << 8 ) |
2099+ (((sword32 )s [17 ] & 0x0f ) << 16 ));
2100+ z [i + 7 ] = DILITHIUM_GAMMA1_19 -
2101+ ( ((sword32 )s [17 ] >> 4 ) |
2102+ ( (sword32 )s [18 ] << 4 ) |
2103+ (((sword32 )s [19 ] ) << 12 ));
20922104 #endif
20932105 /* Move to next place to decode from. */
20942106 s += DILITHIUM_GAMMA1_19_ENC_BITS ;
@@ -2868,7 +2880,7 @@ static int wc_mldsa_gen_matrix_6x5_avx2(sword32* a, byte* seed)
28682880 }
28692881
28702882 for (l = 0 ; l < 2 ; l ++ ) {
2871- state [4 * 4 + l ] = 0x1f0000 + (5 << 8 ) + (l + 3 );
2883+ state [4 * 4 + l ] = 0x1f0000 + (( word32 ) 5 << 8 ) + (l + 3 );
28722884 }
28732885
28742886 sha3_128_blocksx4_seed_avx2 (state , seed );
@@ -5451,7 +5463,7 @@ static sword32 dilithium_mont_red(sword64 a)
54515463 */
54525464static sword32 dilithium_red (sword32 a )
54535465{
5454- sword32 t = (sword32 )((a + (1 << 22 )) >> 23 );
5466+ sword32 t = (sword32 )((a + (( sword32 ) 1 << 22 )) >> 23 );
54555467#ifndef DILITHIUM_MUL_Q_SLOW
54565468 return (sword32 )(a - (t * DILITHIUM_Q ));
54575469#else
@@ -8252,7 +8264,7 @@ static int dilithium_sign_with_seed_mu(dilithium_key* key,
82528264 params -> gamma1_bits , y , params -> l );
82538265 #ifdef WOLFSSL_DILITHIUM_SIGN_CHECK_Y
82548266 valid = dilithium_vec_check_low (y , params -> l ,
8255- (1 << params -> gamma1_bits ) - params -> beta );
8267+ (( sword32 ) 1 << params -> gamma1_bits ) - params -> beta );
82568268 if (valid )
82578269 #endif
82588270 {
@@ -8306,7 +8318,7 @@ static int dilithium_sign_with_seed_mu(dilithium_key* key,
83068318 valid = dilithium_vec_check_low (w0 + i * DILITHIUM_N , 1 ,
83078319 hi );
83088320 }
8309- hi = (1 << params -> gamma1_bits ) - params -> beta ;
8321+ hi = (( sword32 ) 1 << params -> gamma1_bits ) - params -> beta ;
83108322 for (i = 0 ; valid && i < params -> l ; i ++ ) {
83118323 /* Step 19: cs1 = NTT-1(c o s1) */
83128324 dilithium_mul (z + i * DILITHIUM_N , c ,
@@ -8515,7 +8527,7 @@ static int dilithium_sign_with_seed_mu(dilithium_key* key,
85158527 params -> gamma1_bits , y , params -> l );
85168528 #ifdef WOLFSSL_DILITHIUM_SIGN_CHECK_Y
85178529 valid = dilithium_vec_check_low (y , params -> l ,
8518- (1 << params -> gamma1_bits ) - params -> beta );
8530+ (( sword32 ) 1 << params -> gamma1_bits ) - params -> beta );
85198531 #endif
85208532
85218533 #ifdef WOLFSSL_DILITHIUM_SIGN_SMALL_MEM_PRECALC_A
@@ -8743,7 +8755,7 @@ static int dilithium_sign_with_seed_mu(dilithium_key* key,
87438755 dilithium_add (z , yt );
87448756 dilithium_poly_red (z );
87458757 /* Step 23: Check z has low enough values. */
8746- hi = (1 << params -> gamma1_bits ) - params -> beta ;
8758+ hi = (( sword32 ) 1 << params -> gamma1_bits ) - params -> beta ;
87478759 valid = dilithium_check_low (z , hi );
87488760 if (valid ) {
87498761 /* Step 32: Encode z into signature.
@@ -9385,7 +9397,7 @@ static int dilithium_verify_mu(dilithium_key* key, const byte* mu,
93859397 /* Step 2: Decode z from signature. */
93869398 dilithium_vec_decode_gamma1 (ze , params -> l , params -> gamma1_bits , z );
93879399 /* Step 13: Check z is valid - values are low enough. */
9388- hi = (1 << params -> gamma1_bits ) - params -> beta ;
9400+ hi = (( sword32 ) 1 << params -> gamma1_bits ) - params -> beta ;
93899401 valid = dilithium_vec_check_low (z , params -> l , hi );
93909402 }
93919403 if ((ret == 0 ) && valid ) {
@@ -9524,7 +9536,7 @@ static int dilithium_verify_mu(dilithium_key* key, const byte* mu,
95249536 /* Step 2: Decode z from signature. */
95259537 dilithium_vec_decode_gamma1 (ze , params -> l , params -> gamma1_bits , z );
95269538 /* Step 13: Check z is valid - values are low enough. */
9527- hi = (1 << params -> gamma1_bits ) - params -> beta ;
9539+ hi = (( sword32 ) 1 << params -> gamma1_bits ) - params -> beta ;
95289540 valid = dilithium_vec_check_low (z , params -> l , hi );
95299541 }
95309542 if ((ret == 0 ) && valid ) {
0 commit comments