Clarify some comments
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
bd43f67a9b
commit
392d1010dc
@ -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
|
||||
|
@ -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 );
|
||||
|
Loading…
Reference in New Issue
Block a user