config MBEDTLS_DEBUG
bool "Enable mbedTLS debugging"
- default "no"
+ default n
help
Enable mbedTLS debugging functions.
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
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
*/
*/
__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;
while( c != 0 );
}
+#endif
+
#if !defined(MBEDTLS_MPI_MUL_MPI_ALT)
/*
* Baseline multiplication: X = A * B (HAC 14.12)
return( 0 );
}
+#if !defined(MBEDTLS_MPI_EXP_MOD_ALT)
+
/*
* Fast Montgomery initialization (thanks to Tom St Denis)
*/
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)
*/
#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;
/* 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.
*
* 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 */
#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 */
/* 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. */
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