mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
mbedtls hardware RSA: Put into menuconfig, squash warnings
All combinations of enabling/disabling hardware acceleration no longer show unused warnings.
This commit is contained in:
parent
f87be70d51
commit
68d370542a
@ -22,7 +22,7 @@ config MBEDTLS_SSL_MAX_CONTENT_LEN
|
||||
|
||||
config MBEDTLS_DEBUG
|
||||
bool "Enable mbedTLS debugging"
|
||||
default "no"
|
||||
default n
|
||||
help
|
||||
Enable mbedTLS debugging functions.
|
||||
|
||||
@ -34,4 +34,23 @@ config MBEDTLS_DEBUG
|
||||
functionality. See the "https_request_main" example for a
|
||||
sample function which connects the two together.
|
||||
|
||||
config MBEDTLS_HARDWARE_AES
|
||||
bool "Enable hardware AES acceleration"
|
||||
default y
|
||||
help
|
||||
Enable hardware accelerated AES encryption & decryption.
|
||||
|
||||
config MBEDTLS_HARDWARE_MPI
|
||||
bool "Enable hardware MPI (bignum) acceleration"
|
||||
default y
|
||||
help
|
||||
Enable hardware accelerated multiple precision integer operations.
|
||||
|
||||
Hardware accelerated multiplication, modulo multiplication,
|
||||
and modular exponentiation for up to 4096 bit results.
|
||||
|
||||
These operations are used by RSA.
|
||||
|
||||
|
||||
|
||||
endmenu
|
||||
|
@ -1092,6 +1092,8 @@ int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint
|
||||
return( mbedtls_mpi_sub_mpi( X, A, &_B ) );
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_MPI_MUL_MPI_ALT) || !defined(MBEDTLS_MPI_EXP_MOD_ALT)
|
||||
|
||||
/*
|
||||
* Helper for mbedtls_mpi multiplication
|
||||
*/
|
||||
@ -1103,6 +1105,7 @@ static
|
||||
*/
|
||||
__attribute__ ((noinline))
|
||||
#endif
|
||||
|
||||
void mpi_mul_hlp( size_t i, mbedtls_mpi_uint *s, mbedtls_mpi_uint *d, mbedtls_mpi_uint b )
|
||||
{
|
||||
mbedtls_mpi_uint c = 0, t = 0;
|
||||
@ -1164,6 +1167,8 @@ void mpi_mul_hlp( size_t i, mbedtls_mpi_uint *s, mbedtls_mpi_uint *d, mbedtls_mp
|
||||
while( c != 0 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_MPI_MUL_MPI_ALT)
|
||||
/*
|
||||
* Baseline multiplication: X = A * B (HAC 14.12)
|
||||
@ -1526,6 +1531,8 @@ int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_MPI_EXP_MOD_ALT)
|
||||
|
||||
/*
|
||||
* Fast Montgomery initialization (thanks to Tom St Denis)
|
||||
*/
|
||||
@ -1600,7 +1607,6 @@ static int mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, mbedtls_mpi_uint m
|
||||
return( mpi_montmul( A, &U, N, mm, T ) );
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_MPI_EXP_MOD_ALT)
|
||||
/*
|
||||
* Sliding-window exponentiation: X = A^E mod N (HAC 14.85)
|
||||
*/
|
||||
|
@ -35,8 +35,6 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
static const char *TAG = "bignum";
|
||||
|
||||
#if defined(MBEDTLS_MPI_MUL_MPI_ALT) || defined(MBEDTLS_MPI_EXP_MOD_ALT)
|
||||
|
||||
static _lock_t mpi_lock;
|
||||
@ -330,6 +328,8 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi* Z, const mbedtls_mpi* X, const mbedtls_mpi
|
||||
/* Second & final step of a modular multiply - load second multiplication
|
||||
* factor Y, run the multiply, read back the result into Z.
|
||||
*
|
||||
* Called from both mbedtls_mpi_exp_mod and mbedtls_mpi_mod_mpi.
|
||||
*
|
||||
* @param Z result value
|
||||
* @param X first multiplication factor (used to set sign of result).
|
||||
* @param Y second multiplication factor.
|
||||
@ -338,7 +338,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi* Z, const mbedtls_mpi* X, const mbedtls_mpi
|
||||
*
|
||||
* Caller must have already called esp_mpi_acquire_hardware().
|
||||
*/
|
||||
inline static int modular_multiply_finish(mbedtls_mpi *Z, const mbedtls_mpi *X, const mbedtls_mpi *Y, size_t num_words)
|
||||
static int modular_multiply_finish(mbedtls_mpi *Z, const mbedtls_mpi *X, const mbedtls_mpi *Y, size_t num_words)
|
||||
{
|
||||
int ret;
|
||||
/* Load Y to X input memory block, rerun */
|
||||
@ -356,6 +356,8 @@ inline static int modular_multiply_finish(mbedtls_mpi *Z, const mbedtls_mpi *X,
|
||||
|
||||
#if defined(MBEDTLS_MPI_MUL_MPI_ALT) /* MBEDTLS_MPI_MUL_MPI_ALT */
|
||||
|
||||
static const char *TAG = "bignum";
|
||||
|
||||
static int mpi_mult_mpi_failover_mod_mult(mbedtls_mpi *Z, const mbedtls_mpi *X, const mbedtls_mpi *Y, size_t num_words);
|
||||
|
||||
/* Z = X * Y */
|
||||
|
@ -239,7 +239,9 @@
|
||||
/* The following units have ESP32 hardware support,
|
||||
uncommenting each _ALT macro will use the
|
||||
hardware-accelerated implementation. */
|
||||
#ifdef CONFIG_MBEDTLS_HARDWARE_AES
|
||||
#define MBEDTLS_AES_ALT
|
||||
#endif
|
||||
|
||||
/* Currently hardware SHA does not work with TLS handshake,
|
||||
due to concurrency issue. Internal TW#7111. */
|
||||
@ -251,8 +253,10 @@
|
||||
Uncommenting these macros will use the hardware-accelerated
|
||||
implementations.
|
||||
*/
|
||||
#ifdef CONFIG_MBEDTLS_HARDWARE_MPI
|
||||
#define MBEDTLS_MPI_EXP_MOD_ALT
|
||||
#define MBEDTLS_MPI_MUL_MPI_ALT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_MD2_PROCESS_ALT
|
||||
|
Loading…
x
Reference in New Issue
Block a user