|
1 /* |
|
2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: EAP and WLAN authentication protocols. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // This is enumeration of EAPOL source code. |
|
20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
21 #undef EAP_FILE_NUMBER_ENUM |
|
22 #define EAP_FILE_NUMBER_ENUM 55 |
|
23 #undef EAP_FILE_NUMBER_DATE |
|
24 #define EAP_FILE_NUMBER_DATE 1127594498 |
|
25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
26 |
|
27 |
|
28 |
|
29 #include "eapol_rsna_key_data_payloads.h" |
|
30 #include "abs_eap_am_tools.h" |
|
31 #include "eap_tools.h" |
|
32 |
|
33 |
|
34 |
|
35 EAP_FUNC_EXPORT eapol_rsna_variable_data_c::~eapol_rsna_variable_data_c() |
|
36 { |
|
37 } |
|
38 |
|
39 EAP_FUNC_EXPORT eapol_rsna_variable_data_c::eapol_rsna_variable_data_c( |
|
40 abs_eap_am_tools_c * const tools, |
|
41 const bool is_RSNA_when_true, |
|
42 const bool is_WPXM_when_true) |
|
43 : eap_variable_data_c(tools) |
|
44 , m_am_tools(tools) |
|
45 , m_original_header(tools, is_RSNA_when_true, is_WPXM_when_true, 0, 0) |
|
46 { |
|
47 } |
|
48 |
|
49 EAP_FUNC_EXPORT const eapol_rsna_key_data_header_c * eapol_rsna_variable_data_c::get_original_header() const |
|
50 { |
|
51 return &m_original_header; |
|
52 } |
|
53 |
|
54 EAP_FUNC_EXPORT eap_status_e eapol_rsna_variable_data_c::set_buffer(const eapol_rsna_key_data_header_c * const original_header, |
|
55 u8_t *buffer, const u32_t buffer_length, |
|
56 const bool free_buffer, const bool is_writable) |
|
57 { |
|
58 m_original_header.set_header_buffer( |
|
59 original_header->get_header_buffer(original_header->get_header_buffer_length()), |
|
60 original_header->get_header_buffer_length()); |
|
61 if (m_original_header.get_is_valid() == false) |
|
62 { |
|
63 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
64 return EAP_STATUS_RETURN(m_am_tools, eap_status_header_corrupted); |
|
65 } |
|
66 |
|
67 eap_status_e status = eap_variable_data_c::set_buffer(buffer, buffer_length, free_buffer, is_writable); |
|
68 if (status != eap_status_ok) |
|
69 { |
|
70 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
71 return EAP_STATUS_RETURN(m_am_tools, status); |
|
72 } |
|
73 |
|
74 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
75 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
76 } |
|
77 |
|
78 |
|
79 |
|
80 EAP_FUNC_EXPORT eapol_rsna_key_data_payloads_c::~eapol_rsna_key_data_payloads_c() |
|
81 { |
|
82 } |
|
83 |
|
84 EAP_FUNC_EXPORT eapol_rsna_key_data_payloads_c::eapol_rsna_key_data_payloads_c( |
|
85 abs_eap_am_tools_c * const tools, |
|
86 const bool is_RSNA_when_true, |
|
87 const bool is_WPXM_when_true) |
|
88 : m_am_tools(tools) |
|
89 , m_group_key(tools, is_RSNA_when_true, is_WPXM_when_true) |
|
90 , m_group_key_id(0ul) |
|
91 , m_group_key_tx_bit(false) |
|
92 , m_STAKey(tools, is_RSNA_when_true, is_WPXM_when_true) |
|
93 , m_PMKID(tools, is_RSNA_when_true, is_WPXM_when_true) |
|
94 , m_RSN_IE(tools) |
|
95 , m_is_valid(false) |
|
96 { |
|
97 m_is_valid = true; |
|
98 } |
|
99 |
|
100 EAP_FUNC_EXPORT bool eapol_rsna_key_data_payloads_c::check_one_payload( |
|
101 const eapol_rsna_key_data_payload_status_e status, |
|
102 const eapol_rsna_variable_data_c * const payload) |
|
103 { |
|
104 if (status == eapol_rsna_key_data_payload_status_optional) |
|
105 { |
|
106 return true; |
|
107 } |
|
108 else if (status == eapol_rsna_key_data_payload_status_must_not_be |
|
109 && payload->eap_variable_data_c::get_is_valid_data() == false) |
|
110 { |
|
111 return true; |
|
112 } |
|
113 else if (status == eapol_rsna_key_data_payload_status_must_be |
|
114 && payload->eap_variable_data_c::get_is_valid_data() == true) |
|
115 { |
|
116 return true; |
|
117 } |
|
118 else |
|
119 { |
|
120 return false; |
|
121 } |
|
122 } |
|
123 |
|
124 EAP_FUNC_EXPORT bool eapol_rsna_key_data_payloads_c::check_one_payload( |
|
125 const eapol_rsna_key_data_payload_status_e status, |
|
126 const eap_array_c<eap_variable_data_c> * const payload) |
|
127 { |
|
128 if (status == eapol_rsna_key_data_payload_status_optional) |
|
129 { |
|
130 return true; |
|
131 } |
|
132 else if (status == eapol_rsna_key_data_payload_status_must_not_be |
|
133 && (payload->get_object_count() == 0ul |
|
134 || payload->get_object(0ul) == 0 |
|
135 || payload->get_object(0ul)->get_is_valid_data() == false)) |
|
136 { |
|
137 return true; |
|
138 } |
|
139 else if (status == eapol_rsna_key_data_payload_status_must_be |
|
140 && (payload->get_object_count() != 0ul |
|
141 && payload->get_object(0ul) != 0 |
|
142 && payload->get_object(0ul)->get_is_valid_data() == true)) |
|
143 { |
|
144 return true; |
|
145 } |
|
146 else |
|
147 { |
|
148 return false; |
|
149 } |
|
150 } |
|
151 |
|
152 EAP_FUNC_EXPORT bool eapol_rsna_key_data_payloads_c::check_payloads( |
|
153 const eapol_rsna_key_data_payload_status_e key_id_and_group_key, |
|
154 const eapol_rsna_key_data_payload_status_e sta_key, |
|
155 const eapol_rsna_key_data_payload_status_e pmkid, |
|
156 const eapol_rsna_key_data_payload_status_e one_or_more_RSN_IE |
|
157 ) |
|
158 { |
|
159 if (check_one_payload(key_id_and_group_key, get_group_key()) == true |
|
160 && check_one_payload(sta_key, get_STAKey()) == true |
|
161 && check_one_payload(pmkid, get_PMKID()) == true |
|
162 && check_one_payload(one_or_more_RSN_IE, get_RSN_IE()) == true // This will check at least one RSN IE exists if any is required. |
|
163 ) |
|
164 { |
|
165 return true; |
|
166 } |
|
167 else |
|
168 { |
|
169 return false; |
|
170 } |
|
171 } |
|
172 |
|
173 u8_t eapol_rsna_key_data_payloads_c::get_group_key_id() |
|
174 { |
|
175 return m_group_key_id; |
|
176 } |
|
177 |
|
178 bool eapol_rsna_key_data_payloads_c::get_group_key_tx() |
|
179 { |
|
180 return m_group_key_tx_bit; |
|
181 } |
|
182 |
|
183 eapol_rsna_variable_data_c * eapol_rsna_key_data_payloads_c::get_group_key() |
|
184 { |
|
185 return static_cast<eapol_rsna_variable_data_c *>(&m_group_key); |
|
186 } |
|
187 |
|
188 eapol_rsna_variable_data_c * eapol_rsna_key_data_payloads_c::get_STAKey() |
|
189 { |
|
190 return static_cast<eapol_rsna_variable_data_c *>(&m_STAKey); |
|
191 } |
|
192 |
|
193 eapol_rsna_variable_data_c * eapol_rsna_key_data_payloads_c::get_PMKID() |
|
194 { |
|
195 return static_cast<eapol_rsna_variable_data_c *>(&m_PMKID); |
|
196 } |
|
197 |
|
198 eap_array_c<eap_variable_data_c> * eapol_rsna_key_data_payloads_c::get_RSN_IE() |
|
199 { |
|
200 return &m_RSN_IE; |
|
201 } |
|
202 |
|
203 bool eapol_rsna_key_data_payloads_c::get_is_valid() const |
|
204 { |
|
205 return m_is_valid; |
|
206 } |
|
207 |
|
208 |
|
209 void eapol_rsna_key_data_payloads_c::set_group_key_id(const u8_t key_index) |
|
210 { |
|
211 m_group_key_id = key_index; |
|
212 } |
|
213 |
|
214 void eapol_rsna_key_data_payloads_c::set_group_key_tx(const bool key_tx_bit) |
|
215 { |
|
216 m_group_key_tx_bit = key_tx_bit; |
|
217 } |
|
218 |
|
219 |
|
220 //-------------------------------------------------- |
|
221 |
|
222 |
|
223 |
|
224 // End. |