1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-28 00:21:48 +03:00

Bignum: Apply naming conventions

Numbers:

- A, B for mbedtls_mpi_uint* operands
- a, b for mbedtls_mpi_uint operands
- X or x for result
- HAC references where applicable

Lengths:

- Reserve size or length for length/size in bytes or byte buffers.
- For length of mbedtls_mpi_uint* buffers use limbs
- Length parameters are qualified if possible (eg. input_length or
  a_limbs)

Setup functions:

- The parameters match the corresponding structure member's name
- The structure to set up is a standard lower case name even if in other
  functions different naming conventions would apply

Scope of changes/conventions:

- bignum_core
- bignum_mod
- bignum_mod_raw

Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
Janos Follath
2022-08-19 12:24:40 +01:00
parent 6b8a4ad0d8
commit b7a88eca42
8 changed files with 185 additions and 179 deletions

View File

@ -43,18 +43,20 @@
int mbedtls_mpi_mod_raw_read( mbedtls_mpi_uint *X,
const mbedtls_mpi_mod_modulus *m,
const unsigned char *buf,
size_t buflen )
const unsigned char *input,
size_t input_lentgth )
{
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
switch( m->ext_rep )
{
case MBEDTLS_MPI_MOD_EXT_REP_LE:
ret = mbedtls_mpi_core_read_le( X, m->limbs, buf, buflen );
ret = mbedtls_mpi_core_read_le( X, m->limbs,
input, input_lentgth );
break;
case MBEDTLS_MPI_MOD_EXT_REP_BE:
ret = mbedtls_mpi_core_read_be( X, m->limbs, buf, buflen );
ret = mbedtls_mpi_core_read_be( X, m->limbs,
input, input_lentgth );
break;
default:
return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
@ -74,17 +76,19 @@ cleanup:
return( ret );
}
int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *X,
int mbedtls_mpi_mod_raw_write( const mbedtls_mpi_uint *A,
const mbedtls_mpi_mod_modulus *m,
unsigned char *buf,
size_t buflen )
unsigned char *output,
size_t output_length )
{
switch( m->ext_rep )
{
case MBEDTLS_MPI_MOD_EXT_REP_LE:
return( mbedtls_mpi_core_write_le( X, m->limbs, buf, buflen ) );
return( mbedtls_mpi_core_write_le( A, m->limbs,
output, output_length ) );
case MBEDTLS_MPI_MOD_EXT_REP_BE:
return( mbedtls_mpi_core_write_be( X, m->limbs, buf, buflen ) );
return( mbedtls_mpi_core_write_be( A, m->limbs,
output, output_length ) );
default:
return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
}