eapol/eapol_framework/eapol_common/core/eapol_key_state_server.cpp
branchRCL_3
changeset 15 aa67149e0134
parent 2 1c7bc153c08e
child 45 bad0cc58d154
equal deleted inserted replaced
12:66f897dce0dc 15:aa67149e0134
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 46 %
    19 * %version: 46.1.2 %
    20 */
    20 */
    21 
    21 
    22 // This is enumeration of EAPOL source code.
    22 // This is enumeration of EAPOL source code.
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    24 	#undef EAP_FILE_NUMBER_ENUM
    24 	#undef EAP_FILE_NUMBER_ENUM
   354 		= eapol_RSNA_key_header_c::get_header_length()
   354 		= eapol_RSNA_key_header_c::get_header_length()
   355 		+ m_authenticator_RSNA_IE.get_data_length();
   355 		+ m_authenticator_RSNA_IE.get_data_length();
   356 
   356 
   357 	u32_t extra_encryption_padding_and_block(0ul);
   357 	u32_t extra_encryption_padding_and_block(0ul);
   358 
   358 
   359 	if (m_eapol_pairwise_cipher == eapol_RSNA_key_header_c::eapol_RSNA_cipher_CCMP
   359 	//if (m_eapol_pairwise_cipher == eapol_RSNA_key_header_c::eapol_RSNA_cipher_CCMP
   360 		|| m_eapol_group_cipher == eapol_RSNA_key_header_c::eapol_RSNA_cipher_CCMP)
   360 	//	|| m_eapol_group_cipher == eapol_RSNA_key_header_c::eapol_RSNA_cipher_CCMP)
   361 	{
   361 	{
   362 		extra_encryption_padding_and_block = 2ul * EAP_CRYPTO_AES_WRAP_BLOCK_SIZE;
   362 		extra_encryption_padding_and_block = 2ul * EAP_CRYPTO_AES_WRAP_BLOCK_SIZE;
   363 	}
   363 	}
   364 
   364 
   365 	if ((get_is_RSNA() == true
   365 	if ((get_is_RSNA() == true
   976 		// OK, we need 4-Way Handshake.
   976 		// OK, we need 4-Way Handshake.
   977 		EAP_TRACE_DEBUG(
   977 		EAP_TRACE_DEBUG(
   978 			m_am_tools, 
   978 			m_am_tools, 
   979 			TRACE_FLAGS_DEFAULT, 
   979 			TRACE_FLAGS_DEFAULT, 
   980 			(EAPL("EAPOL_KEY: %s: eapol_key_state_c::start_4_way_handshake(): ")
   980 			(EAPL("EAPOL_KEY: %s: eapol_key_state_c::start_4_way_handshake(): ")
   981 			 EAPL("Start 4-Way Handshake, m_authentication_type=%d\n"),
   981 			 EAPL("Start 4-Way Handshake, m_authentication_type=%d=%s\n"),
   982 			 (m_is_client == true ? "client": "server"),
   982 			 (m_is_client == true ? "client": "server"),
   983 			 m_authentication_type));
   983 			 m_authentication_type,
   984 	}
   984 			 eapol_key_state_string_c::get_eapol_key_authentication_type_string(m_authentication_type)));
   985 	else if (m_authentication_type == eapol_key_authentication_type_802_1X)
   985 	}
       
   986 	else if (m_authentication_type == eapol_key_authentication_type_dynamic_WEP
       
   987 			|| m_authentication_type == eapol_key_authentication_type_EAP_authentication_no_encryption
       
   988 			)
   986 	{
   989 	{
   987 		// No 4-Way Handshake needed.
   990 		// No 4-Way Handshake needed.
   988 		// AP will send unicast and broad cast keys in EAPOL key messages.
   991 		// AP will send unicast and broad cast keys in EAPOL key messages.
   989 		EAP_TRACE_DEBUG(
   992 		EAP_TRACE_DEBUG(
   990 			m_am_tools, 
   993 			m_am_tools, 
   991 			TRACE_FLAGS_DEFAULT, 
   994 			TRACE_FLAGS_DEFAULT, 
   992 			(EAPL("EAPOL_KEY: %s: eapol_key_state_c::start_4_way_handshake(): ")
   995 			(EAPL("EAPOL_KEY: %s: eapol_key_state_c::start_4_way_handshake(): ")
   993 			 EAPL("Dynamic WEP, m_authentication_type=%d\n"),
   996 			 EAPL("Dynamic WEP, m_authentication_type=%d=%s\n"),
   994 			(m_is_client == true ? "client": "server"),
   997 			(m_is_client == true ? "client": "server"),
   995 			m_authentication_type));
   998 			m_authentication_type,
       
   999 			eapol_key_state_string_c::get_eapol_key_authentication_type_string(m_authentication_type)));
   996 
  1000 
   997 		m_eapol_key_handshake_type = eapol_key_handshake_type_dynamic_WEP;
  1001 		m_eapol_key_handshake_type = eapol_key_handshake_type_dynamic_WEP;
   998 
  1002 
   999 		send_RC4_eapol_key_messages();
  1003 		send_RC4_eapol_key_messages();
  1000 
  1004 
  1006 		// No 4-Way Handshake needed.
  1010 		// No 4-Way Handshake needed.
  1007 		EAP_TRACE_DEBUG(
  1011 		EAP_TRACE_DEBUG(
  1008 			m_am_tools, 
  1012 			m_am_tools, 
  1009 			TRACE_FLAGS_DEFAULT, 
  1013 			TRACE_FLAGS_DEFAULT, 
  1010 			(EAPL("EAPOL_KEY: %s: eapol_key_state_c::start_4_way_handshake(): ")
  1014 			(EAPL("EAPOL_KEY: %s: eapol_key_state_c::start_4_way_handshake(): ")
  1011 			 EAPL("No 4-Way Handshake, m_authentication_type=%d\n"),
  1015 			 EAPL("No 4-Way Handshake, m_authentication_type=%d=%s\n"),
  1012 			(m_is_client == true ? "client": "server"),
  1016 			(m_is_client == true ? "client": "server"),
  1013 			m_authentication_type));
  1017 			m_authentication_type,
       
  1018 			eapol_key_state_string_c::get_eapol_key_authentication_type_string(m_authentication_type)));
  1014 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1019 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1015 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  1020 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  1016 	}
  1021 	}
  1017 
  1022 
  1018 	if (m_eapol_key_handshake_type != eapol_key_handshake_type_none
  1023 	if (m_eapol_key_handshake_type != eapol_key_handshake_type_none
       
  1024 		&& m_eapol_key_handshake_type != eapol_key_handshake_type_authenticated
  1019 		&& m_eapol_key_handshake_type != eapol_key_handshake_type_4_way_handshake)
  1025 		&& m_eapol_key_handshake_type != eapol_key_handshake_type_4_way_handshake)
  1020 	{
  1026 	{
  1021 		eapol_key_state_string_c state_string;
  1027 		eapol_key_state_string_c state_string;
  1022 		EAP_TRACE_ERROR(
  1028 		EAP_TRACE_ERROR(
  1023 			m_am_tools,
  1029 			m_am_tools,
  1024 			TRACE_FLAGS_DEFAULT,
  1030 			TRACE_FLAGS_DEFAULT,
  1025 			(EAPL("WARNING: EAPOL_KEY: %s: start_4_way_handshake(): wrong handshake type %s\n"),
  1031 			(EAPL("WARNING: EAPOL_KEY: %s: start_4_way_handshake(): wrong handshake type m_eapol_key_handshake_type=%d=%s\n"),
  1026 			(m_is_client == true ? "client": "server"),
  1032 			(m_is_client == true ? "client": "server"),
       
  1033 			m_eapol_key_handshake_type,
  1027 			state_string.get_eapol_key_handshake_type_string(m_eapol_key_handshake_type)));
  1034 			state_string.get_eapol_key_handshake_type_string(m_eapol_key_handshake_type)));
  1028 
  1035 
  1029 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1036 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1030 		return EAP_STATUS_RETURN(m_am_tools, eap_status_wrong_eap_type_state);
  1037 		return EAP_STATUS_RETURN(m_am_tools, eap_status_wrong_eap_type_state);
  1031 	}
  1038 	}
  1833 		// Finishes successfully.
  1840 		// Finishes successfully.
  1834 	}
  1841 	}
  1835 
  1842 
  1836 	set_eapol_key_state(eapol_key_state_4_way_handshake_successfull);
  1843 	set_eapol_key_state(eapol_key_state_4_way_handshake_successfull);
  1837 
  1844 
  1838 	m_eapol_key_handshake_type = eapol_key_handshake_type_none;
  1845 	m_eapol_key_handshake_type = eapol_key_handshake_type_authenticated;
  1839 
  1846 
  1840 	cancel_retransmission();
  1847 	cancel_retransmission();
  1841 
  1848 
  1842 	EAP_TRACE_ALWAYS(
  1849 	EAP_TRACE_ALWAYS(
  1843 		m_am_tools,
  1850 		m_am_tools,
  2467 		}
  2474 		}
  2468 	}
  2475 	}
  2469 
  2476 
  2470 	set_eapol_key_state(eapol_key_state_group_key_handshake_successfull);
  2477 	set_eapol_key_state(eapol_key_state_group_key_handshake_successfull);
  2471 
  2478 
  2472 	m_eapol_key_handshake_type = eapol_key_handshake_type_none;
  2479 	m_eapol_key_handshake_type = eapol_key_handshake_type_authenticated;
  2473 
  2480 
  2474 	cancel_retransmission();
  2481 	cancel_retransmission();
  2475 	cancel_handshake_timeout();
  2482 	cancel_handshake_timeout();
  2476 
  2483 
  2477 	EAP_TRACE_ALWAYS(
  2484 	EAP_TRACE_ALWAYS(