~ubuntu-branches/ubuntu/utopic/freeradius/utopic

« back to all changes in this revision

Viewing changes to src/modules/rlm_eap/types/rlm_eap_tls/rlm_eap_tls.h

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2006-12-16 20:45:11 UTC
  • mfrom: (3.1.10 feisty)
  • Revision ID: james.westby@ubuntu.com-20061216204511-3pbbsu4s8jtehsor
Tags: 1.1.3-3
Fix POSIX compliance problem in init script.  Closes: #403384. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * rlm_eap_tls.h
3
3
 *
4
 
 * Version:     $Id: rlm_eap_tls.h,v 1.5 2004/02/26 19:04:31 aland Exp $
 
4
 * Version:     $Id: rlm_eap_tls.h,v 1.5.4.3 2006/04/28 18:18:58 aland Exp $
5
5
 *
6
6
 *   This program is free software; you can redistribute it and/or modify
7
7
 *   it under the terms of the GNU General Public License as published by
23
23
#ifndef _RLM_EAP_TLS_H
24
24
#define _RLM_EAP_TLS_H
25
25
 
26
 
#include <stdio.h>
27
 
#include <stdlib.h>
28
 
#include <string.h>
29
 
#include <errno.h>
30
 
#include <sys/types.h>
31
 
#include <sys/socket.h>
32
 
#include <netinet/in.h>
33
 
#include <netinet/tcp.h>
34
 
#include <netdb.h>
35
 
#include <fcntl.h>
36
 
#include <signal.h>
37
 
 
38
 
#include <ctype.h>
39
 
#include <sys/time.h>
40
 
#include <arpa/inet.h>
41
 
 
42
 
#ifdef HAVE_LIMITS_H
43
 
#include <limits.h>
44
 
#endif
45
 
 
46
 
#ifdef HAVE_UNISTD_H
47
 
#include <unistd.h>
48
 
#endif
49
 
 
50
 
#include "config.h"
51
 
 
52
 
#ifndef NO_OPENSSL
53
 
/*
54
 
 *      For RH 9, which apparently needs this.
55
 
 */
56
 
#ifndef OPENSSL_NO_KRB5
57
 
#define OPENSSL_NO_KRB5
58
 
#endif
59
 
#include <openssl/err.h>
60
 
#ifdef HAVE_OPENSSL_ENGINE_H
61
 
#include <openssl/engine.h>
62
 
#endif
63
 
#include <openssl/ssl.h>
64
 
#endif /* !defined(NO_OPENSSL) */
65
 
 
66
 
#include "eap.h"
67
 
 
68
 
typedef enum {
69
 
        EAPTLS_INVALID = 0,             /* invalid, don't reply */
70
 
        EAPTLS_REQUEST,                 /* request, ok to send, invalid to receive */
71
 
        EAPTLS_RESPONSE,                /* response, ok to receive, invalid to send */
72
 
        EAPTLS_SUCCESS,                 /* success, send success */
73
 
        EAPTLS_FAIL,                    /* fail, send fail */
74
 
        EAPTLS_NOOP,                    /* noop, continue */
75
 
 
76
 
        EAPTLS_START,                   /* start, ok to send, invalid to receive */
77
 
        EAPTLS_OK,                      /* ok, continue */
78
 
        EAPTLS_ACK,                     /* acknowledge, continue */
79
 
        EAPTLS_FIRST_FRAGMENT,          /* first fragment */
80
 
        EAPTLS_MORE_FRAGMENTS,          /* more fragments, to send/receive */
81
 
        EAPTLS_LENGTH_INCLUDED,                 /* length included */
82
 
        EAPTLS_MORE_FRAGMENTS_WITH_LENGTH,   /* more fragments with length */
83
 
        EAPTLS_HANDLED                  /* tls code has handled it */
84
 
} eaptls_status_t;
85
 
 
86
 
#define MAX_RECORD_SIZE 16384
87
 
 
88
 
/*
89
 
 *      A single TLS record may be up to 16384 octets in length, but a
90
 
 *      TLS message may span multiple TLS records, and a TLS
91
 
 *      certificate message may in principle be as long as 16MB.
92
 
 *
93
 
 *      However, note that in order to protect against reassembly
94
 
 *      lockup and denial of service attacks, it may be desirable for
95
 
 *      an implementation to set a maximum size for one such group of
96
 
 *      TLS messages.
97
 
 *
98
 
 *      The TLS Message Length field is four octets, and provides the
99
 
 *      total length of the TLS message or set of messages that is
100
 
 *      being fragmented; this simplifies buffer allocation.
101
 
 */
102
 
 
103
 
/*
104
 
 * FIXME: Dynamic allocation of buffer to overcome MAX_RECORD_SIZE overflows.
105
 
 *      or configure TLS not to exceed MAX_RECORD_SIZE.
106
 
 */
107
 
typedef struct _record_t {
108
 
        unsigned char data[MAX_RECORD_SIZE];
109
 
        unsigned int  used;
110
 
} record_t;
111
 
 
112
 
typedef struct _tls_info_t {
113
 
        unsigned char   origin;
114
 
        unsigned char   content_type;
115
 
        unsigned char   handshake_type;
116
 
        unsigned char   alert_level;
117
 
        unsigned char   alert_description;
118
 
        char            info_description[256];
119
 
        size_t          record_len;
120
 
        int             version;
121
 
        char            initialized;
122
 
} tls_info_t;
123
 
 
124
 
/*
125
 
 * tls_session_t Structure gets stored as opaque in EAP_HANDLER
126
 
 * This contains EAP-REQUEST specific data
127
 
 * (ie EAPTLS_DATA(fragment), EAPTLS-ALERT, EAPTLS-REQUEST ...)
128
 
 *
129
 
 * clean_in  - data that needs to be sent but only after it is soiled.
130
 
 * dirty_in  - data EAP server receives.
131
 
 * clean_out - data that is cleaned after receiving.
132
 
 * dirty_out - data EAP server sends.
133
 
 * offset    - current fragment size transmitted
134
 
 * fragment  - Flag, In fragment mode or not.
135
 
 * tls_msg_len - Actual/Total TLS message length.
136
 
 * length_flag - A flag to include length in every TLS Data/Alert packet
137
 
 *                                      if set to no then only the first fragment contains length
138
 
 */
139
 
typedef struct _tls_session_t {
140
 
        SSL             *ssl;
141
 
        tls_info_t      info;
142
 
 
143
 
        BIO             *into_ssl;
144
 
        BIO             *from_ssl;
145
 
        record_t        clean_in;
146
 
        record_t        clean_out;
147
 
        record_t        dirty_in;
148
 
        record_t        dirty_out;
149
 
 
150
 
        /*
151
 
         * Framed-MTU attribute in RADIUS,
152
 
         * if present, can also be used to set this
153
 
         */
154
 
        unsigned int    offset;
155
 
        unsigned int    tls_msg_len;
156
 
        int             fragment;
157
 
        int             length_flag;
158
 
        int             peap_flag;
159
 
 
160
 
        /*
161
 
         *      Used by TTLS & PEAP to keep track of other per-session
162
 
         *      data.
163
 
         */
164
 
        void            *opaque;
165
 
        void            (*free_opaque)(void *opaque);
166
 
} tls_session_t;
167
 
 
168
 
 
169
 
/*
170
 
 *      Externally exported TLS functions.
171
 
 */
172
 
eaptls_status_t eaptls_process(EAP_HANDLER *handler);
173
 
 
174
 
int             eaptls_success(EAP_DS *eap_ds, int peap_flag);
175
 
int             eaptls_fail(EAP_DS *eap_ds, int peap_flag);
176
 
int             eaptls_request(EAP_DS *eap_ds, tls_session_t *ssn);
177
 
 
178
 
 
179
 
/* MPPE key generation */
180
 
void            eaptls_gen_mppe_keys(VALUE_PAIR **reply_vps, SSL *s,
181
 
                                     const char *prf_label);
182
 
void            eapttls_gen_challenge(SSL *s, char *buffer, int size);
 
26
#include "eap_tls.h"
 
27
 
 
28
#include "radiusd.h"
 
29
#include "modules.h"
 
30
 
 
31
/* configured values goes right here */
 
32
typedef struct eap_tls_conf {
 
33
        char            *private_key_password;
 
34
        char            *private_key_file;
 
35
        char            *certificate_file;
 
36
        char            *random_file;
 
37
        char            *ca_path;
 
38
        char            *ca_file;
 
39
        char            *dh_file;
 
40
        char            *rsa_file;
 
41
        int             rsa_key;
 
42
        int             dh_key;
 
43
        int             rsa_key_length;
 
44
        int             dh_key_length;
 
45
        int             verify_depth;
 
46
        int             file_type;
 
47
        int             include_length;
 
48
 
 
49
        /*
 
50
         *      Always < 4096 (due to radius limit), 0 by default = 2048
 
51
         */
 
52
        int             fragment_size;
 
53
        int             check_crl;
 
54
        char            *check_cert_cn;
 
55
        char            *cipher_list;
 
56
        char            *check_cert_issuer;
 
57
} EAP_TLS_CONF;
 
58
 
 
59
/* This structure gets stored in arg */
 
60
typedef struct _eap_tls_t {
 
61
        EAP_TLS_CONF    *conf;
 
62
        SSL_CTX         *ctx;
 
63
} eap_tls_t;
 
64
 
183
65
 
184
66
#endif /* _RLM_EAP_TLS_H */