source: mod_gnutls/include/mod_gnutls.h.in @ fb26be5

debian/masterdebian/stretch-backportsjessie-backportsmsvaupstream
Last change on this file since fb26be5 was fb26be5, checked in by Dash Shendy <neuromancer@…>, 8 years ago

Declation of apr_signal_block(int signum)

  • Property mode set to 100644
File size: 9.8 KB
Line 
1/**
2 *  Copyright 2004-2005 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#include "httpd.h"
19#include "http_config.h"
20#include "http_protocol.h"
21#include "http_connection.h"
22#include "http_request.h"
23#include "http_core.h"
24#include "http_log.h"
25#include "apr_buckets.h"
26#include "apr_strings.h"
27#include "apr_tables.h"
28#include "ap_release.h"
29
30#include <gnutls/gnutls.h>
31#include <gnutls/extra.h>
32#include <gnutls/openpgp.h>
33#include <gnutls/x509.h>
34
35#ifndef __mod_gnutls_h_inc
36#define __mod_gnutls_h_inc
37
38#define HAVE_APR_MEMCACHE    @have_apr_memcache@
39
40extern module AP_MODULE_DECLARE_DATA gnutls_module;
41
42#define GNUTLS_OUTPUT_FILTER_NAME "gnutls_output_filter"
43#define GNUTLS_INPUT_FILTER_NAME "gnutls_input_filter"
44
45#define GNUTLS_ENABLED_FALSE 0
46#define GNUTLS_ENABLED_TRUE  1
47
48#define MOD_GNUTLS_VERSION "@MOD_GNUTLS_VERSION@"
49
50#define MOD_GNUTLS_DEBUG @OOO_MAINTAIN@
51
52/* Recent Versions of 2.1 renamed several hooks. This allows us to
53   compile on 2.0.xx  */
54#if AP_SERVER_MINORVERSION_NUMBER >= 2 || (AP_SERVER_MINORVERSION_NUMBER == 1 && AP_SERVER_PATCHLEVEL_NUMBER >= 3)
55#define USING_2_1_RECENT 1
56#else
57#define USING_2_1_RECENT 0
58#endif
59
60typedef enum
61{
62    mgs_cache_none,
63    mgs_cache_dbm,
64    mgs_cache_gdbm,
65#if HAVE_APR_MEMCACHE
66    mgs_cache_memcache
67#endif
68} mgs_cache_e;
69
70typedef struct
71{
72    int client_verify_mode;
73    const char* lua_bytecode;
74    apr_size_t lua_bytecode_len;
75} mgs_dirconf_rec;
76
77
78/* The maximum number of certificates to send in a chain
79 */
80#define MAX_CHAIN_SIZE 8
81
82typedef struct
83{
84    gnutls_certificate_credentials_t certs;
85    gnutls_srp_server_credentials_t srp_creds;
86    gnutls_anon_server_credentials_t anon_creds;
87    char* cert_cn;
88    gnutls_x509_crt_t certs_x509[MAX_CHAIN_SIZE]; /* A certificate chain */
89    unsigned int certs_x509_num;
90    gnutls_x509_privkey_t privkey_x509;
91    gnutls_openpgp_crt_t cert_pgp; /* A certificate chain */
92    gnutls_openpgp_privkey_t privkey_pgp;
93    int enabled;
94    /* whether to send the PEM encoded certificates
95     * to CGIs
96     */
97    int export_certificates_enabled;
98    gnutls_priority_t priorities;
99    gnutls_rsa_params_t rsa_params;
100    gnutls_dh_params_t dh_params;
101    int cache_timeout;
102    mgs_cache_e cache_type;
103    const char* cache_config;
104    const char* srp_tpasswd_file;
105    const char* srp_tpasswd_conf_file;
106    gnutls_x509_crt_t *ca_list;
107    gnutls_openpgp_keyring_t pgp_list;
108    unsigned int ca_list_size;
109    int client_verify_mode;
110    apr_time_t last_cache_check;
111    int tickets; /* whether session tickets are allowed */
112} mgs_srvconf_rec;
113
114typedef struct {
115    int length;
116    char *value;
117} mgs_char_buffer_t;
118
119typedef struct
120{
121    mgs_srvconf_rec *sc;
122    conn_rec* c;
123    gnutls_session_t session;
124
125    apr_status_t input_rc;
126    ap_filter_t *input_filter;
127    apr_bucket_brigade *input_bb;
128    apr_read_type_e input_block;
129    ap_input_mode_t input_mode;
130    mgs_char_buffer_t input_cbuf;
131    char input_buffer[AP_IOBUFSIZE];
132
133    apr_status_t output_rc;
134    ap_filter_t *output_filter;
135    apr_bucket_brigade *output_bb;
136    char output_buffer[AP_IOBUFSIZE];
137    apr_size_t output_blen;
138    apr_size_t output_length;
139
140    int status;
141    int non_https;
142} mgs_handle_t;
143
144/** Functions in gnutls_io.c **/
145
146/* apr_signal_block() for blocking SIGPIPE */
147apr_status_t apr_signal_block(int signum);
148
149/**
150 * mgs_filter_input will filter the input data
151 * by decrypting it using GnuTLS and passes it cleartext.
152 *
153 * @param f     the filter info record
154 * @param bb    the bucket brigade, where to store the result to
155 * @param mode  what shall we read?
156 * @param block a block index we shall read from?
157 * @return result status
158 */
159apr_status_t mgs_filter_input(ap_filter_t * f,
160                                     apr_bucket_brigade * bb,
161                                     ap_input_mode_t mode,
162                                     apr_read_type_e block,
163                                     apr_off_t readbytes);
164
165/**
166 * mgs_filter_output will filter the encrypt
167 * the incoming bucket using GnuTLS and passes it onto the next filter.
168 *
169 * @param f     the filter info record
170 * @param bb    the bucket brigade, where to store the result to
171 * @return result status
172 */
173apr_status_t mgs_filter_output(ap_filter_t * f,
174                                      apr_bucket_brigade * bb);
175
176
177/**
178 * mgs_transport_read is called from GnuTLS to provide encrypted
179 * data from the client.
180 *
181 * @param ptr     pointer to the filter context
182 * @param buffer  place to put data
183 * @param len     maximum size
184 * @return size   length of the data stored in buffer
185 */
186ssize_t mgs_transport_read(gnutls_transport_ptr_t ptr,
187                                  void *buffer, size_t len);
188
189/**
190 * mgs_transport_write is called from GnuTLS to
191 * write data to the client.
192 *
193 * @param ptr     pointer to the filter context
194 * @param buffer  buffer to write to the client
195 * @param len     size of the buffer
196 * @return size   length of the data written
197 */
198ssize_t mgs_transport_write(gnutls_transport_ptr_t ptr,
199                                   const void *buffer, size_t len);
200
201
202int mgs_rehandshake(mgs_handle_t * ctxt);
203
204
205
206/**
207 * Init the Cache after Configuration is done
208 */
209int mgs_cache_post_config(apr_pool_t *p, server_rec *s,
210                                 mgs_srvconf_rec *sc);
211/**
212 * Init the Cache inside each Process
213 */
214int mgs_cache_child_init(apr_pool_t *p, server_rec *s,
215                                mgs_srvconf_rec *sc);
216/**
217 * Setup the Session Caching
218 */
219int mgs_cache_session_init(mgs_handle_t *ctxt);
220
221#define GNUTLS_SESSION_ID_STRING_LEN \
222    ((GNUTLS_MAX_SESSION_ID + 1) * 2)
223   
224/**
225 * Convert a SSL Session ID into a Null Terminated Hex Encoded String
226 * @param id raw SSL Session ID
227 * @param idlen Length of the raw Session ID
228 * @param str Location to store the Hex Encoded String
229 * @param strsize The Maximum Length that can be stored in str
230 */
231char *mgs_session_id2sz(unsigned char *id, int idlen,
232                                char *str, int strsize);
233
234/**
235 * Convert a time_t into a Null Terminated String
236 * @param t time_t time
237 * @param str Location to store the Hex Encoded String
238 * @param strsize The Maximum Length that can be stored in str
239 */
240char *mgs_time2sz(time_t t, char *str, int strsize);
241
242
243/* Configuration Functions */
244
245const char *mgs_set_srp_tpasswd_conf_file(cmd_parms * parms, void *dummy,
246                                        const char *arg);
247const char *mgs_set_srp_tpasswd_file(cmd_parms * parms, void *dummy,
248                                        const char *arg);
249const char *mgs_set_dh_file(cmd_parms * parms, void *dummy,
250                                        const char *arg);
251const char *mgs_set_rsa_export_file(cmd_parms * parms, void *dummy,
252                                        const char *arg);
253const char *mgs_set_cert_file(cmd_parms * parms, void *dummy,
254                                        const char *arg);
255
256const char *mgs_set_key_file(cmd_parms * parms, void *dummy,
257                             const char *arg);
258
259const char *mgs_set_pgpcert_file(cmd_parms * parms, void *dummy,
260                                        const char *arg);
261
262const char *mgs_set_pgpkey_file(cmd_parms * parms, void *dummy,
263                             const char *arg);
264
265const char *mgs_set_cache(cmd_parms * parms, void *dummy,
266                          const char *type, const char* arg);
267
268const char *mgs_set_cache_timeout(cmd_parms * parms, void *dummy,
269                                  const char *arg);
270
271const char *mgs_set_client_verify(cmd_parms * parms, void *dummy,
272                                  const char *arg);
273
274const char *mgs_set_client_ca_file(cmd_parms * parms, void *dummy,
275                                   const char *arg);
276
277const char *mgs_set_keyring_file(cmd_parms * parms, void *dummy,
278                                   const char *arg);
279
280const char *mgs_set_enabled(cmd_parms * parms, void *dummy,
281                            const char *arg);
282const char *mgs_set_export_certificates_enabled(cmd_parms * parms, void *dummy,
283                            const char *arg);
284const char *mgs_set_priorities(cmd_parms * parms, void *dummy,
285                            const char *arg);
286const char *mgs_set_tickets(cmd_parms * parms, void *dummy,
287                            const char *arg);
288                           
289const char *mgs_set_require_section(cmd_parms *cmd,
290                                    void *mconfig, const char *arg);
291void *mgs_config_server_create(apr_pool_t * p, server_rec * s);
292
293void *mgs_config_dir_merge(apr_pool_t *p, void *basev, void *addv);
294
295void *mgs_config_dir_create(apr_pool_t *p, char *dir);
296
297const char *mgs_set_require_bytecode(cmd_parms *cmd,
298                                    void *mconfig, const char *arg);
299
300mgs_srvconf_rec* mgs_find_sni_server(gnutls_session_t session);
301
302/* mod_gnutls Hooks. */
303
304int mgs_hook_pre_config(apr_pool_t * pconf,
305                        apr_pool_t * plog, apr_pool_t * ptemp);
306
307int mgs_hook_post_config(apr_pool_t * p, apr_pool_t * plog,
308                         apr_pool_t * ptemp,
309                         server_rec * base_server);
310
311void mgs_hook_child_init(apr_pool_t *p, server_rec *s);
312
313const char *mgs_hook_http_scheme(const request_rec * r);
314
315apr_port_t mgs_hook_default_port(const request_rec * r);
316
317int mgs_hook_pre_connection(conn_rec * c, void *csd);
318
319int mgs_hook_fixups(request_rec *r);
320
321int mgs_hook_authz(request_rec *r);
322
323#endif /*  __mod_gnutls_h_inc */
Note: See TracBrowser for help on using the repository browser.