Apache HTTPD
tls_filter.h
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef tls_filter_h
17#define tls_filter_h
18
19#define TLS_FILTER_RAW "TLS raw"
20
22
24 conn_rec *c; /* connection this context is for */
25 tls_conf_conn_t *cc; /* tls module configuration of connection */
26
27 ap_filter_t *fin_ctx; /* Apache's entry into the input filter chain */
28 apr_bucket_brigade *fin_tls_bb; /* TLS encrypted, incoming network data */
29 apr_bucket_brigade *fin_tls_buffer_bb; /* TLS encrypted, incoming network data buffering */
30 apr_bucket_brigade *fin_plain_bb; /* decrypted, incoming traffic data */
31 apr_off_t fin_bytes_in_rustls; /* # of input TLS bytes in rustls_connection */
32 apr_read_type_e fin_block; /* Do we block on input reads or not? */
33
34 ap_filter_t *fout_ctx; /* Apache's entry into the output filter chain */
35 char *fout_buf_plain; /* a buffer to collect plain bytes for output */
36 apr_size_t fout_buf_plain_len; /* the amount of bytes in the buffer */
37 apr_size_t fout_buf_plain_size; /* the total size of the buffer */
38 apr_bucket_brigade *fout_tls_bb; /* TLS encrypted, outgoing network data */
39 apr_off_t fout_bytes_in_rustls; /* # of output plain bytes in rustls_connection */
40 apr_off_t fout_bytes_in_tls_bb; /* # of output tls bytes in our brigade */
41
42 apr_size_t fin_max_in_rustls; /* how much tls we like to read into rustls */
43 apr_size_t fout_max_in_rustls; /* how much plain bytes we like in rustls */
44 apr_size_t fout_max_bucket_size; /* how large bucket chunks we handle before splitting */
45 apr_size_t fout_auto_flush_size; /* on much outoing TLS data we flush to network */
46};
47
52
59
66
67/*
68 * <https://tools.ietf.org/html/rfc8449> says:
69 * "For large data transfers, small record sizes can materially affect performance."
70 * and
71 * "For TLS 1.2 and earlier, that limit is 2^14 octets. TLS 1.3 uses a limit of
72 * 2^14+1 octets."
73 * Maybe future TLS versions will raise that value, but for now these limits stand.
74 * Given the choice, we would like rustls to provide traffic data in those chunks.
75 */
76#define TLS_PREF_PLAIN_CHUNK_SIZE (16384)
77
78/*
79 * When retrieving TLS chunks for rustls, or providing it a buffer
80 * to pass out TLS chunks (which are then bucketed and written to the
81 * network filters), we ideally would do that in multiples of TLS
82 * messages sizes.
83 * That would be TLS_PREF_WRITE_SIZE + TLS Message Overhead, such as
84 * MAC and padding. But these vary with protocol and ciphers chosen, so
85 * we define something which should be "large enough", but not overly so.
86 */
87#define TLS_REC_EXTRA (1024)
88#define TLS_REC_MAX_SIZE (TLS_PREF_PLAIN_CHUNK_SIZE + TLS_REC_EXTRA)
89
90#endif /* tls_filter_h */
apr_read_type_e
Definition apr_buckets.h:57
apr_size_t size
const char int apr_pool_t * pool
Definition apr_cstr.h:84
apr_vformatter_buff_t * c
Definition apr_lib.h:175
The representation of a filter chain.
Structure to store things which are per connection.
Definition httpd.h:1152
apr_bucket_brigade * fout_tls_bb
Definition tls_filter.h:38
ap_filter_t * fin_ctx
Definition tls_filter.h:27
apr_bucket_brigade * fin_plain_bb
Definition tls_filter.h:30
apr_off_t fout_bytes_in_rustls
Definition tls_filter.h:39
apr_size_t fin_max_in_rustls
Definition tls_filter.h:42
apr_size_t fout_max_bucket_size
Definition tls_filter.h:44
tls_conf_conn_t * cc
Definition tls_filter.h:25
apr_read_type_e fin_block
Definition tls_filter.h:32
apr_size_t fout_buf_plain_len
Definition tls_filter.h:36
ap_filter_t * fout_ctx
Definition tls_filter.h:34
apr_size_t fout_max_in_rustls
Definition tls_filter.h:43
apr_bucket_brigade * fin_tls_buffer_bb
Definition tls_filter.h:29
char * fout_buf_plain
Definition tls_filter.h:35
apr_off_t fout_bytes_in_tls_bb
Definition tls_filter.h:40
conn_rec * c
Definition tls_filter.h:24
apr_size_t fout_buf_plain_size
Definition tls_filter.h:37
apr_off_t fin_bytes_in_rustls
Definition tls_filter.h:31
apr_size_t fout_auto_flush_size
Definition tls_filter.h:45
apr_bucket_brigade * fin_tls_bb
Definition tls_filter.h:28
void tls_filter_register(apr_pool_t *pool)
void tls_filter_conn_init(conn_rec *c)
Definition tls_filter.c:989
int tls_filter_pre_conn_init(conn_rec *c)
Definition tls_filter.c:927