- Fixed incorrect handling of negative first input value in mpi_mod_mpi() and mpi_mod_int(). Resulting change also affects mpi_write_string() (found by code coverage tests).
diff --git a/include/polarssl/bignum.h b/include/polarssl/bignum.h
index e6abd59..9c06a3f 100644
--- a/include/polarssl/bignum.h
+++ b/include/polarssl/bignum.h
@@ -308,6 +308,8 @@
/**
* \brief Baseline multiplication: X = A * b
+ * Note: b is an unsigned integer type, thus
+ * Negative values of b are ignored.
*
* \return 0 if successful,
* 1 if memory allocation failed
@@ -341,7 +343,8 @@
*
* \return 0 if successful,
* 1 if memory allocation failed,
- * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0,
+ * POLARSSL_ERR_MPI_NEGATIVE_VALUE if B < 0
*/
int mpi_mod_mpi( mpi *R, mpi *A, mpi *B );
@@ -350,7 +353,8 @@
*
* \return 0 if successful,
* 1 if memory allocation failed,
- * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0
+ * POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0,
+ * POLARSSL_ERR_MPI_NEGATIVE_VALUE if b < 0
*/
int mpi_mod_int( t_int *r, mpi *A, int b );