Fix an incorrect comment about fix_negative

We're subtracting multiples of 2^bits, not 2^(bits+32).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2021-04-03 21:40:11 +02:00
parent 618be2ec41
commit 349b37273e

View file

@ -1034,7 +1034,7 @@ static inline void sub32( uint32_t *dst, uint32_t src, signed char *carry )
/* /*
* If the result is negative, we get it in the form * If the result is negative, we get it in the form
* c * 2^(bits + 32) + N, with c negative and N positive shorter than 'bits' * c * 2^bits + N, with c negative and N positive shorter than 'bits'
*/ */
MBEDTLS_STATIC_TESTABLE MBEDTLS_STATIC_TESTABLE
void mbedtls_ecp_fix_negative( mbedtls_mpi *N, signed char c, size_t bits ) void mbedtls_ecp_fix_negative( mbedtls_mpi *N, signed char c, size_t bits )
@ -1049,8 +1049,8 @@ void mbedtls_ecp_fix_negative( mbedtls_mpi *N, signed char c, size_t bits )
} }
N->s = -1; N->s = -1;
/* Add |c| * 2^(bits + 32) to the absolute value. Since c and N are /* Add |c| * 2^bits to the absolute value. Since c and N are
* negative, this adds c * 2^(bits + 32). */ * negative, this adds c * 2^bits. */
mbedtls_mpi_uint msw = (mbedtls_mpi_uint) -c; mbedtls_mpi_uint msw = (mbedtls_mpi_uint) -c;
#if defined(MBEDTLS_HAVE_INT64) #if defined(MBEDTLS_HAVE_INT64)
if( bits == 224 ) if( bits == 224 )