mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-01 10:06:53 +03:00
Move Bignum macros to common header
Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include "mbedtls/bignum.h"
|
#include "mbedtls/bignum.h"
|
||||||
#include "bignum_internal.h"
|
#include "bignum_internal.h"
|
||||||
|
#include "bignum_core.h"
|
||||||
#include "bn_mul.h"
|
#include "bn_mul.h"
|
||||||
#include "mbedtls/platform_util.h"
|
#include "mbedtls/platform_util.h"
|
||||||
#include "mbedtls/error.h"
|
#include "mbedtls/error.h"
|
||||||
@ -57,24 +58,8 @@
|
|||||||
#define mbedtls_free free
|
#define mbedtls_free free
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MPI_VALIDATE_RET( cond ) \
|
|
||||||
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_MPI_BAD_INPUT_DATA )
|
|
||||||
#define MPI_VALIDATE( cond ) \
|
|
||||||
MBEDTLS_INTERNAL_VALIDATE( cond )
|
|
||||||
|
|
||||||
#define ciL (sizeof(mbedtls_mpi_uint)) /* chars in limb */
|
|
||||||
#define biL (ciL << 3) /* bits in limb */
|
|
||||||
#define biH (ciL << 2) /* half limb size */
|
|
||||||
|
|
||||||
#define MPI_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */
|
#define MPI_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert between bits/chars and number of limbs
|
|
||||||
* Divide first in order to avoid potential overflows
|
|
||||||
*/
|
|
||||||
#define BITS_TO_LIMBS(i) ( (i) / biL + ( (i) % biL != 0 ) )
|
|
||||||
#define CHARS_TO_LIMBS(i) ( (i) / ciL + ( (i) % ciL != 0 ) )
|
|
||||||
|
|
||||||
/* Implementation that should never be optimized out by the compiler */
|
/* Implementation that should never be optimized out by the compiler */
|
||||||
static void mbedtls_mpi_zeroize( mbedtls_mpi_uint *v, size_t n )
|
static void mbedtls_mpi_zeroize( mbedtls_mpi_uint *v, size_t n )
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,22 @@
|
|||||||
#include "mbedtls/bignum.h"
|
#include "mbedtls/bignum.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MPI_VALIDATE_RET( cond ) \
|
||||||
|
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_MPI_BAD_INPUT_DATA )
|
||||||
|
#define MPI_VALIDATE( cond ) \
|
||||||
|
MBEDTLS_INTERNAL_VALIDATE( cond )
|
||||||
|
|
||||||
|
#define ciL (sizeof(mbedtls_mpi_uint)) /* chars in limb */
|
||||||
|
#define biL (ciL << 3) /* bits in limb */
|
||||||
|
#define biH (ciL << 2) /* half limb size */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert between bits/chars and number of limbs
|
||||||
|
* Divide first in order to avoid potential overflows
|
||||||
|
*/
|
||||||
|
#define BITS_TO_LIMBS(i) ( (i) / biL + ( (i) % biL != 0 ) )
|
||||||
|
#define CHARS_TO_LIMBS(i) ( (i) / ciL + ( (i) % ciL != 0 ) )
|
||||||
|
|
||||||
int mbedtls_mpi_core_read_le( mbedtls_mpi_uint *X,
|
int mbedtls_mpi_core_read_le( mbedtls_mpi_uint *X,
|
||||||
size_t nx,
|
size_t nx,
|
||||||
const unsigned char *buf,
|
const unsigned char *buf,
|
||||||
|
@ -40,22 +40,6 @@
|
|||||||
#define mbedtls_free free
|
#define mbedtls_free free
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MPI_VALIDATE_RET( cond ) \
|
|
||||||
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_MPI_BAD_INPUT_DATA )
|
|
||||||
#define MPI_VALIDATE( cond ) \
|
|
||||||
MBEDTLS_INTERNAL_VALIDATE( cond )
|
|
||||||
|
|
||||||
#define ciL (sizeof(mbedtls_mpi_uint)) /* chars in limb */
|
|
||||||
#define biL (ciL << 3) /* bits in limb */
|
|
||||||
#define biH (ciL << 2) /* half limb size */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert between bits/chars and number of limbs
|
|
||||||
* Divide first in order to avoid potential overflows
|
|
||||||
*/
|
|
||||||
#define BITS_TO_LIMBS(i) ( (i) / biL + ( (i) % biL != 0 ) )
|
|
||||||
#define CHARS_TO_LIMBS(i) ( (i) / ciL + ( (i) % ciL != 0 ) )
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Count leading zero bits in a given integer
|
* Count leading zero bits in a given integer
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user