mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 17:15:38 +01:00
mpi_lt_mpi_ct: fix condition handling
The code previously only set the done flag if the return value was one. This led to overriding the correct return value later on.
This commit is contained in:
parent
b159ae8409
commit
e25f1ee44d
@ -1147,26 +1147,25 @@ int mbedtls_mpi_lt_mpi_ct( const mbedtls_mpi *X, const mbedtls_mpi *Y,
|
|||||||
for( i = X->n; i > 0; i-- )
|
for( i = X->n; i > 0; i-- )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If Y->p[i - 1] < X->p[i - 1] and both X and Y are negative, then
|
* If Y->p[i - 1] < X->p[i - 1] then X < Y is true if and only if both
|
||||||
* X < Y.
|
* X and Y are negative.
|
||||||
*
|
*
|
||||||
* Again even if we can make a decision, we just mark the result and
|
* Again even if we can make a decision, we just mark the result and
|
||||||
* the fact that we are done and continue looping.
|
* the fact that we are done and continue looping.
|
||||||
*/
|
*/
|
||||||
cond = ct_lt_mpi_uint( Y->p[i - 1], X->p[i - 1] ) & X_is_negative;
|
cond = ct_lt_mpi_uint( Y->p[i - 1], X->p[i - 1] );
|
||||||
*ret |= cond & ( 1 - done );
|
*ret |= cond & ( 1 - done ) & X_is_negative;
|
||||||
done |= cond;
|
done |= cond;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If X->p[i - 1] < Y->p[i - 1] and both X and Y are positive, then
|
* If X->p[i - 1] < Y->p[i - 1] then X < Y is true if and only if both
|
||||||
* X < Y.
|
* X and Y are positive.
|
||||||
*
|
*
|
||||||
* Again even if we can make a decision, we just mark the result and
|
* Again even if we can make a decision, we just mark the result and
|
||||||
* the fact that we are done and continue looping.
|
* the fact that we are done and continue looping.
|
||||||
*/
|
*/
|
||||||
cond = ct_lt_mpi_uint( X->p[i - 1], Y->p[i - 1] )
|
cond = ct_lt_mpi_uint( X->p[i - 1], Y->p[i - 1] );
|
||||||
& ( 1 - X_is_negative );
|
*ret |= cond & ( 1 - done ) & ( 1 - X_is_negative );
|
||||||
*ret |= cond & ( 1 - done );
|
|
||||||
done |= cond;
|
done |= cond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user