source: mod_gnutls/include/mod_gnutls.h.in @ 31645b2

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

working SNI. Not so working Client Cert support.

  • Property mode set to 100644
File size: 5.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 <gcrypt.h>
31#include <gnutls/gnutls.h>
32#include <gnutls/x509.h>
33
34#ifndef __mod_gnutls_h_inc
35#define __mod_gnutls_h_inc
36
37#define HAVE_APR_MEMCACHE    @have_apr_memcache@
38
39module AP_MODULE_DECLARE_DATA gnutls_module;
40
41#define GNUTLS_OUTPUT_FILTER_NAME "gnutls_output_filter"
42#define GNUTLS_INPUT_FILTER_NAME "gnutls_input_filter"
43
44#define GNUTLS_ENABLED_FALSE 0
45#define GNUTLS_ENABLED_TRUE  1
46
47#define MOD_GNUTLS_VERSION "@MOD_GNUTLS_VERSION@"
48
49#define MOD_GNUTLS_DEBUG @OOO_MAINTAIN@
50
51/* Recent Versions of 2.1 renamed several hooks. This allows us to
52   compile on 2.0.xx  */
53#if AP_SERVER_MINORVERSION_NUMBER >= 1
54#if AP_SERVER_PATCHLEVEL_NUMBER >= 3
55#define USING_2_1_RECENT 1
56#endif
57#endif
58
59#ifndef USING_2_1_RECENT
60#define USING_2_1_RECENT 0
61#endif
62
63typedef enum
64{
65    mod_gnutls_cache_none,
66    mod_gnutls_cache_dbm,
67#if HAVE_APR_MEMCACHE
68    mod_gnutls_cache_memcache
69#endif
70} mod_gnutls_cache_e;
71
72typedef struct
73{
74    gnutls_certificate_request_t client_verify_mode;
75} mod_gnutls_dirconf_rec;
76
77typedef struct
78{
79    gnutls_certificate_credentials_t certs;
80    gnutls_x509_crt_t cert_x509;
81    gnutls_x509_privkey_t privkey_x509;
82    int enabled;
83    int ciphers[16];
84    int key_exchange[16];
85    int macs[16];
86    int protocol[16];
87    int compression[16];
88    int cert_types[16];
89    apr_time_t cache_timeout;
90    mod_gnutls_cache_e cache_type;
91    const char* cache_config;
92    const char* rsa_params_file;
93    const char* dh_params_file;
94    gnutls_certificate_request_t client_verify_mode;
95} mod_gnutls_srvconf_rec;
96
97typedef struct {
98    int length;
99    char *value;
100} mod_gnutls_char_buffer_t;
101
102typedef struct
103{
104    mod_gnutls_srvconf_rec *sc;
105    conn_rec* c;
106    gnutls_session_t session;
107
108    apr_status_t input_rc;
109    ap_filter_t *input_filter;
110    apr_bucket_brigade *input_bb;
111    apr_read_type_e input_block;
112    ap_input_mode_t input_mode;
113    mod_gnutls_char_buffer_t input_cbuf;
114    char input_buffer[AP_IOBUFSIZE];
115
116    apr_status_t output_rc;
117    ap_filter_t *output_filter;
118    apr_bucket_brigade *output_bb;
119    char output_buffer[AP_IOBUFSIZE];
120    apr_size_t output_blen;
121    apr_size_t output_length;
122
123    int status;
124    int non_https;
125} mod_gnutls_handle_t;
126
127/** Functions in gnutls_io.c **/
128
129/**
130 * mod_gnutls_filter_input will filter the input data
131 * by decrypting it using GnuTLS and passes it cleartext.
132 *
133 * @param f     the filter info record
134 * @param bb    the bucket brigade, where to store the result to
135 * @param mode  what shall we read?
136 * @param block a block index we shall read from?
137 * @return result status
138 */
139apr_status_t mod_gnutls_filter_input(ap_filter_t * f,
140                                     apr_bucket_brigade * bb,
141                                     ap_input_mode_t mode,
142                                     apr_read_type_e block,
143                                     apr_off_t readbytes);
144
145/**
146 * mod_gnutls_filter_output will filter the encrypt
147 * the incoming bucket using GnuTLS and passes it onto the next filter.
148 *
149 * @param f     the filter info record
150 * @param bb    the bucket brigade, where to store the result to
151 * @return result status
152 */
153apr_status_t mod_gnutls_filter_output(ap_filter_t * f,
154                                      apr_bucket_brigade * bb);
155
156
157/**
158 * mod_gnutls_transport_read is called from GnuTLS to provide encrypted
159 * data from the client.
160 *
161 * @param ptr     pointer to the filter context
162 * @param buffer  place to put data
163 * @param len     maximum size
164 * @return size   length of the data stored in buffer
165 */
166ssize_t mod_gnutls_transport_read(gnutls_transport_ptr_t ptr,
167                                  void *buffer, size_t len);
168
169/**
170 * mod_gnutls_transport_write is called from GnuTLS to
171 * write data to the client.
172 *
173 * @param ptr     pointer to the filter context
174 * @param buffer  buffer to write to the client
175 * @param len     size of the buffer
176 * @return size   length of the data written
177 */
178ssize_t mod_gnutls_transport_write(gnutls_transport_ptr_t ptr,
179                                   const void *buffer, size_t len);
180
181
182/**
183 * Init the Cache after Configuration is done
184 */
185int mod_gnutls_cache_post_config(apr_pool_t *p, server_rec *s,
186                                 mod_gnutls_srvconf_rec *sc);
187/**
188 * Init the Cache inside each Process
189 */
190int mod_gnutls_cache_child_init(apr_pool_t *p, server_rec *s,
191                                mod_gnutls_srvconf_rec *sc);
192/**
193 * Setup the Session Caching
194 */
195int mod_gnutls_cache_session_init(mod_gnutls_handle_t *ctxt);
196
197#define GNUTLS_SESSION_ID_STRING_LEN \
198    ((GNUTLS_MAX_SESSION_ID + 1) * 2)
199   
200/**
201 * Convert a SSL Session ID into a Null Terminated Hex Encoded String
202 * @param id raw SSL Session ID
203 * @param idlen Length of the raw Session ID
204 * @param str Location to store the Hex Encoded String
205 * @param strsize The Maximum Length that can be stored in str
206 */
207char *mod_gnutls_session_id2sz(unsigned char *id, int idlen,
208                                char *str, int strsize);
209
210#endif /*  __mod_gnutls_h_inc */
Note: See TracBrowser for help on using the repository browser.