source: mod_gnutls/include/mod_gnutls.h @ dae0aec

debian/masterdebian/stretch-backportsjessie-backportsmsvaupstream
Last change on this file since dae0aec was dae0aec, checked in by Paul Querna <chip@…>, 15 years ago

input and output filters

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/* ====================================================================
2 *  Copyright 2004 Paul Querna
3 *
4 *  Licensed under the Apache License, Version 2.0 (the "License");
5 *  you may not use this file except in compliance with the License.
6 *  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 */
17
18#ifndef __mod_gnutls_h_inc
19#define __mod_gnutls_h_inc
20
21#include "httpd.h"
22#include "http_config.h"
23#include "http_protocol.h"
24#include "http_connection.h"
25#include "http_core.h"
26#include "http_log.h"
27#include "apr_buckets.h"
28#include "apr_strings.h"
29#include "apr_tables.h"
30
31#include <gcrypt.h>
32#include <gnutls/gnutls.h>
33
34module AP_MODULE_DECLARE_DATA gnutls_module;
35
36#define GNUTLS_OUTPUT_FILTER_NAME "gnutls_output_filter"
37#define GNUTLS_INPUT_FILTER_NAME "gnutls_input_filter"
38
39#define GNUTLS_ENABLED_FALSE 0
40#define GNUTLS_ENABLED_TRUE  1
41
42
43/**
44 * GnuTLS changed the names of several structures between 1.0.X and 1.1.X
45 * This is just a simple hack so we can compile with both versions.
46 * There is a full list in <gnutls/compat.h>, But I am just
47 * doing this for a few types we use.
48 */
49#ifndef gnutls_certificate_credentials_t
50#define gnutls_certificate_credentials_t    gnutls_certificate_credentials
51#define gnutls_anon_server_credentials_t    gnutls_anon_server_credentials
52#define gnutls_session_t                    gnutls_session
53#define gnutls_transport_ptr_t              gnutls_transport_ptr
54#define gnutls_dh_params_t                  gnutls_dh_params
55#define gnutls_rsa_params_t                 gnutls_rsa_params
56#endif
57
58typedef struct
59{
60    gnutls_certificate_credentials_t certs;
61    gnutls_anon_server_credentials_t anoncred;
62    char *key_file;
63    char *cert_file;
64    int enabled;
65    int ciphers[16];
66    int key_exchange[16];
67    int macs[16];
68    int protocol[16];
69    int compression[16];
70} mod_gnutls_srvconf_rec;
71
72typedef struct {
73    int length;
74    char *value;
75} mod_gnutls_char_buffer_t;
76
77typedef struct
78{
79    mod_gnutls_srvconf_rec *sc;
80    conn_rec* c;
81    gnutls_session_t session;
82
83    apr_status_t input_rc;
84    ap_filter_t *input_filter;
85    apr_bucket_brigade *input_bb;
86    apr_read_type_e input_block;
87    ap_input_mode_t input_mode;
88    mod_gnutls_char_buffer_t input_cbuf;
89    char input_buffer[AP_IOBUFSIZE];
90
91    apr_status_t output_rc;
92    ap_filter_t *output_filter;
93    apr_bucket_brigade *output_bb;
94    char output_buffer[AP_IOBUFSIZE];
95    apr_size_t output_blen;
96    apr_size_t output_length;
97
98    int status;
99    int non_https;
100} mod_gnutls_handle_t;
101
102/** Functions in gnutls_io.c **/
103
104/**
105 * mod_gnutls_filter_input will filter the input data
106 * by decrypting it using GnuTLS and passes it cleartext.
107 *
108 * @param f     the filter info record
109 * @param bb    the bucket brigade, where to store the result to
110 * @param mode  what shall we read?
111 * @param block a block index we shall read from?
112 * @return result status
113 */
114apr_status_t mod_gnutls_filter_input(ap_filter_t * f,
115                                     apr_bucket_brigade * bb,
116                                     ap_input_mode_t mode,
117                                     apr_read_type_e block,
118                                     apr_off_t readbytes);
119
120/**
121 * mod_gnutls_filter_output will filter the encrypt
122 * the incoming bucket using GnuTLS and passes it onto the next filter.
123 *
124 * @param f     the filter info record
125 * @param bb    the bucket brigade, where to store the result to
126 * @return result status
127 */
128apr_status_t mod_gnutls_filter_output(ap_filter_t * f,
129                                      apr_bucket_brigade * bb);
130
131
132/**
133 * mod_gnutls_transport_read is called from GnuTLS to provide encrypted
134 * data from the client.
135 *
136 * @param ptr     pointer to the filter context
137 * @param buffer  place to put data
138 * @param len     maximum size
139 * @return size   length of the data stored in buffer
140 */
141ssize_t mod_gnutls_transport_read(gnutls_transport_ptr_t ptr,
142                                  void *buffer, size_t len);
143
144/**
145 * mod_gnutls_transport_write is called from GnuTLS to
146 * write data to the client.
147 *
148 * @param ptr     pointer to the filter context
149 * @param buffer  buffer to write to the client
150 * @param len     size of the buffer
151 * @return size   length of the data written
152 */
153ssize_t mod_gnutls_transport_write(gnutls_transport_ptr_t ptr,
154                                   const void *buffer, size_t len);
155
156
157#endif /*  __mod_gnutls_h_inc */
Note: See TracBrowser for help on using the repository browser.