From e9c013c22218981a79d98fe7a472786b68c5fc41 Mon Sep 17 00:00:00 2001 From: Gabor Mezei Date: Mon, 10 Oct 2022 14:26:57 +0200 Subject: [PATCH] Handle if parameters are alised Signed-off-by: Gabor Mezei --- library/bignum_core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/bignum_core.c b/library/bignum_core.c index 233b22ded6..847ed6eb0f 100644 --- a/library/bignum_core.c +++ b/library/bignum_core.c @@ -167,6 +167,9 @@ void mbedtls_mpi_core_cond_assign( mbedtls_mpi_uint *X, size_t limbs, unsigned char assign ) { + if( X == A ) + return; + mbedtls_ct_mpi_uint_cond_assign( limbs, X, A, assign ); } @@ -175,6 +178,9 @@ void mbedtls_mpi_core_cond_swap( mbedtls_mpi_uint *X, size_t limbs, unsigned char swap ) { + if( X == Y ) + return; + /* all-bits 1 if swap is 1, all-bits 0 if swap is 0 */ mbedtls_mpi_uint limb_mask = mbedtls_ct_mpi_uint_mask( swap );