Skip to content
Open
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
10 changes: 10 additions & 0 deletions ecc/ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,16 @@ int ecc_ecdsa_validate(const uint32_t *x, const uint32_t *y, const uint32_t *e,
if (isZero(r) || isZero(s))
return -1;

/* r and s must be in [1, n-1]; otherwise fieldInv(s) below can loop
* forever when s is a multiple of the order n (e.g. s == n). sub()
* returns borrow == 1 iff the value is < n. */
{
uint32_t tmp_cmp[8];
if (sub(r, ecc_order_m, tmp_cmp, arrayLength) == 0 ||
sub(s, ecc_order_m, tmp_cmp, arrayLength) == 0)
return -1;
}

// 3. Calculate w = s^{-1} \pmod{n}
fieldInv(s, ecc_order_m, ecc_order_r, w);

Expand Down
Loading