diff --git a/lib/EAPBase/include/Config.h b/lib/EAPBase/include/Config.h index 7d79172..f753567 100644 --- a/lib/EAPBase/include/Config.h +++ b/lib/EAPBase/include/Config.h @@ -550,6 +550,7 @@ namespace eap /// @} public: + GUID m_connection_id; ///< Unique connection ID std::vector m_providers; ///< Array of provider configurations }; } diff --git a/lib/EAPBase/include/EAP.h b/lib/EAPBase/include/EAP.h index f1025e7..cf5c572 100644 --- a/lib/EAPBase/include/EAP.h +++ b/lib/EAPBase/include/EAP.h @@ -391,6 +391,31 @@ template inline size_t pksizeof(_In_ const eap::sanitizing_blob_f & /// template inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::sanitizing_blob_f &val); +/// +/// Packs a GUID +/// +/// \param[inout] cursor Memory cursor +/// \param[in] val Variable with data to pack +/// +inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const GUID &val); + +/// +/// Returns packed size of a GUID +/// +/// \param[in] val Data to pack +/// +/// \returns Size of data when packed (in bytes) +/// +inline size_t pksizeof(_In_ const GUID &val); + +/// +/// Unpacks a GUID +/// +/// \param[inout] cursor Memory cursor +/// \param[out] val Variable to receive unpacked value +/// +inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ GUID &val); + #ifndef htonll /// /// Convert host converts an unsigned __int64 from host to TCP/IP network byte order. @@ -975,6 +1000,31 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::sanitizing_blo } +inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const GUID &val) +{ + eap::cursor_out::ptr_type ptr_end = cursor.ptr + sizeof(GUID); + assert(ptr_end <= cursor.ptr_end); + memcpy(cursor.ptr, &val, sizeof(GUID)); + cursor.ptr = ptr_end; +} + + +inline size_t pksizeof(_In_ const GUID &val) +{ + UNREFERENCED_PARAMETER(val); + return sizeof(GUID); +} + + +inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ GUID &val) +{ + eap::cursor_in::ptr_type ptr_end = cursor.ptr + sizeof(GUID); + assert(ptr_end <= cursor.ptr_end); + memcpy(&val, cursor.ptr, sizeof(GUID)); + cursor.ptr = ptr_end; +} + + #ifndef htonll inline unsigned __int64 htonll(unsigned __int64 val) diff --git a/lib/EAPBase/src/Config.cpp b/lib/EAPBase/src/Config.cpp index fe6a27a..6ec145b 100644 --- a/lib/EAPBase/src/Config.cpp +++ b/lib/EAPBase/src/Config.cpp @@ -614,10 +614,12 @@ void eap::config_provider::operator>>(_Inout_ cursor_in &cursor) eap::config_provider_list::config_provider_list(_In_ module &mod) : config(mod) { + memset(&m_connection_id, 0, sizeof(m_connection_id)); } eap::config_provider_list::config_provider_list(_In_ const config_provider_list &other) : + m_connection_id(other.m_connection_id), m_providers(other.m_providers), config(other) { @@ -625,6 +627,7 @@ eap::config_provider_list::config_provider_list(_In_ const config_provider_list eap::config_provider_list::config_provider_list(_Inout_ config_provider_list &&other) : + m_connection_id(std::move(other.m_connection_id)), m_providers(std::move(other.m_providers)), config(std::move(other)) { @@ -634,8 +637,9 @@ eap::config_provider_list::config_provider_list(_Inout_ config_provider_list &&o eap::config_provider_list& eap::config_provider_list::operator=(_In_ const config_provider_list &other) { if (this != &other) { - (config&)*this = other; - m_providers = other.m_providers; + (config&)*this = other; + m_connection_id = other.m_connection_id; + m_providers = other.m_providers; } return *this; @@ -646,6 +650,7 @@ eap::config_provider_list& eap::config_provider_list::operator=(_Inout_ config_p { if (this != &other) { (config&&)*this = std::move(other); + m_connection_id = std::move(other.m_connection_id); m_providers = std::move(other.m_providers); } @@ -693,6 +698,9 @@ void eap::config_provider_list::load(_In_ IXMLDOMNode *pConfigRoot) config::load(pConfigRoot); + // On each configuration import reset ID. + CoCreateGuid(&m_connection_id); + // Iterate authentication providers (). com_obj pXmlListProviders; if (FAILED(hr = eapxml::select_nodes(pConfigRoot, bstr(L"eap-metadata:EAPIdentityProviderList/eap-metadata:EAPIdentityProvider"), &pXmlListProviders))) @@ -717,6 +725,7 @@ void eap::config_provider_list::load(_In_ IXMLDOMNode *pConfigRoot) void eap::config_provider_list::operator<<(_Inout_ cursor_out &cursor) const { config::operator<<(cursor); + cursor << m_connection_id; cursor << m_providers; } @@ -725,7 +734,8 @@ size_t eap::config_provider_list::get_pk_size() const { return config::get_pk_size() + - pksizeof(m_providers); + pksizeof(m_connection_id) + + pksizeof(m_providers ); } @@ -733,6 +743,8 @@ void eap::config_provider_list::operator>>(_Inout_ cursor_in &cursor) { config::operator>>(cursor); + cursor >> m_connection_id; + list::size_type count; cursor >> count; m_providers.clear(); diff --git a/lib/TTLS_UI/src/Module.cpp b/lib/TTLS_UI/src/Module.cpp index f63d230..a5942c6 100644 --- a/lib/TTLS_UI/src/Module.cpp +++ b/lib/TTLS_UI/src/Module.cpp @@ -88,6 +88,7 @@ void eap::peer_ttls_ui::invoke_config_ui( unpack(cfg, pConnectionDataIn, dwConnectionDataInSize); } else { // This is a blank network profile. Create default configuraton. + CoCreateGuid(&(cfg.m_connection_id)); // Start with PAP inner configuration. unique_ptr cfg_method(new config_method_ttls(*this));