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

debian/masterdebian/stretch-backportsjessie-backportsmsvaproxy-ticketupstream
Last change on this file since dab7a25 was dab7a25, checked in by Daniel Kahn Gillmor <dkg@…>, 7 years ago

rip out remaining references to obsolete "export" encryption

  • Property mode set to 100644
File size: 11.9 KB
RevLine 
[fcb122d]1/**
2 *  Copyright 2004-2005 Paul Querna
[7e2b223]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
[3b4c0d0]18/* Apache Runtime Headers */
[7e2b223]19#include "httpd.h"
20#include "http_config.h"
21#include "http_protocol.h"
22#include "http_connection.h"
[76bd3bf]23#include "http_request.h"
[7e2b223]24#include "http_core.h"
25#include "http_log.h"
26#include "apr_buckets.h"
27#include "apr_strings.h"
28#include "apr_tables.h"
[482f47f]29#include "ap_release.h"
[9ddaa29]30#include "apr_fnmatch.h"
[3b4c0d0]31/* GnuTLS Library Headers */
[31645b2]32#include <gnutls/gnutls.h>
[3596d6a]33#if GNUTLS_VERSION_MAJOR == 2
[e5bbda4]34#include <gnutls/extra.h>
[3596d6a]35#endif
[e5bbda4]36#include <gnutls/openpgp.h>
[31645b2]37#include <gnutls/x509.h>
38
[05d56ce]39#ifndef __mod_gnutls_h_inc
40#define __mod_gnutls_h_inc
41
[6e0bfd6]42#define HAVE_APR_MEMCACHE    @have_apr_memcache@
[a66e147]43
[6d4de37]44extern module AP_MODULE_DECLARE_DATA gnutls_module;
[7e2b223]45
[3b4c0d0]46/* IO Filter names */
[7e2b223]47#define GNUTLS_OUTPUT_FILTER_NAME "gnutls_output_filter"
48#define GNUTLS_INPUT_FILTER_NAME "gnutls_input_filter"
[3b4c0d0]49/* GnuTLS Constants */
[7e2b223]50#define GNUTLS_ENABLED_FALSE 0
51#define GNUTLS_ENABLED_TRUE  1
[3b4c0d0]52/* Current module version */
53#define MOD_GNUTLS_VERSION "0.5.10"
54/* Module Debug Mode */
55#define MOD_GNUTLS_DEBUG 1
56
57/*
58 * Recent Versions of 2.1 renamed several hooks.
59 * This allows us to compile on 2.0.xx 
60 */
[7e67487]61#if AP_SERVER_MINORVERSION_NUMBER >= 2 || (AP_SERVER_MINORVERSION_NUMBER == 1 && AP_SERVER_PATCHLEVEL_NUMBER >= 3)
[3b4c0d0]62        #define USING_2_1_RECENT 1
[7c05ed1]63#else
[3b4c0d0]64        #define USING_2_1_RECENT 0
[482f47f]65#endif
66
[3b4c0d0]67/* mod_gnutls Cache Types */
68typedef enum {
69        /* No Cache */
[c301152]70    mgs_cache_none,
[3b4c0d0]71        /* Use Old Berkley DB */
[c301152]72    mgs_cache_dbm,
[3b4c0d0]73        /* Use Gnu's version of Berkley DB */
[d8c7cf4]74    mgs_cache_gdbm,
[fcb122d]75#if HAVE_APR_MEMCACHE
[3b4c0d0]76        /* Use Memcache */
[c301152]77    mgs_cache_memcache
[2e12226]78#endif
[c301152]79} mgs_cache_e;
[2e12226]80
[3b4c0d0]81/* Directory Configuration Record */
82typedef struct {
[e924ddd]83    int client_verify_mode;
[84cb5b2]84    const char* lua_bytecode;
85    apr_size_t lua_bytecode_len;
[c301152]86} mgs_dirconf_rec;
[31645b2]87
[7bebb42]88
[3b4c0d0]89/* The maximum number of certificates to send in a chain */
[5e81262]90#define MAX_CHAIN_SIZE 8
[3b4c0d0]91/* The maximum number of SANs to read from a x509 certificate */
92#define MAX_CERT_SAN 5
[7bebb42]93
[3b4c0d0]94/* Server Configuration Record */
95typedef struct {
96        /* x509 Certificate Structure */
97    gnutls_certificate_credentials_t certs;
98        /* SRP Certificate Structure*/
[7bebb42]99    gnutls_srp_server_credentials_t srp_creds;
[3b4c0d0]100        /* Annonymous Certificate Structure */
[7bebb42]101    gnutls_anon_server_credentials_t anon_creds;
[3b4c0d0]102        /* Current x509 Certificate CN [Common Name] */
[e924ddd]103    char* cert_cn;
[3b4c0d0]104        /* Current x509 Certificate SAN [Subject Alternate Name]s*/
105        char* cert_san[MAX_CERT_SAN];
106        /* A x509 Certificate Chain */
107    gnutls_x509_crt_t *certs_x509_chain;
108        /* Current x509 Certificate Private Key */
[31645b2]109    gnutls_x509_privkey_t privkey_x509;
[3b4c0d0]110        /* OpenPGP Certificate */
111    gnutls_openpgp_crt_t cert_pgp;
112        /* OpenPGP Certificate Private Key */
[e5bbda4]113    gnutls_openpgp_privkey_t privkey_pgp;
[3b4c0d0]114        /* Number of Certificates in Chain */
115    unsigned int certs_x509_chain_num;
116        /* Is the module enabled? */
[7e2b223]117    int enabled;
[3b4c0d0]118        /* GnuTLS Priorities */
[7bebb42]119    gnutls_priority_t priorities;
[3b4c0d0]120        /* GnuTLS RSA Parameters [Obselete] */
[a3c97d1]121    gnutls_rsa_params_t rsa_params;
[3b4c0d0]122        /* GnuTLS DH Parameters */
[a3c97d1]123    gnutls_dh_params_t dh_params;
[3b4c0d0]124        /* Cache timeout value */
[7bebb42]125    int cache_timeout;
[3b4c0d0]126        /* Chose Cache Type */
[c301152]127    mgs_cache_e cache_type;
[a66e147]128    const char* cache_config;
[7bebb42]129    const char* srp_tpasswd_file;
130    const char* srp_tpasswd_conf_file;
[3b4c0d0]131        /* A list of CA Certificates */
[8663ace]132    gnutls_x509_crt_t *ca_list;
[3b4c0d0]133        /* OpenPGP Key Ring */
[e5bbda4]134    gnutls_openpgp_keyring_t pgp_list;
[3b4c0d0]135        /* CA Certificate list size */
[7bebb42]136    unsigned int ca_list_size;
[3b4c0d0]137        /* Client Certificate Verification Mode */
[e924ddd]138    int client_verify_mode;
[3b4c0d0]139        /* Last Cache timestamp */
[f10ab4f]140    apr_time_t last_cache_check;
[3b4c0d0]141        /* GnuTLS uses Session Tickets */
142    int tickets;
143        /* Is mod_proxy enabled? */
[33826c5]144    int proxy_enabled;
[3b4c0d0]145        /* A Plain HTTP request */
[9ee0464]146    int non_ssl_request;
[c301152]147} mgs_srvconf_rec;
[7e2b223]148
[3b4c0d0]149/* Character Buffer */
[dae0aec]150typedef struct {
151    int length;
152    char *value;
[c301152]153} mgs_char_buffer_t;
[dae0aec]154
[3b4c0d0]155/* GnuTLS Handle */
156typedef struct {
157        /* Server configuration record */
[c301152]158    mgs_srvconf_rec *sc;
[3b4c0d0]159        /* Connection record */
[dae0aec]160    conn_rec* c;
[3b4c0d0]161        /* GnuTLS Session handle */
[7e2b223]162    gnutls_session_t session;
[3b4c0d0]163        /* module input status */
[dae0aec]164    apr_status_t input_rc;
[3b4c0d0]165        /* Input filter */
[7e2b223]166    ap_filter_t *input_filter;
[3b4c0d0]167        /* Input Bucket Brigade */
[7e2b223]168    apr_bucket_brigade *input_bb;
[3b4c0d0]169        /* Input Read Type */
[7e2b223]170    apr_read_type_e input_block;
[3b4c0d0]171        /* Input Mode */
[dae0aec]172    ap_input_mode_t input_mode;
[3b4c0d0]173        /* Input Character Buffer */
[c301152]174    mgs_char_buffer_t input_cbuf;
[3b4c0d0]175        /* Input Character Array */
[dae0aec]176    char input_buffer[AP_IOBUFSIZE];
[3b4c0d0]177        /* module Output status */
[dae0aec]178    apr_status_t output_rc;
[3b4c0d0]179        /* Output filter */
[dae0aec]180    ap_filter_t *output_filter;
[3b4c0d0]181        /* Output Bucket Brigade */
[dae0aec]182    apr_bucket_brigade *output_bb;
[3b4c0d0]183        /* Output character array */
[dae0aec]184    char output_buffer[AP_IOBUFSIZE];
[3b4c0d0]185        /* Output buffer length */
[dae0aec]186    apr_size_t output_blen;
[3b4c0d0]187        /* Output length */
[dae0aec]188    apr_size_t output_length;
[3b4c0d0]189        /* General Status */
[7e2b223]190    int status;
[c301152]191} mgs_handle_t;
[7e2b223]192
[3b4c0d0]193
194
[7e2b223]195/** Functions in gnutls_io.c **/
196
[fb26be5]197/* apr_signal_block() for blocking SIGPIPE */
198apr_status_t apr_signal_block(int signum);
199
[33826c5]200 /* Proxy Support */
[37f8282]201/* An optional function which returns non-zero if the given connection
202is using SSL/TLS. */
203APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));
204/* The ssl_proxy_enable() and ssl_engine_disable() optional functions
205 * are used by mod_proxy to enable use of SSL for outgoing
206 * connections. */
207APR_DECLARE_OPTIONAL_FN(int, ssl_proxy_enable, (conn_rec *));
208APR_DECLARE_OPTIONAL_FN(int, ssl_engine_disable, (conn_rec *));
209int ssl_is_https(conn_rec *c);
[33826c5]210int ssl_proxy_enable(conn_rec *c);
211int ssl_engine_disable(conn_rec *c);
[37f8282]212const char *mgs_set_proxy_engine(cmd_parms * parms, void *dummy,
213    const char *arg);
214apr_status_t mgs_cleanup_pre_config(void *data);
[33826c5]215
[7e2b223]216/**
[c301152]217 * mgs_filter_input will filter the input data
[7e2b223]218 * by decrypting it using GnuTLS and passes it cleartext.
219 *
220 * @param f     the filter info record
221 * @param bb    the bucket brigade, where to store the result to
222 * @param mode  what shall we read?
223 * @param block a block index we shall read from?
224 * @return result status
225 */
[c301152]226apr_status_t mgs_filter_input(ap_filter_t * f,
[2e12226]227                                     apr_bucket_brigade * bb,
228                                     ap_input_mode_t mode,
229                                     apr_read_type_e block,
230                                     apr_off_t readbytes);
[7e2b223]231
232/**
[c301152]233 * mgs_filter_output will filter the encrypt
[7e2b223]234 * the incoming bucket using GnuTLS and passes it onto the next filter.
235 *
236 * @param f     the filter info record
237 * @param bb    the bucket brigade, where to store the result to
238 * @return result status
239 */
[c301152]240apr_status_t mgs_filter_output(ap_filter_t * f,
[2e12226]241                                      apr_bucket_brigade * bb);
[7e2b223]242
243
244/**
[c301152]245 * mgs_transport_read is called from GnuTLS to provide encrypted
[7e2b223]246 * data from the client.
247 *
248 * @param ptr     pointer to the filter context
249 * @param buffer  place to put data
250 * @param len     maximum size
251 * @return size   length of the data stored in buffer
252 */
[c301152]253ssize_t mgs_transport_read(gnutls_transport_ptr_t ptr,
[2e12226]254                                  void *buffer, size_t len);
[7e2b223]255
256/**
[c301152]257 * mgs_transport_write is called from GnuTLS to
[7e2b223]258 * write data to the client.
259 *
260 * @param ptr     pointer to the filter context
261 * @param buffer  buffer to write to the client
262 * @param len     size of the buffer
263 * @return size   length of the data written
264 */
[c301152]265ssize_t mgs_transport_write(gnutls_transport_ptr_t ptr,
[2e12226]266                                   const void *buffer, size_t len);
[7e2b223]267
268
[c301152]269int mgs_rehandshake(mgs_handle_t * ctxt);
[e924ddd]270
271
272
[a66e147]273/**
[fcb122d]274 * Init the Cache after Configuration is done
275 */
[c301152]276int mgs_cache_post_config(apr_pool_t *p, server_rec *s,
277                                 mgs_srvconf_rec *sc);
[fcb122d]278/**
[a66e147]279 * Init the Cache inside each Process
280 */
[c301152]281int mgs_cache_child_init(apr_pool_t *p, server_rec *s,
282                                mgs_srvconf_rec *sc);
[a66e147]283/**
284 * Setup the Session Caching
285 */
[c301152]286int mgs_cache_session_init(mgs_handle_t *ctxt);
[05d56ce]287
[42307a9]288#define GNUTLS_SESSION_ID_STRING_LEN \
289    ((GNUTLS_MAX_SESSION_ID + 1) * 2)
290   
291/**
292 * Convert a SSL Session ID into a Null Terminated Hex Encoded String
293 * @param id raw SSL Session ID
294 * @param idlen Length of the raw Session ID
295 * @param str Location to store the Hex Encoded String
296 * @param strsize The Maximum Length that can be stored in str
297 */
[c301152]298char *mgs_session_id2sz(unsigned char *id, int idlen,
[42307a9]299                                char *str, int strsize);
300
[7bebb42]301/**
302 * Convert a time_t into a Null Terminated String
303 * @param t time_t time
304 * @param str Location to store the Hex Encoded String
305 * @param strsize The Maximum Length that can be stored in str
306 */
307char *mgs_time2sz(time_t t, char *str, int strsize);
308
[c301152]309
[46b85d8]310/* Configuration Functions */
311
[7bebb42]312const char *mgs_set_srp_tpasswd_conf_file(cmd_parms * parms, void *dummy,
313                                        const char *arg);
314const char *mgs_set_srp_tpasswd_file(cmd_parms * parms, void *dummy,
315                                        const char *arg);
316const char *mgs_set_dh_file(cmd_parms * parms, void *dummy,
317                                        const char *arg);
[46b85d8]318const char *mgs_set_cert_file(cmd_parms * parms, void *dummy,
319                                        const char *arg);
320
321const char *mgs_set_key_file(cmd_parms * parms, void *dummy,
322                             const char *arg);
323
[e5bbda4]324const char *mgs_set_pgpcert_file(cmd_parms * parms, void *dummy,
325                                        const char *arg);
326
327const char *mgs_set_pgpkey_file(cmd_parms * parms, void *dummy,
328                             const char *arg);
329
[46b85d8]330const char *mgs_set_cache(cmd_parms * parms, void *dummy,
331                          const char *type, const char* arg);
332
333const char *mgs_set_cache_timeout(cmd_parms * parms, void *dummy,
334                                  const char *arg);
335
336const char *mgs_set_client_verify(cmd_parms * parms, void *dummy,
337                                  const char *arg);
338
339const char *mgs_set_client_ca_file(cmd_parms * parms, void *dummy,
340                                   const char *arg);
341
[e5bbda4]342const char *mgs_set_keyring_file(cmd_parms * parms, void *dummy,
343                                   const char *arg);
344
[46b85d8]345const char *mgs_set_enabled(cmd_parms * parms, void *dummy,
346                            const char *arg);
[7bebb42]347const char *mgs_set_export_certificates_enabled(cmd_parms * parms, void *dummy,
348                            const char *arg);
349const char *mgs_set_priorities(cmd_parms * parms, void *dummy,
350                            const char *arg);
[ae233c2]351const char *mgs_set_tickets(cmd_parms * parms, void *dummy,
352                            const char *arg);
[84cb5b2]353                           
354const char *mgs_set_require_section(cmd_parms *cmd,
355                                    void *mconfig, const char *arg);
[46b85d8]356void *mgs_config_server_create(apr_pool_t * p, server_rec * s);
357
[84cb5b2]358void *mgs_config_dir_merge(apr_pool_t *p, void *basev, void *addv);
359
[46b85d8]360void *mgs_config_dir_create(apr_pool_t *p, char *dir);
361
[84cb5b2]362const char *mgs_set_require_bytecode(cmd_parms *cmd,
363                                    void *mconfig, const char *arg);
364
[836417f]365mgs_srvconf_rec* mgs_find_sni_server(gnutls_session_t session);
[c301152]366
367/* mod_gnutls Hooks. */
368
369int mgs_hook_pre_config(apr_pool_t * pconf,
370                        apr_pool_t * plog, apr_pool_t * ptemp);
371
372int mgs_hook_post_config(apr_pool_t * p, apr_pool_t * plog,
373                         apr_pool_t * ptemp,
374                         server_rec * base_server);
375
376void mgs_hook_child_init(apr_pool_t *p, server_rec *s);
377
378const char *mgs_hook_http_scheme(const request_rec * r);
379
380apr_port_t mgs_hook_default_port(const request_rec * r);
381
382int mgs_hook_pre_connection(conn_rec * c, void *csd);
383
384int mgs_hook_fixups(request_rec *r);
385
386int mgs_hook_authz(request_rec *r);
387
[7e2b223]388#endif /*  __mod_gnutls_h_inc */
Note: See TracBrowser for help on using the repository browser.