|
36 | 36 | #include "6LoWPAN/ws/ws_llc.h"
|
37 | 37 | #include "6LoWPAN/ws/ws_mpx_header.h"
|
38 | 38 | #include "6LoWPAN/ws/ws_pae_controller.h"
|
| 39 | +#include "Security/PANA/pana_eap_header.h" |
| 40 | +#include "Security/eapol/eapol_helper.h" |
39 | 41 | #include "Service_Libs/etx/etx.h"
|
40 | 42 | #include "fhss_ws_extension.h"
|
41 | 43 |
|
@@ -617,6 +619,37 @@ static uint16_t ws_mpx_header_size_get(llc_data_base_t *base, uint16_t user_id)
|
617 | 619 | return header_size;
|
618 | 620 | }
|
619 | 621 |
|
| 622 | +static bool ws_eapol_handshake_first_msg(uint8_t *pdu, uint16_t length, protocol_interface_info_entry_t *cur) |
| 623 | +{ |
| 624 | + if (!ws_eapol_relay_state_active(cur)) { |
| 625 | + return false; |
| 626 | + } |
| 627 | + |
| 628 | + eapol_pdu_t eapol_pdu; |
| 629 | + uint8_t kmp_type = *pdu++; |
| 630 | + length--; |
| 631 | + if (!eapol_parse_pdu_header(pdu, length, &eapol_pdu)) { |
| 632 | + return false; |
| 633 | + } |
| 634 | + if (eapol_pdu.packet_type == EAPOL_EAP_TYPE) { |
| 635 | + if (eapol_pdu.msg.eap.eap_code == EAP_REQ && eapol_pdu.msg.eap.type == EAP_IDENTITY) { |
| 636 | + return true; |
| 637 | + } |
| 638 | + } else { |
| 639 | + |
| 640 | + uint8_t key_mask = eapol_pdu_key_mask_get(&eapol_pdu); |
| 641 | + if (kmp_type == 6 && key_mask == KEY_INFO_KEY_ACK) { |
| 642 | + //FWK first message validation |
| 643 | + return true; |
| 644 | + } else if (kmp_type == 7 && key_mask == (KEY_INFO_KEY_ACK | KEY_INFO_KEY_MIC | KEY_INFO_SECURED_KEY_FRAME)) { |
| 645 | + //GWK first message validation |
| 646 | + return true; |
| 647 | + } |
| 648 | + } |
| 649 | + |
| 650 | + return false; |
| 651 | +} |
| 652 | + |
620 | 653 | static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data_req_s *data, uint16_t user_id)
|
621 | 654 | {
|
622 | 655 | llc_data_base_t *base = ws_llc_discover_by_mpx(api);
|
@@ -646,12 +679,8 @@ static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data
|
646 | 679 | nested_wp_id.vp_ie = true;
|
647 | 680 | }
|
648 | 681 | } else if (user_id == MPX_KEY_MANAGEMENT_ENC_USER_ID) {
|
649 |
| - |
650 |
| - if (*data->msdu == 1) { //Only when KMP_ID is 1 |
651 |
| - ie_header_mask.ea_ie = ws_eapol_relay_state_active(base->interface_ptr); |
652 |
| - ie_header_mask.bt_ie = ie_header_mask.ea_ie; |
653 |
| - } |
654 |
| - |
| 682 | + ie_header_mask.ea_ie = ws_eapol_handshake_first_msg(data->msdu, data->msduLength, base->interface_ptr); |
| 683 | + ie_header_mask.bt_ie = ie_header_mask.ea_ie; |
655 | 684 | }
|
656 | 685 |
|
657 | 686 | nested_wp_id.us_ie = true;
|
|
0 commit comments