mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-04-29 11:14:36 +00:00
Use the new pipeline cipher capability to encrypt multiple records being written out all in one go. Two new SSL/SSL_CTX parameters can be used to control how this works: max_pipelines and split_send_fragment. max_pipelines defines the maximum number of pipelines that can ever be used in one go for a single connection. It must always be less than or equal to SSL_MAX_PIPELINES (currently defined to be 32). By default only one pipeline will be used (i.e. normal non-parallel operation). split_send_fragment defines how data is split up into pipelines. The number of pipelines used will be determined by the amount of data provided to the SSL_write call divided by split_send_fragment. For example if split_send_fragment is set to 2000 and max_pipelines is 4 then: SSL_write called with 0-2000 bytes == 1 pipeline used SSL_write called with 2001-4000 bytes == 2 pipelines used SSL_write called with 4001-6000 bytes == 3 pipelines used SSL_write_called with 6001+ bytes == 4 pipelines used split_send_fragment must always be less than or equal to max_send_fragment. By default it is set to be equal to max_send_fragment. This will mean that the same number of records will always be created as would have been created in the non-parallel case, although the data will be apportioned differently. In the parallel case data will be spread equally between the pipelines. Reviewed-by: Tim Hudson <tjh@openssl.org>
Record Layer Design =================== This file provides some guidance on the thinking behind the design of the record layer code to aid future maintenance. The record layer is divided into a number of components. At the time of writing there are four: SSL3_RECORD, SSL3_BUFFER, DLTS1_BITMAP and RECORD_LAYER. Each of these components is defined by: 1) A struct definition of the same name as the component 2) A set of source files that define the functions for that component 3) A set of accessor macros All struct definitions are in record.h. The functions and macros are either defined in record.h or record_locl.h dependent on whether they are intended to be private to the record layer, or whether they form part of the API to the rest of libssl. The source files map to components as follows: dtls1_bitmap.c -> DTLS1_BITMAP component ssl3_buffer.c -> SSL3_BUFFER component ssl3_record.c -> SSL3_RECORD component rec_layer_s3.c, rec_layer_d1.c -> RECORD_LAYER component The RECORD_LAYER component is a facade pattern, i.e. it provides a simplified interface to the record layer for the rest of libssl. The other 3 components are entirely private to the record layer and therefore should never be accessed directly by libssl. Any component can directly access its own members - they are private to that component, e.g. ssl3_buffer.c can access members of the SSL3_BUFFER struct without using a macro. No component can directly access the members of another component, e.g. ssl3_buffer cannot reach inside the RECORD_LAYER component to directly access its members. Instead components use accessor macros, so if code in ssl3_buffer.c wants to access the members of the RECORD_LAYER it uses the RECORD_LAYER_* macros. Conceptually it looks like this: libssl | ---------------------------|-----record.h-------------------------------------- | _______V______________ | | | RECORD_LAYER | | | | rec_layer_s3.c | | ^ | | _________|__________ | || || || DTLS1_RECORD_LAYER || || || || rec_layer_d1.c || ||____________________|| |______________________| record_locl.h ^ ^ ^ _________________| | |_________________ | | | _____V_________ ______V________ _______V________ | | | | | | | SSL3_BUFFER | | SSL3_RECORD | | DTLS1_BITMAP | | |--->| | | | | ssl3_buffer.c | | ssl3_record.c | | dtls1_bitmap.c | |_______________| |_______________| |________________| The two RECORD_LAYER source files build on each other, i.e. the main one is rec_layer_s3.c which provides the core SSL/TLS layer. The second one is rec_layer_d1.c which builds off of the SSL/TLS code to provide DTLS specific capabilities. It uses some DTLS specific RECORD_LAYER component members which should only be accessed from rec_layer_d1.c. These are held in the DTLS1_RECORD_LAYER struct.