feat(mbedtls): Add dynamic buffer and local resource managment to decrease SSL heap cost

This commit is contained in:
Dong Heng
2020-05-18 15:00:30 +08:00
parent 633322bad3
commit cfebde2081
8 changed files with 1234 additions and 2 deletions

View File

@@ -81,6 +81,40 @@ menu "mbedTLS"
This defines maximum outgoing fragment length, overriding default
maximum content length (MBEDTLS_SSL_MAX_CONTENT_LEN).
config MBEDTLS_DYNAMIC_BUFFER
bool "Using dynamic TX/RX buffer"
default n
select MBEDTLS_ASYMMETRIC_CONTENT_LEN
help
Using dynamic TX/RX buffer. After enabling this option, mbedTLS will
allocate TX buffer when need to send data and then free it if all data
is sent, allocate RX buffer when need to receive data and then free it
when all data is used or read by upper layer.
By default, when SSL is initialized, mbedTLS also allocate TX and
RX buffer with the default value of "MBEDTLS_SSL_OUT_CONTENT_LEN" or
"MBEDTLS_SSL_IN_CONTENT_LEN", so to save more heap, users can set
the options to be an appropriate value.
config MBEDTLS_DYNAMIC_FREE_PEER_CERT
bool "Free SSL peer certificate after its usage"
default n
depends on MBEDTLS_DYNAMIC_BUFFER
help
Free peer certificate after its usage in handshake process.
config MBEDTLS_DYNAMIC_FREE_CONFIG_DATA
bool "Free certificate, key and DHM data after its usage"
default n
depends on MBEDTLS_DYNAMIC_BUFFER
help
Free certificate, private key and DHM data after its usage in handshake process.
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
certificate and private key to ssl config object again.
config MBEDTLS_DEBUG
bool "Enable mbedTLS debugging"
default n