~ubuntu-branches/ubuntu/dapper/wpasupplicant/dapper

1.1.1 by Daniel T Chen
Import upstream version 0.4.5
1
/*
2
 * WPA Supplicant / EAP-PSK shared routines
3
 * Copyright (c) 2004-2005, Jouni Malinen <jkmaline@cc.hut.fi>
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License version 2 as
7
 * published by the Free Software Foundation.
8
 *
9
 * Alternatively, this software may be distributed under the terms of BSD
10
 * license.
11
 *
12
 * See README and COPYING for more details.
13
 */
14
15
#ifndef EAP_PSK_COMMON_H
16
#define EAP_PSK_COMMON_H
17
18
19
#define EAP_PSK_RAND_LEN 16
20
#define EAP_PSK_MAC_LEN 16
21
#define EAP_PSK_TEK_LEN 16
22
#define EAP_PSK_MSK_LEN 64
23
#define EAP_PSK_PSK_LEN 16
24
#define EAP_PSK_AK_LEN 16
25
#define EAP_PSK_KDK_LEN 16
26
27
#define EAP_PSK_R_FLAG_CONT 1
28
#define EAP_PSK_R_FLAG_DONE_SUCCESS 2
29
#define EAP_PSK_R_FLAG_DONE_FAILURE 3
30
#define EAP_PSK_E_FLAG 0x20
31
32
/* Shared prefix for all EAP-PSK frames */
33
struct eap_psk_hdr {
34
	u8 code;
35
	u8 identifier;
36
	u16 length; /* including code, identifier, and length */
37
	u8 type; /* EAP_TYPE_PSK */
38
	u8 flags;
39
} __attribute__ ((packed));
40
41
/* EAP-PSK First Message (AS -> Supplicant) */
42
struct eap_psk_hdr_1 {
43
	u8 code;
44
	u8 identifier;
45
	u16 length; /* including code, identifier, and length */
46
	u8 type; /* EAP_TYPE_PSK */
47
	u8 flags;
48
	u8 rand_s[EAP_PSK_RAND_LEN];
49
	/* Followed by variable length ID_S */
50
} __attribute__ ((packed));
51
52
/* EAP-PSK Second Message (Supplicant -> AS) */
53
struct eap_psk_hdr_2 {
54
	u8 code;
55
	u8 identifier;
56
	u16 length; /* including code, identifier, and length */
57
	u8 type; /* EAP_TYPE_PSK */
58
	u8 flags;
59
	u8 rand_s[EAP_PSK_RAND_LEN];
60
	u8 rand_p[EAP_PSK_RAND_LEN];
61
	u8 mac_p[EAP_PSK_MAC_LEN];
62
	/* Followed by variable length ID_P */
63
} __attribute__ ((packed));
64
65
/* EAP-PSK Third Message (AS -> Supplicant) */
66
struct eap_psk_hdr_3 {
67
	u8 code;
68
	u8 identifier;
69
	u16 length; /* including code, identifier, and length */
70
	u8 type; /* EAP_TYPE_PSK */
71
	u8 flags;
72
	u8 rand_s[EAP_PSK_RAND_LEN];
73
	u8 mac_s[EAP_PSK_MAC_LEN];
74
	/* Followed by variable length PCHANNEL */
75
} __attribute__ ((packed));
76
77
/* EAP-PSK Fourth Message (Supplicant -> AS) */
78
struct eap_psk_hdr_4 {
79
	u8 code;
80
	u8 identifier;
81
	u16 length; /* including code, identifier, and length */
82
	u8 type; /* EAP_TYPE_PSK */
83
	u8 flags;
84
	u8 rand_s[EAP_PSK_RAND_LEN];
85
	/* Followed by variable length PCHANNEL */
86
} __attribute__ ((packed));
87
88
89
void eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk);
90
void eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek, u8 *msk);
91
92
#endif /* EAP_PSK_COMMON_H */