Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crypto/fipsmodule/ml_dsa/ml_dsa_ref/poly.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ int ml_dsa_poly_chknorm(const ml_dsa_poly *a, int32_t B) {
data but we must not leak the sign of the centralized representative. */
for(i = 0; i < ML_DSA_N; ++i) {
/* Absolute value */
t = a->coeffs[i] >> 31;
t = a->coeffs[i] - (t & 2*a->coeffs[i]);
t = constant_time_select_int(constant_time_msb_w(a->coeffs[i]),
-a->coeffs[i], a->coeffs[i]);

if(t >= B) {
return 1;
Expand Down
3 changes: 2 additions & 1 deletion crypto/fipsmodule/ml_dsa/ml_dsa_ref/reduce.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ int32_t ml_dsa_reduce32(int32_t a) {
* Returns r.
**************************************************/
int32_t ml_dsa_caddq(int32_t a) {
a += (a >> 31) & ML_DSA_Q;
// a = a < 0 ? a + Q : a;
a = constant_time_select_int(constant_time_msb_w(a), a + ML_DSA_Q, a);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: call to undeclared function 'constant_time_msb_w'; ISO C99 and later do not support implicit function declarations [clang-diagnostic-implicit-function-declaration]

  a = constant_time_select_int(constant_time_msb_w(a), a + ML_DSA_Q, a);
                               ^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: call to undeclared function 'constant_time_select_int'; ISO C99 and later do not support implicit function declarations [clang-diagnostic-implicit-function-declaration]

  a = constant_time_select_int(constant_time_msb_w(a), a + ML_DSA_Q, a);
      ^

return a;
}

Expand Down
15 changes: 9 additions & 6 deletions crypto/fipsmodule/ml_dsa/ml_dsa_ref/rounding.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,20 @@ int32_t ml_dsa_decompose(ml_dsa_params *params, int32_t *a0, int32_t a) {

int32_t a1;

a1 = (a + 127) >> 7;
a1 = (a + 127) >> 7;
if (params->gamma2 == (ML_DSA_Q-1)/32) {
a1 = (a1*1025 + (1 << 21)) >> 22;
a1 &= 15;
}
if (params->gamma2 == (ML_DSA_Q-1)/88) {
} else if (params->gamma2 == (ML_DSA_Q-1)/88) {
a1 = (a1*11275 + (1 << 23)) >> 24;
a1 ^= ((43 - a1) >> 31) & a1;
// a1 = 43 < a1 ? 0 : a1;
a1 = constant_time_select_int(constant_time_msb_w(43 - a1), 0, a1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: call to undeclared function 'constant_time_msb_w'; ISO C99 and later do not support implicit function declarations [clang-diagnostic-implicit-function-declaration]

    a1 = constant_time_select_int(constant_time_msb_w(43 - a1), 0, a1);
                                  ^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: call to undeclared function 'constant_time_select_int'; ISO C99 and later do not support implicit function declarations [clang-diagnostic-implicit-function-declaration]

    a1 = constant_time_select_int(constant_time_msb_w(43 - a1), 0, a1);
         ^

}
*a0 = a - a1*2*params->gamma2;
*a0 -= (((ML_DSA_Q-1)/2 - *a0) >> 31) & ML_DSA_Q;

*a0 = a - a1*2*params->gamma2;
// a0 = (Q-1)/2 < a0 ? a0 - Q : a0;
*a0 = constant_time_select_int(constant_time_msb_w((ML_DSA_Q-1)/2 - *a0),
*a0 - ML_DSA_Q, *a0);
return a1;
}

Expand Down
Loading