summaryrefslogtreecommitdiffstatsabout
path: root/include/mod_gnutls.h.in
diff options
context:
space:
mode:
Diffstat (limited to 'include/mod_gnutls.h.in')
-rw-r--r--include/mod_gnutls.h.in173
1 files changed, 173 insertions, 0 deletions
diff --git a/include/mod_gnutls.h.in b/include/mod_gnutls.h.in
new file mode 100644
index 0000000..03ba4d1
--- /dev/null
+++ b/include/mod_gnutls.h.in
@@ -0,0 +1,173 @@
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#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#if HAVE_APR_MEMCACHE
33#include "apr_memcache.h"
34#endif
35
36#include <gcrypt.h>
37#include <gnutls/gnutls.h>
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
48/**
49 * GnuTLS changed the names of several structures between 1.0.X and 1.1.X
50 * This is just a simple hack so we can compile with both versions.
51 * There is a full list in <gnutls/compat.h>, But I am just
52 * doing this for a few types we use.
53 */
54#ifndef gnutls_certificate_credentials_t
55#define gnutls_certificate_credentials_t gnutls_certificate_credentials
56#define gnutls_anon_server_credentials_t gnutls_anon_server_credentials
57#define gnutls_session_t gnutls_session
58#define gnutls_transport_ptr_t gnutls_transport_ptr
59#define gnutls_dh_params_t gnutls_dh_params
60#define gnutls_rsa_params_t gnutls_rsa_params
61#endif
62
63typedef struct
64{
65 gnutls_certificate_credentials_t certs;
66 gnutls_anon_server_credentials_t anoncred;
67 char *key_file;
68 char *cert_file;
69 int enabled;
70 int ciphers[16];
71 int key_exchange[16];
72 int macs[16];
73 int protocol[16];
74 int compression[16];
75 const char* cache_config;
76} mod_gnutls_srvconf_rec;
77
78typedef struct {
79 int length;
80 char *value;
81} mod_gnutls_char_buffer_t;
82
83typedef struct
84{
85 mod_gnutls_srvconf_rec *sc;
86 conn_rec* c;
87 gnutls_session_t session;
88
89 apr_status_t input_rc;
90 ap_filter_t *input_filter;
91 apr_bucket_brigade *input_bb;
92 apr_read_type_e input_block;
93 ap_input_mode_t input_mode;
94 mod_gnutls_char_buffer_t input_cbuf;
95 char input_buffer[AP_IOBUFSIZE];
96
97 apr_status_t output_rc;
98 ap_filter_t *output_filter;
99 apr_bucket_brigade *output_bb;
100 char output_buffer[AP_IOBUFSIZE];
101 apr_size_t output_blen;
102 apr_size_t output_length;
103
104 int status;
105 int non_https;
106} mod_gnutls_handle_t;
107
108/** Functions in gnutls_io.c **/
109
110/**
111 * mod_gnutls_filter_input will filter the input data
112 * by decrypting it using GnuTLS and passes it cleartext.
113 *
114 * @param f the filter info record
115 * @param bb the bucket brigade, where to store the result to
116 * @param mode what shall we read?
117 * @param block a block index we shall read from?
118 * @return result status
119 */
120apr_status_t mod_gnutls_filter_input(ap_filter_t * f,
121 apr_bucket_brigade * bb,
122 ap_input_mode_t mode,
123 apr_read_type_e block,
124 apr_off_t readbytes);
125
126/**
127 * mod_gnutls_filter_output will filter the encrypt
128 * the incoming bucket using GnuTLS and passes it onto the next filter.
129 *
130 * @param f the filter info record
131 * @param bb the bucket brigade, where to store the result to
132 * @return result status
133 */
134apr_status_t mod_gnutls_filter_output(ap_filter_t * f,
135 apr_bucket_brigade * bb);
136
137
138/**
139 * mod_gnutls_transport_read is called from GnuTLS to provide encrypted
140 * data from the client.
141 *
142 * @param ptr pointer to the filter context
143 * @param buffer place to put data
144 * @param len maximum size
145 * @return size length of the data stored in buffer
146 */
147ssize_t mod_gnutls_transport_read(gnutls_transport_ptr_t ptr,
148 void *buffer, size_t len);
149
150/**
151 * mod_gnutls_transport_write is called from GnuTLS to
152 * write data to the client.
153 *
154 * @param ptr pointer to the filter context
155 * @param buffer buffer to write to the client
156 * @param len size of the buffer
157 * @return size length of the data written
158 */
159ssize_t mod_gnutls_transport_write(gnutls_transport_ptr_t ptr,
160 const void *buffer, size_t len);
161
162
163/**
164 * Init the Cache inside each Process
165 */
166int mod_gnutls_cache_child_init(apr_pool_t *p, server_rec *s,
167 mod_gnutls_srvconf_rec *sc);
168/**
169 * Setup the Session Caching
170 */
171int mod_gnutls_cache_session_init(mod_gnutls_handle_t *ctxt);
172
173#endif /* __mod_gnutls_h_inc */