Skip to content

Commit dd980e7

Browse files
committed
no_asm.h: don't fall into endless loop in eucl_inverse_mod_n.
Even though inverse of zero is formally undefined, it's customary to return zero. Reported by Guido Vranken.
1 parent 81cd381 commit dd980e7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/no_asm.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,11 @@ static bool_t eucl_inverse_mod_n(limb_t out[], const limb_t a[],
448448
bool_t ret = 0;
449449
size_t i;
450450

451+
if (vec_is_zero(a, n*sizeof(limb_t))) {
452+
vec_zero(out, n*sizeof(limb_t));
453+
return 0;
454+
}
455+
451456
vec_copy(ux[0], a, sizeof(ux[0]));
452457
if (one != NULL)
453458
vec_copy(ux[1], one, sizeof(ux[1]));

0 commit comments

Comments
 (0)