From 60165d7708746e5d714b63a2fb95bb047fffa17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tautvydas=20=C5=BDilys?= Date: Wed, 26 Jan 2022 15:33:27 -0800 Subject: [PATCH] =?UTF-8?q?Don't=20inline=20mbedtls=5Fmpi=5Fsafe=5Fcond=5F?= =?UTF-8?q?assign=20on=20MSVC/ARM64=20to=20avoid=20a=20compiler=20bug.=20S?= =?UTF-8?q?igned-off-by:=20Tautvydas=20=C5=BDilys=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/constant_time.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/constant_time.c b/library/constant_time.c index d8870ae7f..4dace4896 100644 --- a/library/constant_time.c +++ b/library/constant_time.c @@ -533,6 +533,13 @@ cleanup: * about whether the assignment was made or not. * (Leaking information about the respective sizes of X and Y is ok however.) */ +#if defined(_MSC_VER) && defined(_M_ARM64) +/* + * MSVC miscompiles this function if it's inlined. See: + * https://developercommunity.visualstudio.com/t/c-compiler-miscompiles-part-of-mbedtls-library-on/1646989 + */ +__declspec(noinline) +#endif int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned char assign )