3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

eapol: Add beginnings of EAPoL utilities

This commit is contained in:
Denis Kenzior 2014-12-18 18:10:10 -06:00
parent ac663fba69
commit 2cc842a302
3 changed files with 125 additions and 1 deletions

View File

@ -61,7 +61,8 @@ monitor_iwmon_SOURCES = monitor/main.c linux/nl80211.h \
monitor/pcap.h monitor/pcap.c \
monitor/display.h monitor/display.c \
src/ie.h src/ie.c \
src/util.h src/util.c
src/util.h src/util.c \
src/eapol.h src/eapol.c
monitor_iwmon_LDADD = ell/libell-internal.la
noinst_PROGRAMS = tools/hwsim

31
src/eapol.c Normal file
View File

@ -0,0 +1,31 @@
/*
*
* Wireless daemon for Linux
*
* Copyright (C) 2013-2014 Intel Corporation. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <ell/ell.h>
#include "eapol.h"

92
src/eapol.h Normal file
View File

@ -0,0 +1,92 @@
/*
*
* Wireless daemon for Linux
*
* Copyright (C) 2013-2014 Intel Corporation. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <stdint.h>
#include <stdbool.h>
#include <asm/byteorder.h>
#include <linux/types.h>
enum eapol_protocol_version {
EAPOL_PROTOCOL_VERSION_2001 = 1,
EAPOL_PTOTOCOL_VERSION_2004 = 2,
};
/*
* 802.1X-2010: Table 11-5Descriptor Type value assignments
* The WPA key type of 254 comes from somewhere else. Seems it is a legacy
* value that might still be used by older implementations
*/
enum eapol_descriptor_type {
EAPOL_DESCRIPTOR_TYPE_RC4 = 1,
EAPOL_DESCRIPTOR_TYPE_80211 = 2,
EAPOL_DESCRIPTOR_TYPE_WPA = 254,
};
enum eapol_key_descriptor_version {
EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4 = 1,
EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_SHA1_AES = 2,
EAPOL_KEY_DESCRIPTOR_VERSION_AES_128_CMAC_AES = 3,
};
struct eapol_key {
uint8_t protocol_version;
uint8_t packet_type;
__be16 packet_len;
uint8_t descriptor_type;
#if defined(__LITTLE_ENDIAN_BITFIELD)
bool key_mic:1;
bool secure:1;
bool error:1;
bool request:1;
bool encrypted_key_data:1;
bool smk_message:1;
uint8_t reserved2:2;
uint8_t key_descriptor_version:3;
bool key_type:1;
uint8_t reserved1:2;
bool install:1;
bool key_ack:1;
#elif defined (__BIG_ENDIAN_BITFIELD)
uint8_t reserved2:2;
bool smk_message:1;
bool encrypted_key_data:1;
bool request:1;
bool error:1;
bool secure:1;
bool key_mic:1;
bool key_ack:1;
bool install:1;
uint8_t reserved1:2;
bool key_type:1;
uint8_t key_descriptor_version:3;
#else
#error "Please fix <asm/byteorder.h>"
#endif
__be16 key_length;
uint8_t key_replay_counter[8];
uint8_t key_nonce[32];
uint8_t eapol_key_iv[16];
uint8_t key_mic_data[16];
__be16 key_data_len;
uint8_t key_data[0];
} __attribute__ ((packed));