eapol/eapol_framework/eapol_common/type/tls_peap/eap/src/eap_type_tls_peap.cpp
branchRCL_3
changeset 19 c74b3d9f6b9e
parent 18 bad0cc58d154
equal deleted inserted replaced
18:bad0cc58d154 19:c74b3d9f6b9e
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: %
    19 * %version: 82.1.3 %
    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
  1627 				return EAP_STATUS_RETURN(m_am_tools, status);
  1627 				return EAP_STATUS_RETURN(m_am_tools, status);
  1628 			}
  1628 			}
  1629 		}
  1629 		}
  1630 
  1630 
  1631 		if (user_certificate_identity != 0
  1631 		if (user_certificate_identity != 0
  1632 			&& user_certificate_identity->get_is_valid_data() == true)
  1632 			&& user_certificate_identity->get_is_valid() == true)
  1633 		{
  1633 		{
  1634 			eap_variable_data_c username(m_am_tools);
  1634 			eap_variable_data_c username(m_am_tools);
  1635 			eap_variable_data_c realm(m_am_tools);
  1635 			eap_variable_data_c realm(m_am_tools);
  1636 
  1636 
  1637 			status = m_am_tools->parse_nai(
  1637 			status = m_am_tools->parse_nai(
  1708 			}
  1708 			}
  1709 		}
  1709 		}
  1710 		else
  1710 		else
  1711 #endif //#if defined(USE_EAP_TLS_IDENTITY_PRIVACY)
  1711 #endif //#if defined(USE_EAP_TLS_IDENTITY_PRIVACY)
  1712 		if (user_certificate_identity != 0
  1712 		if (user_certificate_identity != 0
  1713 			&& user_certificate_identity->get_is_valid_data() == true)
  1713 			&& user_certificate_identity->get_is_valid() == true)
  1714 		{
  1714 		{
  1715 			EAP_TRACE_DEBUG(
  1715 			EAP_TRACE_DEBUG(
  1716 				m_am_tools,
  1716 				m_am_tools,
  1717 				TRACE_FLAGS_DEFAULT,
  1717 				TRACE_FLAGS_DEFAULT,
  1718 				(EAPL("EAP_type_TLS_PEAP: %s: eap_type_tls_peap_c::handle_eap_identity_query(): username from certificate and manual realm.\n"),
  1718 				(EAPL("EAP_type_TLS_PEAP: %s: eap_type_tls_peap_c::handle_eap_identity_query(): username from certificate and manual realm.\n"),
  1793 		{
  1793 		{
  1794 			// No realm.
  1794 			// No realm.
  1795 		}
  1795 		}
  1796 	}
  1796 	}
  1797 	else if (user_certificate_identity != 0
  1797 	else if (user_certificate_identity != 0
  1798 		&& user_certificate_identity->get_is_valid_data() == true)
  1798 		&& user_certificate_identity->get_is_valid() == true)
  1799 	{
  1799 	{
  1800 		EAP_TRACE_DEBUG(
  1800 		EAP_TRACE_DEBUG(
  1801 			m_am_tools,
  1801 			m_am_tools,
  1802 			TRACE_FLAGS_DEFAULT,
  1802 			TRACE_FLAGS_DEFAULT,
  1803 			(EAPL("EAP_type_TLS_PEAP: %s: eap_type_tls_peap_c::handle_eap_identity_query(): username from certificate and realm from certificate.\n"),
  1803 			(EAPL("EAP_type_TLS_PEAP: %s: eap_type_tls_peap_c::handle_eap_identity_query(): username from certificate and realm from certificate.\n"),
  1811 			return EAP_STATUS_RETURN(m_am_tools, status);
  1811 			return EAP_STATUS_RETURN(m_am_tools, status);
  1812 		}
  1812 		}
  1813 	}
  1813 	}
  1814 	else
  1814 	else
  1815 	{
  1815 	{
  1816 		EAP_TRACE_DEBUG(
  1816 		EAP_TRACE_ERROR(
  1817 			m_am_tools,
  1817 			m_am_tools,
  1818 			TRACE_FLAGS_DEFAULT,
  1818 			TRACE_FLAGS_DEFAULT,
  1819 			(EAPL("WARNING: EAP_type_TLS_PEAP: %s: eap_type_tls_peap_c::handle_eap_identity_query(): no identity configured, creates random identity.\n"),
  1819 			(EAPL("EAP_type_TLS_PEAP: %s: eap_type_tls_peap_c::handle_eap_identity_query(): no identity.\n"),
  1820 			(m_is_client == true ? "client": "server")));
  1820 			(m_is_client == true ? "client": "server")));
  1821 
  1821 
  1822 		// Last possibility is random username.
  1822 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1823 		status = create_random_eap_identity(&local_identity);
  1823 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_eap_identity);
  1824 		if (status != eap_status_ok)
       
  1825 		{
       
  1826 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1827 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1828 		}
       
  1829 	}
  1824 	}
  1830 
  1825 
  1831 	status = m_current_identity.set_copy_of_buffer(&local_identity);
  1826 	status = m_current_identity.set_copy_of_buffer(&local_identity);
  1832 	if (status != eap_status_ok)
  1827 	if (status != eap_status_ok)
  1833 	{
  1828 	{
  1945 			eap_status_string_c status_string;
  1940 			eap_status_string_c status_string;
  1946 			EAP_TRACE_ERROR(
  1941 			EAP_TRACE_ERROR(
  1947 				m_am_tools,
  1942 				m_am_tools,
  1948 				TRACE_FLAGS_TLS_PEAP_ERROR,
  1943 				TRACE_FLAGS_TLS_PEAP_ERROR,
  1949 				(EAPL("ERROR: eap_type_tls_peap_c::check_received_eap_identifier() failed,")
  1944 				(EAPL("ERROR: eap_type_tls_peap_c::check_received_eap_identifier() failed,")
  1950 				 EAPL("status %d=%s, received EAP-type 0xfe%06x%08x=%s, received EAP-code %d, ")
  1945 				 EAPL("status %d=%s, received EAP-type 0x%08x, received EAP-code %d, ")
  1951 				 EAPL("received EAP-identifier %d, current EAP-identifier %d, state %s\n"),
  1946 				 EAPL("received EAP-identifier %d, current EAP-identifier %d, state %s\n"),
  1952 				 status,
  1947 				 status,
  1953 				 status_string.get_status_string(status),
  1948 				 status_string.get_status_string(status),
  1954 				 eap_header->get_type().get_vendor_id(),
  1949 				 convert_eap_type_to_u32_t(eap_header->get_type()),
  1955 				 eap_header->get_type().get_vendor_type(),
       
  1956 				 eap_header_string_c::get_eap_type_string(eap_header->get_type()),
       
  1957 				 eap_header->get_code(),
  1950 				 eap_header->get_code(),
  1958 				 eap_header->get_identifier(),
  1951 				 eap_header->get_identifier(),
  1959 				 get_last_eap_identifier(),
  1952 				 get_last_eap_identifier(),
  1960 				 get_state_string()));
  1953 				 get_state_string()));
  1961 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1954 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1975 			eap_status_string_c status_string;
  1968 			eap_status_string_c status_string;
  1976 			EAP_TRACE_ERROR(
  1969 			EAP_TRACE_ERROR(
  1977 				m_am_tools,
  1970 				m_am_tools,
  1978 				TRACE_FLAGS_TLS_PEAP_ERROR,
  1971 				TRACE_FLAGS_TLS_PEAP_ERROR,
  1979 				(EAPL("ERROR: eap_type_tls_peap_c::check_received_eap_identifier() failed,")
  1972 				(EAPL("ERROR: eap_type_tls_peap_c::check_received_eap_identifier() failed,")
  1980 				 EAPL("status %d=%s, received EAP-type 0xfe%06x%08x=%s, received EAP-code %d, ")
  1973 				 EAPL("status %d=%s, received EAP-type 0x%08x, received EAP-code %d, ")
  1981 				 EAPL("received EAP-identifier %d, current EAP-identifier %d, state %s\n"),
  1974 				 EAPL("received EAP-identifier %d, current EAP-identifier %d, state %s\n"),
  1982 				 status,
  1975 				 status,
  1983 				 status_string.get_status_string(status),
  1976 				 status_string.get_status_string(status),
  1984 				 eap_header->get_type().get_vendor_id(),
  1977 				 convert_eap_type_to_u32_t(eap_header->get_type()),
  1985 				 eap_header->get_type().get_vendor_type(),
       
  1986 				 eap_header_string_c::get_eap_type_string(eap_header->get_type()),
       
  1987 				 eap_header->get_code(),
  1978 				 eap_header->get_code(),
  1988 				 eap_header->get_identifier(),
  1979 				 eap_header->get_identifier(),
  1989 				 get_last_eap_identifier(),
  1980 				 get_last_eap_identifier(),
  1990 				 get_state_string()));
  1981 				 get_state_string()));
  1991 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1982 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2140 				eap_status_string_c status_string;
  2131 				eap_status_string_c status_string;
  2141 				EAP_TRACE_ERROR(
  2132 				EAP_TRACE_ERROR(
  2142 					m_am_tools,
  2133 					m_am_tools,
  2143 					TRACE_FLAGS_TLS_PEAP_ERROR,
  2134 					TRACE_FLAGS_TLS_PEAP_ERROR,
  2144 					(EAPL("ERROR: eap_type_tls_peap_c::packet_process() failed,")
  2135 					(EAPL("ERROR: eap_type_tls_peap_c::packet_process() failed,")
  2145 					 EAPL("status %d=%s, received EAP-type 0xfe%06x%08x=%s, received EAP-code %d, ")
  2136 					 EAPL("status %d=%s, received EAP-type 0x%08x, received EAP-code %d, ")
  2146 					 EAPL("received EAP-identifier %d, current EAP-identifier %d, state %s\n"),
  2137 					 EAPL("received EAP-identifier %d, current EAP-identifier %d, state %s\n"),
  2147 					 status,
  2138 					 status,
  2148 					 status_string.get_status_string(status),
  2139 					 status_string.get_status_string(status),
  2149 					 eap_header->get_type().get_vendor_id(),
  2140 					 convert_eap_type_to_u32_t(eap_header->get_type()),
  2150 					 eap_header->get_type().get_vendor_type(),
       
  2151 					 eap_header_string_c::get_eap_type_string(eap_header->get_type()),
       
  2152 					 eap_header->get_code(),
  2141 					 eap_header->get_code(),
  2153 					 eap_header->get_identifier(),
  2142 					 eap_header->get_identifier(),
  2154 					 get_last_eap_identifier(),
  2143 					 get_last_eap_identifier(),
  2155 					 get_state_string()));
  2144 					 get_state_string()));
  2156 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2145 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4001 						else
  3990 						else
  4002 						{
  3991 						{
  4003 							EAP_TRACE_ERROR(
  3992 							EAP_TRACE_ERROR(
  4004 								m_am_tools,
  3993 								m_am_tools,
  4005 								TRACE_FLAGS_DEFAULT|TRACE_TEST_VECTORS,
  3994 								TRACE_FLAGS_DEFAULT|TRACE_TEST_VECTORS,
  4006 								(EAPL("ERROR: EAP_type_TLS_PEAP: %s, unknown EAP-type 0xfe%06x%08x=%s\n"),
  3995 								(EAPL("ERROR: EAP_type_TLS_PEAP: %s, unknown EAP-type 0x%08x\n"),
  4007 								 (m_is_client == true) ? "client": "server",
  3996 								 (m_is_client == true) ? "client": "server",
  4008 								 m_current_eap_type.get_vendor_id(),
  3997 								 convert_eap_type_to_u32_t(m_current_eap_type)));
  4009 								 m_current_eap_type.get_vendor_type(),
       
  4010 								 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  4011 
  3998 
  4012 							restore_saved_reassembly_state();
  3999 							restore_saved_reassembly_state();
  4013 							EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4000 							EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4014 							return EAP_STATUS_RETURN(m_am_tools, status);
  4001 							return EAP_STATUS_RETURN(m_am_tools, status);
  4015 						}
  4002 						}
  4843 		}
  4830 		}
  4844 	}
  4831 	}
  4845 
  4832 
  4846 	//----------------------------------------------------------
  4833 	//----------------------------------------------------------
  4847 
  4834 
       
  4835 #if defined(USE_EAP_EXPANDED_TYPES)
  4848 	{
  4836 	{
  4849 		eap_variable_data_c use_eap_expanded_type(m_am_tools);
  4837 		eap_variable_data_c use_eap_expanded_type(m_am_tools);
  4850 
  4838 
  4851 		eap_status_e status = read_configure(
  4839 		eap_status_e status = read_configure(
  4852 			cf_str_EAP_TLS_PEAP_use_eap_expanded_type.get_field(),
  4840 			cf_str_EAP_TLS_PEAP_use_eap_expanded_type.get_field(),
  4876 					m_use_eap_expanded_type = false;
  4864 					m_use_eap_expanded_type = false;
  4877 				}
  4865 				}
  4878 			}
  4866 			}
  4879 		}
  4867 		}
  4880 	}
  4868 	}
       
  4869 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
  4881 
  4870 
  4882 	//----------------------------------------------------------
  4871 	//----------------------------------------------------------
  4883 
  4872 
  4884 	m_tls_peap_header_offset = get_type_partner()->get_header_offset(
  4873 	m_tls_peap_header_offset = get_type_partner()->get_header_offset(
  4885 		&m_MTU, &m_trailer_length);
  4874 		&m_MTU, &m_trailer_length);
  5151 		{
  5140 		{
  5152 			EAP_TRACE_ERROR(
  5141 			EAP_TRACE_ERROR(
  5153 				m_am_tools,
  5142 				m_am_tools,
  5154 				TRACE_FLAGS_DEFAULT,
  5143 				TRACE_FLAGS_DEFAULT,
  5155 				(EAPL("ERROR: %s: eap_type_tls_peap_c::state_notification(): ")
  5144 				(EAPL("ERROR: %s: eap_type_tls_peap_c::state_notification(): ")
  5156 				 EAPL("authentication failed: EAP-type 0xfe%06x%08x=%s\n"),
  5145 				 EAPL("authentication failed: EAP-type 0x%08x\n"),
  5157 				 (m_is_client == true ? "client": "server"),
  5146 				 (m_is_client == true ? "client": "server"),
  5158 				 m_current_eap_type.get_vendor_id(),
  5147 				 convert_eap_type_to_u32_t(m_current_eap_type)));
  5159 				 m_current_eap_type.get_vendor_type(),
       
  5160 				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5161 
  5148 
  5162 			m_tunneled_eap_type_authentication_state
  5149 			m_tunneled_eap_type_authentication_state
  5163 				= eap_state_authentication_terminated_unsuccessfully;
  5150 				= eap_state_authentication_terminated_unsuccessfully;
  5164 
  5151 
  5165 			// Here we must change the EAP-type of the notification.
  5152 			// Here we must change the EAP-type of the notification.
  5196 		{
  5183 		{
  5197 			EAP_TRACE_ALWAYS(
  5184 			EAP_TRACE_ALWAYS(
  5198 				m_am_tools,
  5185 				m_am_tools,
  5199 				TRACE_FLAGS_DEFAULT,
  5186 				TRACE_FLAGS_DEFAULT,
  5200 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5187 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5201 				 EAPL("PEAPv1 authentication tunneled EAP-SUCCESS: EAP-type 0xfe%06x%08x=%s\n"),
  5188 				 EAPL("PEAPv1 authentication tunneled EAP-SUCCESS: EAP-type 0x%08x\n"),
  5202 				 (m_is_client == true ? "client": "server"),
  5189 				 (m_is_client == true ? "client": "server"),
  5203 				 m_current_eap_type.get_vendor_id(),
  5190 				 convert_eap_type_to_u32_t(m_current_eap_type)));
  5204 				 m_current_eap_type.get_vendor_type(),
       
  5205 				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5206 
  5191 
  5207 			m_tunneled_eap_type_authentication_state
  5192 			m_tunneled_eap_type_authentication_state
  5208 				= static_cast<eap_state_variable_e>(state->get_current_state());
  5193 				= static_cast<eap_state_variable_e>(state->get_current_state());
  5209 
  5194 
  5210 			(void) finish_successful_authentication(true, false, true);
  5195 			(void) finish_successful_authentication(true, false, true);
  5218 		{
  5203 		{
  5219 			EAP_TRACE_ALWAYS(
  5204 			EAP_TRACE_ALWAYS(
  5220 				m_am_tools,
  5205 				m_am_tools,
  5221 				TRACE_FLAGS_DEFAULT,
  5206 				TRACE_FLAGS_DEFAULT,
  5222 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5207 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5223 				 EAPL("authentication EAP-SUCCESS: EAP-type 0xfe%06x%08x=%s\n"),
  5208 				 EAPL("authentication EAP-SUCCESS: EAP-type 0x%08x\n"),
  5224 				 (m_is_client == true ? "client": "server"),
  5209 				 (m_is_client == true ? "client": "server"),
  5225 				 m_current_eap_type.get_vendor_id(),
  5210 				 convert_eap_type_to_u32_t(m_current_eap_type)));
  5226 				 m_current_eap_type.get_vendor_type(),
       
  5227 				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5228 
  5211 
  5229 			m_tunneled_eap_type_authentication_state
  5212 			m_tunneled_eap_type_authentication_state
  5230 				= eap_state_authentication_finished_successfully;
  5213 				= eap_state_authentication_finished_successfully;
  5231 
  5214 
  5232 #if defined(USE_EAP_TLS_PEAP_TPPD_PEAP_V1_NEW_FIXES)
  5215 #if defined(USE_EAP_TLS_PEAP_TPPD_PEAP_V1_NEW_FIXES)
  5404 		{
  5387 		{
  5405 			EAP_TRACE_ERROR(
  5388 			EAP_TRACE_ERROR(
  5406 				m_am_tools,
  5389 				m_am_tools,
  5407 				TRACE_FLAGS_DEFAULT,
  5390 				TRACE_FLAGS_DEFAULT,
  5408 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): TLS tunneled ")
  5391 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): TLS tunneled ")
  5409 				 EAPL("authentication failed: EAP-type 0xfe%06x%08x=%s, tunnel type %s\n"),
  5392 				 EAPL("authentication failed: EAP-type 0x%08x, tunnel type %s\n"),
  5410 				 (m_is_client == true ? "client": "server"),
  5393 				 (m_is_client == true ? "client": "server"),
  5411 				 m_current_eap_type.get_vendor_id(),
  5394 				 convert_eap_type_to_u32_t(m_current_eap_type),
  5412 				 m_current_eap_type.get_vendor_type(),
       
  5413 				 eap_header_string_c::get_eap_type_string(m_current_eap_type),
       
  5414 				 tls_trace.get_peap_version_string(m_current_peap_version)));
  5395 				 tls_trace.get_peap_version_string(m_current_peap_version)));
  5415 
  5396 
  5416 			set_state(eap_type_tls_peap_state_failure);
  5397 			set_state(eap_type_tls_peap_state_failure);
  5417 		}
  5398 		}
  5418 		else if (state->get_current_state() == tls_peap_state_tls_success)
  5399 		else if (state->get_current_state() == tls_peap_state_tls_success)
  5428 					EAP_TRACE_ALWAYS(
  5409 					EAP_TRACE_ALWAYS(
  5429 						m_am_tools,
  5410 						m_am_tools,
  5430 						TRACE_FLAGS_DEFAULT,
  5411 						TRACE_FLAGS_DEFAULT,
  5431 						(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5412 						(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5432 						 EAPL("TLS tunneled authentication ")
  5413 						 EAPL("TLS tunneled authentication ")
  5433 						 EAPL("EAP-SUCCESS: EAP-type 0xfe%06x%08x=%s, tunnel type %s, style %d\n"),
  5414 						 EAPL("EAP-SUCCESS: EAP-type 0x%08x, tunnel type %s, style %d\n"),
  5434 						 (m_is_client == true ? "client": "server"),
  5415 						 (m_is_client == true ? "client": "server"),
  5435 						 m_current_eap_type.get_vendor_id(),
  5416 						 convert_eap_type_to_u32_t(m_current_eap_type),
  5436 						 m_current_eap_type.get_vendor_type(),
       
  5437 						 eap_header_string_c::get_eap_type_string(m_current_eap_type),
       
  5438 						 tls_trace.get_peap_version_string(m_current_peap_version),
  5417 						 tls_trace.get_peap_version_string(m_current_peap_version),
  5439 						 m_use_tppd_tls_peap));
  5418 						 m_use_tppd_tls_peap));
  5440 					
  5419 					
  5441 					if (m_tunneled_eap_type_authentication_state
  5420 					if (m_tunneled_eap_type_authentication_state
  5442 						== eap_state_authentication_finished_successfully)
  5421 						== eap_state_authentication_finished_successfully)
  5475 					EAP_TRACE_DEBUG(
  5454 					EAP_TRACE_DEBUG(
  5476 						m_am_tools,
  5455 						m_am_tools,
  5477 						TRACE_FLAGS_DEFAULT,
  5456 						TRACE_FLAGS_DEFAULT,
  5478 						(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5457 						(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5479 						 EAPL("TLS resumed session authentication ")
  5458 						 EAPL("TLS resumed session authentication ")
  5480 						 EAPL("EAP-SUCCESS: EAP-type 0xfe%06x%08x=%s, m_tls_session_type=%d=%s, tunnel type %s\n"),
  5459 						 EAPL("EAP-SUCCESS: EAP-type 0x%08x, m_tls_session_type=%d=%s, tunnel type %s\n"),
  5481 						 (m_is_client == true ? "client": "server"),
  5460 						 (m_is_client == true ? "client": "server"),
  5482 						 m_current_eap_type.get_vendor_id(),
  5461 						 convert_eap_type_to_u32_t(m_current_eap_type),
  5483 						 m_current_eap_type.get_vendor_type(),
       
  5484 						 eap_header_string_c::get_eap_type_string(m_current_eap_type),
       
  5485 						 get_tls_session_type(),
  5462 						 get_tls_session_type(),
  5486 						 eap_tls_trace_string_c::get_tls_session_type_string(get_tls_session_type()),
  5463 						 eap_tls_trace_string_c::get_tls_session_type_string(get_tls_session_type()),
  5487 						 tls_trace.get_peap_version_string(m_current_peap_version)));
  5464 						 tls_trace.get_peap_version_string(m_current_peap_version)));
  5488 
  5465 
  5489 					// Saved previous session was resumed.
  5466 					// Saved previous session was resumed.
  5511 				{
  5488 				{
  5512 					EAP_TRACE_DEBUG(
  5489 					EAP_TRACE_DEBUG(
  5513 						m_am_tools,
  5490 						m_am_tools,
  5514 						TRACE_FLAGS_DEFAULT,
  5491 						TRACE_FLAGS_DEFAULT,
  5515 						(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5492 						(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5516 						 EAPL("plain TLS authentication EAP-SUCCESS: EAP-type 0xfe%06x%08x=%s, tunnel type %s\n"),
  5493 						 EAPL("plain TLS authentication EAP-SUCCESS: EAP-type 0x%08x, tunnel type %s\n"),
  5517 						 (m_is_client == true ? "client": "server"),
  5494 						 (m_is_client == true ? "client": "server"),
  5518 						 m_current_eap_type.get_vendor_id(),
  5495 						 convert_eap_type_to_u32_t(m_current_eap_type),
  5519 						 m_current_eap_type.get_vendor_type(),
       
  5520 						 eap_header_string_c::get_eap_type_string(m_current_eap_type),
       
  5521 						 tls_trace.get_peap_version_string(m_current_peap_version)));
  5496 						 tls_trace.get_peap_version_string(m_current_peap_version)));
  5522 
  5497 
  5523 					// Plain TLS.
  5498 					// Plain TLS.
  5524 					if (m_is_client == true)
  5499 					if (m_is_client == true)
  5525 					{
  5500 					{
  5558 						else
  5533 						else
  5559 						{
  5534 						{
  5560 							EAP_TRACE_ERROR(
  5535 							EAP_TRACE_ERROR(
  5561 								m_am_tools,
  5536 								m_am_tools,
  5562 								TRACE_FLAGS_DEFAULT|TRACE_TEST_VECTORS,
  5537 								TRACE_FLAGS_DEFAULT|TRACE_TEST_VECTORS,
  5563 								(EAPL("ERROR: EAP_type_TLS_PEAP: %s, unknown EAP-type 0xfe%06x%08x=%s\n"),
  5538 								(EAPL("ERROR: EAP_type_TLS_PEAP: %s, unknown EAP-type 0x%08x\n"),
  5564 								 (m_is_client == true) ? "client": "server",
  5539 								 (m_is_client == true) ? "client": "server",
  5565 								 m_current_eap_type.get_vendor_id(),
  5540 								 convert_eap_type_to_u32_t(m_current_eap_type)));
  5566 								 m_current_eap_type.get_vendor_type(),
       
  5567 								 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5568 							
  5541 							
  5569 							EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5542 							EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5570 							set_state(eap_type_tls_peap_state_failure);
  5543 							set_state(eap_type_tls_peap_state_failure);
  5571 							return;
  5544 							return;
  5572 						}
  5545 						}
  5597 		{
  5570 		{
  5598 			EAP_TRACE_DEBUG(
  5571 			EAP_TRACE_DEBUG(
  5599 				m_am_tools,
  5572 				m_am_tools,
  5600 				TRACE_FLAGS_DEFAULT,
  5573 				TRACE_FLAGS_DEFAULT,
  5601 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5574 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5602 				 EAPL("full TLS authentication: EAP-type 0xfe%06x%08x=%s\n"),
  5575 				 EAPL("full TLS authentication: EAP-type 0x%08x\n"),
  5603 				 (m_is_client == true ? "client": "server"),
  5576 				 (m_is_client == true ? "client": "server"),
  5604 				 m_current_eap_type.get_vendor_id(),
  5577 				 convert_eap_type_to_u32_t(m_current_eap_type)));
  5605 				 m_current_eap_type.get_vendor_type(),
       
  5606 				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5607 		}
  5578 		}
  5608 		else if (state->get_current_state() == tls_peap_state_original_session_resumption)
  5579 		else if (state->get_current_state() == tls_peap_state_original_session_resumption)
  5609 		{
  5580 		{
  5610 			EAP_TRACE_DEBUG(
  5581 			EAP_TRACE_DEBUG(
  5611 				m_am_tools,
  5582 				m_am_tools,
  5612 				TRACE_FLAGS_DEFAULT,
  5583 				TRACE_FLAGS_DEFAULT,
  5613 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5584 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5614 				 EAPL("TLS session resumption: EAP-type 0xfe%06x%08x=%s\n"),
  5585 				 EAPL("TLS session resumption: EAP-type 0x%08x\n"),
  5615 				 (m_is_client == true ? "client": "server"),
  5586 				 (m_is_client == true ? "client": "server"),
  5616 				 m_current_eap_type.get_vendor_id(),
  5587 				 convert_eap_type_to_u32_t(m_current_eap_type)));
  5617 				 m_current_eap_type.get_vendor_type(),
       
  5618 				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5619 		}
  5588 		}
  5620 #if defined(USE_EAP_TLS_SESSION_TICKET)
  5589 #if defined(USE_EAP_TLS_SESSION_TICKET)
  5621 		else if (state->get_current_state() == tls_peap_state_stateless_session_resumption)
  5590 		else if (state->get_current_state() == tls_peap_state_stateless_session_resumption)
  5622 		{
  5591 		{
  5623 			EAP_TRACE_DEBUG(
  5592 			EAP_TRACE_DEBUG(
  5624 				m_am_tools,
  5593 				m_am_tools,
  5625 				TRACE_FLAGS_DEFAULT,
  5594 				TRACE_FLAGS_DEFAULT,
  5626 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5595 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5627 				 EAPL("TLS stateless session resumption: EAP-type 0xfe%06x%08x=%s\n"),
  5596 				 EAPL("TLS stateless session resumption: EAP-type 0x%08x\n"),
  5628 				 (m_is_client == true ? "client": "server"),
  5597 				 (m_is_client == true ? "client": "server"),
  5629 				 m_current_eap_type.get_vendor_id(),
  5598 				 convert_eap_type_to_u32_t(m_current_eap_type)));
  5630 				 m_current_eap_type.get_vendor_type(),
       
  5631 				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5632 		}
  5599 		}
  5633 #endif // #if defined(USE_EAP_TLS_SESSION_TICKET)
  5600 #endif // #if defined(USE_EAP_TLS_SESSION_TICKET)
  5634 #if defined(USE_EAP_TLS_PEAP_TPPD_PEAP_V1_NEW_FIXES)
  5601 #if defined(USE_EAP_TLS_PEAP_TPPD_PEAP_V1_NEW_FIXES)
  5635 		else if (state->get_current_state()
  5602 		else if (state->get_current_state()
  5636 				 == tls_peap_state_tppd_peapv1_waits_eap_success_or_tunneled_packet)
  5603 				 == tls_peap_state_tppd_peapv1_waits_eap_success_or_tunneled_packet)
  5637 		{
  5604 		{
  5638 			EAP_TRACE_DEBUG(
  5605 			EAP_TRACE_DEBUG(
  5639 				m_am_tools,
  5606 				m_am_tools,
  5640 				TRACE_FLAGS_DEFAULT,
  5607 				TRACE_FLAGS_DEFAULT,
  5641 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5608 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5642 				 EAPL("PEAPv1 waits EAP-Success or tunneled packet: EAP-type 0xfe%06x%08x=%s\n"),
  5609 				 EAPL("PEAPv1 waits EAP-Success or tunneled packet: EAP-type 0x%08x\n"),
  5643 				 (m_is_client == true ? "client": "server"),
  5610 				 (m_is_client == true ? "client": "server"),
  5644 				 m_current_eap_type.get_vendor_id(),
  5611 				 convert_eap_type_to_u32_t(m_current_eap_type)));
  5645 				 m_current_eap_type.get_vendor_type(),
       
  5646 				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5647 
  5612 
  5648 			set_state(eap_type_tls_peap_state_tppd_peapv1_waits_eap_success_or_tunneled_packet);
  5613 			set_state(eap_type_tls_peap_state_tppd_peapv1_waits_eap_success_or_tunneled_packet);
  5649 		}
  5614 		}
  5650 #endif //#if defined(USE_EAP_TLS_PEAP_TPPD_PEAP_V1_NEW_FIXES)
  5615 #endif //#if defined(USE_EAP_TLS_PEAP_TPPD_PEAP_V1_NEW_FIXES)
  5651 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
  5616 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
  5653 		{
  5618 		{
  5654 			EAP_TRACE_ALWAYS(
  5619 			EAP_TRACE_ALWAYS(
  5655 				m_am_tools,
  5620 				m_am_tools,
  5656 				TRACE_FLAGS_DEFAULT,
  5621 				TRACE_FLAGS_DEFAULT,
  5657 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5622 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5658 				 EAPL("sends TTLS/plain MsChapv2 empty Ack: EAP-type 0xfe%06x%08x=%s\n"),
  5623 				 EAPL("sends TTLS/plain MsChapv2 empty Ack: EAP-type 0x%08x\n"),
  5659 				 (m_is_client == true ? "client": "server"),
  5624 				 (m_is_client == true ? "client": "server"),
  5660 				 m_current_eap_type.get_vendor_id(),
  5625 				 convert_eap_type_to_u32_t(m_current_eap_type)));
  5661 				 m_current_eap_type.get_vendor_type(),
       
  5662 				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5663 
  5626 
  5664 			// Send empty acknowledge message.
  5627 			// Send empty acknowledge message.
  5665 			eap_status_e status = send_empty_eap_ack();
  5628 			eap_status_e status = send_empty_eap_ack();
  5666 			if (status != eap_status_ok)
  5629 			if (status != eap_status_ok)
  5667 			{
  5630 			{
  5677 		{
  5640 		{
  5678 			EAP_TRACE_ALWAYS(
  5641 			EAP_TRACE_ALWAYS(
  5679 				m_am_tools,
  5642 				m_am_tools,
  5680 				TRACE_FLAGS_DEFAULT,
  5643 				TRACE_FLAGS_DEFAULT,
  5681 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5644 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5682 				 EAPL("waits TTLS/plain MsChapv2 empty Ack: EAP-type 0xfe%06x%08x=%s\n"),
  5645 				 EAPL("waits TTLS/plain MsChapv2 empty Ack: EAP-type 0x%08x\n"),
  5683 				 (m_is_client == true ? "client": "server"),
  5646 				 (m_is_client == true ? "client": "server"),
  5684 				 m_current_eap_type.get_vendor_id(),
  5647 				 convert_eap_type_to_u32_t(m_current_eap_type)));
  5685 				 m_current_eap_type.get_vendor_type(),
       
  5686 				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5687 
  5648 
  5688 			set_state(eap_type_tls_peap_state_server_waits_ttls_plain_ms_chap_v2_empty_ack);
  5649 			set_state(eap_type_tls_peap_state_server_waits_ttls_plain_ms_chap_v2_empty_ack);
  5689 		}
  5650 		}
  5690 #endif //#if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
  5651 #endif //#if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
  5691 		else if (state->get_current_state() == tls_peap_state_peap_tunnel_ready)
  5652 		else if (state->get_current_state() == tls_peap_state_peap_tunnel_ready)
  5692 		{
  5653 		{
  5693 			EAP_TRACE_DEBUG(
  5654 			EAP_TRACE_DEBUG(
  5694 				m_am_tools,
  5655 				m_am_tools,
  5695 				TRACE_FLAGS_DEFAULT,
  5656 				TRACE_FLAGS_DEFAULT,
  5696 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5657 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5697 				 EAPL("TLS tunnel ready: EAP-type 0xfe%06x%08x=%s\n"),
  5658 				 EAPL("TLS tunnel ready: EAP-type 0x%08x\n"),
  5698 				 (m_is_client == true ? "client": "server"),
  5659 				 (m_is_client == true ? "client": "server"),
  5699 				 m_current_eap_type.get_vendor_id(),
  5660 				 convert_eap_type_to_u32_t(m_current_eap_type)));
  5700 				 m_current_eap_type.get_vendor_type(),
       
  5701 				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5702 
  5661 
  5703 			if (m_is_client == true)
  5662 			if (m_is_client == true)
  5704 			{
  5663 			{
  5705 				eap_status_e status = eap_status_process_general_error;
  5664 				eap_status_e status = eap_status_process_general_error;
  5706 
  5665 
  5808 				else
  5767 				else
  5809 				{
  5768 				{
  5810 					EAP_TRACE_ERROR(
  5769 					EAP_TRACE_ERROR(
  5811 						m_am_tools,
  5770 						m_am_tools,
  5812 						TRACE_FLAGS_DEFAULT|TRACE_TEST_VECTORS,
  5771 						TRACE_FLAGS_DEFAULT|TRACE_TEST_VECTORS,
  5813 						(EAPL("ERROR: EAP_type_TLS_PEAP: %s, unknown EAP-type 0xfe%06x%08x=%s\n"),
  5772 						(EAPL("ERROR: EAP_type_TLS_PEAP: %s, unknown EAP-type 0x%08x\n"),
  5814 						 (m_is_client == true) ? "client": "server",
  5773 						 (m_is_client == true) ? "client": "server",
  5815 						 m_current_eap_type.get_vendor_id(),
  5774 						 convert_eap_type_to_u32_t(m_current_eap_type)));
  5816 						 m_current_eap_type.get_vendor_type(),
       
  5817 						 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5818 					
  5775 					
  5819 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5776 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5820 					set_state(eap_type_tls_peap_state_failure);
  5777 					set_state(eap_type_tls_peap_state_failure);
  5821 					return;
  5778 					return;
  5822 				}
  5779 				}
  5849 		{
  5806 		{
  5850 			EAP_TRACE_DEBUG(
  5807 			EAP_TRACE_DEBUG(
  5851 				m_am_tools,
  5808 				m_am_tools,
  5852 				TRACE_FLAGS_DEFAULT,
  5809 				TRACE_FLAGS_DEFAULT,
  5853 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5810 				(EAPL("%s: eap_type_tls_peap_c::state_notification(): ")
  5854 				 EAPL("TLS tunnel ready: EAP-type 0xfe%06x%08x=%s\n"),
  5811 				 EAPL("TLS tunnel ready: EAP-type 0x%08x\n"),
  5855 				 (m_is_client == true ? "client": "server"),
  5812 				 (m_is_client == true ? "client": "server"),
  5856 				 m_current_eap_type.get_vendor_id(),
  5813 				 convert_eap_type_to_u32_t(m_current_eap_type)));
  5857 				 m_current_eap_type.get_vendor_type(),
       
  5858 				 eap_header_string_c::get_eap_type_string(m_current_eap_type)));
       
  5859 
  5814 
  5860 			if (m_is_client == true)
  5815 			if (m_is_client == true)
  5861 			{
  5816 			{
  5862 #if defined(USE_FAST_EAP_TYPE)
  5817 #if defined(USE_FAST_EAP_TYPE)
  5863 				if (m_current_eap_type == eap_type_fast)
  5818 				if (m_current_eap_type == eap_type_fast)
  6244 	return EAP_STATUS_RETURN(m_am_tools, status);
  6199 	return EAP_STATUS_RETURN(m_am_tools, status);
  6245 }
  6200 }
  6246 
  6201 
  6247 //--------------------------------------------------
  6202 //--------------------------------------------------
  6248 
  6203 
       
  6204 //
       
  6205 EAP_FUNC_EXPORT eap_status_e eap_type_tls_peap_c::cancel_all_timers()
       
  6206 {
       
  6207 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  6208 
       
  6209 	eap_status_e status = get_type_partner()->cancel_all_timers();
       
  6210 
       
  6211 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  6212 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  6213 }
       
  6214 
       
  6215 //--------------------------------------------------
       
  6216 
  6249 // This is commented in abs_tls_base_application_c.
  6217 // This is commented in abs_tls_base_application_c.
  6250 EAP_FUNC_EXPORT eap_status_e eap_type_tls_peap_c::load_module(
  6218 EAP_FUNC_EXPORT eap_status_e eap_type_tls_peap_c::load_module(
  6251 	const eap_type_value_e type,
  6219 	const eap_type_value_e type,
  6252 	const eap_type_value_e tunneling_type,
  6220 	const eap_type_value_e tunneling_type,
  6253 	abs_eap_base_type_c * const partner,
  6221 	abs_eap_base_type_c * const partner,