summaryrefslogtreecommitdiffstats
path: root/src/net/tls.c
diff options
context:
space:
mode:
authorMichael Brown2012-06-29 16:28:15 +0200
committerMichael Brown2012-06-29 16:28:15 +0200
commit9a8c6b00d4433eb5c24f50c0c4a93c127d77def0 (patch)
tree4c365afc9d8a34dbaf784779ac842c63142d4c07 /src/net/tls.c
parent[tcp] Add support for TCP window scaling (diff)
downloadipxe-9a8c6b00d4433eb5c24f50c0c4a93c127d77def0.tar.gz
ipxe-9a8c6b00d4433eb5c24f50c0c4a93c127d77def0.tar.xz
ipxe-9a8c6b00d4433eb5c24f50c0c4a93c127d77def0.zip
[tls] Request a maximum fragment length of 2048 bytes
The default maximum plaintext fragment length for TLS is 16kB, which is a substantial amount of memory for iPXE to have to allocate for a temporary decryption buffer. Reduce the memory footprint of TLS connections by requesting a maximum fragment length of 2kB. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/tls.c')
-rw-r--r--src/net/tls.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/net/tls.c b/src/net/tls.c
index 8d6620d3..a3433f92 100644
--- a/src/net/tls.c
+++ b/src/net/tls.c
@@ -869,6 +869,11 @@ static int tls_send_client_hello ( struct tls_session *tls ) {
uint8_t name[ strlen ( tls->name ) ];
} __attribute__ (( packed )) list[1];
} __attribute__ (( packed )) server_name;
+ uint16_t max_fragment_length_type;
+ uint16_t max_fragment_length_len;
+ struct {
+ uint8_t max;
+ } __attribute__ (( packed )) max_fragment_length;
} __attribute__ (( packed )) extensions;
} __attribute__ (( packed )) hello;
unsigned int i;
@@ -894,6 +899,12 @@ static int tls_send_client_hello ( struct tls_session *tls ) {
= htons ( sizeof ( hello.extensions.server_name.list[0].name ));
memcpy ( hello.extensions.server_name.list[0].name, tls->name,
sizeof ( hello.extensions.server_name.list[0].name ) );
+ hello.extensions.max_fragment_length_type
+ = htons ( TLS_MAX_FRAGMENT_LENGTH );
+ hello.extensions.max_fragment_length_len
+ = htons ( sizeof ( hello.extensions.max_fragment_length ) );
+ hello.extensions.max_fragment_length.max
+ = TLS_MAX_FRAGMENT_LENGTH_2048;
return tls_send_handshake ( tls, &hello, sizeof ( hello ) );
}