|
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(_EAPOL_RC4_KEY_HEADER_H_) |
|
22 #define _EAPOL_RC4_KEY_HEADER_H_ |
|
23 |
|
24 #include "eapol_header.h" |
|
25 #include "eapol_key_header.h" |
|
26 #include "eap_general_header_base.h" |
|
27 |
|
28 |
|
29 //------------------------------------------------------ |
|
30 |
|
31 |
|
32 enum eapol_RC4_key_header_constants_e |
|
33 { |
|
34 EAPOL_RC4_KEY_IV_LENGTH = 16ul, |
|
35 EAPOL_RC4_KEY_REPLAY_COUNTER_LENGTH = 8ul, |
|
36 EAPOL_RC4_KEY_SIGNATURE_LENGTH = 16ul, |
|
37 SIZE_OF_EMPTY_EAPOL_RC4_KEY_FRAME = 48ul, |
|
38 SIZE_OF_EMPTY_EAPOL_RC4_KEY_BODY = 44ul, ///< <- This is without version, packet type and packet body length fields. |
|
39 }; |
|
40 |
|
41 |
|
42 /// This is base class of EAPOL RC4 key header. |
|
43 /** |
|
44 * This defined in <a href="../../documentation/RFCs/rfc3580.txt">rfc3580.txt</a>. |
|
45 * See chapter RC4 EAPOL-Key Frame. |
|
46 * @code |
|
47 * 0 1 2 3 |
|
48 * 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 |
|
49 * +-+-+-+-+-+-+-+-+ |
|
50 * | EAPOL Version | |
|
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
52 * | EAPOL Type | EAPOL Packet Body Length | Descriptor Ty.| |
|
53 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
54 * | RC4 Key Length | RC4 Reply Counter 8 octets | |
|
55 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+ |
|
56 * | | |
|
57 * +- -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
58 * | | RC4 Key IV 16 octets | |
|
59 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+ |
|
60 * | | |
|
61 * +- -+ |
|
62 * | | |
|
63 * +- -+ |
|
64 * | | |
|
65 * +- -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
66 * | | RC4 Key Index | | |
|
67 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+ |
|
68 * | RC4 Key Signature 16 octets | |
|
69 * +- -+ |
|
70 * | | |
|
71 * +- -+ |
|
72 * | | |
|
73 * +- +-+-+-+-+-+-+-+-+ |
|
74 * | | | |
|
75 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -+ |
|
76 * | RC4 Key n octets | |
|
77 * +- -+ |
|
78 * | n = (Packet Body Length) - SIZE_OF_EMPTY_EAPOL_KEY_HEADER | |
|
79 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
80 * @endcode |
|
81 */ |
|
82 class EAP_EXPORT eapol_RC4_key_header_c |
|
83 : public eap_general_header_base_c |
|
84 { |
|
85 private: |
|
86 //-------------------------------------------------- |
|
87 |
|
88 /// This is pointer to the tools class. |
|
89 abs_eap_am_tools_c * const m_am_tools; |
|
90 |
|
91 enum bit_masks_e |
|
92 { |
|
93 m_flag_mask_key_flag = 0x80, |
|
94 }; |
|
95 |
|
96 enum bit_shifts_e |
|
97 { |
|
98 m_flag_shift_key_flag = 0x07, |
|
99 }; |
|
100 |
|
101 //-------------------------------------------------- |
|
102 protected: |
|
103 //-------------------------------------------------- |
|
104 |
|
105 enum offsets_e |
|
106 { |
|
107 m_offset_eapol_version = 0ul, |
|
108 m_offset_eapol_type = m_offset_eapol_version + sizeof(u8_t), |
|
109 m_offset_eapol_packet_body_length = m_offset_eapol_type + sizeof(u8_t), |
|
110 m_offset_key_descriptor_type = m_offset_eapol_packet_body_length + sizeof(u16_t), |
|
111 m_offset_key_length = m_offset_key_descriptor_type + sizeof(u8_t), |
|
112 m_offset_replay_counter = m_offset_key_length + sizeof(u16_t), |
|
113 m_offset_key_IV = m_offset_replay_counter + EAPOL_RC4_KEY_REPLAY_COUNTER_LENGTH, |
|
114 m_offset_key_index = m_offset_key_IV + EAPOL_RC4_KEY_IV_LENGTH, |
|
115 m_offset_key_signature = m_offset_key_index + sizeof(u8_t), |
|
116 m_offset_data = m_offset_key_signature + EAPOL_RC4_KEY_SIGNATURE_LENGTH, |
|
117 }; |
|
118 |
|
119 //-------------------------------------------------- |
|
120 public: |
|
121 //-------------------------------------------------- |
|
122 |
|
123 enum eapol_RC4_key_header_constants_e |
|
124 { |
|
125 EAPOL_RC4_EAPOL_KEY_MAXIMUM_SIZE = 0xffff, |
|
126 }; |
|
127 |
|
128 |
|
129 // |
|
130 EAP_FUNC_IMPORT virtual ~eapol_RC4_key_header_c(); |
|
131 |
|
132 // |
|
133 EAP_FUNC_IMPORT eapol_RC4_key_header_c( |
|
134 abs_eap_am_tools_c * const tools, |
|
135 void * const header_begin, |
|
136 const u32_t header_buffer_length); |
|
137 |
|
138 EAP_FUNC_IMPORT eapol_protocol_version_e get_eapol_protocol_version() const; |
|
139 |
|
140 EAP_FUNC_IMPORT eapol_packet_type_e get_eapol_packet_type() const; |
|
141 |
|
142 EAP_FUNC_IMPORT u16_t get_eapol_packet_body_length() const; |
|
143 |
|
144 EAP_FUNC_IMPORT eapol_key_descriptor_type_e get_key_descriptor_type() const; |
|
145 |
|
146 EAP_FUNC_IMPORT u16_t get_key_length() const; |
|
147 |
|
148 EAP_FUNC_IMPORT u8_t *get_replay_counter(); |
|
149 |
|
150 EAP_FUNC_IMPORT u8_t *get_key_IV(); |
|
151 |
|
152 EAP_FUNC_IMPORT eapol_RC4_key_flags_e get_key_flag() const; |
|
153 |
|
154 EAP_FUNC_IMPORT u8_t get_key_index() const; |
|
155 |
|
156 EAP_FUNC_IMPORT u8_t *get_key_signature() const; |
|
157 |
|
158 EAP_FUNC_IMPORT static u16_t get_header_length(); |
|
159 |
|
160 EAP_FUNC_IMPORT u8_t * get_key() const; |
|
161 |
|
162 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
163 |
|
164 EAP_FUNC_IMPORT eap_status_e set_eapol_protocol_version(eapol_protocol_version_e version); |
|
165 |
|
166 EAP_FUNC_IMPORT eap_status_e set_eapol_packet_type(eapol_packet_type_e type); |
|
167 |
|
168 EAP_FUNC_IMPORT eap_status_e set_eapol_packet_body_length(u16_t eapol_length); |
|
169 |
|
170 EAP_FUNC_IMPORT eap_status_e set_key_descriptor_type(eapol_key_descriptor_type_e eapol_key_descriptor_type); |
|
171 |
|
172 EAP_FUNC_IMPORT eap_status_e set_key_length(u16_t length); |
|
173 |
|
174 EAP_FUNC_IMPORT eap_status_e set_key_flag(eapol_RC4_key_flags_e flags); |
|
175 |
|
176 EAP_FUNC_IMPORT eap_status_e set_key_index(u8_t index); |
|
177 |
|
178 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
179 |
|
180 EAP_FUNC_IMPORT void zero_key_signature( |
|
181 abs_eap_am_tools_c * const m_am_tools |
|
182 ); |
|
183 |
|
184 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
185 |
|
186 EAP_FUNC_IMPORT eap_status_e check_header() const; |
|
187 |
|
188 // |
|
189 //-------------------------------------------------- |
|
190 }; // class eapol_RC4_key_header_c |
|
191 |
|
192 |
|
193 #endif //#if !defined(_EAPOL_KEY_H_) |
|
194 |
|
195 //------------------------------------------------------ |
|
196 //------------------------------------------------------ |
|
197 //------------------------------------------------------ |
|
198 |
|
199 |
|
200 |
|
201 // End. |