Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
Gabor Mezei 2022-08-12 15:36:56 +02:00
parent d41f627650
commit 89e31460db
No known key found for this signature in database
GPG key ID: F072ACA227ACD71D
5 changed files with 23 additions and 20 deletions

View file

@ -343,7 +343,7 @@ size_t mbedtls_mpi_lsb( const mbedtls_mpi *X )
*/ */
size_t mbedtls_mpi_bitlen( const mbedtls_mpi *X ) size_t mbedtls_mpi_bitlen( const mbedtls_mpi *X )
{ {
return mbedtls_mpi_core_bitlen( X->p, X->n ); return( mbedtls_mpi_core_bitlen( X->p, X->n ) );
} }
/* /*

View file

@ -50,7 +50,7 @@ size_t mbedtls_mpi_core_clz( const mbedtls_mpi_uint x )
mask >>= 1; mask >>= 1;
} }
return j; return( j );
} }
size_t mbedtls_mpi_core_bitlen( const mbedtls_mpi_uint *X, size_t nx ) size_t mbedtls_mpi_core_bitlen( const mbedtls_mpi_uint *X, size_t nx )
@ -77,7 +77,7 @@ static mbedtls_mpi_uint mpi_bigendian_to_host_c( mbedtls_mpi_uint x )
unsigned char *x_ptr; unsigned char *x_ptr;
mbedtls_mpi_uint tmp = 0; mbedtls_mpi_uint tmp = 0;
for( i = 0, x_ptr = (unsigned char*) &x; i < ciL; i++, x_ptr++ ) for( i = 0, x_ptr = (unsigned char *) &x; i < ciL; i++, x_ptr++ )
{ {
tmp <<= CHAR_BIT; tmp <<= CHAR_BIT;
tmp |= (mbedtls_mpi_uint) *x_ptr; tmp |= (mbedtls_mpi_uint) *x_ptr;

View file

@ -49,8 +49,8 @@ typedef struct
mbedtls_mpi_uint *p; mbedtls_mpi_uint *p;
} mbedtls_mpi_mod_residue; } mbedtls_mpi_mod_residue;
typedef void* mbedtls_mpi_mont_struct; typedef void *mbedtls_mpi_mont_struct;
typedef void* mbedtls_mpi_opt_red_struct; typedef void *mbedtls_mpi_opt_red_struct;
typedef struct { typedef struct {
mbedtls_mpi_uint *p; mbedtls_mpi_uint *p;

View file

@ -82,9 +82,9 @@ int mbedtls_mpi_mod_raw_write( mbedtls_mpi_uint *X,
switch( m->ext_rep ) switch( m->ext_rep )
{ {
case MBEDTLS_MPI_MOD_EXT_REP_LE: case MBEDTLS_MPI_MOD_EXT_REP_LE:
return mbedtls_mpi_core_write_le( X, m->n, buf, buflen ); return( mbedtls_mpi_core_write_le( X, m->n, buf, buflen ) );
case MBEDTLS_MPI_MOD_EXT_REP_BE: case MBEDTLS_MPI_MOD_EXT_REP_BE:
return mbedtls_mpi_core_write_be( X, m->n, buf, buflen ); return( mbedtls_mpi_core_write_be( X, m->n, buf, buflen ) );
default: default:
return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
} }

View file

@ -10,7 +10,7 @@
#if MBEDTLS_MPI_MAX_BITS > 792 #if MBEDTLS_MPI_MAX_BITS > 792
#define MPI_MAX_BITS_LARGER_THAN_792 #define MPI_MAX_BITS_LARGER_THAN_792
#endif #endif
#
/* Check the validity of the sign bit in an MPI object. Reject representations /* Check the validity of the sign bit in an MPI object. Reject representations
* that are not supported by the rest of the library and indicate a bug when * that are not supported by the rest of the library and indicate a bug when
* constructing the value. */ * constructing the value. */
@ -236,9 +236,10 @@ exit:
void mbedtls_mpi_core_io_be( data_t *input, int nb_int, int nx_32_int, int iret, void mbedtls_mpi_core_io_be( data_t *input, int nb_int, int nx_32_int, int iret,
int oret ) int oret )
{ {
#define BMAX 1024 #define BMAX 1024
#define XMAX BMAX / sizeof( mbedtls_mpi_uint )
unsigned char buf[BMAX]; unsigned char buf[BMAX];
#define XMAX BMAX / sizeof( mbedtls_mpi_uint )
mbedtls_mpi_uint X[XMAX]; mbedtls_mpi_uint X[XMAX];
size_t nx, nb; size_t nx, nb;
int ret; int ret;
@ -288,8 +289,8 @@ void mbedtls_mpi_core_io_be( data_t *input, int nb_int, int nx_32_int, int iret,
exit: exit:
; ;
#undef BMAX #undef BMAX
#undef XMAX #undef XMAX
} }
/* END_CASE */ /* END_CASE */
@ -297,9 +298,10 @@ exit:
void mbedtls_mpi_core_io_le( data_t *input, int nb_int, int nx_32_int, int iret, void mbedtls_mpi_core_io_le( data_t *input, int nb_int, int nx_32_int, int iret,
int oret ) int oret )
{ {
#define BMAX 1024 #define BMAX 1024
#define XMAX BMAX / sizeof( mbedtls_mpi_uint )
unsigned char buf[BMAX]; unsigned char buf[BMAX];
#define XMAX BMAX / sizeof( mbedtls_mpi_uint )
mbedtls_mpi_uint X[XMAX]; mbedtls_mpi_uint X[XMAX];
size_t nx, nb; size_t nx, nb;
int ret; int ret;
@ -347,8 +349,8 @@ void mbedtls_mpi_core_io_le( data_t *input, int nb_int, int nx_32_int, int iret,
exit: exit:
; ;
#undef BMAX #undef BMAX
#undef XMAX #undef XMAX
} }
/* END_CASE */ /* END_CASE */
@ -385,9 +387,10 @@ exit:
void mbedtls_mpi_mod_raw_io( data_t *input, int nb_int, int nx_64_int, void mbedtls_mpi_mod_raw_io( data_t *input, int nb_int, int nx_64_int,
int iendian, int iret, int oret ) int iendian, int iret, int oret )
{ {
#define BMAX 1024 #define BMAX 1024
#define XMAX BMAX / sizeof( mbedtls_mpi_uint )
unsigned char buf[BMAX]; unsigned char buf[BMAX];
#define XMAX BMAX / sizeof( mbedtls_mpi_uint )
mbedtls_mpi_uint X[XMAX]; mbedtls_mpi_uint X[XMAX];
mbedtls_mpi_uint init[XMAX]; mbedtls_mpi_uint init[XMAX];
mbedtls_mpi_mod_modulus m; mbedtls_mpi_mod_modulus m;
@ -476,8 +479,8 @@ void mbedtls_mpi_mod_raw_io( data_t *input, int nb_int, int nx_64_int,
exit: exit:
mbedtls_mpi_mod_modulus_free( &m ); mbedtls_mpi_mod_modulus_free( &m );
#undef BMAX #undef BMAX
#undef XMAX #undef XMAX
} }
/* END_CASE */ /* END_CASE */