Skip to content

Commit

Permalink
try to make windows happy
Browse files Browse the repository at this point in the history
  • Loading branch information
dkostic committed Jun 27, 2024
1 parent ca05d18 commit 51e9056
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions crypto/fipsmodule/ec/ec_nistp.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,16 @@ static int16_t get_bit(const EC_SCALAR *in, size_t in_bit_size, size_t i) {
// i.e. signed odd digits with _no zeroes_ -- that makes it "regular".
void scalar_rwnaf(int16_t *out, size_t window_size,
const EC_SCALAR *scalar, size_t scalar_bit_size) {
int16_t window, d;
assert(window_size < 14);

const BN_ULONG window_mask = (1 << (window_size + 1)) - 1;
const size_t num_windows = DIV_AND_CEIL(scalar_bit_size, window_size);
// The assert above ensures this works correctly.
const int16_t window_mask = (1 << (window_size + 1)) - 1;
int16_t window = (int16_t)(scalar->words[0] & (BN_ULONG)window_mask);
window |= 1;

window = (scalar->words[0] & window_mask) | 1;
const size_t num_windows = DIV_AND_CEIL(scalar_bit_size, window_size);
for (size_t i = 0; i < num_windows - 1; i++) {
d = (window & window_mask) - (1 << window_size);
int16_t d = (window & window_mask) - (int16_t)(1 << window_size);
out[i] = d;
window = (window - d) >> window_size;
for (size_t j = 1; j <= window_size; j++) {
Expand Down

0 comments on commit 51e9056

Please sign in to comment.