source: mod_gnutls/include/mod_gnutls.h.in @ 42307a9

debian/masterdebian/stretch-backportsjessie-backportsmsvaupstream
Last change on this file since 42307a9 was 42307a9, checked in by Paul Querna <chip@…>, 14 years ago
  • remove anno creds
  • initial attempt at Server Name Extension
  • change to adding 'mod_gnutls' to the server sig instead of GnuTLS/
  • fix for EOF/EOC/EOS buckets
  • 'general' code cleanups
  • Property mode set to 100644
File size: 5.2 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
29#ifndef __mod_gnutls_h_inc
30#define __mod_gnutls_h_inc
31
32#define HAVE_APR_MEMCACHE    @have_apr_memcache@
33
34#include <gcrypt.h>
35#include <gnutls/gnutls.h>
36
37module AP_MODULE_DECLARE_DATA gnutls_module;
38
39#define GNUTLS_OUTPUT_FILTER_NAME "gnutls_output_filter"
40#define GNUTLS_INPUT_FILTER_NAME "gnutls_input_filter"
41
42#define GNUTLS_ENABLED_FALSE 0
43#define GNUTLS_ENABLED_TRUE  1
44
45#define MOD_GNUTLS_VERSION "@MOD_GNUTLS_VERSION@"
46
47typedef enum
48{
49    mod_gnutls_cache_none,
50    mod_gnutls_cache_dbm,
51#if HAVE_APR_MEMCACHE
52    mod_gnutls_cache_memcache
53#endif
54} mod_gnutls_cache_e;
55
56typedef struct
57{
58    gnutls_certificate_credentials_t certs;
59    char *key_file;
60    char *cert_file;
61    int enabled;
62    int ciphers[16];
63    int key_exchange[16];
64    int macs[16];
65    int protocol[16];
66    int compression[16];
67    int cert_types[16];
68    apr_time_t cache_timeout;
69    mod_gnutls_cache_e cache_type;
70    const char* cache_config;
71    const char* rsa_params_file;
72    const char* dh_params_file;
73} mod_gnutls_srvconf_rec;
74
75typedef struct {
76    int length;
77    char *value;
78} mod_gnutls_char_buffer_t;
79
80typedef struct
81{
82    mod_gnutls_srvconf_rec *sc;
83    conn_rec* c;
84    gnutls_session_t session;
85
86    apr_status_t input_rc;
87    ap_filter_t *input_filter;
88    apr_bucket_brigade *input_bb;
89    apr_read_type_e input_block;
90    ap_input_mode_t input_mode;
91    mod_gnutls_char_buffer_t input_cbuf;
92    char input_buffer[AP_IOBUFSIZE];
93
94    apr_status_t output_rc;
95    ap_filter_t *output_filter;
96    apr_bucket_brigade *output_bb;
97    char output_buffer[AP_IOBUFSIZE];
98    apr_size_t output_blen;
99    apr_size_t output_length;
100
101    int status;
102    int non_https;
103} mod_gnutls_handle_t;
104
105/** Functions in gnutls_io.c **/
106
107/**
108 * mod_gnutls_filter_input will filter the input data
109 * by decrypting it using GnuTLS and passes it cleartext.
110 *
111 * @param f     the filter info record
112 * @param bb    the bucket brigade, where to store the result to
113 * @param mode  what shall we read?
114 * @param block a block index we shall read from?
115 * @return result status
116 */
117apr_status_t mod_gnutls_filter_input(ap_filter_t * f,
118                                     apr_bucket_brigade * bb,
119                                     ap_input_mode_t mode,
120                                     apr_read_type_e block,
121                                     apr_off_t readbytes);
122
123/**
124 * mod_gnutls_filter_output will filter the encrypt
125 * the incoming bucket using GnuTLS and passes it onto the next filter.
126 *
127 * @param f     the filter info record
128 * @param bb    the bucket brigade, where to store the result to
129 * @return result status
130 */
131apr_status_t mod_gnutls_filter_output(ap_filter_t * f,
132                                      apr_bucket_brigade * bb);
133
134
135/**
136 * mod_gnutls_transport_read is called from GnuTLS to provide encrypted
137 * data from the client.
138 *
139 * @param ptr     pointer to the filter context
140 * @param buffer  place to put data
141 * @param len     maximum size
142 * @return size   length of the data stored in buffer
143 */
144ssize_t mod_gnutls_transport_read(gnutls_transport_ptr_t ptr,
145                                  void *buffer, size_t len);
146
147/**
148 * mod_gnutls_transport_write is called from GnuTLS to
149 * write data to the client.
150 *
151 * @param ptr     pointer to the filter context
152 * @param buffer  buffer to write to the client
153 * @param len     size of the buffer
154 * @return size   length of the data written
155 */
156ssize_t mod_gnutls_transport_write(gnutls_transport_ptr_t ptr,
157                                   const void *buffer, size_t len);
158
159
160/**
161 * Init the Cache after Configuration is done
162 */
163int mod_gnutls_cache_post_config(apr_pool_t *p, server_rec *s,
164                                 mod_gnutls_srvconf_rec *sc);
165/**
166 * Init the Cache inside each Process
167 */
168int mod_gnutls_cache_child_init(apr_pool_t *p, server_rec *s,
169                                mod_gnutls_srvconf_rec *sc);
170/**
171 * Setup the Session Caching
172 */
173int mod_gnutls_cache_session_init(mod_gnutls_handle_t *ctxt);
174
175#define GNUTLS_SESSION_ID_STRING_LEN \
176    ((GNUTLS_MAX_SESSION_ID + 1) * 2)
177   
178/**
179 * Convert a SSL Session ID into a Null Terminated Hex Encoded String
180 * @param id raw SSL Session ID
181 * @param idlen Length of the raw Session ID
182 * @param str Location to store the Hex Encoded String
183 * @param strsize The Maximum Length that can be stored in str
184 */
185char *mod_gnutls_session_id2sz(unsigned char *id, int idlen,
186                                char *str, int strsize);
187
188#endif /*  __mod_gnutls_h_inc */
Note: See TracBrowser for help on using the repository browser.