mbedtls/port: Fix dynamic buffers feature for v3.2.1

Co-authored-by: Li Jingyi <lijingyi@espressif.com>
This commit is contained in:
Laukik Hase
2022-08-08 14:28:07 +05:30
parent 6319970ab7
commit 9b290e3668
4 changed files with 145 additions and 23 deletions

View File

@@ -8,8 +8,10 @@
#include "esp_mbedtls_dynamic_impl.h"
int __real_mbedtls_ssl_handshake_client_step(mbedtls_ssl_context *ssl);
int __real_mbedtls_ssl_write_client_hello(mbedtls_ssl_context *ssl);
int __wrap_mbedtls_ssl_handshake_client_step(mbedtls_ssl_context *ssl);
int __wrap_mbedtls_ssl_write_client_hello(mbedtls_ssl_context *ssl);
static const char *TAG = "SSL client";
@@ -27,6 +29,16 @@ static int manage_resource(mbedtls_ssl_context *ssl, bool add)
}
}
/* Change state now, so that it is right in mbedtls_ssl_read_record(), used
* by DTLS for dropping out-of-sequence ChangeCipherSpec records */
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
if( ssl->state == MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC &&
ssl->handshake->new_session_ticket != 0 )
{
ssl->state = MBEDTLS_SSL_SERVER_NEW_SESSION_TICKET;
}
#endif
switch (state) {
case MBEDTLS_SSL_HELLO_REQUEST:
break;
@@ -189,3 +201,14 @@ int __wrap_mbedtls_ssl_handshake_client_step(mbedtls_ssl_context *ssl)
return 0;
}
int __wrap_mbedtls_ssl_write_client_hello(mbedtls_ssl_context *ssl)
{
CHECK_OK(manage_resource(ssl, true));
CHECK_OK(__real_mbedtls_ssl_write_client_hello(ssl));
CHECK_OK(manage_resource(ssl, false));
return 0;
}