rlm_eap: fix channel binding errors
[freeradius.git] / src / modules / rlm_eap / libeap / eap_chbind.h
1 /*
2  * eap_chbind.c
3  *
4  * Version:     $Id$
5  *
6  * Copyright (c) 2012, JANET(UK)
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * 3. Neither the name of JANET(UK) nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
25  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
26  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
27  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
29  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
30  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
31  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
32  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  */
36
37 #ifndef _EAP_CHBIND_H
38 #define _EAP_CHBIND_H
39
40 #include <freeradius-devel/ident.h>
41 RCSIDH(eap_chbind_h, "$Id$")
42
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <sys/types.h>
46 #include <ctype.h>
47
48 #include <freeradius-devel/radiusd.h>
49
50 #include "eap.h"
51
52 /* Structure to hold channel bindings req/resp information */
53 typedef struct CHBIND_REQ {
54   uint8_t       *username;              /* the username */
55   size_t        username_len;           /* length of the username */
56   uint8_t       *chbind_req_pkt;            /* channel binding request buffer */
57   size_t        chbind_req_len;         /* length of the request buffer */
58   uint8_t       *chbind_resp;           /* channel binding response buffer */
59   size_t        chbind_resp_len;        /* length of the response buffer */
60 } CHBIND_REQ;
61
62 /* Structure to represent eap channel binding packet format */
63 typedef struct chbind_packet_t {
64   uint8_t code;
65   uint8_t data[1];
66 } CHBIND_PACKET_T;
67
68 /* Protocol constants */
69 #define CHBIND_NSID_RADIUS              1
70
71 #define CHBIND_CODE_REQUEST             1
72 #define CHBIND_CODE_SUCCESS             2
73 #define CHBIND_CODE_FAILURE             3
74
75 /* Channel binding function prototypes */
76 CHBIND_REQ *chbind_allocate(void);
77 void chbind_free(CHBIND_REQ *chbind);
78 int chbind_process(REQUEST *req, CHBIND_REQ *chbind_req);
79 size_t chbind_get_data(CHBIND_PACKET_T *chbind_packet, size_t chbind_packet_len, int desired_nsid, uint8_t **radbuf_data);
80 uint8_t *chbind_build_response(REQUEST *req, size_t *resp_len);
81
82 #endif /*_EAP_CHBIND_H*/