EAP-GTC implementation started
This commit is contained in:
2
lib/GTC/build/.gitignore
vendored
Normal file
2
lib/GTC/build/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/temp
|
||||
/*.user
|
12
lib/GTC/build/GTC.props
Normal file
12
lib/GTC/build/GTC.props
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\..\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup />
|
||||
</Project>
|
104
lib/GTC/build/GTC.vcxproj
Normal file
104
lib/GTC/build/GTC.vcxproj
Normal file
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{114A70BB-8698-4A0C-8C90-58F22EDD8129}</ProjectGuid>
|
||||
<RootNamespace>GTC</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\include\Win32.props" />
|
||||
<Import Project="..\..\..\include\Debug.props" />
|
||||
<Import Project="GTC.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\include\x64.props" />
|
||||
<Import Project="..\..\..\include\Debug.props" />
|
||||
<Import Project="GTC.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\include\Win32.props" />
|
||||
<Import Project="..\..\..\include\Release.props" />
|
||||
<Import Project="GTC.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\include\x64.props" />
|
||||
<Import Project="..\..\..\include\Release.props" />
|
||||
<Import Project="GTC.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\Config.h" />
|
||||
<ClInclude Include="..\include\Method.h" />
|
||||
<ClInclude Include="..\src\StdAfx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\Config.cpp" />
|
||||
<ClCompile Include="..\src\Method.cpp" />
|
||||
<ClCompile Include="..\src\StdAfx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Events\build\Events.vcxproj">
|
||||
<Project>{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
35
lib/GTC/build/GTC.vcxproj.filters
Normal file
35
lib/GTC/build/GTC.vcxproj.filters
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\StdAfx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\Config.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\Method.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\StdAfx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Config.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Method.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
110
lib/GTC/include/Config.h
Normal file
110
lib/GTC/include/Config.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <sal.h>
|
||||
|
||||
namespace eap
|
||||
{
|
||||
class config_method_eapgtc;
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../EAPBase/include/Config.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <sal.h>
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
namespace eap
|
||||
{
|
||||
/// \addtogroup EAPBaseConfig
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// EAP-GTC configuration
|
||||
///
|
||||
class config_method_eapgtc : public config_method
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs configuration
|
||||
///
|
||||
/// \param[in] mod EAP module to use for global services
|
||||
/// \param[in] level Config level (0=outer, 1=inner, 2=inner-inner...)
|
||||
///
|
||||
config_method_eapgtc(_In_ module &mod, _In_ unsigned int level);
|
||||
|
||||
///
|
||||
/// Copies configuration
|
||||
///
|
||||
/// \param[in] other Configuration to copy from
|
||||
///
|
||||
config_method_eapgtc(_In_ const config_method_eapgtc &other);
|
||||
|
||||
///
|
||||
/// Moves configuration
|
||||
///
|
||||
/// \param[in] other Configuration to move from
|
||||
///
|
||||
config_method_eapgtc(_Inout_ config_method_eapgtc &&other);
|
||||
|
||||
///
|
||||
/// Copies configuration
|
||||
///
|
||||
/// \param[in] other Configuration to copy from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
config_method_eapgtc& operator=(_In_ const config_method_eapgtc &other);
|
||||
|
||||
///
|
||||
/// Moves configuration
|
||||
///
|
||||
/// \param[in] other Configuration to move from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
config_method_eapgtc& operator=(_Inout_ config_method_eapgtc &&other);
|
||||
|
||||
virtual config* clone() const;
|
||||
|
||||
///
|
||||
/// @copydoc eap::config_method::get_method_id()
|
||||
/// \returns This implementation always returns `winstd::eap_type_gtc`
|
||||
///
|
||||
virtual winstd::eap_type_t get_method_id() const;
|
||||
|
||||
///
|
||||
/// @copydoc eap::config_method::get_method_str()
|
||||
/// \returns This implementation always returns `L"EAP-GTC"`
|
||||
///
|
||||
virtual const wchar_t* get_method_str() const;
|
||||
|
||||
///
|
||||
/// @copydoc eap::config_method::make_credentials()
|
||||
/// \returns This implementation always returns `NULL`
|
||||
///
|
||||
virtual credentials* make_credentials() const;
|
||||
};
|
||||
|
||||
/// @}
|
||||
}
|
106
lib/GTC/include/Method.h
Normal file
106
lib/GTC/include/Method.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace eap
|
||||
{
|
||||
class method_gtc;
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include "../../EAPBase/include/Method.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
|
||||
namespace eap
|
||||
{
|
||||
/// \addtogroup EAPBaseMethod
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// GTC method
|
||||
///
|
||||
class method_gtc : public method
|
||||
{
|
||||
WINSTD_NONCOPYABLE(method_gtc)
|
||||
|
||||
public:
|
||||
///
|
||||
/// Constructs a GTC method
|
||||
///
|
||||
/// \param[in] mod GTC module to use for global services
|
||||
/// \param[in] cfg Method configuration
|
||||
///
|
||||
method_gtc(_In_ module &mod, _In_ config_method_eapgtc &cfg);
|
||||
|
||||
///
|
||||
/// Moves a GTC method
|
||||
///
|
||||
/// \param[in] other GTC method to move from
|
||||
///
|
||||
method_gtc(_Inout_ method_gtc &&other);
|
||||
|
||||
///
|
||||
/// Moves a GTC method
|
||||
///
|
||||
/// \param[in] other GTC method to move from
|
||||
///
|
||||
/// \returns Reference to this object
|
||||
///
|
||||
method_gtc& operator=(_Inout_ method_gtc &&other);
|
||||
|
||||
/// \name Session management
|
||||
/// @{
|
||||
|
||||
virtual void begin_session(
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ const EapAttributes *pAttributeArray,
|
||||
_In_ HANDLE hTokenImpersonateUser,
|
||||
_In_opt_ DWORD dwMaxSendPacketSize = MAXDWORD);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Packet processing
|
||||
/// @{
|
||||
|
||||
virtual EapPeerMethodResponseAction process_request_packet(
|
||||
_In_bytecount_(dwReceivedPacketSize) const void *pReceivedPacket,
|
||||
_In_ DWORD dwReceivedPacketSize);
|
||||
|
||||
virtual void get_response_packet(
|
||||
_Out_ sanitizing_blob &packet,
|
||||
_In_opt_ DWORD size_max = MAXDWORD);
|
||||
|
||||
/// @}
|
||||
|
||||
virtual void get_result(
|
||||
_In_ EapPeerMethodResultReason reason,
|
||||
_Out_ EapPeerMethodResult *pResult);
|
||||
|
||||
protected:
|
||||
config_method_eapgtc &m_cfg; ///< Method configuration
|
||||
sanitizing_blob m_packet_res; ///< Response packet
|
||||
};
|
||||
|
||||
/// @}
|
||||
}
|
87
lib/GTC/src/Config.cpp
Normal file
87
lib/GTC/src/Config.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::config_method_eapgtc
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::config_method_eapgtc::config_method_eapgtc(_In_ module &mod, _In_ unsigned int level) : config_method(mod, level)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config_method_eapgtc::config_method_eapgtc(_In_ const config_method_eapgtc &other) :
|
||||
config_method(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config_method_eapgtc::config_method_eapgtc(_Inout_ config_method_eapgtc &&other) :
|
||||
config_method(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::config_method_eapgtc& eap::config_method_eapgtc::operator=(_In_ const config_method_eapgtc &other)
|
||||
{
|
||||
if (this != &other)
|
||||
(config_method&)*this = other;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::config_method_eapgtc& eap::config_method_eapgtc::operator=(_Inout_ config_method_eapgtc &&other)
|
||||
{
|
||||
if (this != &other)
|
||||
(config_method&&)*this = std::move(other);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
eap::config* eap::config_method_eapgtc::clone() const
|
||||
{
|
||||
return new config_method_eapgtc(*this);
|
||||
}
|
||||
|
||||
|
||||
eap_type_t eap::config_method_eapgtc::get_method_id() const
|
||||
{
|
||||
return eap_type_gtc;
|
||||
}
|
||||
|
||||
|
||||
const wchar_t* eap::config_method_eapgtc::get_method_str() const
|
||||
{
|
||||
return L"EAP-GTC";
|
||||
}
|
||||
|
||||
|
||||
eap::credentials* eap::config_method_eapgtc::make_credentials() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
190
lib/GTC/src/Method.cpp
Normal file
190
lib/GTC/src/Method.cpp
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace winstd;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// eap::method_gtc
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::method_gtc::method_gtc(_In_ module &mod, _In_ config_method_eapgtc &cfg) :
|
||||
m_cfg(cfg),
|
||||
method(mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::method_gtc::method_gtc(_Inout_ method_gtc &&other) :
|
||||
m_cfg ( other.m_cfg ),
|
||||
m_packet_res(std::move(other.m_packet_res)),
|
||||
method (std::move(other ))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
eap::method_gtc& eap::method_gtc::operator=(_Inout_ method_gtc &&other)
|
||||
{
|
||||
if (this != std::addressof(other)) {
|
||||
assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move method within same configuration only!
|
||||
(method&)*this = std::move(other );
|
||||
m_packet_res = std::move(other.m_packet_res);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void eap::method_gtc::begin_session(
|
||||
_In_ DWORD dwFlags,
|
||||
_In_ const EapAttributes *pAttributeArray,
|
||||
_In_ HANDLE hTokenImpersonateUser,
|
||||
_In_opt_ DWORD dwMaxSendPacketSize)
|
||||
{
|
||||
method::begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, dwMaxSendPacketSize);
|
||||
|
||||
// Presume authentication will fail with generic protocol failure. (Pesimist!!!)
|
||||
// We will reset once we get get_result(Success) call.
|
||||
m_cfg.m_last_status = config_method::status_auth_failed;
|
||||
m_cfg.m_last_msg.clear();
|
||||
}
|
||||
|
||||
|
||||
EapPeerMethodResponseAction eap::method_gtc::process_request_packet(
|
||||
_In_bytecount_(dwReceivedPacketSize) const void *pReceivedPacket,
|
||||
_In_ DWORD dwReceivedPacketSize)
|
||||
{
|
||||
assert(pReceivedPacket || dwReceivedPacketSize == 0);
|
||||
|
||||
//for (const unsigned char *pck = reinterpret_cast<const unsigned char*>(pReceivedPacket), *pck_end = pck + dwReceivedPacketSize; pck < pck_end; ) {
|
||||
// if (pck + sizeof(chap_header) > pck_end)
|
||||
// throw win_runtime_error(EAP_E_EAPHOST_METHOD_INVALID_PACKET, __FUNCTION__ " Incomplete CHAP header.");
|
||||
// auto hdr = reinterpret_cast<const chap_header*>(pck);
|
||||
// unsigned short length = ntohs(*reinterpret_cast<const unsigned short*>(hdr->length));
|
||||
// const unsigned char
|
||||
// *msg = reinterpret_cast<const unsigned char*>(hdr + 1),
|
||||
// *msg_end = pck + length;
|
||||
// if (msg_end > pck_end)
|
||||
// throw win_runtime_error(EAP_E_EAPHOST_METHOD_INVALID_PACKET, __FUNCTION__ " Incomplete CHAP data.");
|
||||
|
||||
// // Save packet ident.
|
||||
// m_ident = hdr->ident;
|
||||
|
||||
// switch (hdr->code) {
|
||||
// case chap_packet_code_challenge: {
|
||||
// m_module.log_event(&EAPMETHOD_METHOD_HANDSHAKE_START2, event_data((unsigned int)eap_type_gtc), event_data::blank);
|
||||
|
||||
// if (msg + 1 > msg_end)
|
||||
// throw win_runtime_error(EAP_E_EAPHOST_METHOD_INVALID_PACKET, __FUNCTION__ " Incomplete CHAP challenge packet.");
|
||||
|
||||
// // Read server challenge.
|
||||
// if (msg + 1 + msg[0] > msg_end)
|
||||
// throw win_runtime_error(EAP_E_EAPHOST_METHOD_INVALID_PACKET, __FUNCTION__ " Incomplete CHAP server challenge.");
|
||||
// m_challenge_server.assign(msg + 1, msg + 1 + msg[0]);
|
||||
|
||||
// // Randomize Peer-Challenge.
|
||||
// m_challenge_client.randomize(m_cp);
|
||||
|
||||
// // Calculate NT-Response.
|
||||
// sanitizing_string identity_utf8;
|
||||
// WideCharToMultiByte(CP_UTF8, 0, m_cred.m_identity, identity_utf8, NULL, NULL);
|
||||
// m_nt_resp = nt_response(m_cp, m_challenge_server, m_challenge_client, identity_utf8.c_str(), m_cred.m_password.c_str());
|
||||
|
||||
// // Prepare CHAP response value.
|
||||
// sanitizing_blob value;
|
||||
// value.reserve(
|
||||
// sizeof(m_challenge_client) + // Peer-Challenge
|
||||
// 8 + // Reserved
|
||||
// sizeof(m_nt_resp) + // NT-Response
|
||||
// 1); // Flags
|
||||
// value.insert(value.end(), reinterpret_cast<const unsigned char*>(&m_challenge_client), reinterpret_cast<const unsigned char*>(&m_challenge_client + 1)); // Peer-Challenge
|
||||
// value.insert(value.end(), 8, 0); // Reserved (must be zero)
|
||||
// value.insert(value.end(), reinterpret_cast<const unsigned char*>(&m_nt_resp), reinterpret_cast<const unsigned char*>(&m_nt_resp + 1)); // NT-Response
|
||||
// value.push_back(0); // Flags
|
||||
|
||||
// chap_header hdr_resp;
|
||||
// hdr_resp.code = chap_packet_code_response;
|
||||
// hdr_resp.ident = m_ident;
|
||||
// size_t size_value = value.size();
|
||||
// *reinterpret_cast<unsigned short*>(hdr_resp.length) = htons((unsigned short)(sizeof(chap_header) + 1 + size_value + identity_utf8.length()));
|
||||
// assert(size_value <= 0xff); // CHAP value can be 255B max
|
||||
|
||||
// // Append response.
|
||||
// m_packet_res.assign(reinterpret_cast<const unsigned char*>(&hdr_resp), reinterpret_cast<const unsigned char*>(&hdr_resp + 1));
|
||||
// m_packet_res.insert(m_packet_res.end(), 1, (unsigned char)size_value);
|
||||
// m_packet_res.insert(m_packet_res.end(), value.begin(), value.end());
|
||||
// m_packet_res.insert(m_packet_res.end(), identity_utf8.begin(), identity_utf8.end());
|
||||
|
||||
// m_cfg.m_last_status = config_method::status_cred_invalid; // Blame credentials if we fail beyond this point.
|
||||
// return EapPeerMethodResponseActionSend;
|
||||
// }
|
||||
|
||||
// case chap_packet_code_success:
|
||||
// process_success(parse_response(reinterpret_cast<const char*>(msg), reinterpret_cast<const char*>(msg_end) - reinterpret_cast<const char*>(msg)));
|
||||
// if (m_cfg.m_last_status == config_method::status_success) {
|
||||
// // Acknowledge the authentication by sending a "3" (chap_packet_code_success).
|
||||
// m_packet_res.assign(1, chap_packet_code_success);
|
||||
// m_cfg.m_last_status = config_method::status_auth_failed; // Blame protocol if we fail beyond this point.
|
||||
// return EapPeerMethodResponseActionSend;
|
||||
// } else
|
||||
// return EapPeerMethodResponseActionDiscard;
|
||||
|
||||
// case chap_packet_code_failure:
|
||||
// process_error(parse_response(reinterpret_cast<const char*>(msg), reinterpret_cast<const char*>(msg_end) - reinterpret_cast<const char*>(msg)));
|
||||
// return EapPeerMethodResponseActionDiscard;
|
||||
// }
|
||||
|
||||
// pck = msg_end;
|
||||
//}
|
||||
|
||||
return EapPeerMethodResponseActionNone;
|
||||
}
|
||||
|
||||
|
||||
void eap::method_gtc::get_response_packet(
|
||||
_Out_ sanitizing_blob &packet,
|
||||
_In_opt_ DWORD size_max)
|
||||
{
|
||||
if (m_packet_res.size() > size_max)
|
||||
throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %u, maximum: %u).", m_packet_res.size(), size_max));
|
||||
|
||||
packet.assign(m_packet_res.begin(), m_packet_res.end());
|
||||
}
|
||||
|
||||
|
||||
void eap::method_gtc::get_result(
|
||||
_In_ EapPeerMethodResultReason reason,
|
||||
_Inout_ EapPeerMethodResult *pResult)
|
||||
{
|
||||
assert(pResult);
|
||||
|
||||
method::get_result(reason, pResult);
|
||||
|
||||
if (reason == EapPeerMethodResultSuccess)
|
||||
m_cfg.m_last_status = config_method::status_success;
|
||||
|
||||
// Always ask EAP host to save the connection data. And it will save it *only* when we report "success".
|
||||
// Don't worry. EapHost is well aware of failed authentication condition.
|
||||
pResult->fSaveConnectionData = TRUE;
|
||||
pResult->fIsSuccess = TRUE;
|
||||
}
|
21
lib/GTC/src/StdAfx.cpp
Normal file
21
lib/GTC/src/StdAfx.cpp
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
30
lib/GTC/src/StdAfx.h
Normal file
30
lib/GTC/src/StdAfx.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../include/Config.h"
|
||||
#include "../include/Method.h"
|
||||
|
||||
#include <WinStd/Hex.h>
|
||||
|
||||
#include <Windows.h>
|
||||
#include <EapHostError.h> // include after Windows.h
|
||||
#include <RasError.h>
|
Reference in New Issue
Block a user