$search
00001 /* 00002 * EAP server/peer: EAP-PSK shared routines 00003 * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation. 00008 * 00009 * Alternatively, this software may be distributed under the terms of BSD 00010 * license. 00011 * 00012 * See README and COPYING for more details. 00013 */ 00014 00015 #ifndef EAP_PSK_COMMON_H 00016 #define EAP_PSK_COMMON_H 00017 00018 00019 #define EAP_PSK_RAND_LEN 16 00020 #define EAP_PSK_MAC_LEN 16 00021 #define EAP_PSK_TEK_LEN 16 00022 #define EAP_PSK_PSK_LEN 16 00023 #define EAP_PSK_AK_LEN 16 00024 #define EAP_PSK_KDK_LEN 16 00025 00026 #define EAP_PSK_R_FLAG_CONT 1 00027 #define EAP_PSK_R_FLAG_DONE_SUCCESS 2 00028 #define EAP_PSK_R_FLAG_DONE_FAILURE 3 00029 #define EAP_PSK_E_FLAG 0x20 00030 00031 #define EAP_PSK_FLAGS_GET_T(flags) (((flags) & 0xc0) >> 6) 00032 #define EAP_PSK_FLAGS_SET_T(t) ((u8) (t) << 6) 00033 00034 #ifdef _MSC_VER 00035 #pragma pack(push, 1) 00036 #endif /* _MSC_VER */ 00037 00038 /* EAP-PSK First Message (AS -> Supplicant) */ 00039 struct eap_psk_hdr_1 { 00040 u8 flags; 00041 u8 rand_s[EAP_PSK_RAND_LEN]; 00042 /* Followed by variable length ID_S */ 00043 } STRUCT_PACKED; 00044 00045 /* EAP-PSK Second Message (Supplicant -> AS) */ 00046 struct eap_psk_hdr_2 { 00047 u8 flags; 00048 u8 rand_s[EAP_PSK_RAND_LEN]; 00049 u8 rand_p[EAP_PSK_RAND_LEN]; 00050 u8 mac_p[EAP_PSK_MAC_LEN]; 00051 /* Followed by variable length ID_P */ 00052 } STRUCT_PACKED; 00053 00054 /* EAP-PSK Third Message (AS -> Supplicant) */ 00055 struct eap_psk_hdr_3 { 00056 u8 flags; 00057 u8 rand_s[EAP_PSK_RAND_LEN]; 00058 u8 mac_s[EAP_PSK_MAC_LEN]; 00059 /* Followed by variable length PCHANNEL */ 00060 } STRUCT_PACKED; 00061 00062 /* EAP-PSK Fourth Message (Supplicant -> AS) */ 00063 struct eap_psk_hdr_4 { 00064 u8 flags; 00065 u8 rand_s[EAP_PSK_RAND_LEN]; 00066 /* Followed by variable length PCHANNEL */ 00067 } STRUCT_PACKED; 00068 00069 #ifdef _MSC_VER 00070 #pragma pack(pop) 00071 #endif /* _MSC_VER */ 00072 00073 00074 int __must_check eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk); 00075 int __must_check eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek, 00076 u8 *msk, u8 *emsk); 00077 00078 #endif /* EAP_PSK_COMMON_H */