3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-21 03:32:42 +01:00

eapol: Add eapol_verify_gtk_2_of_2

This commit is contained in:
Denis Kenzior 2015-05-05 22:04:21 -05:00
parent 2ba7867e9f
commit 8f3fd6e47d
2 changed files with 45 additions and 11 deletions

View File

@ -382,21 +382,23 @@ bool eapol_verify_ptk_4_of_4(const struct eapol_key *ek, bool is_wpa)
return true;
}
#define VERIFY_GTK_COMMON(ek) \
if (ek->key_type) \
return false; \
if (ek->smk_message) \
return false; \
if (ek->request) \
return false; \
if (ek->error) \
return false; \
if (ek->install) \
return false \
bool eapol_verify_gtk_1_of_2(const struct eapol_key *ek, bool is_wpa)
{
uint16_t key_len;
if (ek->key_type)
return false;
if (ek->smk_message)
return false;
if (ek->request)
return false;
if (ek->error)
return false;
if (ek->install)
return false;
VERIFY_GTK_COMMON(ek);
if (!ek->key_ack)
return false;
@ -429,6 +431,37 @@ bool eapol_verify_gtk_1_of_2(const struct eapol_key *ek, bool is_wpa)
return true;
}
bool eapol_verify_gtk_2_of_2(const struct eapol_key *ek, bool is_wpa)
{
uint16_t key_len;
/* Verify according to 802.11, Section 11.6.7.3 */
VERIFY_GTK_COMMON(ek);
if (ek->key_ack)
return false;
if (!ek->key_mic)
return false;
if (ek->secure != !is_wpa)
return false;
if (ek->encrypted_key_data)
return false;
key_len = L_BE16_TO_CPU(ek->key_length);
if (key_len != 0)
return false;
VERIFY_IS_ZERO(ek->key_nonce);
VERIFY_IS_ZERO(ek->eapol_key_iv);
VERIFY_IS_ZERO(ek->key_rsc);
VERIFY_IS_ZERO(ek->reserved);
return true;
}
static struct eapol_key *eapol_create_common(
enum eapol_protocol_version protocol,
enum eapol_key_descriptor_version version,

View File

@ -126,6 +126,7 @@ bool eapol_verify_ptk_2_of_4(const struct eapol_key *ek);
bool eapol_verify_ptk_3_of_4(const struct eapol_key *ek, bool is_wpa);
bool eapol_verify_ptk_4_of_4(const struct eapol_key *ek, bool is_wpa);
bool eapol_verify_gtk_1_of_2(const struct eapol_key *ek, bool is_wpa);
bool eapol_verify_gtk_2_of_2(const struct eapol_key *ek, bool is_wpa);
struct eapol_key *eapol_create_ptk_2_of_4(
enum eapol_protocol_version protocol,