From e81436ffe9bdc7a999bc9013bb04f9fa3a60beb9 Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 19 Nov 2018 13:26:48 -0800 Subject: [PATCH] Add support for altering the max-fragment size post-handshake using existing API `wolfSSL_UseMaxFragment`. --- src/ssl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/ssl.c b/src/ssl.c index ac9d8d23d..1b047ccef 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -1954,6 +1954,24 @@ int wolfSSL_UseMaxFragment(WOLFSSL* ssl, byte mfl) if (ssl == NULL) return BAD_FUNC_ARG; + /* The following is a non-standard way to reconfigure the max packet size + post-handshake for wolfSSL_write/woflSSL_read */ + if (ssl->options.handShakeState == HANDSHAKE_DONE) { + switch (mfl) { + case WOLFSSL_MFL_2_8 : ssl->max_fragment = 256; break; + case WOLFSSL_MFL_2_9 : ssl->max_fragment = 512; break; + case WOLFSSL_MFL_2_10: ssl->max_fragment = 1024; break; + case WOLFSSL_MFL_2_11: ssl->max_fragment = 2048; break; + case WOLFSSL_MFL_2_12: ssl->max_fragment = 4096; break; + case WOLFSSL_MFL_2_13: ssl->max_fragment = 8192; break; + default: ssl->max_fragment = MAX_RECORD_SIZE; break; + } + return WOLFSSL_SUCCESS; + } + + /* This call sets the max fragment TLS extension, which gets sent to server. + The server_hello response is what sets the `ssl->max_fragment` in + TLSX_MFL_Parse */ return TLSX_UseMaxFragment(&ssl->extensions, mfl, ssl->heap); }