From 392d1010dc460eccd498932d8b25c127b0714ce1 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 9 Apr 2021 15:46:51 +0200 Subject: [PATCH] Clarify some comments Signed-off-by: Gilles Peskine --- library/ecp_invasive.h | 5 +++-- tests/suites/test_suite_ecp.function | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/library/ecp_invasive.h b/library/ecp_invasive.h index 870d9637c..b5239676f 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 0ca2fdf4d..6d23377f3 100644 --- a/tests/suites/test_suite_ecp.function +++ b/tests/suites/test_suite_ecp.function @@ -1216,14 +1216,14 @@ void fix_negative( data_t *N_bin, int c, int bits ) 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 );