Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to disable TLS fragmentation #112

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/config/tls.h
@@ -0,0 +1,26 @@
#ifndef CONFIG_TLS_H
#define CONFIG_TLS_H

/** @file
*
* TLS configuration
*
* These options affect the operation of the behaviour of the
* TLS implementation.
*
*/

FILE_LICENCE ( GPL2_OR_LATER );

#define TLS_FRAGMENTATION_ENABLED /* If the TLS implementation should
* request a maximum fragment length */
#define TLS_REQUESTED_MAX_FRAGMENT_LENGTH TLS_MAX_FRAGMENT_LENGTH_4096 /* Which fragment
* length should
* be requested */

#include <config/named.h>
#include NAMED_CONFIG(tls.h)
#include <config/local/tls.h>
#include LOCAL_NAMED_CONFIG(tls.h)

#endif /* CONFIG_TLS_H */
7 changes: 6 additions & 1 deletion src/net/tls.c
Expand Up @@ -49,6 +49,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/validator.h>
#include <ipxe/job.h>
#include <ipxe/tls.h>
#include <config/tls.h>

/* Disambiguate the various error causes */
#define EINVAL_CHANGE_CIPHER __einfo_error ( EINFO_EINVAL_CHANGE_CIPHER )
Expand Down Expand Up @@ -1036,11 +1037,13 @@ static int tls_send_client_hello ( struct tls_connection *tls ) {
uint8_t name[name_len];
} __attribute__ (( packed )) list[1];
} __attribute__ (( packed )) server_name;
#ifdef TLS_FRAGMENTATION_ENABLED
uint16_t max_fragment_length_type;
uint16_t max_fragment_length_len;
struct {
uint8_t max;
} __attribute__ (( packed )) max_fragment_length;
#endif
uint16_t signature_algorithms_type;
uint16_t signature_algorithms_len;
struct {
Expand Down Expand Up @@ -1091,12 +1094,14 @@ static int tls_send_client_hello ( struct tls_connection *tls ) {
= htons ( sizeof ( hello.extensions.server_name.list[0].name ));
memcpy ( hello.extensions.server_name.list[0].name, session->name,
sizeof ( hello.extensions.server_name.list[0].name ) );
#ifdef TLS_FRAGMENTATION_ENABLED
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_4096;
= TLS_REQUESTED_MAX_FRAGMENT_LENGTH;
#endif
hello.extensions.signature_algorithms_type
= htons ( TLS_SIGNATURE_ALGORITHMS );
hello.extensions.signature_algorithms_len
Expand Down