Skip to content

Commit ab849c6

Browse files
author
Mika Leppänen
committed
Corrected skipping of other elements than KDEs on EAPOL key frames
Unknown elements are now correctly skipped on key data field.
1 parent 61ebe10 commit ab849c6

File tree

7 files changed

+518
-2
lines changed

7 files changed

+518
-2
lines changed

source/Security/eapol/kde_helper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ static const uint8_t *kde_search(const uint8_t *ptr, uint16_t len, const uint8_t
108108
while (len >= KDE_MIN_LEN) {
109109
uint16_t kde_len = ptr[1] + KDE_FIXED_LEN;
110110

111-
// Type shall be 0xdd and length shall be at least 6 */
112-
if (ptr[KDE_TYPE_INDEX] != 0xdd || kde_len < KDE_MIN_LEN || kde_len > len) {
111+
// For the type 0xdd the length shall be at least 6 */
112+
if ((ptr[KDE_TYPE_INDEX] == 0xdd && kde_len < KDE_MIN_LEN) || kde_len > len) {
113113
return NULL;
114114
}
115115

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
include ../../makefile_defines.txt
2+
3+
COMPONENT_NAME = kde_helper_unit
4+
5+
#This must be changed manually
6+
SRC_FILES = \
7+
../../../../../source/Security/eapol/kde_helper.c
8+
9+
TEST_SRC_FILES = \
10+
main.cpp \
11+
kde_helpertest.cpp \
12+
test_kde_helper.c \
13+
../../stub/common_functions_stub.c \
14+
15+
include ../../MakefileWorker.mk
16+
17+
CPPUTESTFLAGS += -DFEA_TRACE_SUPPORT
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright (c) 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+
#include "CppUTest/TestHarness.h"
19+
20+
#include "test_kde_helper.h"
21+
22+
TEST_GROUP(kde_helper)
23+
{
24+
void setup() {
25+
}
26+
27+
void teardown() {
28+
}
29+
};
30+
31+
TEST(kde_helper, test_kde_gtkl_read)
32+
{
33+
CHECK(test_kde_gtkl_read());
34+
}
35+
36+
TEST(kde_helper, test_kde_gtk_read)
37+
{
38+
CHECK(test_kde_gtk_read());
39+
}
40+
41+
TEST(kde_helper, test_kde_pmkid_read)
42+
{
43+
CHECK(test_kde_pmkid_read());
44+
}
45+
46+
TEST(kde_helper, test_kde_ptkid_read)
47+
{
48+
CHECK(test_kde_ptkid_read());
49+
}
50+
51+
TEST(kde_helper, test_kde_lifetime_read)
52+
{
53+
CHECK(test_kde_lifetime_read());
54+
}
55+
56+
TEST(kde_helper, test_kde_gtkl_write)
57+
{
58+
CHECK(test_kde_gtkl_write());
59+
}
60+
61+
TEST(kde_helper, test_kde_gtk_write)
62+
{
63+
CHECK(test_kde_gtk_write());
64+
}
65+
66+
TEST(kde_helper, test_kde_pmkid_write)
67+
{
68+
CHECK(test_kde_pmkid_write());
69+
}
70+
71+
TEST(kde_helper, test_kde_ptkid_write)
72+
{
73+
CHECK(test_kde_ptkid_write());
74+
}
75+
76+
TEST(kde_helper, test_kde_lifetime_write)
77+
{
78+
CHECK(test_kde_lifetime_write());
79+
}
80+
81+
TEST(kde_helper, test_kde_padded_length_calc)
82+
{
83+
CHECK(test_kde_padded_length_calc());
84+
}
85+
86+
TEST(kde_helper, test_kde_padding_write)
87+
{
88+
CHECK(test_kde_padding_write());
89+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 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+
#include "CppUTest/CommandLineTestRunner.h"
19+
#include "CppUTest/TestPlugin.h"
20+
#include "CppUTest/TestRegistry.h"
21+
#include "CppUTestExt/MockSupportPlugin.h"
22+
int main(int ac, char **av)
23+
{
24+
return CommandLineTestRunner::RunAllTests(ac, av);
25+
}
26+
27+
IMPORT_TEST_GROUP(kde_helper);
28+

0 commit comments

Comments
 (0)