port fix from branch_1_1
[freeradius.git] / src / modules / rlm_eap / types / rlm_eap_leap / eap_leap.h
1 #ifndef _EAP_LEAP_H
2 #define _EAP_LEAP_H
3
4 #include <freeradius-devel/ident.h>
5 RCSIDH(eap_leap_h, "$Id$")
6
7 #include "eap.h"
8
9 #define PW_LEAP_CHALLENGE       1
10 #define PW_LEAP_RESPONSE        2
11 #define PW_LEAP_SUCCESS         3
12 #define PW_LEAP_FAILURE         4
13 #define PW_LEAP_MAX_CODES       4
14
15 /*
16  *  Version + unused + count
17  */
18 #define LEAP_HEADER_LEN         3
19
20 /*
21  ****
22  * EAP - LEAP doesnot specify code, id & length but chap specifies them,
23  *      for generalization purpose, complete header should be sent
24  *      and not just value_size, value and name.
25  *      future implementation.
26  */
27
28 /* eap packet structure */
29 typedef struct leap_packet_t {
30         /*
31          *  EAP header, followed by type comes before this.
32          */
33         uint8_t version;
34         uint8_t unused;
35         uint8_t count;
36         uint8_t challenge[1];   /* 8 or 24, followed by user name */
37 } leap_packet_t;
38
39 /*
40  *      Which is decoded into this.
41  */
42 typedef struct leap_packet {
43         unsigned char   code;
44         unsigned char   id;
45         int             length;
46         int             count;
47         unsigned char   *challenge;
48         int             name_len;
49         char            *name;
50 } LEAP_PACKET;
51
52 /*
53  *      The information which must be kept around
54  *      during the LEAP session.
55  */
56 typedef struct leap_session_t {
57         int             stage;
58         uint8_t         peer_challenge[8];
59         uint8_t         peer_response[24];
60 } leap_session_t;
61
62 /* function declarations here */
63
64 LEAP_PACKET     *eapleap_alloc(void);
65 void            eapleap_free(LEAP_PACKET **leap_packet_ptr);
66
67 int             eapleap_compose(EAP_DS *auth, LEAP_PACKET *reply);
68 LEAP_PACKET     *eapleap_extract(EAP_DS *auth);
69 LEAP_PACKET     *eapleap_initiate(EAP_DS *eap_ds, VALUE_PAIR *user_name);
70 int             eapleap_stage4(LEAP_PACKET *packet, VALUE_PAIR* password,
71                                leap_session_t *session);
72 LEAP_PACKET     *eapleap_stage6(LEAP_PACKET *packet, REQUEST *request,
73                                 VALUE_PAIR *user_name, VALUE_PAIR* password,
74                                 leap_session_t *session,
75                                 VALUE_PAIR **reply_vps);
76
77 void eapleap_lmpwdhash(const unsigned char *password,unsigned char *lmhash);
78 void eapleap_mschap(const unsigned char *win_password,
79                  const unsigned char *challenge, unsigned char *response);
80
81 #endif /*_EAP_LEAP_H*/