EC scalar mult with SP Math: fix scalar length check

The support curves in SP all have an order length the same as modulus
length. The scalar cannot be larger than the order and so fix the check.
This commit is contained in:
Sean Parkinson
2023-01-23 10:02:14 +10:00
parent 4b8ab2550d
commit 4592f1a5b4

View File

@ -3465,8 +3465,10 @@ exit:
(void)a;
/* k can't have more bits than modulus count plus 1 */
if (mp_count_bits(k) > mp_count_bits(modulus) + 1) {
/* For supported curves the order is the same length in bits as the modulus.
* Can't have more than order bits for the scalar.
*/
if (mp_count_bits(k) > mp_count_bits(modulus)) {
return ECC_OUT_OF_RANGE_E;
}
if (mp_count_bits(G->x) > mp_count_bits(modulus) ||