mirror of
				https://github.com/yuzu-emu/mbedtls.git
				synced 2025-11-04 08:55:03 +00:00 
			
		
		
		
	mbedtls_mpi_lt_mpi_ct: simplify condition
In the case of *ret we might need to preserve a 0 value throughout the loop and therefore we need an extra condition to protect it from being overwritten. The value of done is always 1 after *ret has been set and does not need to be protected from overwriting. Therefore in this case the extra condition can be removed.
This commit is contained in:
		
							parent
							
								
									1f21c1d519
								
							
						
					
					
						commit
						fbe4c947cd
					
				| 
						 | 
					@ -1155,7 +1155,7 @@ int mbedtls_mpi_lt_mpi_ct( const mbedtls_mpi *X, const mbedtls_mpi *Y,
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        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] ) & X_is_negative;
 | 
				
			||||||
        *ret |= cond & ( 1 - done );
 | 
					        *ret |= cond & ( 1 - done );
 | 
				
			||||||
        done |= cond & ( 1 - done );
 | 
					        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] and both X and Y are positive, then
 | 
				
			||||||
| 
						 | 
					@ -1167,7 +1167,7 @@ int mbedtls_mpi_lt_mpi_ct( const mbedtls_mpi *X, const mbedtls_mpi *Y,
 | 
				
			||||||
        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 );
 | 
					               & ( 1 - X_is_negative );
 | 
				
			||||||
        *ret |= cond & ( 1 - done );
 | 
					        *ret |= cond & ( 1 - done );
 | 
				
			||||||
        done |= cond & ( 1 - done );
 | 
					        done |= cond;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return( 0 );
 | 
					    return( 0 );
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue