]> git.ozlabs.org Git - ppp.git/blob - pppd/eap-tls.h
Cleanup pppoe-discovery fatal functions
[ppp.git] / pppd / eap-tls.h
1 /*
2  * eap-tls.h
3  *
4  * Copyright (c) Beniamino Galvani 2005 All rights reserved.
5  *               Jan Just Keijser  2006-2019 All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in
16  *    the documentation and/or other materials provided with the
17  *    distribution.
18  *
19  * 3. The name(s) of the authors of this software must not be used to
20  *    endorse or promote products derived from this software without
21  *    prior written permission.
22  *
23  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
24  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
25  * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
26  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
27  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
28  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
29  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30  *
31  */
32
33 #ifndef __EAP_TLS_H__
34 #define __EAP_TLS_H__
35
36 #include "eap.h"
37
38 #include <openssl/ssl.h>
39 #include <openssl/bio.h>
40
41 #define EAP_TLS_FLAGS_LI        128    /* length included flag */
42 #define EAP_TLS_FLAGS_MF        64     /* more fragments flag */
43 #define EAP_TLS_FLAGS_START     32     /* start flag */
44
45 #define EAP_TLS_MAX_LEN         65536  /* max eap tls packet size */
46
47 struct eaptls_session
48 {
49     u_char *data;               /* buffered data */
50     int datalen;                /* buffered data len */
51     int offset;                 /* from where to send */
52     int tlslen;                 /* total length of tls data */
53     bool frag;                  /* packet is fragmented */
54     bool tls_v13;               /* whether we've negotiated TLSv1.3 */
55     SSL_CTX *ctx;
56     SSL *ssl;                   /* ssl connection */
57     BIO *from_ssl;
58     BIO *into_ssl;
59     char peer[MAXWORDLEN];      /* peer name */
60     char peercertfile[MAXWORDLEN];
61     bool alert_sent;
62     u_char alert_sent_desc;
63     bool alert_recv;
64     u_char alert_recv_desc;
65     char rtx[EAP_TLS_MAX_LEN];  /* retransmission buffer */
66     int rtx_len;
67     int mtu;                    /* unit mtu */
68 };
69
70
71 SSL_CTX *eaptls_init_ssl(int init_server, char *cacertfile, char *capath,
72             char *certfile, char *peer_certfile, char *privkeyfile);
73 int eaptls_init_ssl_server(eap_state * esp);
74 int eaptls_init_ssl_client(eap_state * esp);
75 void eaptls_free_session(struct eaptls_session *ets);
76
77 int eaptls_is_init_finished(struct eaptls_session *ets);
78
79 int eaptls_receive(struct eaptls_session *ets, u_char * inp, int len);
80 int eaptls_send(struct eaptls_session *ets, u_char ** outp);
81 void eaptls_retransmit(struct eaptls_session *ets, u_char ** outp);
82
83 int get_eaptls_secret(int unit, char *client, char *server,
84               char *clicertfile, char *servcertfile, char *cacertfile,
85               char *capath, char *pkfile, int am_server);
86
87 #ifdef MPPE
88 #include "mppe.h"   /* MPPE_MAX_KEY_LEN */
89 extern u_char mppe_send_key[MPPE_MAX_KEY_LEN];
90 extern u_char mppe_recv_key[MPPE_MAX_KEY_LEN];
91 extern int mppe_keys_set;
92
93 void eaptls_gen_mppe_keys(struct eaptls_session *ets, int client);
94 #endif
95
96 #endif