mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-03-21 22:46:35 +00:00
MPILIB: Fix comparison of negative MPIs
If u and v both represent negative integers and their limb counts happen to differ, mpi_cmp will always return a positive value - this is obviously bogus. u is smaller than v if and only if it is larger in absolute value. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
This commit is contained in:
parent
98dbbcba1b
commit
b9f918a31d
1 changed files with 1 additions and 1 deletions
|
@ -57,7 +57,7 @@ int mpi_cmp(MPI u, MPI v)
|
||||||
if (usize != vsize && !u->sign && !v->sign)
|
if (usize != vsize && !u->sign && !v->sign)
|
||||||
return usize - vsize;
|
return usize - vsize;
|
||||||
if (usize != vsize && u->sign && v->sign)
|
if (usize != vsize && u->sign && v->sign)
|
||||||
return vsize + usize;
|
return vsize - usize;
|
||||||
if (!usize)
|
if (!usize)
|
||||||
return 0;
|
return 0;
|
||||||
cmp = mpihelp_cmp(u->d, v->d, usize);
|
cmp = mpihelp_cmp(u->d, v->d, usize);
|
||||||
|
|
Loading…
Add table
Reference in a new issue