remove @EAP_LDFLAGS@, no longer exists
[mech_eap.orig] / libeap / src / eap_common / eap_psk_common.h
1 /*
2  * EAP server/peer: EAP-PSK shared routines
3  * Copyright (c) 2004-2007, Jouni Malinen <j@w1.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 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 #define EAP_PSK_RAND_LEN 16
23 #define EAP_PSK_MAC_LEN 16
24 #define EAP_PSK_TEK_LEN 16
25 #define EAP_PSK_PSK_LEN 16
26 #define EAP_PSK_AK_LEN 16
27 #define EAP_PSK_KDK_LEN 16
28
29 #define EAP_PSK_R_FLAG_CONT 1
30 #define EAP_PSK_R_FLAG_DONE_SUCCESS 2
31 #define EAP_PSK_R_FLAG_DONE_FAILURE 3
32 #define EAP_PSK_E_FLAG 0x20
33
34 #define EAP_PSK_FLAGS_GET_T(flags) (((flags) & 0xc0) >> 6)
35 #define EAP_PSK_FLAGS_SET_T(t) ((u8) (t) << 6)
36
37 #ifdef _MSC_VER
38 #pragma pack(push, 1)
39 #endif /* _MSC_VER */
40
41 /* EAP-PSK First Message (AS -> Supplicant) */
42 struct eap_psk_hdr_1 {
43         u8 flags;
44         u8 rand_s[EAP_PSK_RAND_LEN];
45         /* Followed by variable length ID_S */
46 } STRUCT_PACKED;
47
48 /* EAP-PSK Second Message (Supplicant -> AS) */
49 struct eap_psk_hdr_2 {
50         u8 flags;
51         u8 rand_s[EAP_PSK_RAND_LEN];
52         u8 rand_p[EAP_PSK_RAND_LEN];
53         u8 mac_p[EAP_PSK_MAC_LEN];
54         /* Followed by variable length ID_P */
55 } STRUCT_PACKED;
56
57 /* EAP-PSK Third Message (AS -> Supplicant) */
58 struct eap_psk_hdr_3 {
59         u8 flags;
60         u8 rand_s[EAP_PSK_RAND_LEN];
61         u8 mac_s[EAP_PSK_MAC_LEN];
62         /* Followed by variable length PCHANNEL */
63 } STRUCT_PACKED;
64
65 /* EAP-PSK Fourth Message (Supplicant -> AS) */
66 struct eap_psk_hdr_4 {
67         u8 flags;
68         u8 rand_s[EAP_PSK_RAND_LEN];
69         /* Followed by variable length PCHANNEL */
70 } STRUCT_PACKED;
71
72 #ifdef _MSC_VER
73 #pragma pack(pop)
74 #endif /* _MSC_VER */
75
76
77 int __must_check eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk);
78 int __must_check eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek,
79                                      u8 *msk, u8 *emsk);
80
81 #ifdef __cplusplus
82 }
83 #endif
84
85 #endif /* EAP_PSK_COMMON_H */