1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-30 22:43:08 +03:00

Use X rather than A for accumulator-style input (and output!) params, and rename others accordingly

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
This commit is contained in:
Tom Cosgrove
2022-09-15 15:55:07 +01:00
parent 5c0e8104bc
commit 3bd7bc3add
2 changed files with 27 additions and 27 deletions

View File

@ -293,8 +293,8 @@ int mbedtls_mpi_core_write_be( const mbedtls_mpi_uint *X,
return( 0 ); return( 0 );
} }
mbedtls_mpi_uint mbedtls_mpi_core_add_if( mbedtls_mpi_uint *A, mbedtls_mpi_uint mbedtls_mpi_core_add_if( mbedtls_mpi_uint *X,
const mbedtls_mpi_uint *B, const mbedtls_mpi_uint *A,
size_t limbs, size_t limbs,
unsigned cond ) unsigned cond )
{ {
@ -305,12 +305,12 @@ mbedtls_mpi_uint mbedtls_mpi_core_add_if( mbedtls_mpi_uint *A,
for( size_t i = 0; i < limbs; i++ ) for( size_t i = 0; i < limbs; i++ )
{ {
mbedtls_mpi_uint add = mask & B[i]; mbedtls_mpi_uint add = mask & A[i];
mbedtls_mpi_uint t = c + A[i]; mbedtls_mpi_uint t = c + X[i];
c = ( t < A[i] ); c = ( t < X[i] );
t += add; t += add;
c += ( t < add ); c += ( t < add );
A[i] = t; X[i] = t;
} }
return( c ); return( c );

View File

@ -163,28 +163,28 @@ int mbedtls_mpi_core_write_be( const mbedtls_mpi_uint *A,
* *
* ``` * ```
* if( cond ) * if( cond )
* A += B; * X += A;
* return carry; * return carry;
* ``` * ```
* *
* \param[in,out] A The pointer to the (little-endian) array * \param[in,out] X The pointer to the (little-endian) array
* representing the bignum to accumulate onto. * representing the bignum to accumulate onto.
* \param[in] B The pointer to the (little-endian) array * \param[in] A The pointer to the (little-endian) array
* representing the bignum to conditionally add * representing the bignum to conditionally add
* to \p A. This may be aliased to \p A but may not * to \p X. This may be aliased to \p X but may not
* overlap otherwise. * overlap otherwise.
* \param limbs Number of limbs of \p A and \p B. * \param limbs Number of limbs of \p X and \p A.
* \param cond Condition bit dictating whether addition should * \param cond Condition bit dictating whether addition should
* happen or not. This must be \c 0 or \c 1. * happen or not. This must be \c 0 or \c 1.
* *
* \warning If \p cond is neither 0 nor 1, the result of this function * \warning If \p cond is neither 0 nor 1, the result of this function
* is unspecified, and the resulting value in \p A might be * is unspecified, and the resulting value in \p X might be
* neither its original value nor \p A + \p B. * neither its original value nor \p X + \p A.
* *
* \return 1 if `A + cond * B >= 2^(biL*limbs)`, 0 otherwise. * \return 1 if `X + cond * A >= 2^(biL*limbs)`, 0 otherwise.
*/ */
mbedtls_mpi_uint mbedtls_mpi_core_add_if( mbedtls_mpi_uint *A, mbedtls_mpi_uint mbedtls_mpi_core_add_if( mbedtls_mpi_uint *X,
const mbedtls_mpi_uint *B, const mbedtls_mpi_uint *A,
size_t limbs, size_t limbs,
unsigned cond ); unsigned cond );
@ -212,24 +212,24 @@ mbedtls_mpi_uint mbedtls_mpi_core_sub( mbedtls_mpi_uint *X,
size_t limbs ); size_t limbs );
/** /**
* \brief Perform a fixed-size multiply accumulate operation: A += c * B * \brief Perform a fixed-size multiply accumulate operation: X += b * A
* *
* \param[in,out] A The pointer to the (little-endian) array * \param[in,out] X The pointer to the (little-endian) array
* representing the bignum to accumulate onto. * representing the bignum to accumulate onto.
* \param A_limbs The number of limbs of \p A. This must be * \param X_limbs The number of limbs of \p X. This must be
* at least \p B_limbs. * at least \p A_limbs.
* \param[in] B The pointer to the (little-endian) array * \param[in] A The pointer to the (little-endian) array
* representing the bignum to multiply with. * representing the bignum to multiply with.
* This may be aliased to \p A but may not overlap * This may be aliased to \p X but may not overlap
* otherwise. * otherwise.
* \param B_limbs The number of limbs of \p B. * \param A_limbs The number of limbs of \p A.
* \param c A scalar to multiply with. * \param b X scalar to multiply with.
* *
* \return The carry at the end of the operation. * \return The carry at the end of the operation.
*/ */
mbedtls_mpi_uint mbedtls_mpi_core_mla( mbedtls_mpi_uint *A, size_t A_limbs, mbedtls_mpi_uint mbedtls_mpi_core_mla( mbedtls_mpi_uint *X, size_t X_limbs,
const mbedtls_mpi_uint *B, size_t B_limbs, const mbedtls_mpi_uint *A, size_t A_limbs,
mbedtls_mpi_uint c ); mbedtls_mpi_uint b );
/** /**
* \brief Calculate initialisation value for fast Montgomery modular * \brief Calculate initialisation value for fast Montgomery modular