eapol/eapol_framework/eapol_common/type/simple_config/simple_config/include/simple_config_record.h
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     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(_SIMPLE_CONFIG_RECORD_H_)
       
    22 #define _SIMPLE_CONFIG_RECORD_H_
       
    23 
       
    24 
       
    25 #include "abs_simple_config_am_services.h"
       
    26 #include "simple_config_base_record.h"
       
    27 #include "eap_array_algorithms.h"
       
    28 #include "simple_config_types.h"
       
    29 #include "simple_config_completion.h"
       
    30 #include "simple_config_types.h"
       
    31 #include "simple_config_attribute_type.h"
       
    32 #include "simple_config_payloads.h"
       
    33 #include "simple_config_message.h"
       
    34 #include "eap_am_network_id.h"
       
    35 #include "eap_automatic_variable.h"
       
    36 #include "eap_master_session_key.h"
       
    37 #include "abs_eap_base_timer.h"
       
    38 
       
    39 
       
    40 class abs_simple_config_base_record_c;
       
    41 class abs_eap_am_tools_c;
       
    42 class eap_am_network_id_c;
       
    43 class simple_config_record_header_c;
       
    44 class simple_config_am_services_c;
       
    45 class abs_crypto_cbc_block_algorithm_c;
       
    46 class abs_crypto_block_algorithm_c;
       
    47 class abs_crypto_stream_algorithm_c;
       
    48 
       
    49 //--------------------------------------------------------------------
       
    50 
       
    51 /**
       
    52  * This is the timer ID used with abs_eap_am_tools_c::set_timer() and abs_eap_am_tools_c::cancel_timer().
       
    53  */
       
    54 enum simple_config_record_timer_id_e
       
    55 {
       
    56 	SIMPLE_CONFIG_RECORD_ERROR_MESSAGE_RECEIVED_ID, ///< This is timer ID after a Failure message is handled.
       
    57 	SIMPLE_CONFIG_RECORD_M2D_RECEIVED_ID, ///< This is timer ID after a M2D messages are used.
       
    58 };
       
    59 
       
    60 
       
    61 enum simple_config_record_timer_timeouts_e
       
    62 {
       
    63 	/**
       
    64 	 * This is time after a Failure message is handled.
       
    65 	 */
       
    66 	SIMPLE_CONFIG_RECORD_ERROR_MESSAGE_RECEIVED_TIMEOUT = 15000ul,
       
    67 };
       
    68 
       
    69 
       
    70 //--------------------------------------------------------------------
       
    71 
       
    72 
       
    73 /**
       
    74  * The simple_config_record_c class implements simple_config_base_record_c.
       
    75  * See more detailed design and architecture document <a href="../../type/simple_config/documentation/EAP_SIMPLE_CONFIG.doc">EAP_SIMPLE_CONFIG.doc</a>
       
    76  * and <a href="../../type/simple_config/documentation/rfc2246.txt">RFC 2246</a>.
       
    77  */
       
    78 class EAP_EXPORT simple_config_record_c
       
    79 : public simple_config_base_record_c
       
    80 , public abs_simple_config_am_services_c
       
    81 , public abs_eap_base_timer_c
       
    82 {
       
    83 private:
       
    84 	//--------------------------------------------------
       
    85 
       
    86 	/// This is pointer to the tools class. @see abs_eap_am_tools_c.
       
    87 	abs_eap_am_tools_c * const m_am_tools;
       
    88 
       
    89 	/// This is pointer to adaptation module of SIMPLE_CONFIG.
       
    90 	simple_config_am_services_c * m_am_simple_config_services;
       
    91 
       
    92 	/// This flag tells whether the m_am_simple_config_services must be freed in destructor.
       
    93 	const bool m_free_am_simple_config_services;
       
    94 
       
    95 
       
    96 	/// This object includes pending asyncronous actions or it may be empty.
       
    97 	/// The check_sent_simple_config_message() function call will check and complete pending actions.
       
    98 	eap_array_c<simple_config_completion_c> m_completion_queue;
       
    99 
       
   100 
       
   101 	/// This object stores all received M2D payloads. If nothing else is received
       
   102 	/// adaptation layer could show this information to user.
       
   103 	eap_array_c<simple_config_payloads_c> m_M2D_payloads;
       
   104 
       
   105 
       
   106 	/// This object includes received message.
       
   107 	simple_config_message_c m_received_simple_config_message;
       
   108 
       
   109 	/// This object includes all received payloads.
       
   110 	simple_config_payloads_c m_received_payloads;
       
   111 
       
   112 
       
   113 	/// This object includes the previous sent message.
       
   114 	/// The send message will be generated from this.
       
   115 	simple_config_message_c m_previous_simple_config_message;
       
   116 
       
   117 	/// This object includes the new created message.
       
   118 	/// The send message will be generated from this.
       
   119 	simple_config_message_c m_new_simple_config_message;
       
   120 	
       
   121 	/// This object cotains the type of the new message.
       
   122     /// The type will be indicated to the lower layer for adding correct Op-Code.
       
   123 	simple_config_Message_Type_e m_current_simple_config_message_type;
       
   124 
       
   125 	/// This object includes Enrollee Nonce.
       
   126 	eap_variable_data_c m_enrollee_nonce;
       
   127 
       
   128 	/// This object includes Enrollee MAC.
       
   129 	eap_variable_data_c m_enrollee_mac;
       
   130 
       
   131 	/// This object includes Registrar Nonce.
       
   132 	eap_variable_data_c m_registrar_nonce;
       
   133 
       
   134 
       
   135 	/// This object is the Simple Config device password.
       
   136 	eap_variable_data_c m_device_password;
       
   137 
       
   138 	/// This object is the Simple Config PSK1.
       
   139 	eap_variable_data_c m_PSK1;
       
   140 
       
   141 	/// This object is the Simple Config PSK2.
       
   142 	eap_variable_data_c m_PSK2;
       
   143 
       
   144 
       
   145 	/// This object is the Simple Config E-SNonce1 (E-S1).
       
   146 	eap_variable_data_c m_E_SNonce1;
       
   147 
       
   148 	/// This object is the Simple Config E-SNonce2 (E-S2).
       
   149 	eap_variable_data_c m_E_SNonce2;
       
   150 
       
   151 	/// This object is the Simple Config E-Hash1.
       
   152 	eap_variable_data_c m_EHash1;
       
   153 
       
   154 	/// This object is the Simple Config E-Hash1.
       
   155 	eap_variable_data_c m_EHash2;
       
   156 
       
   157 
       
   158 	/// This object is the Simple Config R-SNonce1 (R-S1).
       
   159 	eap_variable_data_c m_R_SNonce1;
       
   160 
       
   161 	/// This object is the Simple Config R-SNonce2 (R-S2).
       
   162 	eap_variable_data_c m_R_SNonce2;
       
   163 
       
   164 	/// This object is the Simple Config R-Hash1.
       
   165 	eap_variable_data_c m_RHash1;
       
   166 
       
   167 	/// This object is the Simple Config R-Hash1.
       
   168 	eap_variable_data_c m_RHash2;
       
   169 
       
   170 
       
   171 	/// This object includes Diffie-Hellman private key of this SIMPLE_CONFIG end point.
       
   172 	eap_variable_data_c m_own_private_dhe_key;
       
   173 
       
   174 	/// This object includes Diffie-Hellman public key of this SIMPLE_CONFIG end point.
       
   175 	eap_variable_data_c m_own_public_dhe_key;
       
   176 
       
   177 	/// This object includes Diffie-Hellman public key of other SIMPLE_CONFIG end point.
       
   178 	eap_variable_data_c m_peer_public_dhe_key;
       
   179 
       
   180 	/// This object includes Diffie-Hellman shared key of the SIMPLE_CONFIG session.
       
   181 	eap_variable_data_c m_shared_dh_key;
       
   182 
       
   183 	/// This object includes Diffie-Hellman prime of the SIMPLE_CONFIG session.
       
   184 	eap_variable_data_c m_dhe_prime;
       
   185 
       
   186 	/// This object includes Diffie-Hellman group generator of the SIMPLE_CONFIG session.
       
   187 	eap_variable_data_c m_dhe_group_generator;
       
   188 
       
   189 	/// This object includes Simple Config KDK.
       
   190 	eap_variable_data_c m_kdk;
       
   191 
       
   192 	/// These are the additional keys of Simple Config.
       
   193 	eap_variable_data_c m_auth_key;
       
   194 	eap_variable_data_c m_key_wrap_key;
       
   195 	eap_variable_data_c m_EMSK;
       
   196 
       
   197 	eap_variable_data_c m_SSID;
       
   198 
       
   199 	/// This object includes signed HASH. This is needed to store asyncronously completed signature creation.
       
   200 	eap_variable_data_c m_signed_message_hash;
       
   201 
       
   202 	/// This is the full NAI of the client.
       
   203 	eap_variable_data_c m_NAI;
       
   204 
       
   205 	/// This is the realm part of the NAI of the client.
       
   206 	eap_variable_data_c m_NAI_realm;
       
   207 
       
   208 	/// This is network identity of the sent packet from this authentication session.
       
   209 	eap_am_network_id_c m_send_network_id;
       
   210 
       
   211 #if defined(USE_EAP_TYPE_SERVER_SIMPLE_CONFIG)
       
   212 	eap_variable_data_c m_network_key;
       
   213 	simple_config_Authentication_Type_e m_authentication_type;
       
   214 #endif //#if defined(USE_EAP_TYPE_SERVER_SIMPLE_CONFIG)
       
   215 
       
   216 	/// This variable stored the internal state of SIMPLE_CONFIG-session. See simple_config_state_e.
       
   217 	simple_config_state_e m_simple_config_state;
       
   218 
       
   219 	/// This variable stores the first error on handshake.
       
   220 	eap_status_e m_handshake_error;
       
   221 
       
   222 	/// This object stores the universally unique identifier of Enrollee.
       
   223 	eap_variable_data_c m_UUID_E;
       
   224 
       
   225 	/// This object stores the universally unique identifier of Registrar.
       
   226 	eap_variable_data_c m_UUID_R;
       
   227 
       
   228 	/// These are the RF-Bands this entity supports.
       
   229 	simple_config_RF_Bands_e m_Rf_Bands;
       
   230 
       
   231 	/// This object includes the MAC address of the new configuration.
       
   232 	eap_variable_data_c m_MAC_address;
       
   233 
       
   234 	/// This variable stores the Device Password ID that this entity uses.
       
   235 	simple_config_Device_Password_ID_e m_local_Device_Password_ID;
       
   236 
       
   237 	/// This variable stores the Device Password ID that other entity uses.
       
   238 	simple_config_Device_Password_ID_e m_received_Device_Password_ID;
       
   239 
       
   240 	/// This object stores the new password the Enrollee should use. This is optional.
       
   241 	eap_variable_data_c m_new_password;
       
   242 
       
   243 	/// This object stores the new Device Password ID the Enrollee should use. This is optional.
       
   244 	simple_config_Device_Password_ID_e m_new_Device_Password_ID;
       
   245 
       
   246 	/// This is the timeout in milli seconds after the error message is processed.
       
   247 	/// This allows correct message to be processed before session is terminated.
       
   248 	u32_t m_error_message_received_timeout;
       
   249 
       
   250 	/// This indicates whether this object was generated successfully.
       
   251 	bool m_is_valid;
       
   252 
       
   253 	/// This indicates whether this object is client (true) or server (false).
       
   254 	const bool m_is_client;
       
   255 
       
   256 	/// This flag tells whether messages could be send in the check_sent_simple_config_message() function.
       
   257 	bool m_allow_message_send;
       
   258 
       
   259 	/// This flag prevents recursive calls of the completion_action_check() function.
       
   260 	bool m_already_in_completion_action_check;
       
   261 
       
   262 	/// This flag tells whether this function call is pending (true value).
       
   263 	/// After this function call is completed with appropriate completion function flag is set to false value.
       
   264 	bool m_pending_query_network_and_device_parameters;
       
   265 
       
   266 	/// This flag tells whether this instance is test version (true) or real version (false).
       
   267 	/// Test version allows many subsequent SIMPLE_CONFIG-sessions.
       
   268 	bool m_simple_config_test_version;
       
   269 
       
   270 	/// The flag prevents multiple call of generate_key_material() function.
       
   271 	bool m_key_material_generated;
       
   272 
       
   273 	/// This flag tells whether the check_sent_simple_config_message() must send SIMPLE_CONFIG-alert message (true) or not (false).
       
   274 	/// This flag is set after the SIMPLE_CONFIG-alert message is generated. This flag forses send of the SIMPLE_CONFIG-alert message.
       
   275 	bool m_force_simple_config_message_send;
       
   276 
       
   277 	/// This flag tells whether the shutdown() function was called (true) or not (false).
       
   278 	bool m_shutdown_was_called;
       
   279 
       
   280 	/// This flag tells whether the SIMPLE_CONFIG_RECORD_M2D_RECEIVED_ID timeout is active (true) or not (false).
       
   281 	bool m_M2D_received_timeout_active;
       
   282 
       
   283 	//--------------------------------------------------
       
   284 
       
   285 	/**
       
   286 	 * The set_is_valid() function sets the state of the object valid.
       
   287 	 * The creator of this object calls this function after it is initialized. 
       
   288 	 */
       
   289 	EAP_FUNC_IMPORT void set_is_valid();
       
   290 
       
   291 
       
   292 	EAP_FUNC_IMPORT eap_status_e add_common_attributes(
       
   293 		simple_config_payloads_c * const payloads,
       
   294 		const simple_config_Message_Type_e message_type,
       
   295 		const bool add_enrollee_nonce,
       
   296 		const bool add_registrar_nonce);
       
   297 
       
   298 
       
   299 	EAP_FUNC_IMPORT eap_status_e send_M1(
       
   300 		const simple_config_payloads_c * const network_and_device_parameters);
       
   301 
       
   302 	EAP_FUNC_IMPORT eap_status_e send_M3();
       
   303 
       
   304 	EAP_FUNC_IMPORT eap_status_e send_M5();
       
   305 
       
   306 	EAP_FUNC_IMPORT eap_status_e send_M7();
       
   307 
       
   308 	EAP_FUNC_IMPORT eap_status_e send_WSC_ACK();
       
   309 
       
   310 	EAP_FUNC_IMPORT eap_status_e send_WSC_NACK();
       
   311 
       
   312 	EAP_FUNC_IMPORT eap_status_e send_WSC_Done();
       
   313 
       
   314 
       
   315 #if defined(USE_EAP_TYPE_SERVER_SIMPLE_CONFIG)
       
   316 
       
   317 	EAP_FUNC_IMPORT eap_status_e send_M2(
       
   318 		const simple_config_payloads_c * const network_and_device_parameters);
       
   319 
       
   320 	EAP_FUNC_IMPORT eap_status_e send_M2D(
       
   321 		const simple_config_payloads_c * const network_and_device_parameters);
       
   322 
       
   323 	EAP_FUNC_IMPORT eap_status_e send_M4();
       
   324 
       
   325 	EAP_FUNC_IMPORT eap_status_e send_M6();
       
   326 
       
   327 	EAP_FUNC_IMPORT eap_status_e send_M8();
       
   328 
       
   329 #endif //#if defined(USE_EAP_TYPE_SERVER_SIMPLE_CONFIG)
       
   330 
       
   331 
       
   332 	EAP_FUNC_IMPORT eap_status_e process_M2(
       
   333 		const simple_config_payloads_c * const payloads);
       
   334 
       
   335 	EAP_FUNC_IMPORT eap_status_e process_M2D(
       
   336 		const simple_config_payloads_c * const payloads);
       
   337 
       
   338 	EAP_FUNC_IMPORT eap_status_e process_M4(
       
   339 		const simple_config_payloads_c * const payloads);
       
   340 
       
   341 	EAP_FUNC_IMPORT eap_status_e process_M6(
       
   342 		const simple_config_payloads_c * const payloads);
       
   343 
       
   344 	EAP_FUNC_IMPORT eap_status_e process_M8(
       
   345 		const simple_config_payloads_c * const payloads);
       
   346 
       
   347 	EAP_FUNC_IMPORT eap_status_e process_WSC_ACK(
       
   348 		const simple_config_payloads_c * const payloads);
       
   349 
       
   350 	EAP_FUNC_IMPORT eap_status_e process_WSC_NACK(
       
   351 		const simple_config_payloads_c * const payloads);
       
   352 
       
   353 #if defined(USE_EAP_TYPE_SERVER_SIMPLE_CONFIG)
       
   354 
       
   355 	EAP_FUNC_IMPORT eap_status_e process_M1(
       
   356 		const simple_config_payloads_c * const payloads);
       
   357 
       
   358 	EAP_FUNC_IMPORT eap_status_e process_M3(
       
   359 		const simple_config_payloads_c * const payloads);
       
   360 
       
   361 	EAP_FUNC_IMPORT eap_status_e process_M5(
       
   362 		const simple_config_payloads_c * const payloads);
       
   363 
       
   364 	EAP_FUNC_IMPORT eap_status_e process_M7(
       
   365 		const simple_config_payloads_c * const payloads);
       
   366 
       
   367 	EAP_FUNC_IMPORT eap_status_e process_WSC_DONE(
       
   368 		const simple_config_payloads_c * const payloads);
       
   369 
       
   370 #endif //#if defined(USE_EAP_TYPE_SERVER_SIMPLE_CONFIG)
       
   371 
       
   372 	EAP_FUNC_IMPORT void send_error_notification(const eap_status_e error);
       
   373 
       
   374 
       
   375 	/**
       
   376 	 * This function processes received SIMPLE_CONFIG attributes.
       
   377 	 */
       
   378 	EAP_FUNC_IMPORT eap_status_e process_simple_config_attributes(
       
   379 		const simple_config_payloads_c * const payloads);
       
   380 
       
   381 	/**
       
   382 	 * This function processes received SIMPLE_CONFIG message.
       
   383 	 */
       
   384 	EAP_FUNC_IMPORT eap_status_e process_simple_config_message();
       
   385 
       
   386 
       
   387 	/**
       
   388 	 * This function initialises timeout for received erroneous message.
       
   389 	 * If no correct message is received before this timeout the authentication
       
   390 	 * is terminated.
       
   391 	 */
       
   392 	EAP_FUNC_IMPORT eap_status_e initalize_error_message_timeout();
       
   393 
       
   394 	/**
       
   395 	 * This function cancels timeout for received erroneous message.
       
   396 	 */
       
   397 	EAP_FUNC_IMPORT eap_status_e cancel_error_message_timeout();
       
   398 
       
   399 
       
   400 	EAP_FUNC_IMPORT eap_status_e initialize_M2D_received_timeout();
       
   401 
       
   402 	EAP_FUNC_IMPORT eap_status_e cancel_M2D_received_timeout();
       
   403 
       
   404 
       
   405 	EAP_FUNC_IMPORT eap_status_e timer_expired(
       
   406 		const u32_t id,
       
   407 		void * data);
       
   408 
       
   409 	EAP_FUNC_IMPORT eap_status_e timer_delete_data(
       
   410 		const u32_t id,
       
   411 		void * data);
       
   412 
       
   413 	/**
       
   414 	 * This function verifies the Authenticator of received SIMPLE_CONFIG message.
       
   415 	 */
       
   416 	EAP_FUNC_IMPORT eap_status_e verify_nonces_and_authenticator(
       
   417 		const eap_variable_data_c * const auth_key,
       
   418 		const eap_variable_data_c * const registrar_nonce,
       
   419 		const eap_variable_data_c * const enrollee_nonce,
       
   420 		const simple_config_payloads_c * const payloads,
       
   421 		const bool check_enrollee_nonce,
       
   422 		const bool check_registrar_nonce,
       
   423 		const bool check_authenticator);
       
   424 
       
   425 	/**
       
   426 	 * This function checks whether all pending queries are completed.
       
   427 	 */
       
   428 	EAP_FUNC_IMPORT eap_status_e are_pending_queries_completed();
       
   429 
       
   430 	/**
       
   431 	 * This function indicates state to lower layer.
       
   432 	 */
       
   433 	EAP_FUNC_IMPORT eap_status_e indicate_state_to_lower_layer(
       
   434 		const simple_config_state_e indicated_state);
       
   435 
       
   436 	/**
       
   437 	 * This function indicates all message processed to lower layer.
       
   438 	 */
       
   439 	EAP_FUNC_IMPORT eap_status_e indicate_messages_processed();
       
   440 
       
   441 	/**
       
   442 	 * This function combines SIMPLE_CONFIG-protocols data to a buffer and sends SIMPLE_CONFIG-message.
       
   443 	 */
       
   444 	EAP_FUNC_IMPORT eap_status_e send_simple_config_message();
       
   445 
       
   446 	/**
       
   447 	 * This function checks all queries are completed.
       
   448 	 * If all queries are completed this function send the pending LS-messages.
       
   449 	 */
       
   450 	EAP_FUNC_IMPORT eap_status_e check_sent_simple_config_message();
       
   451 
       
   452 	/**
       
   453 	 * This function generates ephemeral Diffie-Hellman keys.
       
   454 	 * Keys are stored to m_own_private_dhe_key and m_own_public_dhe_key.
       
   455 	 */
       
   456 	EAP_FUNC_IMPORT eap_status_e generate_dhe_keys();
       
   457 
       
   458 	/**
       
   459 	 * This function generates ephemeral Diffie-Hellman shared secret.
       
   460 	 * Shared secret is stored to dhe_shared_secret.
       
   461 	 */
       
   462 	EAP_FUNC_IMPORT eap_status_e generate_dhe_shared_secret(
       
   463 		const eap_variable_data_c * const registrar_public_key_data,
       
   464 		eap_variable_data_c * const dhe_shared_secret);
       
   465 
       
   466 	EAP_FUNC_IMPORT eap_status_e generate_nonce(
       
   467 		eap_variable_data_c * const nonce,
       
   468 		const u32_t nonce_length);
       
   469 
       
   470 	EAP_FUNC_IMPORT eap_status_e generate_erhash(
       
   471 		const bool verify,
       
   472 		const eap_variable_data_c * const half_of_device_password,
       
   473 		const eap_variable_data_c * const PKE,
       
   474 		const eap_variable_data_c * const PKR,
       
   475 		eap_variable_data_c * const PSKn,
       
   476 		eap_variable_data_c * const ERSn,
       
   477 		eap_variable_data_c * const ERHash);
       
   478 
       
   479 	EAP_FUNC_IMPORT eap_status_e generate_er_hashs(
       
   480 		const bool verify,
       
   481 		const eap_variable_data_c * const device_password,
       
   482 		const eap_variable_data_c * const PKE,
       
   483 		const eap_variable_data_c * const PKR,
       
   484 		eap_variable_data_c * const PSK1,
       
   485 		eap_variable_data_c * const ER_S1,
       
   486 		eap_variable_data_c * const ER_Hash1,
       
   487 		eap_variable_data_c * const PSK2,
       
   488 		eap_variable_data_c * const ER_S2,
       
   489 		eap_variable_data_c * const ER_Hash2);
       
   490 
       
   491 
       
   492 	EAP_FUNC_IMPORT eap_status_e keyed_hmac(
       
   493 		const eap_variable_data_c * const key,
       
   494 		const eap_variable_data_c * const input,
       
   495 		eap_variable_data_c * const output);
       
   496 
       
   497 	/**
       
   498 	 * This function generates KDK of Simple Config.
       
   499 	 */
       
   500 	EAP_FUNC_IMPORT eap_status_e generate_kdk(
       
   501 		const eap_variable_data_c * const dhe_shared_secret,
       
   502 		const eap_variable_data_c * const nonce_1,
       
   503 		const eap_variable_data_c * const enrollee_mac,
       
   504 		const eap_variable_data_c * const nonce_2,
       
   505 		eap_variable_data_c * const kdk);
       
   506 
       
   507 	/**
       
   508 	 * This is key derivation function of Simple Config.
       
   509 	 */
       
   510 	EAP_FUNC_IMPORT eap_status_e key_derivation_function(
       
   511 		const eap_variable_data_c * const key,
       
   512 		const eap_variable_data_c * const personalization_string,
       
   513 		const u32_t total_key_bits,
       
   514 		eap_variable_data_c * const result);
       
   515 
       
   516 	/**
       
   517 	 * This function derives additional keys of Simple Config.
       
   518 	 */
       
   519 	EAP_FUNC_IMPORT eap_status_e derive_additional_keys(
       
   520 		const eap_variable_data_c * const kdk,
       
   521 		eap_variable_data_c * const auth_key,
       
   522 		eap_variable_data_c * const key_wrap_key,
       
   523 		eap_variable_data_c * const EMSK);
       
   524 
       
   525 	EAP_FUNC_IMPORT eap_status_e generate_authenticator(
       
   526 		const eap_variable_data_c * const received_simple_config_message,
       
   527 		const eap_variable_data_c * const new_simple_config_message_data,
       
   528 		eap_variable_data_c * const authenticator);
       
   529 
       
   530 	EAP_FUNC_IMPORT eap_status_e add_authenticator_attribute(
       
   531 		simple_config_message_c * const received_simple_config_message,
       
   532 		simple_config_message_c * const new_simple_config_message);
       
   533 
       
   534 	EAP_FUNC_IMPORT eap_status_e encrypt_payloads(
       
   535 		const eap_variable_data_c * const auth_key,
       
   536 		const eap_variable_data_c * const key_wrap_key,
       
   537 		simple_config_payloads_c * const plaintext_payloads,
       
   538 		simple_config_variable_data_c * const encrypted_settings);
       
   539 
       
   540 	EAP_FUNC_IMPORT eap_status_e decrypt_payloads(
       
   541 		const eap_variable_data_c * const auth_key,
       
   542 		const eap_variable_data_c * const key_wrap_key,
       
   543 		simple_config_variable_data_c * const encrypted_settings,
       
   544 		simple_config_payloads_c * const plaintext_payloads);
       
   545 
       
   546 	/**
       
   547 	 * This function adds new completion action to the end of the m_completion_queue.
       
   548 	 */
       
   549 	EAP_FUNC_IMPORT eap_status_e completion_action_add(
       
   550 		simple_config_completion_action_e action);
       
   551 
       
   552 	/**
       
   553 	 * This function verifies all completion actions are completed.
       
   554 	 */
       
   555 	EAP_FUNC_IMPORT eap_status_e completion_action_clenup();
       
   556 
       
   557 	/**
       
   558 	 * This function checks and completes completion actions.
       
   559 	 * This function could return eap_status_pending_request if the
       
   560 	 * first completion action cannot be completed yet.
       
   561 	 */
       
   562 	EAP_FUNC_IMPORT eap_status_e completion_action_check();
       
   563 
       
   564 	/**
       
   565 	 * This function sets the state of SIMPLE_CONFIG.
       
   566 	 */
       
   567 	EAP_FUNC_IMPORT simple_config_state_e get_state() const;
       
   568 
       
   569 	/**
       
   570 	 * This function gets the state of SIMPLE_CONFIG.
       
   571 	 */
       
   572 	EAP_FUNC_IMPORT void set_state(const simple_config_state_e state);
       
   573 
       
   574 	/**
       
   575 	 * This function verified the current state of SIMPLE_CONFIG and parameter state are equal.
       
   576 	 */
       
   577 	EAP_FUNC_IMPORT bool verify_state(const simple_config_state_e state);
       
   578 
       
   579 	eap_status_e fix_incorrect_network_key(
       
   580 		eap_variable_data_c * const network_key, 
       
   581 		const simple_config_Authentication_Type_e authentication_type);
       
   582 
       
   583 	//--------------------------------------------------
       
   584 protected:
       
   585 	//--------------------------------------------------
       
   586 
       
   587 	//--------------------------------------------------
       
   588 public:
       
   589 	//--------------------------------------------------
       
   590 
       
   591 	/**
       
   592 	 * The destructor of the simple_config_record_c class does nothing special.
       
   593 	 */
       
   594 	EAP_FUNC_IMPORT virtual ~simple_config_record_c();
       
   595 
       
   596 	/**
       
   597 	 * The constructor of the simple_config_record_c class simply initializes the attributes.
       
   598 	 * The simple_config_record_c object sends packets to the network using simple_config_base_record_c::get_type_partner() object.
       
   599 	 */
       
   600 	EAP_FUNC_IMPORT simple_config_record_c(
       
   601 		abs_eap_am_tools_c * const tools, ///< tools is pointer to the tools class. @see abs_eap_am_tools_c.
       
   602 		simple_config_am_services_c * const am_simple_config_services, ///< This is pointer to adaoptation module of SIMPLE_CONFIG.
       
   603 		const bool free_am_simple_config_services,
       
   604 		const bool is_client_when_true, ///< Indicates whether this is client (true) or server (false).
       
   605 		const eap_am_network_id_c * const receive_network_id);
       
   606 
       
   607 	/**
       
   608 	 * The configure() function is called after the constructor of the 
       
   609 	 * object is successfully executed. During the function call the object 
       
   610 	 * could query the configuration. Each derived class must define this function.
       
   611 	 */
       
   612 	EAP_FUNC_IMPORT eap_status_e configure();
       
   613 
       
   614 	/**
       
   615 	 * The shutdown() function is called before the destructor of the 
       
   616 	 * object is executed. During the function call the object 
       
   617 	 * could shutdown the operations, for example cancel timers.
       
   618 	 * Each derived class must define this function.
       
   619 	 */
       
   620 	EAP_FUNC_IMPORT eap_status_e shutdown();
       
   621 
       
   622 	/**
       
   623 	 * This function sets the NAI realm.
       
   624 	 */
       
   625 	EAP_FUNC_IMPORT eap_status_e set_nai_realm(
       
   626 		const eap_variable_data_c * const NAI_realm ///< This is the full NAI realm.
       
   627 		);
       
   628 
       
   629 	// This is commented in abs_simple_config_base_application_c.
       
   630 	EAP_FUNC_IMPORT eap_status_e read_configure(
       
   631 		const eap_configuration_field_c * const field,
       
   632 		eap_variable_data_c * const data);
       
   633 
       
   634 	// This is commented in abs_simple_config_base_application_c.
       
   635 	EAP_FUNC_IMPORT eap_status_e write_configure(
       
   636 		const eap_configuration_field_c * const field,
       
   637 		eap_variable_data_c * const data);
       
   638 
       
   639 	/**
       
   640 	 * This function sends starts EAP-SIMPLE_CONFIG/PEAP after a start message is received.
       
   641 	 */
       
   642 	EAP_FUNC_IMPORT eap_status_e start_simple_config_authentication(
       
   643 		const eap_variable_data_c * const NAI ///< This is the full NAI of the client.
       
   644 		);
       
   645 
       
   646 	/**
       
   647 	 * This function processes the received packet.
       
   648 	 * @param simple_config_packet includes the buffer of the whole reassembled SIMPLE_CONFIG-packet.
       
   649 	 */
       
   650 	EAP_FUNC_IMPORT eap_status_e packet_process(
       
   651 		eap_variable_data_c * const simple_config_packet,
       
   652 		const u8_t received_eap_identifier);
       
   653 
       
   654 	/**
       
   655 	 * Object must indicate it's validity.
       
   656 	 * If object initialization fails this function must return false.
       
   657 	 * @return This function returns the validity of this object.
       
   658 	 */
       
   659 	EAP_FUNC_IMPORT bool get_is_valid();
       
   660 
       
   661 	/**
       
   662 	 * This function must reset the state of object to same as 
       
   663 	 * state was after the configure() function call.
       
   664 	 * If object reset succeeds this function must return eap_status_ok.
       
   665 	 * If object reset fails this function must return corresponding error status.
       
   666 	 * @return This function returns the status of reset operation.
       
   667 	 */
       
   668 	EAP_FUNC_IMPORT eap_status_e reset();
       
   669 
       
   670 	// This is commented in abs_simple_config_am_services_c::complete_query_network_and_device_parameters().
       
   671 	EAP_FUNC_IMPORT eap_status_e complete_query_network_and_device_parameters(
       
   672 		const simple_config_state_e state,
       
   673 		simple_config_payloads_c * const network_and_device_parameters,
       
   674 		const eap_status_e completion_status);
       
   675 
       
   676 	//--------------------------------------------------
       
   677 }; // class simple_config_record_c
       
   678 
       
   679 #endif //#if !defined(_SIMPLE_CONFIG_RECORD_H_)
       
   680 
       
   681 //--------------------------------------------------
       
   682 
       
   683 
       
   684 
       
   685 // End.