/* * * 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 #endif #include #include #include "eapol.h" bool eapol_verify(const uint8_t *data, size_t len) { struct eapol_key *ek; uint16_t key_data_len; if (len < sizeof(struct eapol_key)) return false; ek = (struct eapol_key *) data; if (ek->protocol_version != EAPOL_PROTOCOL_VERSION_2001 && ek->protocol_version != EAPOL_PROTOCOL_VERSION_2004) return false; if (ek->packet_type != 3) return false; switch (ek->descriptor_type) { case EAPOL_DESCRIPTOR_TYPE_RC4: case EAPOL_DESCRIPTOR_TYPE_80211: case EAPOL_DESCRIPTOR_TYPE_WPA: break; default: return false; } 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: break; default: return false; } key_data_len = L_BE16_TO_CPU(ek->key_data_len); if (len < sizeof(struct eapol_key) + key_data_len) return false; return true; }