1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-12-24 17:41:01 +03:00

Apply the function parameter naming convention

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
This commit is contained in:
Tom Cosgrove
2022-08-24 11:51:58 +01:00
parent f0ffb1585a
commit 72594633a1
2 changed files with 92 additions and 88 deletions

View File

@@ -158,28 +158,28 @@ int mbedtls_mpi_core_write_be( const mbedtls_mpi_uint *A,
/**
* \brief Montgomery multiplication: X = A * B * R^-1 mod N (HAC 14.36)
*
* \param[out] X The destination MPI, as a little-endian array of
* length \p n.
* On successful completion, X contains the result of
* the multiplication A * B * R^-1 mod N where
* R = (2^ciL)^n.
* \param[in] A Little-endian presentation of first operand.
* Must have exactly \p n limbs.
* \param[in] B Little-endian presentation of second operand.
* \param[in] B_len The number of limbs in \p B.
* \param[in] N Little-endian presentation of the modulus.
* This must be odd and have exactly \p n limbs.
* \param[in] n The number of limbs in \p X, \p A, \p N.
* \param mm The Montgomery constant for \p N: -N^-1 mod 2^ciL.
* This can be calculated by `mbedtls_mpi_montg_init()`.
* \param[in,out] T Temporary storage of size at least 2*n+1 limbs.
* Its initial content is unused and
* its final content is indeterminate.
* \param[out] X The destination MPI, as a little-endian array of
* length \p AN_limbs.
* On successful completion, X contains the result of
* the multiplication A * B * R^-1 mod N where
* R = (2^ciL)^AN_limbs.
* \param[in] A Little-endian presentation of first operand.
* Must have exactly \p AN_limbs limbs.
* \param[in] B Little-endian presentation of second operand.
* \param[in] B_limbs The number of limbs in \p B.
* \param[in] N Little-endian presentation of the modulus.
* This must be odd and have exactly \p AN_limbs limbs.
* \param[in] AN_limbs The number of limbs in \p X, \p A, \p N.
* \param mm The Montgomery constant for \p N: -N^-1 mod 2^ciL.
* This can be calculated by `mbedtls_mpi_montg_init()`.
* \param[in,out] T Temporary storage of size at least 2*AN_limbs+1 limbs.
* Its initial content is unused and
* its final content is indeterminate.
*/
void mbedtls_mpi_core_montmul( mbedtls_mpi_uint *X,
const mbedtls_mpi_uint *A,
const mbedtls_mpi_uint *B, size_t B_len,
const mbedtls_mpi_uint *N, size_t n,
const mbedtls_mpi_uint *B, size_t B_limbs,
const mbedtls_mpi_uint *N, size_t AN_limbs,
mbedtls_mpi_uint mm, mbedtls_mpi_uint *T );
/**
@@ -194,46 +194,46 @@ void mbedtls_mpi_core_montmul( mbedtls_mpi_uint *X,
mbedtls_mpi_uint mbedtls_mpi_montg_init( const mbedtls_mpi_uint *N );
/**
* \brief Perform a known-size multiply accumulate operation: d += b * s
* \brief Perform a known-size multiply accumulate operation: A += c * B
*
* \param[in,out] d The pointer to the (little-endian) array
* representing the bignum to accumulate onto.
* \param d_len The number of limbs of \p d. This must be
* at least \p s_len.
* \param[in] s The pointer to the (little-endian) array
* representing the bignum to multiply with.
* This may be the same as \p d. Otherwise,
* it must be disjoint from \p d.
* \param s_len The number of limbs of \p s.
* \param b A scalar to multiply with.
* \param[in,out] A The pointer to the (little-endian) array
* representing the bignum to accumulate onto.
* \param A_limbs The number of limbs of \p A. This must be
* at least \p B_limbs.
* \param[in] B The pointer to the (little-endian) array
* representing the bignum to multiply with.
* This may be the same as \p A. Otherwise,
* it must be disjoint from \p A.
* \param B_limbs The number of limbs of \p B.
* \param c A scalar to multiply with.
*
* \return c 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 *d, size_t d_len,
const mbedtls_mpi_uint *s, size_t s_len,
mbedtls_mpi_uint b );
mbedtls_mpi_uint mbedtls_mpi_core_mla( mbedtls_mpi_uint *A, size_t A_limbs,
const mbedtls_mpi_uint *B, size_t B_limbs,
mbedtls_mpi_uint c );
/**
* \brief Subtract two known-size large unsigned integers, returning the borrow.
*
* Calculate l - r where l and r have the same size.
* This function operates modulo (2^ciL)^n and returns the carry
* (1 if there was a wraparound, i.e. if `l < r`, and 0 otherwise).
* Calculate A - B where A and B have the same size.
* This function operates modulo (2^ciL)^limbs and returns the carry
* (1 if there was a wraparound, i.e. if `A < B`, and 0 otherwise).
*
* d may be aliased to l or r.
* X may be aliased to A or B.
*
* \param[out] d The result of the subtraction.
* \param[in] l Little-endian presentation of left operand.
* \param[in] r Little-endian presentation of right operand.
* \param n Number of limbs of \p d, \p l and \p r.
* \param[out] X The result of the subtraction.
* \param[in] A Little-endian presentation of left operand.
* \param[in] B Little-endian presentation of right operand.
* \param limbs Number of limbs of \p X, \p A and \p B.
*
* \return 1 if `l < r`.
* 0 if `l >= r`.
* \return 1 if `A < B`.
* 0 if `A >= B`.
*/
mbedtls_mpi_uint mbedtls_mpi_core_sub( mbedtls_mpi_uint *d,
const mbedtls_mpi_uint *l,
const mbedtls_mpi_uint *r,
size_t n );
mbedtls_mpi_uint mbedtls_mpi_core_sub( mbedtls_mpi_uint *X,
const mbedtls_mpi_uint *A,
const mbedtls_mpi_uint *B,
size_t limbs );
/**
* \brief Constant-time conditional addition of two known-size large unsigned
@@ -243,24 +243,28 @@ mbedtls_mpi_uint mbedtls_mpi_core_sub( mbedtls_mpi_uint *d,
*
* ```
* if( cond )
* d += r;
* A += B;
* return carry;
* ```
*
* \param[in,out] d The pointer to the (little-endian) array
* representing the bignum to accumulate onto.
* \param[in] r The pointer to the (little-endian) array
* representing the bignum to conditionally add
* to \p d. This must be disjoint from \p d.
* \param n Number of limbs of \p d and \p r.
* \param cond Condition bit dictating whether addition should
* happen or not. This must be \c 0 or \c 1.
* \param[in,out] A The pointer to the (little-endian) array
* representing the bignum to accumulate onto.
* \param[in] B The pointer to the (little-endian) array
* representing the bignum to conditionally add
* to \p A. This must be disjoint from \p A.
* \param limbs Number of limbs of \p A and \p B.
* \param cond Condition bit dictating whether addition should
* happen or not. This must be \c 0 or \c 1.
*
* \return 1 if `d + cond*r >= (2^{ciL})^n`, 0 otherwise.
* \warning If \p assign is neither 0 nor 1, the result of this function
* is unspecified, and the resulting value in \p A might be
* neither its original value nor \p A + \p B.
*
* \return 1 if `A + cond * B >= (2^{ciL})^limbs`, 0 otherwise.
*/
mbedtls_mpi_uint mbedtls_mpi_core_add_if( mbedtls_mpi_uint *d,
const mbedtls_mpi_uint *r,
size_t n,
mbedtls_mpi_uint mbedtls_mpi_core_add_if( mbedtls_mpi_uint *A,
const mbedtls_mpi_uint *B,
size_t limbs,
unsigned cond );
#endif /* MBEDTLS_BIGNUM_CORE_H */