mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-24 11:16:45 +00:00
Make mbedtls_cf_size_mask_lt function static
The mbedtls_cf_size_mask_lt is solely used as an auxiliary function for mbedtls_cf_size_mask_ge. Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
parent
d5a392aa2c
commit
2c5ed2244b
|
@ -103,8 +103,20 @@ mbedtls_mpi_uint mbedtls_cf_mpi_uint_mask( mbedtls_mpi_uint value )
|
||||||
|
|
||||||
#endif /* MBEDTLS_BIGNUM_C */
|
#endif /* MBEDTLS_BIGNUM_C */
|
||||||
|
|
||||||
size_t mbedtls_cf_size_mask_lt( size_t x,
|
/** Constant-flow mask generation for "less than" comparison:
|
||||||
size_t y )
|
* - if \p x < \p y, return all-bits 1, that is (size_t) -1
|
||||||
|
* - otherwise, return all bits 0, that is 0
|
||||||
|
*
|
||||||
|
* This function can be used to write constant-time code by replacing branches
|
||||||
|
* with bit operations using masks.
|
||||||
|
*
|
||||||
|
* \param x The first value to analyze.
|
||||||
|
* \param y The second value to analyze.
|
||||||
|
*
|
||||||
|
* \return All-bits-one if \p x is less than \p y, otherwise zero.
|
||||||
|
*/
|
||||||
|
static size_t mbedtls_cf_size_mask_lt( size_t x,
|
||||||
|
size_t y )
|
||||||
{
|
{
|
||||||
/* This has the most significant bit set if and only if x < y */
|
/* This has the most significant bit set if and only if x < y */
|
||||||
const size_t sub = x - y;
|
const size_t sub = x - y;
|
||||||
|
|
|
@ -104,24 +104,6 @@ mbedtls_mpi_uint mbedtls_cf_mpi_uint_mask( mbedtls_mpi_uint value );
|
||||||
|
|
||||||
#endif /* MBEDTLS_BIGNUM_C */
|
#endif /* MBEDTLS_BIGNUM_C */
|
||||||
|
|
||||||
/** Constant-flow mask generation for "less than" comparison:
|
|
||||||
* - if \p x < \p y, return all-bits 1, that is (size_t) -1
|
|
||||||
* - otherwise, return all bits 0, that is 0
|
|
||||||
*
|
|
||||||
* This function can be used to write constant-time code by replacing branches
|
|
||||||
* with bit operations using masks.
|
|
||||||
*
|
|
||||||
* This function is implemented without using comparison operators, as those
|
|
||||||
* might be translated to branches by some compilers on some platforms.
|
|
||||||
*
|
|
||||||
* \param x The first value to analyze.
|
|
||||||
* \param y The second value to analyze.
|
|
||||||
*
|
|
||||||
* \return All-bits-one if \p x is less than \p y, otherwise zero.
|
|
||||||
*/
|
|
||||||
size_t mbedtls_cf_size_mask_lt( size_t x,
|
|
||||||
size_t y );
|
|
||||||
|
|
||||||
/** Constant-flow mask generation for "greater or equal" comparison:
|
/** Constant-flow mask generation for "greater or equal" comparison:
|
||||||
* - if \p x >= \p y, return all-bits 1, that is (size_t) -1
|
* - if \p x >= \p y, return all-bits 1, that is (size_t) -1
|
||||||
* - otherwise, return all bits 0, that is 0
|
* - otherwise, return all bits 0, that is 0
|
||||||
|
|
Loading…
Reference in a new issue