Skip to content

Commit 5ad1743

Browse files
author
Juha Heiskanen
committed
EAPOL helper update
EAPOL key mask function moved to eapol_helper. Now we have a generic common function for read key mask. Change-Id: I9f11f613f0cfa9a686d7f777f7f96e3810f3e2d2
1 parent 64e924e commit 5ad1743

File tree

10 files changed

+111
-37
lines changed

10 files changed

+111
-37
lines changed

source/Security/eapol/eapol_helper.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,5 +274,25 @@ uint16_t eapol_pdu_key_frame_init(eapol_pdu_t *eapol_pdu, uint16_t data_length,
274274

275275
}
276276

277+
uint8_t eapol_pdu_key_mask_get(eapol_pdu_t *eapol_pdu)
278+
{
279+
uint8_t key_mask = 0;
280+
281+
if (eapol_pdu->msg.key.key_information.install) {
282+
key_mask |= KEY_INFO_INSTALL;
283+
}
284+
if (eapol_pdu->msg.key.key_information.key_ack) {
285+
key_mask |= KEY_INFO_KEY_ACK;
286+
}
287+
if (eapol_pdu->msg.key.key_information.key_mic) {
288+
key_mask |= KEY_INFO_KEY_MIC;
289+
}
290+
if (eapol_pdu->msg.key.key_information.secured_key_frame) {
291+
key_mask |= KEY_INFO_SECURED_KEY_FRAME;
292+
}
293+
294+
return key_mask;
295+
}
296+
277297
#endif
278298

source/Security/eapol/eapol_helper.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,18 @@ uint16_t eapol_pdu_key_frame_init(eapol_pdu_t *eapol_pdu, uint16_t data_length,
9696

9797
void eapol_write_key_packet_mic(uint8_t *eapol_pdu, uint8_t *mic);
9898

99+
#define KEY_INFO_INSTALL 0x01
100+
#define KEY_INFO_KEY_ACK 0x02
101+
#define KEY_INFO_KEY_MIC 0x04
102+
#define KEY_INFO_SECURED_KEY_FRAME 0x08
103+
104+
/**
105+
* eapol_pdu_key_mask_get gets masked EAPOL-Key message bits
106+
*
107+
* \param eapol_pdu EAPOL PDU
108+
*
109+
* \return mask
110+
*/
111+
uint8_t eapol_pdu_key_mask_get(eapol_pdu_t *eapol_pdu);
112+
99113
#endif /* EAPOL_HELPER_H_ */

source/Security/protocols/fwh_sec_prot/auth_fwh_sec_prot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static fwh_sec_prot_msg_e auth_fwh_sec_prot_message_get(eapol_pdu_t *eapol_pdu,
186186
return FWH_MESSAGE_UNKNOWN;
187187
}
188188

189-
uint8_t key_mask = sec_prot_lib_key_mask_get(eapol_pdu);
189+
uint8_t key_mask = eapol_pdu_key_mask_get(eapol_pdu);
190190

191191
switch (key_mask) {
192192
case KEY_INFO_KEY_MIC:

source/Security/protocols/fwh_sec_prot/supp_fwh_sec_prot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static fwh_sec_prot_msg_e supp_fwh_sec_prot_message_get(sec_prot_t *prot, eapol_
204204
return FWH_MESSAGE_UNKNOWN;
205205
}
206206

207-
uint8_t key_mask = sec_prot_lib_key_mask_get(eapol_pdu);
207+
uint8_t key_mask = eapol_pdu_key_mask_get(eapol_pdu);
208208

209209
switch (key_mask) {
210210
// Message 1

source/Security/protocols/gkh_sec_prot/auth_gkh_sec_prot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static gkh_sec_prot_msg_e auth_gkh_sec_prot_message_get(eapol_pdu_t *eapol_pdu,
169169
return GKH_MESSAGE_UNKNOWN;
170170
}
171171

172-
uint8_t key_mask = sec_prot_lib_key_mask_get(eapol_pdu);
172+
uint8_t key_mask = eapol_pdu_key_mask_get(eapol_pdu);
173173

174174
switch (key_mask) {
175175
case KEY_INFO_KEY_MIC | KEY_INFO_SECURED_KEY_FRAME:

source/Security/protocols/gkh_sec_prot/supp_gkh_sec_prot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static gkh_sec_prot_msg_e supp_gkh_sec_prot_message_get(eapol_pdu_t *eapol_pdu,
172172
return GKH_MESSAGE_UNKNOWN;
173173
}
174174

175-
uint8_t key_mask = sec_prot_lib_key_mask_get(eapol_pdu);
175+
uint8_t key_mask = eapol_pdu_key_mask_get(eapol_pdu);
176176

177177
switch (key_mask) {
178178
case KEY_INFO_KEY_ACK | KEY_INFO_KEY_MIC | KEY_INFO_SECURED_KEY_FRAME:

source/Security/protocols/sec_prot_lib.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -429,26 +429,6 @@ int8_t sec_prot_lib_mic_validate(uint8_t *ptk, uint8_t *mic, uint8_t *pdu, uint8
429429
return 0;
430430
}
431431

432-
uint8_t sec_prot_lib_key_mask_get(eapol_pdu_t *eapol_pdu)
433-
{
434-
uint8_t key_mask = 0;
435-
436-
if (eapol_pdu->msg.key.key_information.install) {
437-
key_mask |= KEY_INFO_INSTALL;
438-
}
439-
if (eapol_pdu->msg.key.key_information.key_ack) {
440-
key_mask |= KEY_INFO_KEY_ACK;
441-
}
442-
if (eapol_pdu->msg.key.key_information.key_mic) {
443-
key_mask |= KEY_INFO_KEY_MIC;
444-
}
445-
if (eapol_pdu->msg.key.key_information.secured_key_frame) {
446-
key_mask |= KEY_INFO_SECURED_KEY_FRAME;
447-
}
448-
449-
return key_mask;
450-
}
451-
452432
int8_t sec_prot_lib_pmkid_generate(sec_prot_t *prot, uint8_t *pmkid, bool is_auth)
453433
{
454434
uint8_t *pmk = sec_prot_keys_pmk_get(prot->sec_keys);

source/Security/protocols/sec_prot_lib.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@
3434
#define SEC_TOTAL_TIMEOUT 30 * 60 * 10 // 30 minutes
3535
#define SEC_FINISHED_TIMEOUT 5 * 10 // 5 seconds
3636

37-
#define KEY_INFO_INSTALL 0x01
38-
#define KEY_INFO_KEY_ACK 0x02
39-
#define KEY_INFO_KEY_MIC 0x04
40-
#define KEY_INFO_SECURED_KEY_FRAME 0x08
4137

4238
// Common data shared between security protocols needing general timers and state machines
4339
typedef struct {
@@ -159,15 +155,6 @@ int8_t sec_prot_lib_gtk_read(uint8_t *kde, uint16_t kde_len, sec_prot_keys_t *se
159155
*/
160156
int8_t sec_prot_lib_mic_validate(uint8_t *ptk, uint8_t *mic, uint8_t *pdu, uint8_t pdu_size);
161157

162-
/**
163-
* sec_prot_lib_key_mask_get gets masked EAPOL-Key message bits
164-
*
165-
* \param eapol_pdu EAPOL PDU
166-
*
167-
* \return mask
168-
*/
169-
uint8_t sec_prot_lib_key_mask_get(eapol_pdu_t *eapol_pdu);
170-
171158
/**
172159
* sec_prot_lib_pmkid_generate generate PMK ID from PMK
173160
*

test/nanostack/unittest/6LoWPAN/ws_llc_data_service/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ TEST_SRC_FILES = \
3535
../../stub/mac_neighbor_table_stub.c \
3636
../../stub/iphc_decompress_stub.c \
3737
../../stub/fhss_config_stub.c \
38+
../../stub/eapol_helper_stub.c \
3839

3940

4041
include ../../MakefileWorker.mk
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2018-2019, Arm Limited and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
19+
20+
#include "nsconfig.h"
21+
22+
#include "ns_types.h"
23+
#include "eventOS_event.h"
24+
#include "ns_trace.h"
25+
#include "string.h"
26+
#include "common_functions.h"
27+
#include "Security/PANA/pana_eap_header.h"
28+
#include "Security/eapol/eapol_helper.h"
29+
30+
#ifdef HAVE_WS
31+
32+
void eapol_write_key_packet_mic(uint8_t *eapol_pdu, uint8_t *mic)
33+
{
34+
35+
}
36+
37+
bool eapol_parse_pdu_header(uint8_t *ptr, uint16_t data_length, eapol_pdu_t *eapol_pdu)
38+
{
39+
return false;
40+
}
41+
42+
uint8_t *eapol_write_pdu_frame(uint8_t *ptr, eapol_pdu_t *eapol_pdu)
43+
{
44+
return ptr;
45+
}
46+
47+
48+
49+
uint16_t eapol_pdu_eap_frame_init(eapol_pdu_t *eapol_pdu, uint8_t eap_code, uint8_t id_seq, uint8_t type, uint16_t data_length, uint8_t *data_ptr)
50+
{
51+
memset(eapol_pdu, 0, sizeof(eapol_pdu_t));
52+
53+
return eapol_pdu_total_length(eapol_pdu);
54+
55+
}
56+
57+
uint16_t eapol_pdu_key_frame_init(eapol_pdu_t *eapol_pdu, uint16_t data_length, uint8_t *data_ptr)
58+
{
59+
60+
return eapol_pdu_total_length(eapol_pdu);
61+
62+
}
63+
64+
uint8_t eapol_pdu_key_mask_get(eapol_pdu_t *eapol_pdu)
65+
{
66+
67+
68+
return 0;
69+
}
70+
71+
#endif
72+

0 commit comments

Comments
 (0)