mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-01 10:06:53 +03:00
Switch to the new code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -92,8 +92,7 @@
|
||||
* This also determines which fields of the modulus structure are valid and
|
||||
* what their contents are (see #mbedtls_mpi_mod_modulus).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
/** Representation not chosen (makes the modulus structure invalid). */
|
||||
MBEDTLS_MPI_MOD_REP_INVALID = 0,
|
||||
/* Skip 1 as it is slightly easier to accidentally pass to functions. */
|
||||
@ -108,15 +107,13 @@ typedef enum
|
||||
|
||||
/* Make mbedtls_mpi_mod_rep_selector and mbedtls_mpi_mod_ext_rep disjoint to
|
||||
* make it easier to catch when they are accidentally swapped. */
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
MBEDTLS_MPI_MOD_EXT_REP_INVALID = 0,
|
||||
MBEDTLS_MPI_MOD_EXT_REP_LE = 8,
|
||||
MBEDTLS_MPI_MOD_EXT_REP_BE
|
||||
} mbedtls_mpi_mod_ext_rep;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
mbedtls_mpi_uint *p;
|
||||
size_t limbs;
|
||||
} mbedtls_mpi_mod_residue;
|
||||
@ -133,8 +130,7 @@ typedef struct {
|
||||
size_t limbs; // number of limbs
|
||||
size_t bits; // bitlen of p
|
||||
mbedtls_mpi_mod_rep_selector int_rep; // selector to signal the active member of the union
|
||||
union rep
|
||||
{
|
||||
union rep {
|
||||
/* if int_rep == #MBEDTLS_MPI_MOD_REP_MONTGOMERY */
|
||||
mbedtls_mpi_mont_struct mont;
|
||||
/* if int_rep == #MBEDTLS_MPI_MOD_REP_OPT_RED */
|
||||
@ -170,10 +166,10 @@ typedef struct {
|
||||
* \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \p p_limbs is less than the
|
||||
* limbs in \p m or if \p p is not less than \p m.
|
||||
*/
|
||||
int mbedtls_mpi_mod_residue_setup( mbedtls_mpi_mod_residue *r,
|
||||
const mbedtls_mpi_mod_modulus *m,
|
||||
mbedtls_mpi_uint *p,
|
||||
size_t p_limbs );
|
||||
int mbedtls_mpi_mod_residue_setup(mbedtls_mpi_mod_residue *r,
|
||||
const mbedtls_mpi_mod_modulus *m,
|
||||
mbedtls_mpi_uint *p,
|
||||
size_t p_limbs);
|
||||
|
||||
/** Unbind elements of a residue structure.
|
||||
*
|
||||
@ -185,13 +181,13 @@ int mbedtls_mpi_mod_residue_setup( mbedtls_mpi_mod_residue *r,
|
||||
*
|
||||
* \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.
|
||||
*
|
||||
* \param[out] m The address of the modulus structure to initialize.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@ -207,10 +203,10 @@ void mbedtls_mpi_mod_modulus_init( mbedtls_mpi_mod_modulus *m );
|
||||
* \return \c 0 if successful.
|
||||
* \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \p int_rep is invalid.
|
||||
*/
|
||||
int mbedtls_mpi_mod_modulus_setup( mbedtls_mpi_mod_modulus *m,
|
||||
const mbedtls_mpi_uint *p,
|
||||
size_t p_limbs,
|
||||
mbedtls_mpi_mod_rep_selector int_rep );
|
||||
int mbedtls_mpi_mod_modulus_setup(mbedtls_mpi_mod_modulus *m,
|
||||
const mbedtls_mpi_uint *p,
|
||||
size_t p_limbs,
|
||||
mbedtls_mpi_mod_rep_selector int_rep);
|
||||
|
||||
/** Free elements of a modulus structure.
|
||||
*
|
||||
@ -222,7 +218,7 @@ int mbedtls_mpi_mod_modulus_setup( mbedtls_mpi_mod_modulus *m,
|
||||
*
|
||||
* \param[in,out] m The address of the modulus structure to free.
|
||||
*/
|
||||
void mbedtls_mpi_mod_modulus_free( mbedtls_mpi_mod_modulus *m );
|
||||
void mbedtls_mpi_mod_modulus_free(mbedtls_mpi_mod_modulus *m);
|
||||
|
||||
/* BEGIN MERGE SLOT 1 */
|
||||
|
||||
@ -259,10 +255,10 @@ void mbedtls_mpi_mod_modulus_free( mbedtls_mpi_mod_modulus *m );
|
||||
* have the same number of limbs or \p N is invalid.
|
||||
* \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure.
|
||||
*/
|
||||
int mbedtls_mpi_mod_mul( mbedtls_mpi_mod_residue *X,
|
||||
const mbedtls_mpi_mod_residue *A,
|
||||
const mbedtls_mpi_mod_residue *B,
|
||||
const mbedtls_mpi_mod_modulus *N );
|
||||
int mbedtls_mpi_mod_mul(mbedtls_mpi_mod_residue *X,
|
||||
const mbedtls_mpi_mod_residue *A,
|
||||
const mbedtls_mpi_mod_residue *B,
|
||||
const mbedtls_mpi_mod_modulus *N);
|
||||
|
||||
/* END MERGE SLOT 2 */
|
||||
|
||||
@ -292,10 +288,10 @@ int mbedtls_mpi_mod_mul( mbedtls_mpi_mod_residue *X,
|
||||
* \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if the given MPIs do not
|
||||
* have the correct number of limbs.
|
||||
*/
|
||||
int mbedtls_mpi_mod_sub( mbedtls_mpi_mod_residue *X,
|
||||
const mbedtls_mpi_mod_residue *A,
|
||||
const mbedtls_mpi_mod_residue *B,
|
||||
const mbedtls_mpi_mod_modulus *N );
|
||||
int mbedtls_mpi_mod_sub(mbedtls_mpi_mod_residue *X,
|
||||
const mbedtls_mpi_mod_residue *A,
|
||||
const mbedtls_mpi_mod_residue *B,
|
||||
const mbedtls_mpi_mod_modulus *N);
|
||||
|
||||
/**
|
||||
* \brief Perform modular inversion of an MPI with respect to a modulus \p N.
|
||||
@ -322,9 +318,9 @@ int mbedtls_mpi_mod_sub( mbedtls_mpi_mod_residue *X,
|
||||
* by the inversion calculation itself).
|
||||
*/
|
||||
|
||||
int mbedtls_mpi_mod_inv( mbedtls_mpi_mod_residue *X,
|
||||
const mbedtls_mpi_mod_residue *A,
|
||||
const mbedtls_mpi_mod_modulus *N );
|
||||
int mbedtls_mpi_mod_inv(mbedtls_mpi_mod_residue *X,
|
||||
const mbedtls_mpi_mod_residue *A,
|
||||
const mbedtls_mpi_mod_modulus *N);
|
||||
/* END MERGE SLOT 3 */
|
||||
|
||||
/* BEGIN MERGE SLOT 4 */
|
||||
@ -358,10 +354,10 @@ int mbedtls_mpi_mod_inv( mbedtls_mpi_mod_residue *X,
|
||||
* \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if the given MPIs do not
|
||||
* have the correct number of limbs.
|
||||
*/
|
||||
int mbedtls_mpi_mod_add( mbedtls_mpi_mod_residue *X,
|
||||
const mbedtls_mpi_mod_residue *A,
|
||||
const mbedtls_mpi_mod_residue *B,
|
||||
const mbedtls_mpi_mod_modulus *N );
|
||||
int mbedtls_mpi_mod_add(mbedtls_mpi_mod_residue *X,
|
||||
const mbedtls_mpi_mod_residue *A,
|
||||
const mbedtls_mpi_mod_residue *B,
|
||||
const mbedtls_mpi_mod_modulus *N);
|
||||
/* END MERGE SLOT 5 */
|
||||
|
||||
/* BEGIN MERGE SLOT 6 */
|
||||
@ -393,11 +389,11 @@ int mbedtls_mpi_mod_add( mbedtls_mpi_mod_residue *X,
|
||||
* is significantly larger than \p min, which is the case
|
||||
* for all usual cryptographic applications.
|
||||
*/
|
||||
int mbedtls_mpi_mod_random( mbedtls_mpi_mod_residue *X,
|
||||
mbedtls_mpi_uint min,
|
||||
const mbedtls_mpi_mod_modulus *N,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng );
|
||||
int mbedtls_mpi_mod_random(mbedtls_mpi_mod_residue *X,
|
||||
mbedtls_mpi_uint min,
|
||||
const mbedtls_mpi_mod_modulus *N,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng);
|
||||
|
||||
/* END MERGE SLOT 6 */
|
||||
|
||||
@ -425,11 +421,11 @@ int mbedtls_mpi_mod_random( mbedtls_mpi_mod_residue *X,
|
||||
* \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \p ext_rep
|
||||
* is invalid or the value in the buffer is not less than \p m.
|
||||
*/
|
||||
int mbedtls_mpi_mod_read( mbedtls_mpi_mod_residue *r,
|
||||
const mbedtls_mpi_mod_modulus *m,
|
||||
const unsigned char *buf,
|
||||
size_t buflen,
|
||||
mbedtls_mpi_mod_ext_rep ext_rep );
|
||||
int mbedtls_mpi_mod_read(mbedtls_mpi_mod_residue *r,
|
||||
const mbedtls_mpi_mod_modulus *m,
|
||||
const unsigned char *buf,
|
||||
size_t buflen,
|
||||
mbedtls_mpi_mod_ext_rep ext_rep);
|
||||
|
||||
/** Write a residue into a byte buffer.
|
||||
*
|
||||
@ -463,11 +459,11 @@ int mbedtls_mpi_mod_read( mbedtls_mpi_mod_residue *r,
|
||||
* memory for conversion. Can occur only for moduli with
|
||||
* MBEDTLS_MPI_MOD_REP_MONTGOMERY.
|
||||
*/
|
||||
int mbedtls_mpi_mod_write( const mbedtls_mpi_mod_residue *r,
|
||||
const mbedtls_mpi_mod_modulus *m,
|
||||
unsigned char *buf,
|
||||
size_t buflen,
|
||||
mbedtls_mpi_mod_ext_rep ext_rep );
|
||||
int mbedtls_mpi_mod_write(const mbedtls_mpi_mod_residue *r,
|
||||
const mbedtls_mpi_mod_modulus *m,
|
||||
unsigned char *buf,
|
||||
size_t buflen,
|
||||
mbedtls_mpi_mod_ext_rep ext_rep);
|
||||
/* END MERGE SLOT 7 */
|
||||
|
||||
/* BEGIN MERGE SLOT 8 */
|
||||
|
Reference in New Issue
Block a user