From: Alexey Skalozub Date: Sat, 28 Oct 2017 00:47:00 +0000 (+0300) Subject: Fix losing sign when multiplying by -1 X-Git-Tag: v3.1-dev~95^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=54052559280563002eab746eb2f2eb2bb77216e1;p=esp-idf Fix losing sign when multiplying by -1 --- diff --git a/components/mbedtls/port/esp_bignum.c b/components/mbedtls/port/esp_bignum.c index a9faa2670f..f18652c7bb 100644 --- a/components/mbedtls/port/esp_bignum.c +++ b/components/mbedtls/port/esp_bignum.c @@ -497,10 +497,14 @@ int mbedtls_mpi_mul_mpi( mbedtls_mpi *Z, const mbedtls_mpi *X, const mbedtls_mpi return 0; } if (bits_x == 1) { - return mbedtls_mpi_copy(Z, Y); + ret = mbedtls_mpi_copy(Z, Y); + Z->s *= X->s; + return ret; } if (bits_y == 1) { - return mbedtls_mpi_copy(Z, X); + ret = mbedtls_mpi_copy(Z, X); + Z->s *= Y->s; + return ret; } words_mult = (words_x > words_y ? words_x : words_y);