eapol/eapol_framework/eapol_common/core/eapol_key_state_common.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
--- a/eapol/eapol_framework/eapol_common/core/eapol_key_state_common.cpp	Tue Aug 31 15:16:37 2010 +0300
+++ b/eapol/eapol_framework/eapol_common/core/eapol_key_state_common.cpp	Wed Sep 01 12:23:57 2010 +0100
@@ -16,7 +16,7 @@
 */
 
 /*
-* %version: 135 %
+* %version: 120.1.6.1.2 %
 */
 
 // This is enumeration of EAPOL source code.
@@ -277,6 +277,7 @@
 		}
 	}
 
+#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 	{
 		m_is_associated = true;
 
@@ -287,12 +288,15 @@
 			 (m_is_client == true) ? "client": "server",
 			 (m_is_associated == true) ? "true": "false"));
 	}
+#endif //#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 
 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
 }
 
 //--------------------------------------------------
 
+#if defined(USE_EAPOL_KEY_STATE) && defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
+
 // 
 EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::initialize(
 	const eap_am_network_id_c * const receive_network_id,
@@ -324,6 +328,7 @@
 
 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
+#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 	// Creates SNonce. This is done here in early phase of authentication.
 	// This will reduce the CPU load when time critical first message
 	// of 4-Way handshake is processed.
@@ -333,6 +338,7 @@
 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
 		return EAP_STATUS_RETURN(m_am_tools, status);
 	}
+#endif //#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 
 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
@@ -340,6 +346,8 @@
 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
 }
 
+#endif //#if defined(USE_EAPOL_KEY_STATE) && defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
+
 //--------------------------------------------------
 
 // 
@@ -513,7 +521,9 @@
 	, m_indicate_pmkid_to_lower_layer(false)
 	, m_handshake_timeout_set(false)
 	, m_server_TEST_group_key_update(false)
+#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 	, m_is_associated(false)
+#endif //#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 {
 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
 
@@ -606,7 +616,9 @@
 	, m_indicate_pmkid_to_lower_layer(false)
 	, m_handshake_timeout_set(false)
 	, m_server_TEST_group_key_update(false)
+#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 	, m_is_associated(false)
+#endif //#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 {
 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
 
@@ -941,8 +953,6 @@
 	const eapol_key_authentication_type_e authentication_type
 	)
 {
-	EAP_UNREFERENCED_PARAMETER(eapol_key_handshake_type);
-	EAP_UNREFERENCED_PARAMETER(authentication_type);
 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
 
 	EAP_TRACE_DEBUG(
@@ -1138,6 +1148,8 @@
 	}
 
 
+#if defined(USE_EAPOL_KEY_STATE) && defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
+
 	status = new_state->initialize(
 		receive_network_id,
 		m_authentication_type);
@@ -1149,6 +1161,9 @@
 		return 0;
 	}
 
+#endif //#if defined(USE_EAPOL_KEY_STATE) && defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
+
+
 	eapol_key_handshake_type_e eapol_key_handshake_type(m_eapol_key_handshake_type);
 
 	eapol_key_authentication_type_e authentication_type(m_authentication_type);
@@ -1406,17 +1421,11 @@
 	EAP_TRACE_DEBUG(
 		m_am_tools, 
 		TRACE_FLAGS_DEFAULT, 
-		(EAPL("EAPOL_KEY: %s: eapol_key_state_c::check_pmksa_cache(): this = 0x%08x, state %d=%s,\n"),
+		(EAPL("EAPOL_KEY: %s: eapol_key_state_c::check_pmksa_cache(): this = 0x%08x, state %d=%s, selected_eapol_key_authentication_type %d=%s, m_authentication_type %d=%s.\n"),
 		 (m_is_client == true) ? "client": "server",
 		 this,
 		 get_eapol_key_state(),
-		 eapol_key_state_string_c::get_eapol_key_state_string(get_eapol_key_state())));
-
-	EAP_TRACE_DEBUG(
-		m_am_tools, 
-		TRACE_FLAGS_DEFAULT, 
-		(EAPL("EAPOL_KEY: %s: eapol_key_state_c::check_pmksa_cache(): selected_eapol_key_authentication_type %d=%s, m_authentication_type %d=%s.\n"),
-		 (m_is_client == true) ? "client": "server",
+		 eapol_key_state_string_c::get_eapol_key_state_string(get_eapol_key_state()),
 		 selected_eapol_key_authentication_type,
 		 eapol_key_state_string_c::get_eapol_key_authentication_type_string(selected_eapol_key_authentication_type),
 		 m_authentication_type,
@@ -1560,6 +1569,7 @@
 
 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
+#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 	// Creates SNonce. This is done here in early phase of authentication.
 	// This will reduce the CPU load when time critical first message
 	// of 4-Way handshake is processed.
@@ -1569,6 +1579,7 @@
 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
 		return EAP_STATUS_RETURN(m_am_tools, status);
 	}
+#endif //#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 
 	status = init_handshake_timeout(m_handshake_timeout);
 	if (status != eap_status_ok)
@@ -1671,7 +1682,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::complete_reassociation(
+eap_status_e eapol_key_state_c::complete_reassociation(
 	const eapol_wlan_authentication_state_e reassociation_result,
 	const eap_am_network_id_c * const /* receive_network_id */,
 	const eapol_key_authentication_type_e authentication_type,
@@ -1734,6 +1745,7 @@
 			return EAP_STATUS_RETURN(m_am_tools, eap_status_authentication_failure);
 		}
 
+#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 		{
 			m_is_associated = true;
 
@@ -1744,6 +1756,8 @@
 				 (m_is_client == true) ? "client": "server",
 				 (m_is_associated == true) ? "true": "false"));
 		}
+#endif //#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
+
 	}
 	else
 	{
@@ -2679,7 +2693,7 @@
 //--------------------------------------------------
 
 // 
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::check_is_aes_key_wrap_padding(
+eap_status_e eapol_key_state_c::check_is_aes_key_wrap_padding(
 	const eapol_RSNA_key_descriptor_type_e /* current_key_data_type */,
 	eapol_rsna_key_data_header_c * const key_data_payload,
 	const u32_t key_data_max_length
@@ -2711,7 +2725,7 @@
 //--------------------------------------------------
 
 // 
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::parse_generic_key_data_payload(
+eap_status_e eapol_key_state_c::parse_generic_key_data_payload(
 	const eapol_key_descriptor_type_e eapol_key_descriptor_type,
 	const eapol_RSNA_key_descriptor_type_e current_key_descriptor_type,
 	eapol_rsna_key_data_header_c * const key_data_payload,
@@ -3473,7 +3487,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::parse_key_data(
+eap_status_e eapol_key_state_c::parse_key_data(
 	const eapol_key_descriptor_type_e eapol_key_descriptor_type,
 	const eapol_rsna_key_data_header_c * const p_payload,
 	u32_t * const buffer_length,
@@ -3645,7 +3659,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::rsna_prf(
+eap_status_e eapol_key_state_c::rsna_prf(
 	const eap_variable_data_c * const key_K,
 	const eap_variable_data_c * const label_A,
 	const eap_variable_data_c * const input_B,
@@ -3785,7 +3799,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::select_minimum(
+eap_status_e eapol_key_state_c::select_minimum(
 	const eap_variable_data_c * const input_a,
 	const eap_variable_data_c * const input_b,
 	const eap_variable_data_c ** const minimum,
@@ -3834,7 +3848,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::derive_PTK()
+eap_status_e eapol_key_state_c::derive_PTK()
 {
 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
 
@@ -4116,7 +4130,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::create_nonce(
+eap_status_e eapol_key_state_c::create_nonce(
 	eap_variable_data_c * const nonce,	const u32_t nonce_length)
 {
 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
@@ -4168,7 +4182,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::create_PMKID()
+eap_status_e eapol_key_state_c::create_PMKID()
 {
 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
 	eap_status_e status = eap_status_process_general_error;
@@ -4305,7 +4319,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::encrypt_key_data(
+eap_status_e eapol_key_state_c::encrypt_key_data(
 	eapol_RSNA_key_header_c * const eapol_key_message)
 {
 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
@@ -4538,7 +4552,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::decrypt_key_data(
+eap_status_e eapol_key_state_c::decrypt_key_data(
 	eapol_RSNA_key_header_c * const eapol_key_message)
 {
 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
@@ -4687,7 +4701,7 @@
 
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::create_key_mic(
+eap_status_e eapol_key_state_c::create_key_mic(
 	eapol_RSNA_key_header_c * const eapol_key_message,
 	const eap_variable_data_c * const confirmation_key)
 {
@@ -4859,7 +4873,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::verify_key_mic(
+eap_status_e eapol_key_state_c::verify_key_mic(
 	eapol_RSNA_key_header_c * const eapol_key_message,
 	const eap_variable_data_c * const confirmation_key)
 {
@@ -5289,6 +5303,8 @@
 
 //--------------------------------------------------
 
+#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
+
 EAP_FUNC_EXPORT bool eapol_key_state_c::get_is_associated()
 {
 	EAP_TRACE_DEBUG(
@@ -5301,6 +5317,8 @@
 	return m_is_associated;
 }
 
+#endif //#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
+
 //--------------------------------------------------
 
 EAP_FUNC_EXPORT void eapol_key_state_c::set_eapol_key_state(const eapol_key_state_e state)
@@ -5694,6 +5712,7 @@
 
 	eap_status_e status(eap_status_process_general_error);
 
+#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 	{
 		m_is_associated = false;
 
@@ -5704,6 +5723,7 @@
 			 (m_is_client == true) ? "client": "server",
 			 (m_is_associated == true) ? "true": "false"));
 	}
+#endif //#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
 
 	if ((m_authentication_type == eapol_key_authentication_type_RSNA_EAP
 #if defined(EAP_USE_WPXM)
@@ -6138,7 +6158,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::create_tkip_mic_failure_message(
+eap_status_e eapol_key_state_c::create_tkip_mic_failure_message(
 	eap_buf_chain_wr_c * const sent_packet,
 	const u32_t eapol_header_offset,
 	u32_t * const data_length,
@@ -6474,7 +6494,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::allow_4_way_handshake()
+eap_status_e eapol_key_state_c::allow_4_way_handshake()
 {
 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
 	eap_status_e status = eap_status_process_general_error;
@@ -6589,6 +6609,18 @@
 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
 	}
 	
+#if !defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
+	// Creates SNonce. This is done here in early phase of authentication.
+	// This will reduce the CPU load when time critical first message
+	// of 4-Way handshake is processed.
+	status = create_nonce(&m_SNonce, EAPOL_RSNA_NONCE_LENGTH_BYTES);
+	if (status != eap_status_ok)
+	{
+		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
+		return EAP_STATUS_RETURN(m_am_tools, status);
+	}
+#endif //#if !defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
+
 	status = init_handshake_timeout(m_handshake_timeout);
 	if (status != eap_status_ok)
 	{
@@ -6610,7 +6642,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::start_group_key_handshake(
+eap_status_e eapol_key_state_c::start_group_key_handshake(
 	const eap_am_network_id_c * const receive_network_id,
 	const eapol_protocol_version_e received_eapol_version,
 	const eapol_key_descriptor_type_e received_key_descriptor_type)
@@ -6741,7 +6773,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::get_key_length(
+eap_status_e eapol_key_state_c::get_key_length(
 	const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e cipher,
 	u16_t * const key_length)
 {
@@ -6779,7 +6811,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::process_4_way_handshake_message(
+eap_status_e eapol_key_state_c::process_4_way_handshake_message(
 	const eap_am_network_id_c * const receive_network_id,
 	eapol_RSNA_key_header_c * const eapol_key_message,
 	const u32_t packet_length)
@@ -6884,7 +6916,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::process_group_key_handshake_message(
+eap_status_e eapol_key_state_c::process_group_key_handshake_message(
 	const eap_am_network_id_c * const receive_network_id,
 	eapol_RSNA_key_header_c * const eapol_key_message,
 	const u32_t packet_length)
@@ -6953,7 +6985,7 @@
 //--------------------------------------------------
 
 //
-EAP_FUNC_EXPORT eap_status_e eapol_key_state_c::process_RSNA_key_descriptor(
+eap_status_e eapol_key_state_c::process_RSNA_key_descriptor(
 	const eap_am_network_id_c * const receive_network_id,
 	eap_general_header_base_c * const packet_data,
 	const u32_t packet_length)