Skip to content

Commit 6481549

Browse files
author
Mika Leppänen
committed
Added GKH MIC validation and encryption
1 parent cc3ce58 commit 6481549

File tree

12 files changed

+732
-420
lines changed

12 files changed

+732
-420
lines changed

source/6LoWPAN/ws/ws_pae_auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "Security/protocols/key_sec_prot/key_sec_prot.h"
3636
#include "Security/protocols/eap_tls_sec_prot/eap_tls_sec_prot.h"
3737
#include "Security/protocols/fwh_sec_prot/auth_fwh_sec_prot.h"
38-
#include "Security/protocols/gkh_sec_prot/gkh_sec_prot.h"
38+
#include "Security/protocols/gkh_sec_prot/auth_gkh_sec_prot.h"
3939
#include "6LoWPAN/ws/ws_pae_controller.h"
4040
#include "6LoWPAN/ws/ws_pae_auth.h"
4141
#include "6LoWPAN/ws/ws_pae_lib.h"
@@ -138,7 +138,7 @@ int8_t ws_pae_auth_init(protocol_interface_info_entry_t *interface_ptr, uint16_t
138138
goto error;
139139
}
140140

141-
if (gkh_auth_sec_prot_register(pae_auth->kmp_service) < 0) {
141+
if (auth_gkh_sec_prot_register(pae_auth->kmp_service) < 0) {
142142
goto error;
143143
}
144144

source/6LoWPAN/ws/ws_pae_supp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include "Security/protocols/key_sec_prot/key_sec_prot.h"
3838
#include "Security/protocols/eap_tls_sec_prot/eap_tls_sec_prot.h"
3939
#include "Security/protocols/fwh_sec_prot/supp_fwh_sec_prot.h"
40-
#include "Security/protocols/gkh_sec_prot/gkh_sec_prot.h"
40+
#include "Security/protocols/gkh_sec_prot/supp_gkh_sec_prot.h"
4141
#include "6LoWPAN/ws/ws_pae_controller.h"
4242
#include "6LoWPAN/ws/ws_pae_supp.h"
4343
#include "6LoWPAN/ws/ws_pae_lib.h"
@@ -255,7 +255,7 @@ int8_t ws_pae_supp_init(protocol_interface_info_entry_t *interface_ptr)
255255
goto error;
256256
}
257257

258-
if (gkh_supp_sec_prot_register(pae_supp->kmp_service) < 0) {
258+
if (supp_gkh_sec_prot_register(pae_supp->kmp_service) < 0) {
259259
goto error;
260260
}
261261

source/Security/protocols/fwh_sec_prot/auth_fwh_sec_prot.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
typedef enum {
4444
FWH_STATE_INIT = SEC_STATE_INIT,
4545
FWH_STATE_CREATE_REQ = SEC_STATE_CREATE_REQ,
46-
FWH_STATE_MESSAGE_2,
46+
FWH_STATE_MESSAGE_2 = SEC_STATE_FIRST,
4747
FWH_STATE_MESSAGE_4,
4848
FWH_STATE_FINISH = SEC_STATE_FINISH,
4949
FWH_STATE_FINISHED = SEC_STATE_FINISHED
@@ -57,11 +57,6 @@ typedef enum {
5757
FWH_MESSAGE_4
5858
} fwh_sec_prot_msg_e;
5959

60-
#define KEY_INFO_INSTALL 0x01
61-
#define KEY_INFO_KEY_ACK 0x02
62-
#define KEY_INFO_KEY_MIC 0x04
63-
#define KEY_INFO_SECURED_KEY_FRAME 0x08
64-
6560
typedef struct {
6661
sec_prot_common_t common; /**< Common data */
6762
eapol_pdu_t recv_eapol_pdu; /**< Received EAPOL PDU */
@@ -178,26 +173,14 @@ static int8_t auth_fwh_sec_prot_receive(sec_prot_t *prot, void *pdu, uint16_t si
178173

179174
static fwh_sec_prot_msg_e auth_fwh_sec_prot_message_get(eapol_pdu_t *eapol_pdu, sec_prot_keys_t *sec_keys)
180175
{
181-
uint8_t key_mask = 0;
182176
fwh_sec_prot_msg_e msg = FWH_MESSAGE_UNKNOWN;
183177

184178
if (!eapol_pdu->msg.key.key_information.pairwise_key) {
185179
// This is mismatch between KMP ID indicating 802.11/4WH and key type
186180
return FWH_MESSAGE_UNKNOWN;
187181
}
188182

189-
if (eapol_pdu->msg.key.key_information.install) {
190-
key_mask |= KEY_INFO_INSTALL;
191-
}
192-
if (eapol_pdu->msg.key.key_information.key_ack) {
193-
key_mask |= KEY_INFO_KEY_ACK;
194-
}
195-
if (eapol_pdu->msg.key.key_information.key_mic) {
196-
key_mask |= KEY_INFO_KEY_MIC;
197-
}
198-
if (eapol_pdu->msg.key.key_information.secured_key_frame) {
199-
key_mask |= KEY_INFO_SECURED_KEY_FRAME;
200-
}
183+
uint8_t key_mask = sec_prot_lib_key_mask_get(eapol_pdu);
201184

202185
switch (key_mask) {
203186
case KEY_INFO_KEY_MIC:
@@ -387,6 +370,7 @@ static void auth_fwh_sec_prot_state_machine(sec_prot_t *prot)
387370
if (auth_fwh_sec_prot_mic_validate(prot) < 0) {
388371
return;
389372
}
373+
memcpy(prot->sec_keys->ptk, data->new_ptk, PTK_LEN);
390374
sec_prot_state_set(prot, &data->common, FWH_STATE_FINISH);
391375
}
392376
break;

source/Security/protocols/fwh_sec_prot/supp_fwh_sec_prot.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,26 +190,14 @@ static int8_t supp_fwh_sec_prot_receive(sec_prot_t *prot, void *pdu, uint16_t si
190190

191191
static fwh_sec_prot_msg_e supp_fwh_sec_prot_message_get(eapol_pdu_t *eapol_pdu, sec_prot_keys_t *sec_keys)
192192
{
193-
uint8_t key_mask = 0;
194193
fwh_sec_prot_msg_e msg = FWH_MESSAGE_UNKNOWN;
195194

196195
if (!eapol_pdu->msg.key.key_information.pairwise_key) {
197196
// This is mismatch between KMP ID indicating 802.11/4WH and key type
198197
return FWH_MESSAGE_UNKNOWN;
199198
}
200199

201-
if (eapol_pdu->msg.key.key_information.install) {
202-
key_mask |= KEY_INFO_INSTALL;
203-
}
204-
if (eapol_pdu->msg.key.key_information.key_ack) {
205-
key_mask |= KEY_INFO_KEY_ACK;
206-
}
207-
if (eapol_pdu->msg.key.key_information.key_mic) {
208-
key_mask |= KEY_INFO_KEY_MIC;
209-
}
210-
if (eapol_pdu->msg.key.key_information.secured_key_frame) {
211-
key_mask |= KEY_INFO_SECURED_KEY_FRAME;
212-
}
200+
uint8_t key_mask = sec_prot_lib_key_mask_get(eapol_pdu);
213201

214202
switch (key_mask) {
215203
case KEY_INFO_KEY_ACK:

0 commit comments

Comments
 (0)