eapol/eapol_framework/eapol_common/type/tls_peap/tls/src/tls_application_eap_core.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
equal deleted inserted replaced
45:bad0cc58d154 46: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: 99 %
    19 * %version: 92.1.4 %
    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
   327 			{
   327 			{
   328 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   328 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   329 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
   329 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
   330 			}
   330 			}
   331 		}
   331 		}
       
   332 //#if defined(USE_EAP_EXPANDED_TYPES)
   332 		else if (tunneled_eap_type.get_data_length()
   333 		else if (tunneled_eap_type.get_data_length()
   333 				 == eap_expanded_type_c::get_eap_expanded_type_size()
   334 				 == eap_expanded_type_c::get_eap_expanded_type_size()
   334 			&& tunneled_eap_type.get_data(tunneled_eap_type.get_data_length()) != 0)
   335 			&& tunneled_eap_type.get_data(tunneled_eap_type.get_data_length()) != 0)
   335 		{
   336 		{
   336 			eap_expanded_type_c eap_type(eap_type_none);
   337 			eap_expanded_type_c eap_type(eap_type_none);
   351 			{
   352 			{
   352 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   353 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   353 				return EAP_STATUS_RETURN(m_am_tools, status);
   354 				return EAP_STATUS_RETURN(m_am_tools, status);
   354 			}
   355 			}
   355 		}
   356 		}
       
   357 //#endif //#if defined(USE_EAP_EXPANDED_TYPES)
   356 		else
   358 		else
   357 		{
   359 		{
   358 			EAP_TRACE_DEBUG(
   360 			EAP_TRACE_DEBUG(
   359 				m_am_tools, 
   361 				m_am_tools, 
   360 				TRACE_FLAGS_DEFAULT, 
   362 				TRACE_FLAGS_DEFAULT, 
   366 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
   368 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
   367 		}
   369 		}
   368 
   370 
   369 
   371 
   370 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
   372 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
   371 		if (m_peap_tunneled_eap_type == eap_expanded_type_ttls_plain_mschapv2.get_type())
   373 		if (
       
   374 #if defined(USE_EAP_EXPANDED_TYPES)
       
   375 			m_peap_tunneled_eap_type == eap_expanded_type_ttls_plain_mschapv2.get_type()
       
   376 #else
       
   377 			m_peap_tunneled_eap_type == eap_type_plain_mschapv2
       
   378 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
   379 			)
   372 		{
   380 		{
   373 			// This is special case.
   381 			// This is special case.
   374 			// We must tell to inner EAP-stack to use EAP-MsChapv2.
   382 			// We must tell to inner EAP-stack to use EAP-MsChapv2.
   375 			m_tunneled_eap_in_ttls = false;
   383 			m_tunneled_eap_in_ttls = false;
   376 		}
   384 		}
   673 
   681 
   674 #endif //#if defined(USE_EAP_ERROR_TESTS)
   682 #endif //#if defined(USE_EAP_ERROR_TESTS)
   675 
   683 
   676 	//----------------------------------------------------------
   684 	//----------------------------------------------------------
   677 
   685 
       
   686 #if defined(USE_EAP_EXPANDED_TYPES) && 0
       
   687 	{
       
   688 		eap_variable_data_c use_eap_expanded_type(m_am_tools);
       
   689 
       
   690 		eap_status_e status = read_configure(
       
   691 			cf_str_EAP_TLS_PEAP_use_eap_expanded_type.get_field(),
       
   692 			&use_eap_expanded_type);
       
   693 
       
   694 		if (status != eap_status_ok)
       
   695 		{
       
   696 			status = read_configure(
       
   697 				cf_str_EAP_CORE_use_eap_expanded_type.get_field(),
       
   698 				&use_eap_expanded_type);
       
   699 		}
       
   700 
       
   701 		if (status == eap_status_ok
       
   702 			&& use_eap_expanded_type.get_data_length() == sizeof(u32_t)
       
   703 			&& use_eap_expanded_type.get_data() != 0)
       
   704 		{
       
   705 			u32_t *flag = reinterpret_cast<u32_t *>(use_eap_expanded_type.get_data(use_eap_expanded_type.get_data_length()));
       
   706 
       
   707 			if (flag != 0)
       
   708 			{
       
   709 				if ((*flag) != 0ul)
       
   710 				{
       
   711 					m_use_eap_expanded_type = true;
       
   712 				}
       
   713 				else
       
   714 				{
       
   715 					m_use_eap_expanded_type = false;
       
   716 				}
       
   717 			}
       
   718 		}
       
   719 	}
       
   720 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
   721 
       
   722 	//----------------------------------------------------------
       
   723 
   678 	status = m_eap_core->configure();
   724 	status = m_eap_core->configure();
   679 
   725 
   680 	if (m_peap_tunneled_eap_type == eap_expanded_type_ttls_plain_pap.get_type())
   726 	if (m_peap_tunneled_eap_type == eap_type_ttls_plain_pap)
   681 	{
   727 	{
   682 		if (m_free_eap_core == true)
   728 		if (m_free_eap_core == true)
   683 		{
   729 		{
   684 			m_eap_core->ignore_notifications();
   730 			m_eap_core->ignore_notifications();
   685 
   731 
  1311 
  1357 
  1312 	eap_status_e status(eap_status_process_general_error);
  1358 	eap_status_e status(eap_status_process_general_error);
  1313 
  1359 
  1314 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1360 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1315 
  1361 
  1316 	if (m_peap_tunneled_eap_type == eap_expanded_type_ttls_plain_pap.get_type())
  1362 	if (
       
  1363 #if defined(USE_EAP_EXPANDED_TYPES)
       
  1364 		m_peap_tunneled_eap_type == eap_expanded_type_ttls_plain_pap.get_type()
       
  1365 #else
       
  1366 		m_peap_tunneled_eap_type == eap_type_ttls_plain_pap
       
  1367 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
  1368 		)
  1317 	{
  1369 	{
  1318 		// Query PAP username and password.
  1370 		// Query PAP username and password.
  1319 		status = m_application_partner->query_ttls_pap_username_and_password(0);
  1371 		status = m_application_partner->query_ttls_pap_username_and_password(0);
  1320 		if (status != eap_status_ok)
  1372 		if (status != eap_status_ok)
  1321 		{
  1373 		{
  1414 		// NOTE, here we process client send packets separately to 
  1466 		// NOTE, here we process client send packets separately to 
  1415 		// reduce stack consumption.
  1467 		// reduce stack consumption.
  1416 
  1468 
  1417 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
  1469 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
  1418 		if (m_eap_type == eap_type_ttls
  1470 		if (m_eap_type == eap_type_ttls
  1419 			&& m_peap_tunneled_eap_type == eap_expanded_type_ttls_plain_mschapv2.get_type())
  1471 #if defined(USE_EAP_EXPANDED_TYPES)
       
  1472 			&& m_peap_tunneled_eap_type == eap_expanded_type_ttls_plain_mschapv2.get_type()
       
  1473 #else
       
  1474 			&& m_peap_tunneled_eap_type == eap_type_plain_mschapv2
       
  1475 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
  1476 			)
  1420 		{
  1477 		{
  1421 			eap_header_wr_c sent_eap_packet(
  1478 			eap_header_wr_c sent_eap_packet(
  1422 				m_am_tools,
  1479 				m_am_tools,
  1423 				m_ttls_sent_eap_packet.get_data(),
  1480 				m_ttls_sent_eap_packet.get_data(),
  1424 				m_ttls_sent_eap_packet.get_data_length());
  1481 				m_ttls_sent_eap_packet.get_data_length());
  1448 
  1505 
  1449 		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1506 		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1450 
  1507 
  1451 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
  1508 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
  1452 		if (m_eap_type == eap_type_ttls
  1509 		if (m_eap_type == eap_type_ttls
  1453 			&& m_peap_tunneled_eap_type == eap_expanded_type_ttls_plain_mschapv2.get_type())
  1510 #if defined(USE_EAP_EXPANDED_TYPES)
       
  1511 			&& m_peap_tunneled_eap_type == eap_expanded_type_ttls_plain_mschapv2.get_type()
       
  1512 #else
       
  1513 			&& m_peap_tunneled_eap_type == eap_type_plain_mschapv2
       
  1514 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
  1515 			)
  1454 		{
  1516 		{
  1455 			eap_header_wr_c sent_eap_packet(
  1517 			eap_header_wr_c sent_eap_packet(
  1456 				m_am_tools,
  1518 				m_am_tools,
  1457 				m_ttls_sent_eap_packet.get_data(),
  1519 				m_ttls_sent_eap_packet.get_data(),
  1458 				m_ttls_sent_eap_packet.get_data_length());
  1520 				m_ttls_sent_eap_packet.get_data_length());
  6364 	{
  6426 	{
  6365 		eap_type_value_e tunneled_type = m_peap_tunneled_eap_type;
  6427 		eap_type_value_e tunneled_type = m_peap_tunneled_eap_type;
  6366 
  6428 
  6367 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
  6429 #if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
  6368 		if (m_tunneled_eap_in_ttls == false
  6430 		if (m_tunneled_eap_in_ttls == false
  6369 			&& m_peap_tunneled_eap_type == eap_expanded_type_ttls_plain_mschapv2.get_type())
  6431 			&& (
       
  6432 #if defined(USE_EAP_EXPANDED_TYPES)
       
  6433 				m_peap_tunneled_eap_type == eap_expanded_type_ttls_plain_mschapv2.get_type()
       
  6434 #else
       
  6435 				m_peap_tunneled_eap_type == eap_type_plain_mschapv2
       
  6436 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
  6437 			))
  6370 		{
  6438 		{
  6371 			tunneled_type = eap_type_mschapv2;
  6439 			tunneled_type = eap_type_mschapv2;
  6372 		}
  6440 		}
  6373 #endif //#if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
  6441 #endif //#if defined(EAP_USE_TTLS_PLAIN_MS_CHAP_V2_HACK)
  6374 
  6442 
  6870 	return EAP_STATUS_RETURN(m_am_tools, status);
  6938 	return EAP_STATUS_RETURN(m_am_tools, status);
  6871 }
  6939 }
  6872 
  6940 
  6873 //--------------------------------------------------
  6941 //--------------------------------------------------
  6874 
  6942 
       
  6943 EAP_FUNC_EXPORT eap_status_e tls_application_eap_core_c::cancel_all_timers()
       
  6944 {
       
  6945 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  6946 	eap_status_e status = eap_status_process_general_error;
       
  6947 	abs_tls_base_application_c * partner = get_application_partner();
       
  6948 	if (partner != 0)
       
  6949 	{
       
  6950 		status = partner->cancel_all_timers();
       
  6951 	}
       
  6952 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  6953 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  6954 }
       
  6955 
       
  6956 //--------------------------------------------------
       
  6957 
  6875 EAP_FUNC_EXPORT eap_status_e tls_application_eap_core_c::check_is_valid_eap_type(
  6958 EAP_FUNC_EXPORT eap_status_e tls_application_eap_core_c::check_is_valid_eap_type(
  6876 	const eap_type_value_e eap_type)
  6959 	const eap_type_value_e eap_type)
  6877 {
  6960 {
  6878 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6961 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6879 
  6962 
       
  6963 	eap_header_string_c eap_string;
       
  6964 	EAP_UNREFERENCED_PARAMETER(eap_string);
       
  6965 
  6880 	EAP_TRACE_DEBUG(
  6966 	EAP_TRACE_DEBUG(
  6881 		m_am_tools,
  6967 		m_am_tools,
  6882 		TRACE_FLAGS_DEFAULT,
  6968 		TRACE_FLAGS_DEFAULT,
  6883 		(EAPL("tls_application_eap_core_c::check_is_valid_eap_type(): EAP-type=0xfe%06x%08x=%s\n"),
  6969 		(EAPL("tls_application_eap_core_c::check_is_valid_eap_type(): EAP-type=0x%08x=%s\n"),
  6884 		eap_type.get_vendor_id(),
  6970 		convert_eap_type_to_u32_t(eap_type),
  6885 		eap_type.get_vendor_type(),
  6971 		eap_string.get_eap_type_string(eap_type)));
  6886 		eap_header_string_c::get_eap_type_string(eap_type)));
       
  6887 
  6972 
  6888 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: tls_application_eap_core_c::check_is_valid_eap_type()");
  6973 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: tls_application_eap_core_c::check_is_valid_eap_type()");
  6889 
  6974 
  6890 	if (m_accepted_tunneled_eap_types.get_object_count() > 0ul)
  6975 	if (m_accepted_tunneled_eap_types.get_object_count() > 0ul)
  6891 	{
  6976 	{
  6919 		{
  7004 		{
  6920 			// Not allowed EAP-type inside PEAP.
  7005 			// Not allowed EAP-type inside PEAP.
  6921 			EAP_TRACE_DEBUG(
  7006 			EAP_TRACE_DEBUG(
  6922 				m_am_tools,
  7007 				m_am_tools,
  6923 				TRACE_FLAGS_DEFAULT,
  7008 				TRACE_FLAGS_DEFAULT,
  6924 				(EAPL("ERROR: tls_application_eap_core_c::check_is_valid_eap_type(): No allowed EAP-type=0xfe%06x%08x=%s\n"),
  7009 				(EAPL("ERROR: tls_application_eap_core_c::check_is_valid_eap_type(): No allowed EAP-type=0x%08x=%s\n"),
  6925 				eap_type.get_vendor_id(),
  7010 				convert_eap_type_to_u32_t(eap_type),
  6926 				eap_type.get_vendor_type(),
  7011 				eap_string.get_eap_type_string(eap_type)));
  6927 				eap_header_string_c::get_eap_type_string(eap_type)));
       
  6928 
  7012 
  6929 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_eap_type);
  7013 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_eap_type);
  6930 		}
  7014 		}
  6931 		else
  7015 		else
  6932 		{
  7016 		{