1 /* 2 * EAP server/peer: EAP-PSK shared routines 3 * Copyright (c) 2004-2007, Jouni Malinen <j (at) w1.fi> 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9 #ifndef EAP_PSK_COMMON_H 10 #define EAP_PSK_COMMON_H 11 12 13 #define EAP_PSK_RAND_LEN 16 14 #define EAP_PSK_MAC_LEN 16 15 #define EAP_PSK_TEK_LEN 16 16 #define EAP_PSK_PSK_LEN 16 17 #define EAP_PSK_AK_LEN 16 18 #define EAP_PSK_KDK_LEN 16 19 20 #define EAP_PSK_R_FLAG_CONT 1 21 #define EAP_PSK_R_FLAG_DONE_SUCCESS 2 22 #define EAP_PSK_R_FLAG_DONE_FAILURE 3 23 #define EAP_PSK_E_FLAG 0x20 24 25 #define EAP_PSK_FLAGS_GET_T(flags) (((flags) & 0xc0) >> 6) 26 #define EAP_PSK_FLAGS_SET_T(t) ((u8) (t) << 6) 27 28 #ifdef _MSC_VER 29 #pragma pack(push, 1) 30 #endif /* _MSC_VER */ 31 32 /* EAP-PSK First Message (AS -> Supplicant) */ 33 struct eap_psk_hdr_1 { 34 u8 flags; 35 u8 rand_s[EAP_PSK_RAND_LEN]; 36 /* Followed by variable length ID_S */ 37 } STRUCT_PACKED; 38 39 /* EAP-PSK Second Message (Supplicant -> AS) */ 40 struct eap_psk_hdr_2 { 41 u8 flags; 42 u8 rand_s[EAP_PSK_RAND_LEN]; 43 u8 rand_p[EAP_PSK_RAND_LEN]; 44 u8 mac_p[EAP_PSK_MAC_LEN]; 45 /* Followed by variable length ID_P */ 46 } STRUCT_PACKED; 47 48 /* EAP-PSK Third Message (AS -> Supplicant) */ 49 struct eap_psk_hdr_3 { 50 u8 flags; 51 u8 rand_s[EAP_PSK_RAND_LEN]; 52 u8 mac_s[EAP_PSK_MAC_LEN]; 53 /* Followed by variable length PCHANNEL */ 54 } STRUCT_PACKED; 55 56 /* EAP-PSK Fourth Message (Supplicant -> AS) */ 57 struct eap_psk_hdr_4 { 58 u8 flags; 59 u8 rand_s[EAP_PSK_RAND_LEN]; 60 /* Followed by variable length PCHANNEL */ 61 } STRUCT_PACKED; 62 63 #ifdef _MSC_VER 64 #pragma pack(pop) 65 #endif /* _MSC_VER */ 66 67 68 int __must_check eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk); 69 int __must_check eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek, 70 u8 *msk, u8 *emsk); 71 72 #endif /* EAP_PSK_COMMON_H */ 73