mirror of
https://github.com/espressif/mbedtls.git
synced 2025-05-08 19:04:04 +08:00
mbedtls: Re-apply MBEDTLS_BIGNUM_ALT & related macros for custom bignum functions
(IDF-specific patch.) (cherry picked from commit f859b9bc7579246703446c158270ae038442351c)
This commit is contained in:
parent
1873d3bfc2
commit
5e106db3a1
@ -111,6 +111,8 @@
|
||||
MBEDTLS_LN_2_DIV_LN_10_SCALE100 - 1) / \
|
||||
MBEDTLS_LN_2_DIV_LN_10_SCALE100) + 10 + 6)
|
||||
|
||||
#if !defined(MBEDTLS_BIGNUM_ALT)
|
||||
|
||||
/*
|
||||
* Define the base integer type, architecture-wise.
|
||||
*
|
||||
@ -1052,6 +1054,9 @@ typedef enum {
|
||||
int mbedtls_mpi_gen_prime(mbedtls_mpi *X, size_t nbits, int flags,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng);
|
||||
#else /* MBEDTLS_BIGNUM_ALT */
|
||||
#include "bignum_alt.h"
|
||||
#endif /* MBEDTLS_BIGNUM_ALT */
|
||||
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
|
||||
|
@ -49,10 +49,19 @@
|
||||
|
||||
#include "mbedtls/platform.h"
|
||||
|
||||
<<<<<<< HEAD
|
||||
#define MPI_VALIDATE_RET(cond) \
|
||||
MBEDTLS_INTERNAL_VALIDATE_RET(cond, MBEDTLS_ERR_MPI_BAD_INPUT_DATA)
|
||||
#define MPI_VALIDATE(cond) \
|
||||
MBEDTLS_INTERNAL_VALIDATE(cond)
|
||||
=======
|
||||
#if !defined(MBEDTLS_BIGNUM_ALT)
|
||||
|
||||
#define MPI_VALIDATE_RET( cond ) \
|
||||
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_MPI_BAD_INPUT_DATA )
|
||||
#define MPI_VALIDATE( cond ) \
|
||||
MBEDTLS_INTERNAL_VALIDATE( cond )
|
||||
>>>>>>> f859b9bc7 (mbedtls: Re-apply MBEDTLS_BIGNUM_ALT & related macros for custom bignum functions)
|
||||
|
||||
#define MPI_SIZE_T_MAX ((size_t) -1) /* SIZE_T_MAX is not standard */
|
||||
|
||||
@ -1123,6 +1132,7 @@ int mbedtls_mpi_sub_int(mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b
|
||||
return mbedtls_mpi_sub_mpi(X, A, &B);
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_MPI_MUL_MPI_ALT)
|
||||
/*
|
||||
* Baseline multiplication: X = A * B (HAC 14.12)
|
||||
*/
|
||||
@ -1229,6 +1239,7 @@ int mbedtls_mpi_mul_int(mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_uint b
|
||||
cleanup:
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Unsigned integer divide - double mbedtls_mpi_uint dividend, u1/u0, and
|
||||
@ -1566,6 +1577,8 @@ int mbedtls_mpi_mod_int(mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_s
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_MPI_EXP_MOD_ALT)
|
||||
|
||||
static void mpi_montg_init(mbedtls_mpi_uint *mm, const mbedtls_mpi *N)
|
||||
{
|
||||
*mm = mbedtls_mpi_core_montmul_init(N->p);
|
||||
@ -1944,6 +1957,7 @@ cleanup:
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Greatest common divisor: G = gcd(A, B) (HAC 14.54)
|
||||
@ -2517,6 +2531,7 @@ cleanup:
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_GENPRIME */
|
||||
#endif /* MBEDTLS_BIGNUM_ALT */
|
||||
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user