Clarify some comments
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/library/ecp_invasive.h b/library/ecp_invasive.h
index 870d963..b523967 100644
--- a/library/ecp_invasive.h
+++ b/library/ecp_invasive.h
@@ -38,9 +38,10 @@
* - bits is a multiple of 64 or is 224
* - c is -1 or -2
* - 0 <= N < 2^bits
- * - N has room for bits+64 bits
+ * - N has room for bits plus one limb
*
- * Set N to c * 2^bits + N.
+ * Behavior:
+ * Set N to c * 2^bits + old_value_of_N.
*/
void mbedtls_ecp_fix_negative( mbedtls_mpi *N, signed char c, size_t bits );
#endif
diff --git a/tests/suites/test_suite_ecp.function b/tests/suites/test_suite_ecp.function
index 0ca2fdf..6d23377 100644
--- a/tests/suites/test_suite_ecp.function
+++ b/tests/suites/test_suite_ecp.function
@@ -1216,14 +1216,14 @@
mbedtls_mpi_init( &M );
mbedtls_mpi_init( &N );
- /* C = - c * 2^bits */
+ /* C = - c * 2^bits (positive since c is negative) */
TEST_EQUAL( 0, mbedtls_mpi_lset( &C, -c ) );
TEST_EQUAL( 0, mbedtls_mpi_shift_l( &C, bits ) );
TEST_EQUAL( 0, mbedtls_mpi_read_binary( &N, N_bin->x, N_bin->len ) );
TEST_EQUAL( 0, mbedtls_mpi_grow( &N, C.n ) );
- /* M = - ( C - N ) */
+ /* M = N - C = - ( C - N ) (expected result of fix_negative) */
TEST_EQUAL( 0, mbedtls_mpi_sub_mpi( &M, &N, &C ) );
mbedtls_ecp_fix_negative( &N, c, bits );