mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-31 19:21:18 +00:00
Bignum: update const qualifiers
While at it, mark parameters based on their role. Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
cc93908b88
commit
6b8a4ad0d8
@ -129,7 +129,7 @@ static mbedtls_mpi_uint mpi_bigendian_to_host( mbedtls_mpi_uint x )
|
|||||||
return( mpi_bigendian_to_host_c( x ) );
|
return( mpi_bigendian_to_host_c( x ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_mpi_core_bigendian_to_host( mbedtls_mpi_uint * const X,
|
void mbedtls_mpi_core_bigendian_to_host( mbedtls_mpi_uint *X,
|
||||||
size_t limbs )
|
size_t limbs )
|
||||||
{
|
{
|
||||||
mbedtls_mpi_uint *cur_limb_left;
|
mbedtls_mpi_uint *cur_limb_left;
|
||||||
|
@ -44,8 +44,8 @@ size_t mbedtls_mpi_core_clz( const mbedtls_mpi_uint x );
|
|||||||
*
|
*
|
||||||
* \note This function returns 0 if all the limbs of \p X are 0.
|
* \note This function returns 0 if all the limbs of \p X are 0.
|
||||||
*
|
*
|
||||||
* \param X The address of the MPI.
|
* \param[in] X The address of the MPI.
|
||||||
* \param nx The number of limbs of \p X.
|
* \param nx The number of limbs of \p X.
|
||||||
*
|
*
|
||||||
* \return The number of bits in \p X.
|
* \return The number of bits in \p X.
|
||||||
*/
|
*/
|
||||||
@ -54,10 +54,10 @@ size_t mbedtls_mpi_core_bitlen( const mbedtls_mpi_uint *X, size_t nx );
|
|||||||
/** Convert a big-endian byte array aligned to the size of mbedtls_mpi_uint
|
/** Convert a big-endian byte array aligned to the size of mbedtls_mpi_uint
|
||||||
* into the storage form used by mbedtls_mpi.
|
* into the storage form used by mbedtls_mpi.
|
||||||
*
|
*
|
||||||
* \param X The address of the MPI.
|
* \param[in,out] X The address of the MPI.
|
||||||
* \param limbs The number of limbs of \p X.
|
* \param limbs The number of limbs of \p X.
|
||||||
*/
|
*/
|
||||||
void mbedtls_mpi_core_bigendian_to_host( mbedtls_mpi_uint * const X,
|
void mbedtls_mpi_core_bigendian_to_host( mbedtls_mpi_uint *X,
|
||||||
size_t limbs );
|
size_t limbs );
|
||||||
|
|
||||||
/** Import X from unsigned binary data, little endian.
|
/** Import X from unsigned binary data, little endian.
|
||||||
@ -65,10 +65,10 @@ void mbedtls_mpi_core_bigendian_to_host( mbedtls_mpi_uint * const X,
|
|||||||
* The MPI needs to have enough limbs to store the full value (including any
|
* The MPI needs to have enough limbs to store the full value (including any
|
||||||
* most significant zero bytes in the input).
|
* most significant zero bytes in the input).
|
||||||
*
|
*
|
||||||
* \param X The address of the MPI.
|
* \param[out] X The address of the MPI.
|
||||||
* \param nx The number of limbs of \p X.
|
* \param nx The number of limbs of \p X.
|
||||||
* \param buf The input buffer to import from.
|
* \param[in] buf The input buffer to import from.
|
||||||
* \param buflen The length in bytes of \p buf.
|
* \param buflen The length in bytes of \p buf.
|
||||||
*
|
*
|
||||||
* \return \c 0 if successful.
|
* \return \c 0 if successful.
|
||||||
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p X isn't
|
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p X isn't
|
||||||
@ -84,12 +84,12 @@ int mbedtls_mpi_core_read_le( mbedtls_mpi_uint *X,
|
|||||||
* The MPI needs to have enough limbs to store the full value (including any
|
* The MPI needs to have enough limbs to store the full value (including any
|
||||||
* most significant zero bytes in the input).
|
* most significant zero bytes in the input).
|
||||||
*
|
*
|
||||||
* \param X The address of the MPI.
|
* \param[out] X The address of the MPI.
|
||||||
* May only be #NULL if \nx is 0 and \p buflen is 0.
|
* May only be #NULL if \nx is 0 and \p buflen is 0.
|
||||||
* \param nx The number of limbs of \p X.
|
* \param nx The number of limbs of \p X.
|
||||||
* \param buf The input buffer to import from.
|
* \param[in] buf The input buffer to import from.
|
||||||
* May only be #NULL if \p buflen is 0.
|
* May only be #NULL if \p buflen is 0.
|
||||||
* \param buflen The length in bytes of \p buf.
|
* \param buflen The length in bytes of \p buf.
|
||||||
*
|
*
|
||||||
* \return \c 0 if successful.
|
* \return \c 0 if successful.
|
||||||
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p X isn't
|
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p X isn't
|
||||||
@ -106,10 +106,10 @@ int mbedtls_mpi_core_read_be( mbedtls_mpi_uint *X,
|
|||||||
* value held in \p X fits in the buffer (that is, if enough of the most
|
* value held in \p X fits in the buffer (that is, if enough of the most
|
||||||
* significant bytes of \p X are 0).
|
* significant bytes of \p X are 0).
|
||||||
*
|
*
|
||||||
* \param X The address of the MPI.
|
* \param[in] X The address of the MPI.
|
||||||
* \param nx The number of limbs of \p X.
|
* \param nx The number of limbs of \p X.
|
||||||
* \param buf The output buffer to export to.
|
* \param[out] buf The output buffer to export to.
|
||||||
* \param buflen The length in bytes of \p buf.
|
* \param buflen The length in bytes of \p buf.
|
||||||
*
|
*
|
||||||
* \return \c 0 if successful.
|
* \return \c 0 if successful.
|
||||||
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p buf isn't
|
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p buf isn't
|
||||||
@ -126,10 +126,10 @@ int mbedtls_mpi_core_write_le( const mbedtls_mpi_uint *X,
|
|||||||
* value held in \p X fits in the buffer (that is, if enough of the most
|
* value held in \p X fits in the buffer (that is, if enough of the most
|
||||||
* significant bytes of \p X are 0).
|
* significant bytes of \p X are 0).
|
||||||
*
|
*
|
||||||
* \param X The address of the MPI.
|
* \param[in] X The address of the MPI.
|
||||||
* \param nx The number of limbs of \p X.
|
* \param nx The number of limbs of \p X.
|
||||||
* \param buf The output buffer to export to.
|
* \param[out] buf The output buffer to export to.
|
||||||
* \param buflen The length in bytes of \p buf.
|
* \param buflen The length in bytes of \p buf.
|
||||||
*
|
*
|
||||||
* \return \c 0 if successful.
|
* \return \c 0 if successful.
|
||||||
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p buf isn't
|
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p buf isn't
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#include "constant_time_internal.h"
|
#include "constant_time_internal.h"
|
||||||
|
|
||||||
int mbedtls_mpi_mod_residue_setup( mbedtls_mpi_mod_residue *r,
|
int mbedtls_mpi_mod_residue_setup( mbedtls_mpi_mod_residue *r,
|
||||||
mbedtls_mpi_mod_modulus *m,
|
const mbedtls_mpi_mod_modulus *m,
|
||||||
mbedtls_mpi_uint *p,
|
mbedtls_mpi_uint *p,
|
||||||
size_t pn )
|
size_t pn )
|
||||||
{
|
{
|
||||||
|
@ -67,22 +67,23 @@ typedef struct {
|
|||||||
|
|
||||||
/** Setup a residue structure.
|
/** Setup a residue structure.
|
||||||
*
|
*
|
||||||
* \param r The address of residue to setup. The size is determined by \p m.
|
* \param[out] r The address of residue to setup. The size is determined by
|
||||||
* (In particular, it must have at least as many limbs as the
|
* \p m.
|
||||||
* modulus \p m.)
|
* (In particular, it must have at least as many limbs as the
|
||||||
* \param m The address of the modulus related to \p r.
|
* modulus \p m.)
|
||||||
* \param p The address of the limb array storing the value of \p r. The
|
* \param[in] m The address of the modulus related to \p r.
|
||||||
* memory pointed to by \p p will be used by \p r and must not be
|
* \param[in] p The address of the limb array storing the value of \p r.
|
||||||
* modified in any way until after mbedtls_mpi_mod_residue_release()
|
* The memory pointed to by \p p will be used by \p r and must
|
||||||
* is called.
|
* not be modified in any way until after
|
||||||
* \param pn The number of limbs of \p p.
|
* mbedtls_mpi_mod_residue_release() is called.
|
||||||
|
* \param pn The number of limbs of \p p.
|
||||||
*
|
*
|
||||||
* \return \c 0 if successful.
|
* \return \c 0 if successful.
|
||||||
* \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \p pn is less than the limbs
|
* \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \p pn is less than the limbs
|
||||||
* in \p m or if \p p is not less than \p m.
|
* in \p m or if \p p is not less than \p m.
|
||||||
*/
|
*/
|
||||||
int mbedtls_mpi_mod_residue_setup( mbedtls_mpi_mod_residue *r,
|
int mbedtls_mpi_mod_residue_setup( mbedtls_mpi_mod_residue *r,
|
||||||
mbedtls_mpi_mod_modulus *m,
|
const mbedtls_mpi_mod_modulus *m,
|
||||||
mbedtls_mpi_uint *p,
|
mbedtls_mpi_uint *p,
|
||||||
size_t pn );
|
size_t pn );
|
||||||
|
|
||||||
@ -94,22 +95,22 @@ int mbedtls_mpi_mod_residue_setup( mbedtls_mpi_mod_residue *r,
|
|||||||
* This function invalidates \p r and it must not be used until after
|
* This function invalidates \p r and it must not be used until after
|
||||||
* mbedtls_mpi_mod_residue_setup() is called on it again.
|
* mbedtls_mpi_mod_residue_setup() is called on it again.
|
||||||
*
|
*
|
||||||
* \param r The address of residue to release.
|
* \param[out] r The address of residue to release.
|
||||||
*/
|
*/
|
||||||
void mbedtls_mpi_mod_residue_release( mbedtls_mpi_mod_residue *r );
|
void mbedtls_mpi_mod_residue_release( mbedtls_mpi_mod_residue *r );
|
||||||
|
|
||||||
/** Initialize a modulus structure.
|
/** Initialize a modulus structure.
|
||||||
*
|
*
|
||||||
* \param m The address of a modulus.
|
* \param[out] m The address of a modulus.
|
||||||
*/
|
*/
|
||||||
void mbedtls_mpi_mod_modulus_init( mbedtls_mpi_mod_modulus *m );
|
void mbedtls_mpi_mod_modulus_init( mbedtls_mpi_mod_modulus *m );
|
||||||
|
|
||||||
/** Setup a modulus structure.
|
/** Setup a modulus structure.
|
||||||
*
|
*
|
||||||
* \param m The address of the modulus structure to populate.
|
* \param[out] m The address of the modulus structure to populate.
|
||||||
* \param p The address of the limb array storing the value of \p m. The
|
* \param[in] p The address of the limb array storing the value of \p m.
|
||||||
* memory pointed to by \p p will be used by \p m and must not
|
* The memory pointed to by \p p will be used by \p m and must
|
||||||
* be modified in any way until after
|
* not be modified in any way until after
|
||||||
* mbedtls_mpi_mod_modulus_free() is called.
|
* mbedtls_mpi_mod_modulus_free() is called.
|
||||||
* \param pn The number of limbs of \p p.
|
* \param pn The number of limbs of \p p.
|
||||||
* \param ext_rep The external representation to be used for residues
|
* \param ext_rep The external representation to be used for residues
|
||||||
@ -135,7 +136,7 @@ int mbedtls_mpi_mod_modulus_setup( mbedtls_mpi_mod_modulus *m,
|
|||||||
* mbedtls_mpi_mod_modulus_setup() only removes the reference to it,
|
* mbedtls_mpi_mod_modulus_setup() only removes the reference to it,
|
||||||
* making it safe to free or to use it again.
|
* making it safe to free or to use it again.
|
||||||
*
|
*
|
||||||
* \param m The address of a modulus.
|
* \param[in,out] m The address of a modulus.
|
||||||
*/
|
*/
|
||||||
void mbedtls_mpi_mod_modulus_free( mbedtls_mpi_mod_modulus *m );
|
void mbedtls_mpi_mod_modulus_free( mbedtls_mpi_mod_modulus *m );
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@
|
|||||||
#include "constant_time_internal.h"
|
#include "constant_time_internal.h"
|
||||||
|
|
||||||
int mbedtls_mpi_mod_raw_read( mbedtls_mpi_uint *X,
|
int mbedtls_mpi_mod_raw_read( mbedtls_mpi_uint *X,
|
||||||
mbedtls_mpi_mod_modulus *m,
|
const mbedtls_mpi_mod_modulus *m,
|
||||||
unsigned char *buf,
|
const unsigned char *buf,
|
||||||
size_t buflen )
|
size_t buflen )
|
||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
@ -74,8 +74,8 @@ cleanup:
|
|||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_mpi_mod_raw_write( mbedtls_mpi_uint *X,
|
int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *X,
|
||||||
mbedtls_mpi_mod_modulus *m,
|
const mbedtls_mpi_mod_modulus *m,
|
||||||
unsigned char *buf,
|
unsigned char *buf,
|
||||||
size_t buflen )
|
size_t buflen )
|
||||||
{
|
{
|
||||||
|
@ -38,12 +38,12 @@
|
|||||||
* The MPI needs to have enough limbs to store the full value (including any
|
* The MPI needs to have enough limbs to store the full value (including any
|
||||||
* most significant zero bytes in the input).
|
* most significant zero bytes in the input).
|
||||||
*
|
*
|
||||||
* \param X The address of the MPI. The size is determined by \p m. (In
|
* \param[out] X The address of the MPI. The size is determined by \p m. (In
|
||||||
* particular, it must have at least as many limbs as the modulus
|
* particular, it must have at least as many limbs as the
|
||||||
* \p m.)
|
* modulus \p m.)
|
||||||
* \param m The address of the modulus related to \p X.
|
* \param[in] m The address of the modulus related to \p X.
|
||||||
* \param buf The input buffer to import from.
|
* \param[in] buf The input buffer to import from.
|
||||||
* \param buflen The length in bytes of \p buf.
|
* \param buflen The length in bytes of \p buf.
|
||||||
*
|
*
|
||||||
* \return \c 0 if successful.
|
* \return \c 0 if successful.
|
||||||
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p X isn't
|
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p X isn't
|
||||||
@ -52,18 +52,18 @@
|
|||||||
* of \p m is invalid or \p X is not less than \p m.
|
* of \p m is invalid or \p X is not less than \p m.
|
||||||
*/
|
*/
|
||||||
int mbedtls_mpi_mod_raw_read( mbedtls_mpi_uint *X,
|
int mbedtls_mpi_mod_raw_read( mbedtls_mpi_uint *X,
|
||||||
mbedtls_mpi_mod_modulus *m,
|
const mbedtls_mpi_mod_modulus *m,
|
||||||
unsigned char *buf,
|
const unsigned char *buf,
|
||||||
size_t buflen );
|
size_t buflen );
|
||||||
|
|
||||||
/** Export X into unsigned binary data.
|
/** Export X into unsigned binary data.
|
||||||
*
|
*
|
||||||
* \param X The address of the MPI. The size is determined by \p m. (In
|
* \param[in] X The address of the MPI. The size is determined by \p m. (In
|
||||||
* particular, it must have at least as many limbs as the modulus
|
* particular, it must have at least as many limbs as the modulus
|
||||||
* \p m.)
|
* \p m.)
|
||||||
* \param m The address of the modulus related to \p X.
|
* \param[in] m The address of the modulus related to \p X.
|
||||||
* \param buf The output buffer to export to.
|
* \param[out] buf The output buffer to export to.
|
||||||
* \param buflen The length in bytes of \p buf.
|
* \param buflen The length in bytes of \p buf.
|
||||||
*
|
*
|
||||||
* \return \c 0 if successful.
|
* \return \c 0 if successful.
|
||||||
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p buf isn't
|
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p buf isn't
|
||||||
@ -71,8 +71,8 @@ int mbedtls_mpi_mod_raw_read( mbedtls_mpi_uint *X,
|
|||||||
* \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if the external representation
|
* \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if the external representation
|
||||||
* of \p m is invalid.
|
* of \p m is invalid.
|
||||||
*/
|
*/
|
||||||
int mbedtls_mpi_mod_raw_write( mbedtls_mpi_uint *X,
|
int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *X,
|
||||||
mbedtls_mpi_mod_modulus *m,
|
const mbedtls_mpi_mod_modulus *m,
|
||||||
unsigned char *buf,
|
unsigned char *buf,
|
||||||
size_t buflen );
|
size_t buflen );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user