2018-09-14 17:30:03 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Wireless daemon for Linux
|
|
|
|
*
|
2019-10-25 00:43:08 +02:00
|
|
|
* Copyright (C) 2013-2019 Intel Corporation. All rights reserved.
|
2018-09-14 17:30:03 +02:00
|
|
|
*
|
|
|
|
* 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 <stdio.h>
|
|
|
|
#include <ell/ell.h>
|
|
|
|
|
2018-10-26 21:31:52 +02:00
|
|
|
#include "src/eapolutil.h"
|
2018-09-14 17:30:03 +02:00
|
|
|
|
2019-01-17 21:25:28 +01:00
|
|
|
const struct eapol_key *eapol_key_validate(const uint8_t *frame, size_t len,
|
|
|
|
size_t mic_len)
|
2018-09-14 17:30:03 +02:00
|
|
|
{
|
|
|
|
const struct eapol_key *ek;
|
|
|
|
|
2019-01-17 21:25:28 +01:00
|
|
|
/*
|
|
|
|
* Since EAPOL_KEY_DATA_LEN actually gets the key data length bytes we
|
|
|
|
* have to check this first, otherwise we could potentially overrun the
|
|
|
|
* frame buffer
|
|
|
|
*/
|
|
|
|
if (len < EAPOL_FRAME_LEN(mic_len))
|
2018-09-14 17:30:03 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ek = (const struct eapol_key *) frame;
|
|
|
|
|
2019-01-17 21:25:28 +01:00
|
|
|
if (len < EAPOL_FRAME_LEN(mic_len) + EAPOL_KEY_DATA_LEN(ek, mic_len))
|
|
|
|
return NULL;
|
|
|
|
|
2018-09-14 17:30:03 +02:00
|
|
|
switch (ek->header.protocol_version) {
|
|
|
|
case EAPOL_PROTOCOL_VERSION_2001:
|
|
|
|
case EAPOL_PROTOCOL_VERSION_2004:
|
2021-03-22 20:09:19 +01:00
|
|
|
case EAPOL_PROTOCOL_VERSION_2010:
|
2018-09-14 17:30:03 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ek->header.packet_type != 3)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
switch (ek->descriptor_type) {
|
|
|
|
case EAPOL_DESCRIPTOR_TYPE_RC4:
|
|
|
|
case EAPOL_DESCRIPTOR_TYPE_80211:
|
|
|
|
case EAPOL_DESCRIPTOR_TYPE_WPA:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ek->key_descriptor_version) {
|
|
|
|
case EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_MD5_ARC4:
|
|
|
|
case EAPOL_KEY_DESCRIPTOR_VERSION_HMAC_SHA1_AES:
|
|
|
|
case EAPOL_KEY_DESCRIPTOR_VERSION_AES_128_CMAC_AES:
|
|
|
|
case EAPOL_KEY_DESCRIPTOR_VERSION_AKM_DEFINED:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ek;
|
|
|
|
}
|