diff --git a/EAPMethods/EAPTTLS/EAPTTLS.vcxproj b/EAPMethods/EAPTTLS/EAPTTLS.vcxproj
index 7b4d742..fc28fc8 100644
--- a/EAPMethods/EAPTTLS/EAPTTLS.vcxproj
+++ b/EAPMethods/EAPTTLS/EAPTTLS.vcxproj
@@ -100,6 +100,9 @@
{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}
+
+ {86a6d6a0-4b7d-4134-be81-a5755c77584d}
+
{36b0cf8a-7794-46c3-8099-825ba962b4c7}
diff --git a/EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj b/EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj
index e3714a1..2fc1565 100644
--- a/EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj
+++ b/EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj
@@ -103,6 +103,12 @@
{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}
+
+ {86a6d6a0-4b7d-4134-be81-a5755c77584d}
+
+
+ {7af5b922-7c17-428a-97e0-09e3b41a684d}
+
{36b0cf8a-7794-46c3-8099-825ba962b4c7}
diff --git a/VS10Solution.sln b/VS10Solution.sln
index 3f1a075..3e6fe99 100644
--- a/VS10Solution.sln
+++ b/VS10Solution.sln
@@ -46,6 +46,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxExtend", "lib\wxExtend\bu
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WLANManager", "WLANManager\WLANManager.vcxproj", "{BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MSCHAPv2", "lib\MSCHAPv2\build\MSCHAPv2.vcxproj", "{86A6D6A0-4B7D-4134-BE81-A5755C77584D}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MSCHAPv2_UI", "lib\MSCHAPv2_UI\build\MSCHAPv2_UI.vcxproj", "{7AF5B922-7C17-428A-97E0-09E3B41A684D}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -190,6 +194,22 @@ Global
{BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}.Release|Win32.Build.0 = Release|Win32
{BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}.Release|x64.ActiveCfg = Release|x64
{BFCAA3B4-97A9-4EA9-8FE1-F30280142BCC}.Release|x64.Build.0 = Release|x64
+ {86A6D6A0-4B7D-4134-BE81-A5755C77584D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {86A6D6A0-4B7D-4134-BE81-A5755C77584D}.Debug|Win32.Build.0 = Debug|Win32
+ {86A6D6A0-4B7D-4134-BE81-A5755C77584D}.Debug|x64.ActiveCfg = Debug|x64
+ {86A6D6A0-4B7D-4134-BE81-A5755C77584D}.Debug|x64.Build.0 = Debug|x64
+ {86A6D6A0-4B7D-4134-BE81-A5755C77584D}.Release|Win32.ActiveCfg = Release|Win32
+ {86A6D6A0-4B7D-4134-BE81-A5755C77584D}.Release|Win32.Build.0 = Release|Win32
+ {86A6D6A0-4B7D-4134-BE81-A5755C77584D}.Release|x64.ActiveCfg = Release|x64
+ {86A6D6A0-4B7D-4134-BE81-A5755C77584D}.Release|x64.Build.0 = Release|x64
+ {7AF5B922-7C17-428A-97E0-09E3B41A684D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {7AF5B922-7C17-428A-97E0-09E3B41A684D}.Debug|Win32.Build.0 = Debug|Win32
+ {7AF5B922-7C17-428A-97E0-09E3B41A684D}.Debug|x64.ActiveCfg = Debug|x64
+ {7AF5B922-7C17-428A-97E0-09E3B41A684D}.Debug|x64.Build.0 = Debug|x64
+ {7AF5B922-7C17-428A-97E0-09E3B41A684D}.Release|Win32.ActiveCfg = Release|Win32
+ {7AF5B922-7C17-428A-97E0-09E3B41A684D}.Release|Win32.Build.0 = Release|Win32
+ {7AF5B922-7C17-428A-97E0-09E3B41A684D}.Release|x64.ActiveCfg = Release|x64
+ {7AF5B922-7C17-428A-97E0-09E3B41A684D}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -208,6 +228,8 @@ Global
{9A25C261-8ADE-4938-8393-E857EF0E37E9} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
{42F0F0F4-C928-4860-A4E4-94991C2C3D90} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
{D3E29951-D9F5-486D-A167-20AE8E90B1FA} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
+ {86A6D6A0-4B7D-4134-BE81-A5755C77584D} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
+ {7AF5B922-7C17-428A-97E0-09E3B41A684D} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
{2D3CE079-7EB1-4F47-B79E-F0310671ECCB} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4}
{679D03C5-CD70-4FFA-93F8-A4AB3637509B} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4}
{E0D0725B-B2FC-4225-9481-CA9B1B6306F2} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4}
diff --git a/lib/Events/res/EventsETW.man b/lib/Events/res/EventsETW.man
index bc2469f..3cc4aa4 100644
Binary files a/lib/Events/res/EventsETW.man and b/lib/Events/res/EventsETW.man differ
diff --git a/lib/MSCHAPv2/build/.gitignore b/lib/MSCHAPv2/build/.gitignore
new file mode 100644
index 0000000..9c8716a
--- /dev/null
+++ b/lib/MSCHAPv2/build/.gitignore
@@ -0,0 +1,2 @@
+/temp
+/*.user
diff --git a/lib/MSCHAPv2/build/MSCHAPv2.props b/lib/MSCHAPv2/build/MSCHAPv2.props
new file mode 100644
index 0000000..4997b71
--- /dev/null
+++ b/lib/MSCHAPv2/build/MSCHAPv2.props
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+ ..\..\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\..\WinStd\include;%(AdditionalIncludeDirectories)
+
+
+
+
\ No newline at end of file
diff --git a/lib/MSCHAPv2/build/MSCHAPv2.vcxproj b/lib/MSCHAPv2/build/MSCHAPv2.vcxproj
new file mode 100644
index 0000000..4982661
--- /dev/null
+++ b/lib/MSCHAPv2/build/MSCHAPv2.vcxproj
@@ -0,0 +1,101 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {86A6D6A0-4B7D-4134-BE81-A5755C77584D}
+ MSCHAPv2
+
+
+
+ StaticLibrary
+ true
+ Unicode
+
+
+ StaticLibrary
+ true
+ Unicode
+
+
+ StaticLibrary
+ false
+ true
+ Unicode
+
+
+ StaticLibrary
+ false
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create
+ Create
+ Create
+ Create
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/MSCHAPv2/build/MSCHAPv2.vcxproj.filters b/lib/MSCHAPv2/build/MSCHAPv2.vcxproj.filters
new file mode 100644
index 0000000..8c96e75
--- /dev/null
+++ b/lib/MSCHAPv2/build/MSCHAPv2.vcxproj.filters
@@ -0,0 +1,41 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
\ No newline at end of file
diff --git a/lib/MSCHAPv2/include/Config.h b/lib/MSCHAPv2/include/Config.h
new file mode 100644
index 0000000..ff4c4ae
--- /dev/null
+++ b/lib/MSCHAPv2/include/Config.h
@@ -0,0 +1,109 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+#include
+
+namespace eap
+{
+ ///
+ /// MSCHAPv2 configuration
+ ///
+ class config_method_mschapv2;
+}
+
+#pragma once
+
+#include "Credentials.h"
+#include "../../EAPBase/include/Config.h"
+
+#include
+#include
+#include
+
+
+namespace eap
+{
+ class config_method_mschapv2 : public config_method_with_cred
+ {
+ public:
+ ///
+ /// Constructs configuration
+ ///
+ /// \param[in] mod EAP module to use for global services
+ ///
+ config_method_mschapv2(_In_ module &mod);
+
+ ///
+ /// Copies configuration
+ ///
+ /// \param[in] other Configuration to copy from
+ ///
+ config_method_mschapv2(_In_ const config_method_mschapv2 &other);
+
+ ///
+ /// Moves configuration
+ ///
+ /// \param[in] other Configuration to move from
+ ///
+ config_method_mschapv2(_Inout_ config_method_mschapv2 &&other);
+
+ ///
+ /// Copies configuration
+ ///
+ /// \param[in] other Configuration to copy from
+ ///
+ /// \returns Reference to this object
+ ///
+ config_method_mschapv2& operator=(_In_ const config_method_mschapv2 &other);
+
+ ///
+ /// Moves configuration
+ ///
+ /// \param[in] other Configuration to move from
+ ///
+ /// \returns Reference to this object
+ ///
+ config_method_mschapv2& operator=(_Inout_ config_method_mschapv2 &&other);
+
+ ///
+ /// Clones configuration
+ ///
+ /// \returns Pointer to cloned configuration
+ ///
+ virtual config* clone() const;
+
+ ///
+ /// Returns EAP method type of this configuration
+ ///
+ /// \returns `eap::type_mschapv2`
+ ///
+ virtual winstd::eap_type_t get_method_id() const;
+
+ ///
+ /// Returns a string \c L"MSCHAPv2"
+ ///
+ virtual const wchar_t* get_method_str() const;
+
+ ///
+ /// Creates a blank set of credentials suitable for this method
+ ///
+ virtual credentials* make_credentials() const;
+ };
+}
diff --git a/lib/MSCHAPv2/include/Credentials.h b/lib/MSCHAPv2/include/Credentials.h
new file mode 100644
index 0000000..7f1fbee
--- /dev/null
+++ b/lib/MSCHAPv2/include/Credentials.h
@@ -0,0 +1,122 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+namespace eap
+{
+ ///
+ /// MSCHAPv2 credentials
+ ///
+ class credentials_mschapv2;
+}
+
+#pragma once
+
+#include "Config.h"
+
+#include "../../EAPBase/include/Credentials.h"
+
+#include
+#include
+#include
+
+
+namespace eap
+{
+ class credentials_mschapv2 : public credentials_pass
+ {
+ public:
+ ///
+ /// Constructs credentials
+ ///
+ /// \param[in] mod EAP module to use for global services
+ ///
+ credentials_mschapv2(_In_ module &mod);
+
+ ///
+ /// Copies credentials
+ ///
+ /// \param[in] other Credentials to copy from
+ ///
+ credentials_mschapv2(_In_ const credentials_mschapv2 &other);
+
+ ///
+ /// Moves credentials
+ ///
+ /// \param[in] other Credentials to move from
+ ///
+ credentials_mschapv2(_Inout_ credentials_mschapv2 &&other);
+
+ ///
+ /// Copies credentials
+ ///
+ /// \param[in] other Credentials to copy from
+ ///
+ /// \returns Reference to this object
+ ///
+ credentials_mschapv2& operator=(_In_ const credentials_mschapv2 &other);
+
+ ///
+ /// Moves credentials
+ ///
+ /// \param[in] other Credentials to move from
+ ///
+ /// \returns Reference to this object
+ ///
+ credentials_mschapv2& operator=(_Inout_ credentials_mschapv2 &&other);
+
+ ///
+ /// Clones credentials
+ ///
+ /// \returns Pointer to cloned credentials
+ ///
+ virtual config* clone() const;
+
+ /// \name Storage
+ /// @{
+
+ ///
+ /// Return target suffix for Windows Credential Manager credential name
+ ///
+ virtual LPCTSTR target_suffix() const;
+
+ /// @}
+
+ ///
+ /// Combine credentials in the following order:
+ ///
+ /// 1. Cached credentials
+ /// 2. Pre-configured credentials
+ /// 3. Stored credentials
+ ///
+ /// \param[in] cred_cached Cached credentials (optional, can be \c NULL, must be credentials_mschapv2* type)
+ /// \param[in] cfg Method configuration (must be config_method_mschapv2 type)
+ /// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from (optional, can be \c NULL)
+ ///
+ /// \returns
+ /// - \c source_cache Credentials were obtained from EapHost cache
+ /// - \c source_preshared Credentials were set by method configuration
+ /// - \c source_storage Credentials were loaded from Windows Credential Manager
+ ///
+ virtual source_t combine(
+ _In_ const credentials *cred_cached,
+ _In_ const config_method_with_cred &cfg,
+ _In_opt_z_ LPCTSTR pszTargetName);
+ };
+}
diff --git a/lib/MSCHAPv2/include/Method.h b/lib/MSCHAPv2/include/Method.h
new file mode 100644
index 0000000..a3b7ec4
--- /dev/null
+++ b/lib/MSCHAPv2/include/Method.h
@@ -0,0 +1,112 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+namespace eap
+{
+ ///
+ /// MSCHAPv2 method
+ ///
+ class method_mschapv2;
+}
+
+
+#pragma once
+
+#include "Config.h"
+#include "Credentials.h"
+
+#include "../../EAPBase/include/Method.h"
+
+
+namespace eap
+{
+ class method_mschapv2 : public method
+ {
+ public:
+ ///
+ /// Constructs an EAP method
+ ///
+ /// \param[in] mod EAP module to use for global services
+ /// \param[in] cfg Method configuration
+ /// \param[in] cred User credentials
+ ///
+ method_mschapv2(_In_ module &module, _In_ config_method_mschapv2 &cfg, _In_ credentials_mschapv2 &cred);
+
+ ///
+ /// Moves an EAP method
+ ///
+ /// \param[in] other EAP method to move from
+ ///
+ method_mschapv2(_Inout_ method_mschapv2 &&other);
+
+ ///
+ /// Moves an EAP method
+ ///
+ /// \param[in] other EAP method to move from
+ ///
+ /// \returns Reference to this object
+ ///
+ method_mschapv2& operator=(_Inout_ method_mschapv2 &&other);
+
+ /// \name Packet processing
+ /// @{
+
+ ///
+ /// Processes a packet received by EapHost from a supplicant.
+ ///
+ /// \sa [EapPeerProcessRequestPacket function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363621.aspx)
+ ///
+ virtual void process_request_packet(
+ _In_bytecount_(dwReceivedPacketSize) const EapPacket *pReceivedPacket,
+ _In_ DWORD dwReceivedPacketSize,
+ _Inout_ EapPeerMethodOutput *pEapOutput);
+
+ ///
+ /// Obtains a response packet from the EAP method.
+ ///
+ /// \sa [EapPeerGetResponsePacket function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363610.aspx)
+ ///
+ virtual void get_response_packet(
+ _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket,
+ _Inout_ DWORD *pdwSendPacketSize);
+
+ ///
+ /// Obtains the result of an authentication session from the EAP method.
+ ///
+ /// \sa [EapPeerGetResult function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363611.aspx)
+ ///
+ virtual void get_result(
+ _In_ EapPeerMethodResultReason reason,
+ _Inout_ EapPeerMethodResult *ppResult);
+
+ /// @}
+
+ protected:
+ credentials_mschapv2 &m_cred; ///< EAP-TLS user credentials
+
+ packet m_packet_res; ///< Response packet
+
+ enum {
+ phase_unknown = -1, ///< Unknown phase
+ phase_init = 0, ///< Handshake initialize
+ phase_finished, ///< Connection shut down
+ } m_phase, m_phase_prev; ///< What phase is our communication at?
+ };
+}
diff --git a/lib/MSCHAPv2/src/Config.cpp b/lib/MSCHAPv2/src/Config.cpp
new file mode 100644
index 0000000..632fd37
--- /dev/null
+++ b/lib/MSCHAPv2/src/Config.cpp
@@ -0,0 +1,88 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+#include "StdAfx.h"
+
+using namespace std;
+using namespace winstd;
+
+
+//////////////////////////////////////////////////////////////////////
+// eap::config_method_mschapv2
+//////////////////////////////////////////////////////////////////////
+
+eap::config_method_mschapv2::config_method_mschapv2(_In_ module &mod) : config_method_with_cred(mod)
+{
+ m_preshared.reset(new credentials_mschapv2(mod));
+}
+
+
+eap::config_method_mschapv2::config_method_mschapv2(_In_ const config_method_mschapv2 &other) :
+ config_method_with_cred(other)
+{
+}
+
+
+eap::config_method_mschapv2::config_method_mschapv2(_Inout_ config_method_mschapv2 &&other) :
+ config_method_with_cred(std::move(other))
+{
+}
+
+
+eap::config_method_mschapv2& eap::config_method_mschapv2::operator=(_In_ const config_method_mschapv2 &other)
+{
+ if (this != &other)
+ (config_method_with_cred&)*this = other;
+
+ return *this;
+}
+
+
+eap::config_method_mschapv2& eap::config_method_mschapv2::operator=(_Inout_ config_method_mschapv2 &&other)
+{
+ if (this != &other)
+ (config_method_with_cred&&)*this = std::move(other);
+
+ return *this;
+}
+
+
+eap::config* eap::config_method_mschapv2::clone() const
+{
+ return new config_method_mschapv2(*this);
+}
+
+
+eap_type_t eap::config_method_mschapv2::get_method_id() const
+{
+ return eap_type_legacy_mschapv2;
+}
+
+
+const wchar_t* eap::config_method_mschapv2::get_method_str() const
+{
+ return L"MSCHAPv2";
+}
+
+
+eap::credentials* eap::config_method_mschapv2::make_credentials() const
+{
+ return new credentials_mschapv2(m_module);
+}
diff --git a/lib/MSCHAPv2/src/Credentials.cpp b/lib/MSCHAPv2/src/Credentials.cpp
new file mode 100644
index 0000000..6b4c0b4
--- /dev/null
+++ b/lib/MSCHAPv2/src/Credentials.cpp
@@ -0,0 +1,112 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+#include "StdAfx.h"
+
+using namespace std;
+using namespace winstd;
+
+
+//////////////////////////////////////////////////////////////////////
+// eap::credentials_mschapv2
+//////////////////////////////////////////////////////////////////////
+
+eap::credentials_mschapv2::credentials_mschapv2(_In_ module &mod) : credentials_pass(mod)
+{
+}
+
+
+eap::credentials_mschapv2::credentials_mschapv2(_In_ const credentials_mschapv2 &other) :
+ credentials_pass(other)
+{
+}
+
+
+eap::credentials_mschapv2::credentials_mschapv2(_Inout_ credentials_mschapv2 &&other) :
+ credentials_pass(std::move(other))
+{
+}
+
+
+eap::credentials_mschapv2& eap::credentials_mschapv2::operator=(_In_ const credentials_mschapv2 &other)
+{
+ if (this != &other)
+ (credentials_pass&)*this = other;
+
+ return *this;
+}
+
+
+eap::credentials_mschapv2& eap::credentials_mschapv2::operator=(_Inout_ credentials_mschapv2 &&other)
+{
+ if (this != &other)
+ (credentials_pass&&)*this = std::move(other);
+
+ return *this;
+}
+
+
+eap::config* eap::credentials_mschapv2::clone() const
+{
+ return new credentials_mschapv2(*this);
+}
+
+
+LPCTSTR eap::credentials_mschapv2::target_suffix() const
+{
+ return _T("MSCHAPv2");
+}
+
+
+eap::credentials::source_t eap::credentials_mschapv2::combine(
+ _In_ const credentials *cred_cached,
+ _In_ const config_method_with_cred &cfg,
+ _In_opt_z_ LPCTSTR pszTargetName)
+{
+ if (cred_cached) {
+ // Using EAP service cached credentials.
+ *this = *(credentials_mschapv2*)cred_cached;
+ m_module.log_event(&EAPMETHOD_TRACE_EVT_CRED_CACHED1, event_data((unsigned int)eap_type_legacy_mschapv2), event_data(credentials_mschapv2::get_name()), event_data::blank);
+ return source_cache;
+ }
+
+ if (cfg.m_use_preshared) {
+ // Using preshared credentials.
+ *this = *(credentials_mschapv2*)cfg.m_preshared.get();
+ m_module.log_event(&EAPMETHOD_TRACE_EVT_CRED_PRESHARED1, event_data((unsigned int)eap_type_legacy_mschapv2), event_data(credentials_mschapv2::get_name()), event_data::blank);
+ return source_preshared;
+ }
+
+ if (pszTargetName) {
+ try {
+ credentials_mschapv2 cred_loaded(m_module);
+ cred_loaded.retrieve(pszTargetName);
+
+ // Using stored credentials.
+ *this = std::move(cred_loaded);
+ m_module.log_event(&EAPMETHOD_TRACE_EVT_CRED_STORED1, event_data((unsigned int)eap_type_legacy_mschapv2), event_data(credentials_mschapv2::get_name()), event_data::blank);
+ return source_storage;
+ } catch (...) {
+ // Not actually an error.
+ }
+ }
+
+ return source_unknown;
+}
diff --git a/lib/MSCHAPv2/src/Method.cpp b/lib/MSCHAPv2/src/Method.cpp
new file mode 100644
index 0000000..fefe15c
--- /dev/null
+++ b/lib/MSCHAPv2/src/Method.cpp
@@ -0,0 +1,214 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+#include "StdAfx.h"
+
+using namespace std;
+using namespace winstd;
+
+
+//////////////////////////////////////////////////////////////////////
+// eap::method_mschapv2
+//////////////////////////////////////////////////////////////////////
+
+eap::method_mschapv2::method_mschapv2(_In_ module &module, _In_ config_method_mschapv2 &cfg, _In_ credentials_mschapv2 &cred) :
+ m_cred(cred),
+ m_phase(phase_unknown),
+ m_phase_prev(phase_unknown),
+ method(module, cfg, cred)
+{
+}
+
+
+eap::method_mschapv2::method_mschapv2(_Inout_ method_mschapv2 &&other) :
+ m_cred ( other.m_cred ),
+ m_packet_res(std::move(other.m_packet_res)),
+ m_phase (std::move(other.m_phase )),
+ m_phase_prev(std::move(other.m_phase_prev)),
+ method (std::move(other ))
+{
+}
+
+
+eap::method_mschapv2& eap::method_mschapv2::operator=(_Inout_ method_mschapv2 &&other)
+{
+ if (this != std::addressof(other)) {
+ assert(std::addressof(m_cred) == std::addressof(other.m_cred)); // Move method with same credentials only!
+ (method&)*this = std::move(other );
+ m_packet_res = std::move(other.m_packet_res);
+ m_phase = std::move(other.m_phase );
+ m_phase_prev = std::move(other.m_phase_prev);
+ }
+
+ return *this;
+}
+
+
+void eap::method_mschapv2::process_request_packet(
+ _In_bytecount_(dwReceivedPacketSize) const EapPacket *pReceivedPacket,
+ _In_ DWORD dwReceivedPacketSize,
+ _Inout_ EapPeerMethodOutput *pEapOutput)
+{
+ assert(pReceivedPacket && dwReceivedPacketSize >= 4);
+ assert(pEapOutput);
+
+ m_module.log_event(&EAPMETHOD_PACKET_RECV, event_data((unsigned int)eap_type_legacy_mschapv2), event_data((unsigned int)dwReceivedPacketSize - 4), event_data::blank);
+
+ if (pReceivedPacket->Id == 0) {
+ m_module.log_event(&EAPMETHOD_METHOD_HANDSHAKE_START2, event_data((unsigned int)eap_type_legacy_mschapv2), event_data::blank);
+ m_phase = phase_init;
+ }
+
+ m_phase_prev = m_phase;
+ switch (m_phase) {
+ case phase_init: {
+ // Convert username and password to UTF-8.
+ sanitizing_string identity_utf8, password_utf8;
+ WideCharToMultiByte(CP_UTF8, 0, m_cred.m_identity.c_str(), (int)m_cred.m_identity.length(), identity_utf8, NULL, NULL);
+ WideCharToMultiByte(CP_UTF8, 0, m_cred.m_password.c_str(), (int)m_cred.m_password.length(), password_utf8, NULL, NULL);
+
+ // PAP passwords must be padded to 16B boundary according to RFC 5281. Will not add random extra padding here, as length obfuscation should be done by outer transport layers.
+ size_t padding_password_ex = (16 - password_utf8.length()) % 16;
+ password_utf8.append(padding_password_ex, 0);
+
+ size_t
+ size_identity = identity_utf8.length(),
+ size_password = password_utf8.length(),
+ padding_identity = (4 - size_identity ) % 4,
+ padding_password = (4 - password_utf8.length()) % 4,
+ size_identity_outer,
+ size_password_outer;
+
+ m_packet_res.m_code = EapCodeResponse;
+ m_packet_res.m_id = pReceivedPacket->Id;
+ m_packet_res.m_data.clear();
+ m_packet_res.m_data.reserve(
+ (size_identity_outer =
+ sizeof(diameter_avp_header) + // Diameter header
+ size_identity) + // Identity
+ padding_identity + // Identity padding
+ (size_password_outer =
+ sizeof(diameter_avp_header) + // Diameter header
+ size_password) + // Password
+ padding_password); // Password padding
+
+ // Diameter AVP Code User-Name (0x00000001)
+ diameter_avp_header hdr;
+ *(unsigned int*)hdr.code = htonl(0x00000001);
+ hdr.flags = diameter_avp_flag_mandatory;
+ hton24((unsigned int)size_identity_outer, hdr.length);
+ m_packet_res.m_data.insert(m_packet_res.m_data.end(), (unsigned char*)&hdr, (unsigned char*)(&hdr + 1));
+
+ // Identity
+ m_packet_res.m_data.insert(m_packet_res.m_data.end(), identity_utf8.begin(), identity_utf8.end());
+ m_packet_res.m_data.insert(m_packet_res.m_data.end(), padding_identity, 0);
+
+ // Diameter AVP Code User-Password (0x00000002)
+ *(unsigned int*)hdr.code = htonl(0x00000002);
+ hton24((unsigned int)size_password_outer, hdr.length);
+ m_packet_res.m_data.insert(m_packet_res.m_data.end(), (unsigned char*)&hdr, (unsigned char*)(&hdr + 1));
+
+ // Password
+ m_packet_res.m_data.insert(m_packet_res.m_data.end(), password_utf8.begin(), password_utf8.end());
+ m_packet_res.m_data.insert(m_packet_res.m_data.end(), padding_password, 0);
+
+ m_phase = phase_finished;
+ break;
+ }
+
+ case phase_finished:
+ break;
+ }
+
+ pEapOutput->fAllowNotifications = TRUE;
+ pEapOutput->action = EapPeerMethodResponseActionSend;
+}
+
+
+void eap::method_mschapv2::get_response_packet(
+ _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket,
+ _Inout_ DWORD *pdwSendPacketSize)
+{
+ assert(pdwSendPacketSize);
+ assert(pSendPacket);
+
+ unsigned int
+ size_data = (unsigned int)m_packet_res.m_data.size(),
+ size_packet = size_data + 4;
+ unsigned short size_packet_limit = (unsigned short)std::min(*pdwSendPacketSize, USHRT_MAX);
+
+ // Not fragmented.
+ if (size_packet <= size_packet_limit) {
+ // No need to fragment the packet.
+ m_module.log_event(&EAPMETHOD_PACKET_SEND, event_data((unsigned int)eap_type_legacy_mschapv2), event_data((unsigned int)size_data), event_data::blank);
+ } else {
+ // But it should be fragmented.
+ throw com_runtime_error(TYPE_E_SIZETOOBIG, __FUNCTION__ " PAP message exceeds 64kB.");
+ }
+
+ pSendPacket->Code = (BYTE)m_packet_res.m_code;
+ pSendPacket->Id = m_packet_res.m_id;
+ *(unsigned short*)pSendPacket->Length = htons((unsigned short)size_packet);
+ memcpy(pSendPacket->Data, m_packet_res.m_data.data(), size_data);
+ m_packet_res.m_data.erase(m_packet_res.m_data.begin(), m_packet_res.m_data.begin() + size_data);
+ *pdwSendPacketSize = size_packet;
+}
+
+
+void eap::method_mschapv2::get_result(
+ _In_ EapPeerMethodResultReason reason,
+ _Inout_ EapPeerMethodResult *ppResult)
+{
+ assert(ppResult);
+
+ switch (reason) {
+ case EapPeerMethodResultSuccess: {
+ m_module.log_event(&EAPMETHOD_METHOD_SUCCESS, event_data((unsigned int)eap_type_legacy_mschapv2), event_data::blank);
+ m_cfg.m_auth_failed = false;
+
+ ppResult->fIsSuccess = TRUE;
+ ppResult->dwFailureReasonCode = ERROR_SUCCESS;
+
+ break;
+ }
+
+ case EapPeerMethodResultFailure:
+ m_module.log_event(
+ m_phase_prev < phase_finished ? &EAPMETHOD_METHOD_FAILURE_INIT : &EAPMETHOD_METHOD_FAILURE,
+ event_data((unsigned int)eap_type_legacy_mschapv2), event_data::blank);
+
+ // Mark credentials as failed, so GUI can re-prompt user.
+ // But be careful: do so only after credentials were actually tried.
+ m_cfg.m_auth_failed = m_phase == phase_finished;
+
+ // Do not report failure to EapHost, as it will not save updated configuration then. But we need it to save it, to alert user on next connection attempt.
+ // EapHost is well aware of the failed condition.
+ //ppResult->fIsSuccess = FALSE;
+ //ppResult->dwFailureReasonCode = EAP_E_AUTHENTICATION_FAILED;
+
+ break;
+
+ default:
+ throw win_runtime_error(ERROR_NOT_SUPPORTED, __FUNCTION__ " Not supported.");
+ }
+
+ // Always ask EAP host to save the connection data.
+ ppResult->fSaveConnectionData = TRUE;
+}
diff --git a/lib/MSCHAPv2/src/PAP.cpp b/lib/MSCHAPv2/src/PAP.cpp
new file mode 100644
index 0000000..0a362bf
--- /dev/null
+++ b/lib/MSCHAPv2/src/PAP.cpp
@@ -0,0 +1,60 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+#include "StdAfx.h"
+
+
+//////////////////////////////////////////////////////////////////////
+// eap::credentials_mschapv2
+//////////////////////////////////////////////////////////////////////
+
+eap::credentials_mschapv2::credentials_mschapv2(_In_ module &mod) : credentials_pass(mod)
+{
+}
+
+
+eap::credentials_mschapv2::credentials_mschapv2(_In_ const credentials_mschapv2 &other) :
+ credentials_pass(other)
+{
+}
+
+
+eap::credentials_mschapv2::credentials_mschapv2(_Inout_ credentials_mschapv2 &&other) :
+ credentials_pass(std::move(other))
+{
+}
+
+
+eap::credentials_mschapv2& eap::credentials_mschapv2::operator=(_In_ const credentials_mschapv2 &other)
+{
+ if (this != &other)
+ (credentials_pass&)*this = other;
+
+ return *this;
+}
+
+
+eap::credentials_mschapv2& eap::credentials_mschapv2::operator=(_Inout_ credentials_mschapv2 &&other)
+{
+ if (this != &other)
+ (credentials_pass&&)*this = std::move(other);
+
+ return *this;
+}
diff --git a/lib/MSCHAPv2/src/StdAfx.cpp b/lib/MSCHAPv2/src/StdAfx.cpp
new file mode 100644
index 0000000..4af5ec1
--- /dev/null
+++ b/lib/MSCHAPv2/src/StdAfx.cpp
@@ -0,0 +1,21 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+#include "StdAfx.h"
diff --git a/lib/MSCHAPv2/src/StdAfx.h b/lib/MSCHAPv2/src/StdAfx.h
new file mode 100644
index 0000000..cc1d372
--- /dev/null
+++ b/lib/MSCHAPv2/src/StdAfx.h
@@ -0,0 +1,28 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+#pragma once
+
+#include "../include/Config.h"
+#include "../include/Credentials.h"
+#include "../include/Method.h"
+
+#include
+#include // include after Windows.h
diff --git a/lib/MSCHAPv2_UI/build/.gitignore b/lib/MSCHAPv2_UI/build/.gitignore
new file mode 100644
index 0000000..9c8716a
--- /dev/null
+++ b/lib/MSCHAPv2_UI/build/.gitignore
@@ -0,0 +1,2 @@
+/temp
+/*.user
diff --git a/lib/MSCHAPv2_UI/build/MSCHAPv2_UI.props b/lib/MSCHAPv2_UI/build/MSCHAPv2_UI.props
new file mode 100644
index 0000000..4997b71
--- /dev/null
+++ b/lib/MSCHAPv2_UI/build/MSCHAPv2_UI.props
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+ ..\..\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\..\WinStd\include;%(AdditionalIncludeDirectories)
+
+
+
+
\ No newline at end of file
diff --git a/lib/MSCHAPv2_UI/build/MSCHAPv2_UI.vcxproj b/lib/MSCHAPv2_UI/build/MSCHAPv2_UI.vcxproj
new file mode 100644
index 0000000..987b75c
--- /dev/null
+++ b/lib/MSCHAPv2_UI/build/MSCHAPv2_UI.vcxproj
@@ -0,0 +1,102 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {7AF5B922-7C17-428A-97E0-09E3B41A684D}
+ MSCHAPv2_UI
+
+
+
+ StaticLibrary
+ true
+ Unicode
+
+
+ StaticLibrary
+ true
+ Unicode
+
+
+ StaticLibrary
+ false
+ true
+ Unicode
+
+
+ StaticLibrary
+ false
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create
+ Create
+ Create
+ Create
+
+
+
+
+ {d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/MSCHAPv2_UI/build/MSCHAPv2_UI.vcxproj.filters b/lib/MSCHAPv2_UI/build/MSCHAPv2_UI.vcxproj.filters
new file mode 100644
index 0000000..6975d39
--- /dev/null
+++ b/lib/MSCHAPv2_UI/build/MSCHAPv2_UI.vcxproj.filters
@@ -0,0 +1,33 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+
\ No newline at end of file
diff --git a/lib/MSCHAPv2_UI/include/MSCHAPv2_UI.h b/lib/MSCHAPv2_UI/include/MSCHAPv2_UI.h
new file mode 100644
index 0000000..16af1c1
--- /dev/null
+++ b/lib/MSCHAPv2_UI/include/MSCHAPv2_UI.h
@@ -0,0 +1,68 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+#include "../../EAPBase_UI/include/EAP_UI.h"
+#include "../../MSCHAPv2/include/Config.h"
+#include "../../MSCHAPv2/include/Credentials.h"
+
+///
+/// MSCHAPv2 credential configuration panel
+///
+typedef wxEAPCredentialsConfigPanel > wxMSCHAPv2CredentialsConfigPanel;
+
+///
+/// MSCHAPv2 configuration panel
+///
+class wxMSCHAPv2ConfigPanel;
+
+///
+/// MSCHAPv2 credential entry panel
+///
+typedef wxPasswordCredentialsPanel wxMSCHAPv2CredentialsPanel;
+
+#pragma once
+
+#include
+#include
+
+#include
+
+
+class wxMSCHAPv2ConfigPanel : public wxPanel
+{
+public:
+ ///
+ /// Constructs a configuration panel
+ ///
+ wxMSCHAPv2ConfigPanel(const eap::config_provider &prov, eap::config_method_mschapv2 &cfg, LPCTSTR pszCredTarget, wxWindow* parent);
+
+ ///
+ /// Destructs the configuration panel
+ ///
+ virtual ~wxMSCHAPv2ConfigPanel();
+
+protected:
+ /// \cond internal
+ virtual void OnInitDialog(wxInitDialogEvent& event);
+ /// \endcond
+
+protected:
+ wxMSCHAPv2CredentialsConfigPanel *m_credentials; ///< Credentials configuration panel
+};
diff --git a/lib/MSCHAPv2_UI/src/MSCHAPv2_UI.cpp b/lib/MSCHAPv2_UI/src/MSCHAPv2_UI.cpp
new file mode 100644
index 0000000..c45d225
--- /dev/null
+++ b/lib/MSCHAPv2_UI/src/MSCHAPv2_UI.cpp
@@ -0,0 +1,56 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+#include "StdAfx.h"
+
+
+//////////////////////////////////////////////////////////////////////
+// wxMSCHAPv2ConfigPanel
+//////////////////////////////////////////////////////////////////////
+
+wxMSCHAPv2ConfigPanel::wxMSCHAPv2ConfigPanel(const eap::config_provider &prov, eap::config_method_mschapv2 &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : wxPanel(parent)
+{
+ wxBoxSizer* sb_content;
+ sb_content = new wxBoxSizer( wxVERTICAL );
+
+ m_credentials = new wxMSCHAPv2CredentialsConfigPanel(prov, cfg, pszCredTarget, this);
+ sb_content->Add(m_credentials, 0, wxEXPAND, 5);
+
+ this->SetSizer(sb_content);
+ this->Layout();
+
+ // Connect Events
+ this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxMSCHAPv2ConfigPanel::OnInitDialog));
+}
+
+
+wxMSCHAPv2ConfigPanel::~wxMSCHAPv2ConfigPanel()
+{
+ // Disconnect Events
+ this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxMSCHAPv2ConfigPanel::OnInitDialog));
+}
+
+
+void wxMSCHAPv2ConfigPanel::OnInitDialog(wxInitDialogEvent& event)
+{
+ // Forward the event to child panels.
+ if (m_credentials)
+ m_credentials->GetEventHandler()->ProcessEvent(event);
+}
diff --git a/lib/MSCHAPv2_UI/src/StdAfx.cpp b/lib/MSCHAPv2_UI/src/StdAfx.cpp
new file mode 100644
index 0000000..4af5ec1
--- /dev/null
+++ b/lib/MSCHAPv2_UI/src/StdAfx.cpp
@@ -0,0 +1,21 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+#include "StdAfx.h"
diff --git a/lib/MSCHAPv2_UI/src/StdAfx.h b/lib/MSCHAPv2_UI/src/StdAfx.h
new file mode 100644
index 0000000..02cd321
--- /dev/null
+++ b/lib/MSCHAPv2_UI/src/StdAfx.h
@@ -0,0 +1,25 @@
+/*
+ Copyright 2015-2016 Amebis
+ Copyright 2016 GÉANT
+
+ This file is part of GÉANTLink.
+
+ GÉANTLink is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GÉANTLink is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GÉANTLink. If not, see .
+*/
+
+#pragma once
+
+#define _CRT_SECURE_NO_WARNINGS // Prevent warnings from wxWidgets headers
+
+#include "../include/MSCHAPv2_UI.h"
diff --git a/lib/TTLS/src/Config.cpp b/lib/TTLS/src/Config.cpp
index 21f1ed1..1e7b168 100644
--- a/lib/TTLS/src/Config.cpp
+++ b/lib/TTLS/src/Config.cpp
@@ -265,19 +265,21 @@ eap::credentials* eap::config_method_ttls::make_credentials() const
eap::config_method_with_cred* eap::config_method_ttls::make_config_method(_In_ winstd::eap_type_t eap_type) const
{
switch (eap_type) {
- case eap_type_tls : return new config_method_tls (m_module);
- case eap_type_ttls: return new config_method_ttls(m_module);
- case eap_type_pap : return new config_method_pap (m_module);
- default : throw invalid_argument(__FUNCTION__ " Unsupported inner authentication method.");
+ case eap_type_tls : return new config_method_tls (m_module);
+ case eap_type_ttls : return new config_method_ttls (m_module);
+ case eap_type_legacy_pap : return new config_method_pap (m_module);
+ case eap_type_legacy_mschapv2: return new config_method_mschapv2(m_module);
+ default : throw invalid_argument(__FUNCTION__ " Unsupported inner authentication method.");
}
}
eap::config_method_with_cred* eap::config_method_ttls::make_config_method(_In_ const wchar_t *eap_type) const
{
- if (_wcsicmp(eap_type, L"EAP-TLS" ) == 0) return new config_method_tls (m_module);
- else if (_wcsicmp(eap_type, L"EAP-TTLS") == 0) return new config_method_ttls(m_module);
- else if (_wcsicmp(eap_type, L"PAP" ) == 0) return new config_method_pap (m_module);
+ if (_wcsicmp(eap_type, L"EAP-TLS" ) == 0) return new config_method_tls (m_module);
+ else if (_wcsicmp(eap_type, L"EAP-TTLS") == 0) return new config_method_ttls (m_module);
+ else if (_wcsicmp(eap_type, L"PAP" ) == 0) return new config_method_pap (m_module);
+ else if (_wcsicmp(eap_type, L"MSCHAPv2") == 0) return new config_method_mschapv2(m_module);
else throw invalid_argument(__FUNCTION__ " Unsupported inner authentication method.");
}
diff --git a/lib/TTLS/src/Method.cpp b/lib/TTLS/src/Method.cpp
index 2ac733e..e822003 100644
--- a/lib/TTLS/src/Method.cpp
+++ b/lib/TTLS/src/Method.cpp
@@ -75,8 +75,9 @@ void eap::method_ttls::begin_session(
// Initialize inner method.
switch (m_cfg.m_inner->get_method_id()) {
- case eap_type_pap: m_inner.reset(new method_pap(m_module, (config_method_pap&)*m_cfg.m_inner, (credentials_pap&)*m_cred.m_inner.get()));
- default: invalid_argument(__FUNCTION__ " Unsupported inner authentication method.");
+ case eap_type_legacy_pap : m_inner.reset(new method_pap (m_module, (config_method_pap &)*m_cfg.m_inner, (credentials_pap &)*m_cred.m_inner.get())); break;
+ case eap_type_legacy_mschapv2: m_inner.reset(new method_mschapv2(m_module, (config_method_mschapv2&)*m_cfg.m_inner, (credentials_mschapv2&)*m_cred.m_inner.get())); break;
+ default: throw invalid_argument(__FUNCTION__ " Unsupported inner authentication method.");
}
m_inner->begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, m_size_inner_packet_max = dwMaxSendPacketSize); // TODO: Maximum inner packet size should have subtracted TLS overhead
m_inner_packet_id = 0;
diff --git a/lib/TTLS/src/StdAfx.h b/lib/TTLS/src/StdAfx.h
index 57b1ef2..e030902 100644
--- a/lib/TTLS/src/StdAfx.h
+++ b/lib/TTLS/src/StdAfx.h
@@ -30,6 +30,10 @@
#include "../../PAP/include/Credentials.h"
#include "../../PAP/include/Method.h"
+#include "../../MSCHAPv2/include/Config.h"
+#include "../../MSCHAPv2/include/Credentials.h"
+#include "../../MSCHAPv2/include/Method.h"
+
#include "../../EAPBase/include/EAPXML.h"
#include
diff --git a/lib/TTLS_UI/include/TTLS_UI.h b/lib/TTLS_UI/include/TTLS_UI.h
index b51f66d..b9927e0 100644
--- a/lib/TTLS_UI/include/TTLS_UI.h
+++ b/lib/TTLS_UI/include/TTLS_UI.h
@@ -41,6 +41,7 @@ class wxTTLSCredentialsPanel;
#include "../../TTLS/include/Config.h"
#include "../../PAP/include/Config.h"
+#include "../../MSCHAPv2/include/Config.h"
#include
@@ -107,7 +108,8 @@ protected:
wxChoicebook *m_inner_type; ///< Inner authentication type
// Temporary inner method configurations to hold data until applied
- eap::config_method_pap m_cfg_pap; ///< PAP configuration
+ eap::config_method_pap m_cfg_pap; ///< PAP configuration
+ eap::config_method_mschapv2 m_cfg_mschapv2; ///< MSCHAPv2 configuration
};
diff --git a/lib/TTLS_UI/src/StdAfx.h b/lib/TTLS_UI/src/StdAfx.h
index 595d5e8..bb9941f 100644
--- a/lib/TTLS_UI/src/StdAfx.h
+++ b/lib/TTLS_UI/src/StdAfx.h
@@ -26,6 +26,7 @@
#include "../include/TTLS_UI.h"
#include "../../PAP_UI/include/PAP_UI.h"
+#include "../../MSCHAPv2_UI/include/MSCHAPv2_UI.h"
#include
#include
diff --git a/lib/TTLS_UI/src/TTLS_UI.cpp b/lib/TTLS_UI/src/TTLS_UI.cpp
index 3c7cf58..55567ca 100644
--- a/lib/TTLS_UI/src/TTLS_UI.cpp
+++ b/lib/TTLS_UI/src/TTLS_UI.cpp
@@ -96,6 +96,7 @@ void wxTTLSConfigPanel::OnUpdateUI(wxUpdateUIEvent& /*event*/)
wxTTLSConfigWindow::wxTTLSConfigWindow(eap::config_provider &prov, eap::config_method &cfg, LPCTSTR pszCredTarget, wxWindow* parent) :
m_cfg((eap::config_method_ttls&)cfg),
m_cfg_pap(cfg.m_module),
+ m_cfg_mschapv2(cfg.m_module),
wxEAPConfigWindow(prov, cfg, parent)
{
wxBoxSizer* sb_content;
@@ -113,6 +114,8 @@ wxTTLSConfigWindow::wxTTLSConfigWindow(eap::config_provider &prov, eap::config_m
m_inner_type->SetToolTip( _("Select inner authentication method from the list") );
wxPAPConfigPanel *panel_pap = new wxPAPConfigPanel(m_prov, m_cfg_pap, pszCredTarget, m_inner_type);
m_inner_type->AddPage(panel_pap, _("PAP"));
+ wxMSCHAPv2ConfigPanel *panel_mschapv2 = new wxMSCHAPv2ConfigPanel(m_prov, m_cfg_mschapv2, pszCredTarget, m_inner_type);
+ m_inner_type->AddPage(panel_mschapv2, _("MSCHAPv2"));
sb_content->Add(m_inner_type, 0, wxALL|wxEXPAND, 5);
sb_content->Add(20, 20, 1, wxALL|wxEXPAND, 5);
@@ -154,12 +157,20 @@ wxTTLSConfigWindow::~wxTTLSConfigWindow()
bool wxTTLSConfigWindow::TransferDataToWindow()
{
- eap::config_method_pap *cfg_pap = dynamic_cast(m_cfg.m_inner.get());
- if (cfg_pap) {
- m_cfg_pap = *cfg_pap;
+ switch (m_cfg.m_inner->get_method_id()) {
+ case winstd::eap_type_legacy_pap:
+ m_cfg_pap = *(eap::config_method_pap*)m_cfg.m_inner.get();
m_inner_type->SetSelection(0); // 0=PAP
- } else
+ break;
+
+ case winstd::eap_type_legacy_mschapv2:
+ m_cfg_mschapv2 = *(eap::config_method_mschapv2*)m_cfg.m_inner.get();
+ m_inner_type->SetSelection(1); // 1=MSCHAPv2
+ break;
+
+ default:
wxFAIL_MSG(wxT("Unsupported inner authentication method type."));
+ }
// Do not invoke inherited TransferDataToWindow(), as it will call others TransferDataToWindow().
// This will handle wxTTLSConfigWindow::OnInitDialog() via wxEVT_INIT_DIALOG forwarding.
@@ -178,6 +189,10 @@ bool wxTTLSConfigWindow::TransferDataFromWindow()
m_cfg.m_inner.reset(new eap::config_method_pap(m_cfg_pap));
break;
+ case 1: // 1=MSCHAPv2
+ m_cfg.m_inner.reset(new eap::config_method_mschapv2(m_cfg_mschapv2));
+ break;
+
default:
wxFAIL_MSG(wxT("Unsupported inner authentication method type."));
}