From dc3331a98d27d175072c73c94a62dc551c0df79a Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Sat, 27 Dec 2014 22:32:07 -0600 Subject: [PATCH] eapol: Add eapol_process_ptk_2_of_4 --- src/eapol.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/eapol.h | 2 ++ 2 files changed, 50 insertions(+) diff --git a/src/eapol.c b/src/eapol.c index a25ec5a0..8fcff5bb 100644 --- a/src/eapol.c +++ b/src/eapol.c @@ -126,3 +126,51 @@ bool eapol_process_ptk_1_of_4(const uint8_t *data, size_t len, return true; } + +bool eapol_process_ptk_2_of_4(const uint8_t *data, size_t len, + uint8_t out_snonce[]) +{ + struct eapol_key *ek; + uint16_t key_len; + + if (!eapol_verify(data, len)) + return false; + + ek = (struct eapol_key *) data; + + /* Verify according to 802.11, Section 11.6.6.2 */ + if (!ek->key_type) + return false; + + if (ek->smk_message) + return false; + + if (ek->install) + return false; + + if (ek->key_ack) + return false; + + if (!ek->key_mic) + return false; + + if (ek->secure) + return false; + + if (ek->error) + return false; + + if (ek->request) + return false; + + if (ek->encrypted_key_data) + return false; + + key_len = L_BE16_TO_CPU(ek->key_length); + if (key_len != 0) + return false; + + memcpy(out_snonce, ek->key_nonce, sizeof(ek->key_nonce)); + + return true; +} diff --git a/src/eapol.h b/src/eapol.h index 51031cf4..1eabc730 100644 --- a/src/eapol.h +++ b/src/eapol.h @@ -97,3 +97,5 @@ bool eapol_verify(const uint8_t *data, size_t len); bool eapol_process_ptk_1_of_4(const uint8_t *data, size_t len, uint8_t out_anonce[]); +bool eapol_process_ptk_2_of_4(const uint8_t *data, size_t len, + uint8_t out_snonce[]);