diff -r e03a3db4489e -r 9abfd4f00d37 eapol/eapol_framework/eapol_common/type/simple_config/simple_config/src/simple_config_record.cpp --- a/eapol/eapol_framework/eapol_common/type/simple_config/simple_config/src/simple_config_record.cpp Thu May 13 22:51:27 2010 +0300 +++ b/eapol/eapol_framework/eapol_common/type/simple_config/simple_config/src/simple_config_record.cpp Mon May 24 20:32:47 2010 +0300 @@ -16,7 +16,7 @@ */ /* -* %version: 73 % +* %version: % */ // This is enumeration of EAPOL source code. @@ -47,6 +47,9 @@ #include "abs_eap_am_mutex.h" #include "simple_config_credential.h" #include "eapol_key_types.h" +#include "eap_config.h" +#include "eap_network_id_selector.h" +#include "eap_tlv_message_data.h" //-------------------------------------------------- @@ -414,6 +417,7 @@ //---------------------------------------------------------- +#if 0 { status = get_type_partner()->read_configure( cf_str_EAP_SIMPLE_CONFIG_device_password.get_field(), @@ -431,9 +435,26 @@ return EAP_STATUS_RETURN(m_am_tools, eap_status_wrong_password); } } +#endif if (m_is_client == false) { + status = get_type_partner()->read_configure( + cf_str_EAP_SIMPLE_CONFIG_device_password.get_field(), + &m_device_password); + if (status != eap_status_ok + || m_device_password.get_is_valid_data() == false) + { + // This is mandatory value. + EAP_TRACE_ERROR( + m_am_tools, + TRACE_FLAGS_DEFAULT, + (EAPL("ERROR: SIMPLE_CONFIG: %s: simple_config_record_c::configure(): Missing device password.\n"), + (m_is_client == true ? "client": "server"))); + EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); + return EAP_STATUS_RETURN(m_am_tools, eap_status_wrong_password); + } + (void) get_type_partner()->read_configure( cf_str_EAP_SIMPLE_CONFIG_server_device_password.get_field(), &m_device_password); @@ -4461,6 +4482,18 @@ // Compare RHash1. if (local_RHash1.compare(&m_RHash1) != 0) { + EAP_TRACE_DATA_DEBUG( + m_am_tools, + TRACE_FLAGS_DEFAULT, + (EAPL("local_RHash1"), + local_RHash1.get_data(), + local_RHash1.get_data_length())); + EAP_TRACE_DATA_DEBUG( + m_am_tools, + TRACE_FLAGS_DEFAULT, + (EAPL("m_RHash1"), + m_RHash1.get_data(), + m_RHash1.get_data_length())); EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); return EAP_STATUS_RETURN(m_am_tools, eap_status_device_password_authentication_failure); } @@ -6486,6 +6519,12 @@ eap_variable_data_c * const ER_S2, eap_variable_data_c * const ER_Hash2) { + EAP_TRACE_DATA_DEBUG( + m_am_tools, + TRACE_FLAGS_DEFAULT, + (EAPL("SIMPLE_CONFIG: generate_er_hashs(): device_password"), + device_password->get_data(), + device_password->get_data_length())); eap_variable_data_c first_half_of_device_password(m_am_tools); @@ -8160,6 +8199,118 @@ return EAP_STATUS_RETURN(m_am_tools, status); } } + else if (m_local_Device_Password_ID == simple_config_Device_Password_ID_Default_PIN + && m_is_client == true) + { + // Read PIN from memory store. + + eap_variable_data_c memory_store_key(m_am_tools); + + eap_status_e status = memory_store_key.set_copy_of_buffer( + EAP_WPS_CONFIGURATION_MEMORY_STORE_KEY, + sizeof(EAP_WPS_CONFIGURATION_MEMORY_STORE_KEY)); + if (status != eap_status_ok) + { + EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); + return EAP_STATUS_RETURN(m_am_tools, status); + } + + status = memory_store_key.add_data( + &m_is_client, + sizeof(m_is_client)); + if (status != eap_status_ok) + { + EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); + return EAP_STATUS_RETURN(m_am_tools, status); + } + + eap_am_network_id_c receive_network_id(m_am_tools, + m_send_network_id.get_destination_id(), + m_send_network_id.get_source_id(), + m_send_network_id.get_type()); + + eap_network_id_selector_c state_selector( + m_am_tools, + &receive_network_id); + + status = memory_store_key.add_data( + &state_selector); + if (status != eap_status_ok) + { + EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); + return EAP_STATUS_RETURN(m_am_tools, status); + } + + eap_tlv_message_data_c tlv_data(m_am_tools); + + status = m_am_tools->memory_store_get_data( + &memory_store_key, + &tlv_data); + if (status != eap_status_ok) + { + EAP_TRACE_DEBUG( + m_am_tools, + TRACE_FLAGS_DEFAULT, + (EAPL("simple_config_record_c::complete_query_network_and_device_parameters(): cannot get WPS credentials\n"))); + } + else + { + EAP_TRACE_DEBUG( + m_am_tools, + TRACE_FLAGS_DEFAULT, + (EAPL("simple_config_record_c::complete_query_network_and_device_parameters(): WPS credentials found\n"))); + + // Parse read data. + eap_array_c tlv_blocks(m_am_tools); + + status = tlv_data.parse_message_data(&tlv_blocks); + if (status != eap_status_ok) + { + EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); + return EAP_STATUS_RETURN(m_am_tools, status); + } + + for (u32_t ind = 0ul; ind < tlv_blocks.get_object_count(); ind++) + { + eap_tlv_header_c * const tlv = tlv_blocks.get_object(ind); + if (tlv != 0) + { + if (tlv->get_type() == eap_type_protected_setup_stored_preshared_key) + { + status = m_device_password.set_copy_of_buffer( + tlv->get_value(tlv->get_value_length()), + tlv->get_value_length()); + if (status != eap_status_ok) + { + EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); + return EAP_STATUS_RETURN(m_am_tools, status); + } + } + else if (tlv->get_type() == eap_type_protected_setup_stored_ssid) + { + status = m_SSID.set_copy_of_buffer( + tlv->get_value(tlv->get_value_length()), + tlv->get_value_length()); + if (status != eap_status_ok) + { + EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); + return EAP_STATUS_RETURN(m_am_tools, status); + } + } + } + } // for() + + if (m_device_password.get_is_valid_data() == false) + { + EAP_TRACE_ERROR( + m_am_tools, + TRACE_FLAGS_ERROR, + (EAPL("simple_config_record_c::complete_query_network_and_device_parameters(): cannot get WPS PIN\n"))); + EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); + return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter); + } + } + } if (local_completion_status == eap_status_ok)