feat(mbedtls): add kconfig option for MBEDTLS_ERROR_C

Disabling this config can reduce footprint for the cases where
mbedtls_strerror() is used and hence the debug strings are getting
pulled into the application image.
This commit is contained in:
Mahavir Jain
2024-04-03 18:49:19 +05:30
parent 53e2f9096d
commit b6f5573e0f
2 changed files with 29 additions and 17 deletions

View File

@ -123,7 +123,7 @@ menu "mbedTLS"
The option will decrease heap cost when handshake, but also lead to problem: The option will decrease heap cost when handshake, but also lead to problem:
Becasue all certificate, private key and DHM data are freed so users should register Because all certificate, private key and DHM data are freed so users should register
certificate and private key to ssl config object again. certificate and private key to ssl config object again.
config MBEDTLS_DYNAMIC_FREE_CA_CERT config MBEDTLS_DYNAMIC_FREE_CA_CERT
@ -425,6 +425,17 @@ menu "mbedTLS"
These operations are used by RSA. These operations are used by RSA.
config MBEDTLS_LARGE_KEY_SOFTWARE_MPI
bool "Fallback to software implementation for larger MPI values"
depends on MBEDTLS_HARDWARE_MPI
default y if SOC_RSA_MAX_BIT_LEN <= 3072 # HW max 3072 bits
default n
help
Fallback to software implementation for RSA key lengths
larger than SOC_RSA_MAX_BIT_LEN. If this is not active
then the ESP will be unable to process keys greater
than SOC_RSA_MAX_BIT_LEN.
config MBEDTLS_MPI_USE_INTERRUPT config MBEDTLS_MPI_USE_INTERRUPT
bool "Use interrupt for MPI exp-mod operations" bool "Use interrupt for MPI exp-mod operations"
depends on !IDF_TARGET_ESP32 && MBEDTLS_HARDWARE_MPI depends on !IDF_TARGET_ESP32 && MBEDTLS_HARDWARE_MPI
@ -865,13 +876,13 @@ menu "mbedTLS"
bool "X.509 CRL parsing" bool "X.509 CRL parsing"
default y default y
help help
Support for parsing X.509 Certifificate Revocation Lists. Support for parsing X.509 Certificate Revocation Lists.
config MBEDTLS_X509_CSR_PARSE_C config MBEDTLS_X509_CSR_PARSE_C
bool "X.509 CSR parsing" bool "X.509 CSR parsing"
default y default y
help help
Support for parsing X.509 Certifificate Signing Requests Support for parsing X.509 Certificate Signing Requests
endmenu # Certificates endmenu # Certificates
@ -1062,16 +1073,13 @@ menu "mbedTLS"
help help
Enable the pthread wrapper layer for the threading layer. Enable the pthread wrapper layer for the threading layer.
config MBEDTLS_LARGE_KEY_SOFTWARE_MPI config MBEDTLS_ERROR_STRINGS
bool "Fallback to software implementation for larger MPI values" bool "Enable error code to error string conversion"
depends on MBEDTLS_HARDWARE_MPI default y
default y if SOC_RSA_MAX_BIT_LEN <= 3072 # HW max 3072 bits
default n
help help
Fallback to software implementation for RSA key lengths Enables mbedtls_strerror() for converting error codes to error strings.
larger than SOC_RSA_MAX_BIT_LEN. If this is not active Disabling this config can save some code/rodata size as the error
then the ESP will be unable to process keys greater string conversion implementation is replaced with an empty stub.
than SOC_RSA_MAX_BIT_LEN.
config MBEDTLS_USE_CRYPTO_ROM_IMPL config MBEDTLS_USE_CRYPTO_ROM_IMPL
bool "Use ROM implementation of the crypto algorithm" bool "Use ROM implementation of the crypto algorithm"

View File

@ -71,7 +71,7 @@
* \def MBEDTLS_HAVE_TIME_DATE * \def MBEDTLS_HAVE_TIME_DATE
* *
* System has time.h and time(), gmtime() and the clock is correct. * System has time.h and time(), gmtime() and the clock is correct.
* The time needs to be correct (not necesarily very accurate, but at least * The time needs to be correct (not necessarily very accurate, but at least
* the date should be correct). This is used to verify the validity period of * the date should be correct). This is used to verify the validity period of
* X.509 certificates. * X.509 certificates.
* *
@ -986,7 +986,7 @@
* functions mbedtls_ssl_context_save() and mbedtls_ssl_context_load(). * functions mbedtls_ssl_context_save() and mbedtls_ssl_context_load().
* *
* This pair of functions allows one side of a connection to serialize the * This pair of functions allows one side of a connection to serialize the
* context associated with the connection, then free or re-use that context * context associated with the connection, then free or reuse that context
* while the serialized state is persisted elsewhere, and finally deserialize * while the serialized state is persisted elsewhere, and finally deserialize
* that state to a live context for resuming read/write operations on the * that state to a live context for resuming read/write operations on the
* connection. From a protocol perspective, the state of the connection is * connection. From a protocol perspective, the state of the connection is
@ -1484,7 +1484,7 @@
* \def MBEDTLS_SSL_SESSION_TICKETS * \def MBEDTLS_SSL_SESSION_TICKETS
* *
* Enable support for RFC 5077 session tickets in SSL. * Enable support for RFC 5077 session tickets in SSL.
* Client-side, provides full support for session tickets (maintainance of a * Client-side, provides full support for session tickets (maintenance of a
* session store remains the responsibility of the application, though). * session store remains the responsibility of the application, though).
* Server-side, you also need to provide callbacks for writing and parsing * Server-side, you also need to provide callbacks for writing and parsing
* tickets, including authenticated encryption and key management. Example * tickets, including authenticated encryption and key management. Example
@ -2066,7 +2066,11 @@
* *
* This module enables mbedtls_strerror(). * This module enables mbedtls_strerror().
*/ */
#if CONFIG_MBEDTLS_ERROR_STRINGS
#define MBEDTLS_ERROR_C #define MBEDTLS_ERROR_C
#else
#undef MBEDTLS_ERROR_C
#endif
/** /**
* \def MBEDTLS_GCM_C * \def MBEDTLS_GCM_C
@ -2116,7 +2120,7 @@
* *
* Requires: MBEDTLS_MD_C * Requires: MBEDTLS_MD_C
* *
* Uncomment to enable the HMAC_DRBG random number geerator. * Uncomment to enable the HMAC_DRBG random number generator.
*/ */
#define MBEDTLS_HMAC_DRBG_C #define MBEDTLS_HMAC_DRBG_C
@ -2808,7 +2812,7 @@
/* SSL options */ /* SSL options */
#ifndef CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN #ifndef CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN
#define MBEDTLS_SSL_MAX_CONTENT_LEN CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN /**< Maxium fragment length in bytes, determines the size of each of the two internal I/O buffers */ #define MBEDTLS_SSL_MAX_CONTENT_LEN CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN /**< Maximum fragment length in bytes, determines the size of each of the two internal I/O buffers */
#else #else