Skip to content

Commit

Permalink
enforce single source for SSL buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
devsaurus committed Feb 2, 2018
1 parent 2cbce29 commit fb96406
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/include/user_mbedtls.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "c_types.h"

#include "user_config.h"

#undef MBEDTLS_HAVE_ASM
#undef MBEDTLS_HAVE_SSE2

Expand Down Expand Up @@ -288,7 +290,19 @@
//#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */
//#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */
//#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */
#define MBEDTLS_SSL_MAX_CONTENT_LEN 4096 /**< Maxium fragment length in bytes, determines the size of each of the two internal I/O buffers */

#if 0
// dynamic buffer sizing with espconn_secure_set_size()
extern unsigned int max_content_len;
#define MBEDTLS_SSL_MAX_CONTENT_LEN max_content_len;
#else
// the current mbedtls integration doesn't allow to set the buffer size dynamically:
// MBEDTLS_SSL_MAX_FRAGMENT_LENGTH feature and dynamic sizing are mutually exclusive
// due to non-constant initializer element in app/mbedtls/library/ssl_tls.c:150
// the buffer size is hardcoded here and value is taken from SSL_BUFFER_SIZE (user_config.h)
#define MBEDTLS_SSL_MAX_CONTENT_LEN SSL_BUFFER_SIZE /**< Maxium fragment length in bytes, determines the size of each of the two internal I/O buffers */
#endif

//#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */
//#define MBEDTLS_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */
//#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */
Expand Down
4 changes: 4 additions & 0 deletions app/user/user_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,13 @@ void nodemcu_init(void)
return;
}

#if 0
// espconn_secure_set_size() is not effective
// see comments for MBEDTLS_SSL_MAX_CONTENT_LEN in user_mbedtls.h
#if defined ( CLIENT_SSL_ENABLE ) && defined ( SSL_BUFFER_SIZE )
espconn_secure_set_size(ESPCONN_CLIENT, SSL_BUFFER_SIZE);
#endif
#endif

#ifdef BUILD_SPIFFS
if (!vfs_mount("/FLASH", 0)) {
Expand Down

0 comments on commit fb96406

Please sign in to comment.