|
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 |
|
20 |
|
21 #if !defined(_AKA_HEADER_H_) |
|
22 #define _AKA_HEADER_H_ |
|
23 |
|
24 #include "eap_tools.h" |
|
25 #include "eap_header.h" |
|
26 #include "eap_header_string.h" |
|
27 |
|
28 /** @file */ |
|
29 |
|
30 const u32_t AKA_FIRST_SEQUENCE = 1u; |
|
31 const u32_t AKA_PAYLOAD_LENGTH_ALIGN = 4u; |
|
32 const u32_t EAP_AKA_PAYLOAD_ZERO_DATA_LENGTH = 0u; |
|
33 const u8_t AKA_NAI_AT_BYTE = '@'; |
|
34 |
|
35 |
|
36 enum aka_subtype_e |
|
37 { |
|
38 aka_subtype_NONE = 0, |
|
39 aka_subtype_Challenge = 1, |
|
40 aka_subtype_Authentication_Reject = 2, |
|
41 aka_subtype_Synchronization_Failure = 4, |
|
42 aka_subtype_Identity = 5, |
|
43 aka_subtype_Notification = 12, |
|
44 aka_subtype_Re_authentication = 13, |
|
45 aka_subtype_Client_Error = 14, |
|
46 }; |
|
47 |
|
48 enum aka_payload_AT_type_e |
|
49 { |
|
50 aka_payload_NONE = 0, |
|
51 |
|
52 aka_payload_AT_RAND = 1, |
|
53 aka_payload_AT_AUTN = 2, |
|
54 aka_payload_AT_RES = 3, |
|
55 aka_payload_AT_AUTS = 4, |
|
56 aka_payload_AT_PADDING = 6, |
|
57 aka_payload_AT_PERMANENT_ID_REQ = 10, |
|
58 aka_payload_AT_MAC = 11, |
|
59 aka_payload_AT_NOTIFICATION = 12, |
|
60 aka_payload_AT_ANY_ID_REQ = 13, |
|
61 aka_payload_AT_IDENTITY = 14, |
|
62 aka_payload_AT_FULLAUTH_ID_REQ = 17, |
|
63 aka_payload_AT_COUNTER = 19, |
|
64 aka_payload_AT_COUNTER_TOO_SMALL = 20, |
|
65 aka_payload_AT_NONCE_S = 21, |
|
66 aka_payload_AT_CLIENT_ERROR_CODE = 22, |
|
67 |
|
68 aka_payload_AT_IV = 129, |
|
69 aka_payload_AT_ENCR_DATA = 130, |
|
70 aka_payload_AT_NEXT_PSEUDONYM = 132, |
|
71 aka_payload_AT_NEXT_REAUTH_ID = 133, |
|
72 aka_payload_AT_CHECKCODE = 134, |
|
73 aka_payload_AT_RESULT_IND = 135, |
|
74 }; |
|
75 |
|
76 enum eap_aka_client_error_code_e |
|
77 { |
|
78 eap_aka_client_error_code_unable_to_process_packet = 0, |
|
79 eap_aka_client_error_code_unsupported_version = 1, |
|
80 eap_aka_client_error_code_insufficient_number_of_challenges = 2, |
|
81 eap_aka_client_error_code_rands_are_not_fresh = 3, |
|
82 eap_aka_client_error_code_maximum_value = eap_aka_client_error_code_rands_are_not_fresh, |
|
83 eap_aka_client_error_code_none = 0xff, |
|
84 }; |
|
85 |
|
86 //---------------------------------------------------------------------------- |
|
87 |
|
88 |
|
89 /// This class defines the attribute payload header of AKA EAP-type. |
|
90 /** |
|
91 * Here is a figure of attribute payload header of AKA EAP-type. |
|
92 * Attribute payload data is (m_length*4)-sizeof(aka_payload_AT_header_c) data octets that follows aka_payload_AT_header_c. |
|
93 * @code |
|
94 * 0 1 2 3 |
|
95 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
|
96 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
97 * | Type | Length | Value ... | |
|
98 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
99 * | Attribute payload data ... |
|
100 * +-+-+-+-+-+-+-+-+-+-+- |
|
101 * @endcode |
|
102 * |
|
103 */ |
|
104 class EAP_EXPORT aka_payload_AT_header_c |
|
105 : public eap_general_header_base_c |
|
106 { |
|
107 private: |
|
108 //-------------------------------------------------- |
|
109 |
|
110 /// This is pointer to the tools class. |
|
111 abs_eap_am_tools_c * const m_am_tools; |
|
112 |
|
113 //-------------------------------------------------- |
|
114 protected: |
|
115 //-------------------------------------------------- |
|
116 |
|
117 enum offsets |
|
118 { |
|
119 m_type_offset = 0ul, |
|
120 m_length_offset = m_type_offset+sizeof(u8_t), |
|
121 m_reserved_offset = m_length_offset+sizeof(u8_t), |
|
122 m_data_offset = m_reserved_offset+sizeof(u16_t), |
|
123 }; |
|
124 |
|
125 //-------------------------------------------------- |
|
126 public: |
|
127 //-------------------------------------------------- |
|
128 |
|
129 // |
|
130 EAP_FUNC_IMPORT virtual ~aka_payload_AT_header_c(); |
|
131 |
|
132 // |
|
133 EAP_FUNC_IMPORT aka_payload_AT_header_c( |
|
134 abs_eap_am_tools_c * const tools, |
|
135 void * const header_buffer, |
|
136 const u32_t header_buffer_length); |
|
137 |
|
138 EAP_FUNC_IMPORT aka_payload_AT_type_e get_current_payload() const; |
|
139 |
|
140 EAP_FUNC_IMPORT u16_t get_payload_length() const; |
|
141 |
|
142 EAP_FUNC_IMPORT u16_t get_reserved() const; |
|
143 |
|
144 EAP_FUNC_IMPORT u8_t * get_reserved_pointer(const u32_t contignuous_bytes) const; |
|
145 |
|
146 EAP_FUNC_IMPORT u32_t get_data_length() const; |
|
147 |
|
148 EAP_FUNC_IMPORT static u16_t get_header_length(); |
|
149 |
|
150 EAP_FUNC_IMPORT static u16_t get_max_payload_data_length(); |
|
151 |
|
152 EAP_FUNC_IMPORT u8_t * get_data(const u32_t contignuous_bytes) const; |
|
153 |
|
154 EAP_FUNC_IMPORT u8_t * get_data_offset(const u32_t offset, const u32_t contignuous_bytes) const; |
|
155 |
|
156 EAP_FUNC_IMPORT u8_t * get_next_header() const; |
|
157 |
|
158 // Mostly this is zero. |
|
159 // With some attributes this is used for special purposes. |
|
160 EAP_FUNC_IMPORT void set_reserved(const u16_t reserved); |
|
161 |
|
162 EAP_FUNC_IMPORT void set_current_payload(const aka_payload_AT_type_e p_current_payload); |
|
163 |
|
164 EAP_FUNC_IMPORT void set_data_length(const u16_t p_data_length); |
|
165 |
|
166 EAP_FUNC_IMPORT void reset_header(const u16_t data_length); |
|
167 |
|
168 EAP_FUNC_IMPORT static eap_const_string get_payload_AT_string(const aka_payload_AT_type_e payload_type); |
|
169 |
|
170 EAP_FUNC_IMPORT eap_const_string get_payload_AT_string() const; |
|
171 |
|
172 EAP_FUNC_IMPORT eap_status_e check_header() const; |
|
173 |
|
174 // |
|
175 //-------------------------------------------------- |
|
176 }; // class aka_payload_AT_header_c |
|
177 |
|
178 |
|
179 |
|
180 //---------------------------------------------------------------------------- |
|
181 |
|
182 |
|
183 /// This class defines header of AKA EAP-type. |
|
184 /** |
|
185 * Here is a figure of header of AKA EAP-type. |
|
186 * Subtype-Data is m_length-sizeof(aka_header_c) data octets that follows aka_header_c. |
|
187 * @code |
|
188 * 0 1 2 3 |
|
189 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
|
190 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
191 * | Code | Identifier | Length | |
|
192 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
193 * | Type=18 | Subtype | Reserved = 0 | |
|
194 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
195 * | Subtype-Data... |
|
196 * +-+-+-+-+-+-+-+-+-+-+- |
|
197 * @endcode |
|
198 * |
|
199 */ |
|
200 class EAP_EXPORT aka_header_c |
|
201 : public eap_header_base_c |
|
202 { |
|
203 private: |
|
204 //-------------------------------------------------- |
|
205 |
|
206 /// This is pointer to the tools class. |
|
207 abs_eap_am_tools_c * const m_am_tools; |
|
208 |
|
209 enum delta_offsets |
|
210 { |
|
211 m_subtype_delta_offset = 0ul, // This is offset from the end of the type field. NOTE type field could be extented 8 bytes in length. |
|
212 m_reserved_delta_offset = m_subtype_delta_offset+sizeof(u8_t), |
|
213 m_data_delta_offset = m_reserved_delta_offset+sizeof(u16_t), |
|
214 }; |
|
215 |
|
216 //-------------------------------------------------- |
|
217 public: |
|
218 //-------------------------------------------------- |
|
219 |
|
220 // |
|
221 EAP_FUNC_IMPORT virtual ~aka_header_c(); |
|
222 |
|
223 // |
|
224 EAP_FUNC_IMPORT aka_header_c( |
|
225 abs_eap_am_tools_c * const tools, |
|
226 u8_t * const header_buffer, |
|
227 const u32_t header_buffer_length); |
|
228 |
|
229 EAP_FUNC_IMPORT aka_subtype_e get_subtype() const; |
|
230 |
|
231 EAP_FUNC_IMPORT u16_t get_data_length() const; |
|
232 |
|
233 /// This returns the length of EAP-header, EAP-type, subtype and reserved fields. |
|
234 EAP_FUNC_IMPORT u32_t get_header_length() const; |
|
235 |
|
236 EAP_FUNC_IMPORT u32_t get_sub_type_offset() const; |
|
237 |
|
238 EAP_FUNC_IMPORT u8_t * get_data_offset(const u32_t offset, const u32_t contignuous_bytes) const; |
|
239 |
|
240 |
|
241 EAP_FUNC_IMPORT u8_t * get_data(const u32_t contignuous_bytes) const; |
|
242 |
|
243 |
|
244 EAP_FUNC_IMPORT u16_t get_reserved() const; |
|
245 |
|
246 |
|
247 EAP_FUNC_IMPORT eap_status_e check_header() const; |
|
248 |
|
249 EAP_FUNC_IMPORT eap_const_string get_subtype_string() const; |
|
250 |
|
251 EAP_FUNC_IMPORT eap_const_string get_code_string() const; |
|
252 |
|
253 EAP_FUNC_IMPORT eap_const_string get_eap_type_string() const; |
|
254 |
|
255 EAP_FUNC_IMPORT void set_reserved(const u16_t reserved); |
|
256 |
|
257 EAP_FUNC_IMPORT void set_subtype(const aka_subtype_e p_subtype); |
|
258 |
|
259 EAP_FUNC_IMPORT void set_data_length( |
|
260 const u32_t p_data_length, |
|
261 const bool expanded_type_when_true); |
|
262 |
|
263 EAP_FUNC_IMPORT void reset_header( |
|
264 const u32_t buffer_length, |
|
265 const bool expanded_type_when_true); |
|
266 |
|
267 // |
|
268 //-------------------------------------------------- |
|
269 }; // class aka_header_c |
|
270 |
|
271 //-------------------------------------------------- |
|
272 |
|
273 #endif //#if !defined(_AKA_HEADER_H_) |
|
274 |
|
275 |
|
276 |
|
277 // End. |