mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-25 09:02:48 +00:00
Introduce MBEDTLS_MPI_IS_TEST
A + B + 1 is not a good way to get a number that's neither A nor B. This can be a problem for example if values later are changed to A = 0 and B = -1. Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
55be79b500
commit
42f72b3ea5
@ -747,8 +747,7 @@ static void exp_mod_precompute_window(const mbedtls_mpi_uint *A,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MBEDTLS_TEST_HOOKS) && !defined(MBEDTLS_THREADING_C)
|
#if defined(MBEDTLS_TEST_HOOKS) && !defined(MBEDTLS_THREADING_C)
|
||||||
// Set to a default that is neither MBEDTLS_MPI_IS_PUBLIC nor MBEDTLS_MPI_IS_SECRET
|
int mbedtls_mpi_optionally_safe_codepath = MBEDTLS_MPI_IS_TEST;
|
||||||
int mbedtls_mpi_optionally_safe_codepath = MBEDTLS_MPI_IS_PUBLIC + MBEDTLS_MPI_IS_SECRET + 1;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -110,6 +110,10 @@
|
|||||||
* other than the two below is passed, default to the safe path.) */
|
* other than the two below is passed, default to the safe path.) */
|
||||||
#define MBEDTLS_MPI_IS_PUBLIC 0x2a2a2a2a
|
#define MBEDTLS_MPI_IS_PUBLIC 0x2a2a2a2a
|
||||||
#define MBEDTLS_MPI_IS_SECRET 0
|
#define MBEDTLS_MPI_IS_SECRET 0
|
||||||
|
#if defined(MBEDTLS_TEST_HOOKS) && !defined(MBEDTLS_THREADING_C)
|
||||||
|
// Default value for testing that is neither MBEDTLS_MPI_IS_PUBLIC nor MBEDTLS_MPI_IS_SECRET
|
||||||
|
#define MBEDTLS_MPI_IS_TEST 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Count leading zero bits in a given integer.
|
/** Count leading zero bits in a given integer.
|
||||||
*
|
*
|
||||||
@ -825,8 +829,7 @@ extern int mbedtls_mpi_optionally_safe_codepath;
|
|||||||
|
|
||||||
static inline void mbedtls_mpi_optionally_safe_codepath_reset(void)
|
static inline void mbedtls_mpi_optionally_safe_codepath_reset(void)
|
||||||
{
|
{
|
||||||
// Set to a default that is neither MBEDTLS_MPI_IS_PUBLIC nor MBEDTLS_MPI_IS_SECRET
|
mbedtls_mpi_optionally_safe_codepath = MBEDTLS_MPI_IS_TEST;
|
||||||
mbedtls_mpi_optionally_safe_codepath = MBEDTLS_MPI_IS_PUBLIC + MBEDTLS_MPI_IS_SECRET + 1;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user