From ccbd46435f455488f55b1fad124b0e25b7cf50cb Mon Sep 17 00:00:00 2001 From: Simon Butcher Date: Sun, 22 Jul 2018 14:43:39 +0100 Subject: [PATCH 1/2] Increase the memory buffer size for ssl_server2.c Newer features in the library have increased the overall RAM usage of the library, when all features are enabled. ssl_server2.c, with all features enabled was running out of memory for the ssl-opt.sh test 'Authentication: client max_int chain, server required'. This commit increases the memory buffer allocation for ssl_server2.c to allow the test to work with all features enabled. --- programs/ssl/ssl_server2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 3a413ad5e..26f023d7f 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1212,7 +1212,7 @@ int main( int argc, char *argv[] ) const char *alpn_list[ALPN_LIST_SIZE]; #endif #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) - unsigned char alloc_buf[100000]; + unsigned char alloc_buf[120000]; #endif int i; From cce68bec1d47bf985f75485df3b77a371679cea5 Mon Sep 17 00:00:00 2001 From: Simon Butcher Date: Mon, 23 Jul 2018 14:26:09 +0100 Subject: [PATCH 2/2] Add a macro to define the memory size in ssl_server2.c When MBEDTLS_MEMORY_BUFFER_ALLOC_C was defined, the sample ssl_server2.c was using its own memory buffer for memory allocated by the library. The memory used wasn't obvious, so this adds a macro for the memory buffer allocated to make the allocated memory size more obvious and hence easier to configure. --- programs/ssl/ssl_server2.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 26f023d7f..7654a6446 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -97,6 +97,10 @@ int main( void ) #include #endif +/* Size of memory to be allocated for the heap, when using the library's memory + * management and MBEDTLS_MEMORY_BUFFER_ALLOC_C is enabled. */ +#define MEMORY_HEAP_SIZE 120000 + #define DFL_SERVER_ADDR NULL #define DFL_SERVER_PORT "4433" #define DFL_DEBUG_LEVEL 0 @@ -1212,7 +1216,7 @@ int main( int argc, char *argv[] ) const char *alpn_list[ALPN_LIST_SIZE]; #endif #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) - unsigned char alloc_buf[120000]; + unsigned char alloc_buf[MEMORY_HEAP_SIZE]; #endif int i;