]> granicus.if.org Git - esp-idf/commitdiff
Fix losing sign when multiplying by -1
authorAlexey Skalozub <pieceofsummer@gmail.com>
Sat, 28 Oct 2017 00:47:00 +0000 (03:47 +0300)
committerAlexey Skalozub <pieceofsummer@gmail.com>
Sat, 28 Oct 2017 00:47:00 +0000 (03:47 +0300)
components/mbedtls/port/esp_bignum.c

index a9faa2670fe3722d47e293c4dfa62a95a8de72d7..f18652c7bb5a456c43c865369a1677b167596bc2 100644 (file)
@@ -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);