1189251Ssam/* 2189251Ssam * EAP server/peer: EAP-PSK shared routines 3189251Ssam * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi> 4189251Ssam * 5189251Ssam * This program is free software; you can redistribute it and/or modify 6189251Ssam * it under the terms of the GNU General Public License version 2 as 7189251Ssam * published by the Free Software Foundation. 8189251Ssam * 9189251Ssam * Alternatively, this software may be distributed under the terms of BSD 10189251Ssam * license. 11189251Ssam * 12189251Ssam * See README and COPYING for more details. 13189251Ssam */ 14189251Ssam 15189251Ssam#ifndef EAP_PSK_COMMON_H 16189251Ssam#define EAP_PSK_COMMON_H 17189251Ssam 18189251Ssam 19189251Ssam#define EAP_PSK_RAND_LEN 16 20189251Ssam#define EAP_PSK_MAC_LEN 16 21189251Ssam#define EAP_PSK_TEK_LEN 16 22189251Ssam#define EAP_PSK_PSK_LEN 16 23189251Ssam#define EAP_PSK_AK_LEN 16 24189251Ssam#define EAP_PSK_KDK_LEN 16 25189251Ssam 26189251Ssam#define EAP_PSK_R_FLAG_CONT 1 27189251Ssam#define EAP_PSK_R_FLAG_DONE_SUCCESS 2 28189251Ssam#define EAP_PSK_R_FLAG_DONE_FAILURE 3 29189251Ssam#define EAP_PSK_E_FLAG 0x20 30189251Ssam 31189251Ssam#define EAP_PSK_FLAGS_GET_T(flags) (((flags) & 0xc0) >> 6) 32189251Ssam#define EAP_PSK_FLAGS_SET_T(t) ((u8) (t) << 6) 33189251Ssam 34189251Ssam#ifdef _MSC_VER 35189251Ssam#pragma pack(push, 1) 36189251Ssam#endif /* _MSC_VER */ 37189251Ssam 38189251Ssam/* EAP-PSK First Message (AS -> Supplicant) */ 39189251Ssamstruct eap_psk_hdr_1 { 40189251Ssam u8 flags; 41189251Ssam u8 rand_s[EAP_PSK_RAND_LEN]; 42189251Ssam /* Followed by variable length ID_S */ 43189251Ssam} STRUCT_PACKED; 44189251Ssam 45189251Ssam/* EAP-PSK Second Message (Supplicant -> AS) */ 46189251Ssamstruct eap_psk_hdr_2 { 47189251Ssam u8 flags; 48189251Ssam u8 rand_s[EAP_PSK_RAND_LEN]; 49189251Ssam u8 rand_p[EAP_PSK_RAND_LEN]; 50189251Ssam u8 mac_p[EAP_PSK_MAC_LEN]; 51189251Ssam /* Followed by variable length ID_P */ 52189251Ssam} STRUCT_PACKED; 53189251Ssam 54189251Ssam/* EAP-PSK Third Message (AS -> Supplicant) */ 55189251Ssamstruct eap_psk_hdr_3 { 56189251Ssam u8 flags; 57189251Ssam u8 rand_s[EAP_PSK_RAND_LEN]; 58189251Ssam u8 mac_s[EAP_PSK_MAC_LEN]; 59189251Ssam /* Followed by variable length PCHANNEL */ 60189251Ssam} STRUCT_PACKED; 61189251Ssam 62189251Ssam/* EAP-PSK Fourth Message (Supplicant -> AS) */ 63189251Ssamstruct eap_psk_hdr_4 { 64189251Ssam u8 flags; 65189251Ssam u8 rand_s[EAP_PSK_RAND_LEN]; 66189251Ssam /* Followed by variable length PCHANNEL */ 67189251Ssam} STRUCT_PACKED; 68189251Ssam 69189251Ssam#ifdef _MSC_VER 70189251Ssam#pragma pack(pop) 71189251Ssam#endif /* _MSC_VER */ 72189251Ssam 73189251Ssam 74189251Ssamint __must_check eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk); 75189251Ssamint __must_check eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek, 76189251Ssam u8 *msk, u8 *emsk); 77189251Ssam 78189251Ssam#endif /* EAP_PSK_COMMON_H */ 79