From cf7ca9c8e93d31f4b2e816bad6edb9d2cf0717c5 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 10 Jun 2016 07:01:42 +0200 Subject: [PATCH] EAP modules divided to libraries --- .gitignore | 1 + CredWrite/CredWrite.props | 3 +- CredWrite/CredWrite.rc | Bin 5912 -> 5904 bytes CredWrite/CredWrite.vcxproj | 10 +- CredWrite/CredWrite.vcxproj.filters | 6 - CredWrite/Main.cpp | 4 +- CredWrite/StdAfx.h | 27 +- EAPMethods/Doxyfile => Doxyfile | 16 +- EAPMethods/.gitignore | 1 - .../EAPMethodEvents/EAPMethodEvents.props | 11 - EAPMethods/EAPTTLS/EAPTTLS.rc | Bin 5206 -> 5200 bytes EAPMethods/EAPTTLS/EAPTTLS.vcxproj | 28 +- EAPMethods/EAPTTLS/EAPTTLS.vcxproj.filters | 30 - EAPMethods/EAPTTLS/StdAfx.h | 30 +- EAPMethods/EAPTTLSUI/EAPTTLSUI.rc | Bin 6364 -> 6400 bytes EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj | 56 +- .../EAPTTLSUI/EAPTTLSUI.vcxproj.filters | 87 - EAPMethods/EAPTTLSUI/StdAfx.h | 44 +- EAPMethods/MSIBuild/Makefile | Bin 19382 -> 17930 bytes EAPMethods/build/Common.props | 5 +- EAPMethods/include/EAP.h | 1583 ----------------- EAPMethods/include/TTLS.h | 405 ----- EAPMethods/locale/EAPMethods.pot | 235 +-- EAPMethods/src/EAP.cpp | 727 -------- EAPMethods/src/Main_UI.cpp | 2 + EAPMethods/src/TTLS.cpp | 375 ---- VS10Solution.sln | 92 +- include/MSIBuildCfg.mak | Bin 8428 -> 8546 bytes .../EAPBase/build}/.gitignore | 0 lib/EAPBase/build/EAPBase.props | 12 + lib/EAPBase/build/EAPBase.vcxproj | 111 ++ lib/EAPBase/build/EAPBase.vcxproj.filters | 56 + lib/EAPBase/include/Config.h | 850 +++++++++ .../EAPBase/include/Credentials.h | 285 +-- lib/EAPBase/include/EAP.h | 52 + .../EAPBase}/include/EAPSerial.h | 242 +-- {EAPMethods => lib/EAPBase}/include/EAPXML.h | 12 +- lib/EAPBase/include/Module.h | 313 ++++ lib/EAPBase/include/Session.h | 164 ++ lib/EAPBase/src/Config.cpp | 168 ++ lib/EAPBase/src/Credentials.cpp | 355 ++++ lib/EAPBase/src/Module.cpp | 123 ++ lib/EAPBase/src/Session.cpp | 156 ++ lib/EAPBase/src/StdAfx.cpp | 21 + lib/EAPBase/src/StdAfx.h | 35 + lib/EAPBase_UI/build/.gitignore | 2 + lib/EAPBase_UI/build/EAPBase_UI.props | 12 + lib/EAPBase_UI/build/EAPBase_UI.vcxproj | 108 ++ .../build/EAPBase_UI.vcxproj.filters | 47 + .../EAPBase_UI}/include/EAP_UI.h | 155 +- lib/EAPBase_UI/include/Module.h | 109 ++ .../EAPBase_UI}/res/wxEAP_UI.cpp | 0 .../EAPBase_UI}/res/wxEAP_UI.fbp | 0 {EAPMethods => lib/EAPBase_UI}/res/wxEAP_UI.h | 0 {EAPMethods => lib/EAPBase_UI}/src/EAP_UI.cpp | 2 +- lib/EAPBase_UI/src/StdAfx.cpp | 21 + lib/EAPBase_UI/src/StdAfx.h | 26 + lib/Events/MSIBuild/.gitignore | 9 + lib/Events/MSIBuild/Makefile | Bin 0 -> 6888 bytes lib/Events/build/.gitignore | 2 + .../Events/build/Events.filters | 4 +- lib/Events/build/Events.props | 16 + .../Events/build/Events.rc | Bin 4974 -> 4968 bytes .../Events/build/Events.vcxproj | 38 +- .../Events/res/EventsETW.man | Bin 9588 -> 9552 bytes lib/PAP/build/.gitignore | 2 + lib/PAP/build/PAP.props | 12 + lib/PAP/build/PAP.vcxproj | 99 ++ lib/PAP/build/PAP.vcxproj.filters | 35 + .../include/PAP.h => lib/PAP/include/Config.h | 80 +- lib/PAP/include/Credentials.h | 102 ++ lib/PAP/src/Config.cpp | 62 + lib/PAP/src/Credentials.cpp | 60 + {EAPMethods => lib/PAP}/src/PAP.cpp | 41 +- lib/PAP/src/StdAfx.cpp | 21 + lib/PAP/src/StdAfx.h | 24 + lib/PAP_UI/build/.gitignore | 2 + lib/PAP_UI/build/PAP_UI.props | 12 + lib/PAP_UI/build/PAP_UI.vcxproj | 102 ++ lib/PAP_UI/build/PAP_UI.vcxproj.filters | 33 + {EAPMethods => lib/PAP_UI}/include/PAP_UI.h | 19 +- {EAPMethods => lib/PAP_UI}/src/PAP_UI.cpp | 2 +- lib/PAP_UI/src/StdAfx.cpp | 21 + lib/PAP_UI/src/StdAfx.h | 25 + lib/TLS/build/.gitignore | 2 + lib/TLS/build/TLS.props | 12 + lib/TLS/build/TLS.vcxproj | 99 ++ lib/TLS/build/TLS.vcxproj.filters | 35 + lib/TLS/include/Config.h | 198 +++ lib/TLS/include/Credentials.h | 207 +++ .../src/TLS.cpp => lib/TLS/src/Config.cpp | 130 +- lib/TLS/src/Credentials.cpp | 152 ++ lib/TLS/src/StdAfx.cpp | 21 + lib/TLS/src/StdAfx.h | 28 + lib/TLS_UI/build/.gitignore | 2 + lib/TLS_UI/build/TLS_UI.props | 12 + lib/TLS_UI/build/TLS_UI.vcxproj | 107 ++ lib/TLS_UI/build/TLS_UI.vcxproj.filters | 44 + {EAPMethods => lib/TLS_UI}/include/TLS_UI.h | 87 +- {EAPMethods => lib/TLS_UI}/res/wxTLS_UI.cpp | 0 {EAPMethods => lib/TLS_UI}/res/wxTLS_UI.fbp | 0 {EAPMethods => lib/TLS_UI}/res/wxTLS_UI.h | 0 lib/TLS_UI/src/StdAfx.cpp | 21 + lib/TLS_UI/src/StdAfx.h | 32 + {EAPMethods => lib/TLS_UI}/src/TLS_UI.cpp | 3 +- lib/TTLS/build/.gitignore | 2 + lib/TTLS/build/TTLS.props | 12 + lib/TTLS/build/TTLS.vcxproj | 108 ++ lib/TTLS/build/TTLS.vcxproj.filters | 47 + lib/TTLS/include/Config.h | 216 +++ lib/TTLS/include/Credentials.h | 144 ++ lib/TTLS/include/Module.h | 94 + lib/TTLS/include/Session.h | 44 + lib/TTLS/src/Config.cpp | 149 ++ lib/TTLS/src/Credentials.cpp | 146 ++ lib/TTLS/src/Module.cpp | 116 ++ lib/TTLS/src/Session.cpp | 33 + lib/TTLS/src/StdAfx.cpp | 21 + lib/TTLS/src/StdAfx.h | 28 + lib/TTLS_UI/build/.gitignore | 2 + lib/TTLS_UI/build/TTLS_UI.props | 12 + lib/TTLS_UI/build/TTLS_UI.vcxproj | 109 ++ lib/TTLS_UI/build/TTLS_UI.vcxproj.filters | 50 + .../TTLS_UI.h => lib/TTLS_UI/include/Module.h | 87 +- lib/TTLS_UI/include/TTLS_UI.h | 104 ++ {EAPMethods => lib/TTLS_UI}/res/wxTTLS_UI.cpp | 0 {EAPMethods => lib/TTLS_UI}/res/wxTTLS_UI.fbp | 0 {EAPMethods => lib/TTLS_UI}/res/wxTTLS_UI.h | 0 lib/TTLS_UI/src/Module.cpp | 101 ++ lib/TTLS_UI/src/StdAfx.cpp | 21 + lib/TTLS_UI/src/StdAfx.h | 30 + {EAPMethods => lib/TTLS_UI}/src/TTLS_UI.cpp | 82 +- lib/WinStd | 2 +- output/Setup/.gitignore | 2 + 134 files changed, 6712 insertions(+), 4280 deletions(-) rename EAPMethods/Doxyfile => Doxyfile (97%) delete mode 100644 EAPMethods/.gitignore delete mode 100644 EAPMethods/EAPMethodEvents/EAPMethodEvents.props delete mode 100644 EAPMethods/include/EAP.h delete mode 100644 EAPMethods/include/TTLS.h delete mode 100644 EAPMethods/src/EAP.cpp delete mode 100644 EAPMethods/src/TTLS.cpp rename {EAPMethods/EAPMethodEvents => lib/EAPBase/build}/.gitignore (100%) create mode 100644 lib/EAPBase/build/EAPBase.props create mode 100644 lib/EAPBase/build/EAPBase.vcxproj create mode 100644 lib/EAPBase/build/EAPBase.vcxproj.filters create mode 100644 lib/EAPBase/include/Config.h rename EAPMethods/include/TLS.h => lib/EAPBase/include/Credentials.h (55%) create mode 100644 lib/EAPBase/include/EAP.h rename {EAPMethods => lib/EAPBase}/include/EAPSerial.h (96%) rename {EAPMethods => lib/EAPBase}/include/EAPXML.h (97%) create mode 100644 lib/EAPBase/include/Module.h create mode 100644 lib/EAPBase/include/Session.h create mode 100644 lib/EAPBase/src/Config.cpp create mode 100644 lib/EAPBase/src/Credentials.cpp create mode 100644 lib/EAPBase/src/Module.cpp create mode 100644 lib/EAPBase/src/Session.cpp create mode 100644 lib/EAPBase/src/StdAfx.cpp create mode 100644 lib/EAPBase/src/StdAfx.h create mode 100644 lib/EAPBase_UI/build/.gitignore create mode 100644 lib/EAPBase_UI/build/EAPBase_UI.props create mode 100644 lib/EAPBase_UI/build/EAPBase_UI.vcxproj create mode 100644 lib/EAPBase_UI/build/EAPBase_UI.vcxproj.filters rename {EAPMethods => lib/EAPBase_UI}/include/EAP_UI.h (73%) create mode 100644 lib/EAPBase_UI/include/Module.h rename {EAPMethods => lib/EAPBase_UI}/res/wxEAP_UI.cpp (100%) rename {EAPMethods => lib/EAPBase_UI}/res/wxEAP_UI.fbp (100%) rename {EAPMethods => lib/EAPBase_UI}/res/wxEAP_UI.h (100%) rename {EAPMethods => lib/EAPBase_UI}/src/EAP_UI.cpp (96%) create mode 100644 lib/EAPBase_UI/src/StdAfx.cpp create mode 100644 lib/EAPBase_UI/src/StdAfx.h create mode 100644 lib/Events/MSIBuild/.gitignore create mode 100644 lib/Events/MSIBuild/Makefile create mode 100644 lib/Events/build/.gitignore rename EAPMethods/EAPMethodEvents/EAPMethodEvents.vcxproj.filters => lib/Events/build/Events.filters (88%) create mode 100644 lib/Events/build/Events.props rename EAPMethods/EAPMethodEvents/EAPMethodEvents.rc => lib/Events/build/Events.rc (97%) rename EAPMethods/EAPMethodEvents/EAPMethodEvents.vcxproj => lib/Events/build/Events.vcxproj (79%) rename EAPMethods/res/EAPMethodETW.man => lib/Events/res/EventsETW.man (98%) create mode 100644 lib/PAP/build/.gitignore create mode 100644 lib/PAP/build/PAP.props create mode 100644 lib/PAP/build/PAP.vcxproj create mode 100644 lib/PAP/build/PAP.vcxproj.filters rename EAPMethods/include/PAP.h => lib/PAP/include/Config.h (66%) create mode 100644 lib/PAP/include/Credentials.h create mode 100644 lib/PAP/src/Config.cpp create mode 100644 lib/PAP/src/Credentials.cpp rename {EAPMethods => lib/PAP}/src/PAP.cpp (64%) create mode 100644 lib/PAP/src/StdAfx.cpp create mode 100644 lib/PAP/src/StdAfx.h create mode 100644 lib/PAP_UI/build/.gitignore create mode 100644 lib/PAP_UI/build/PAP_UI.props create mode 100644 lib/PAP_UI/build/PAP_UI.vcxproj create mode 100644 lib/PAP_UI/build/PAP_UI.vcxproj.filters rename {EAPMethods => lib/PAP_UI}/include/PAP_UI.h (83%) rename {EAPMethods => lib/PAP_UI}/src/PAP_UI.cpp (96%) create mode 100644 lib/PAP_UI/src/StdAfx.cpp create mode 100644 lib/PAP_UI/src/StdAfx.h create mode 100644 lib/TLS/build/.gitignore create mode 100644 lib/TLS/build/TLS.props create mode 100644 lib/TLS/build/TLS.vcxproj create mode 100644 lib/TLS/build/TLS.vcxproj.filters create mode 100644 lib/TLS/include/Config.h create mode 100644 lib/TLS/include/Credentials.h rename EAPMethods/src/TLS.cpp => lib/TLS/src/Config.cpp (66%) create mode 100644 lib/TLS/src/Credentials.cpp create mode 100644 lib/TLS/src/StdAfx.cpp create mode 100644 lib/TLS/src/StdAfx.h create mode 100644 lib/TLS_UI/build/.gitignore create mode 100644 lib/TLS_UI/build/TLS_UI.props create mode 100644 lib/TLS_UI/build/TLS_UI.vcxproj create mode 100644 lib/TLS_UI/build/TLS_UI.vcxproj.filters rename {EAPMethods => lib/TLS_UI}/include/TLS_UI.h (90%) rename {EAPMethods => lib/TLS_UI}/res/wxTLS_UI.cpp (100%) rename {EAPMethods => lib/TLS_UI}/res/wxTLS_UI.fbp (100%) rename {EAPMethods => lib/TLS_UI}/res/wxTLS_UI.h (100%) create mode 100644 lib/TLS_UI/src/StdAfx.cpp create mode 100644 lib/TLS_UI/src/StdAfx.h rename {EAPMethods => lib/TLS_UI}/src/TLS_UI.cpp (96%) create mode 100644 lib/TTLS/build/.gitignore create mode 100644 lib/TTLS/build/TTLS.props create mode 100644 lib/TTLS/build/TTLS.vcxproj create mode 100644 lib/TTLS/build/TTLS.vcxproj.filters create mode 100644 lib/TTLS/include/Config.h create mode 100644 lib/TTLS/include/Credentials.h create mode 100644 lib/TTLS/include/Module.h create mode 100644 lib/TTLS/include/Session.h create mode 100644 lib/TTLS/src/Config.cpp create mode 100644 lib/TTLS/src/Credentials.cpp create mode 100644 lib/TTLS/src/Module.cpp create mode 100644 lib/TTLS/src/Session.cpp create mode 100644 lib/TTLS/src/StdAfx.cpp create mode 100644 lib/TTLS/src/StdAfx.h create mode 100644 lib/TTLS_UI/build/.gitignore create mode 100644 lib/TTLS_UI/build/TTLS_UI.props create mode 100644 lib/TTLS_UI/build/TTLS_UI.vcxproj create mode 100644 lib/TTLS_UI/build/TTLS_UI.vcxproj.filters rename EAPMethods/include/TTLS_UI.h => lib/TTLS_UI/include/Module.h (61%) create mode 100644 lib/TTLS_UI/include/TTLS_UI.h rename {EAPMethods => lib/TTLS_UI}/res/wxTTLS_UI.cpp (100%) rename {EAPMethods => lib/TTLS_UI}/res/wxTTLS_UI.fbp (100%) rename {EAPMethods => lib/TTLS_UI}/res/wxTTLS_UI.h (100%) create mode 100644 lib/TTLS_UI/src/Module.cpp create mode 100644 lib/TTLS_UI/src/StdAfx.cpp create mode 100644 lib/TTLS_UI/src/StdAfx.h rename {EAPMethods => lib/TTLS_UI}/src/TTLS_UI.cpp (70%) diff --git a/.gitignore b/.gitignore index 39021c37..3a2bb0db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /*.opensdf /*.suo /*.sdf +/doc /ipch diff --git a/CredWrite/CredWrite.props b/CredWrite/CredWrite.props index b20e0cda..2a3442e2 100644 --- a/CredWrite/CredWrite.props +++ b/CredWrite/CredWrite.props @@ -7,8 +7,7 @@ - ..\EAPMethods\EAPMethodEvents\temp\EAPMethodEvents.$(Platform).$(Configuration).$(PlatformToolset);..\lib\WinStd\include;%(AdditionalIncludeDirectories) - EAPMETHOD_TYPE=0;%(PreprocessorDefinitions) + ..\lib\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\lib\WinStd\include;%(AdditionalIncludeDirectories) diff --git a/CredWrite/CredWrite.rc b/CredWrite/CredWrite.rc index 3b5e8ac7dba2f3eb89be38ac583e06bfb3c3fec0..5e0e025969acdee873caf0867eb3ee0c27a8693d 100644 GIT binary patch delta 76 zcmbQCH$iWM0GpsbLncEWLo!1SLn%WFLn?#*WK}jpO?@CglOc&gpTU*Eks*M=i6N1p O7$l3XdUG?|Q~>~D$Pd2& delta 48 zcmbQBH$!iO0NdmyPO-^KYzE>n3^5F@42}!|489Dh3?&R14EYQx48@ZhImI{EuuTyF E04BZ*@Bjb+ diff --git a/CredWrite/CredWrite.vcxproj b/CredWrite/CredWrite.vcxproj index d7397912..a95ec396 100644 --- a/CredWrite/CredWrite.vcxproj +++ b/CredWrite/CredWrite.vcxproj @@ -86,8 +86,6 @@ - - Create @@ -100,9 +98,15 @@ - + + {ad6816a0-9600-4e01-8c49-39d03d1e791f} + + {d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b} + + {36b0cf8a-7794-46c3-8099-825ba962b4c7} + {47399d91-7eb9-41de-b521-514ba5db0c43} diff --git a/CredWrite/CredWrite.vcxproj.filters b/CredWrite/CredWrite.vcxproj.filters index d59c8f14..21c5de5d 100644 --- a/CredWrite/CredWrite.vcxproj.filters +++ b/CredWrite/CredWrite.vcxproj.filters @@ -26,12 +26,6 @@ Source Files - - Source Files - - - Source Files - diff --git a/CredWrite/Main.cpp b/CredWrite/Main.cpp index c1544d70..a5809980 100644 --- a/CredWrite/Main.cpp +++ b/CredWrite/Main.cpp @@ -20,12 +20,10 @@ #include "StdAfx.h" -#pragma comment(lib, "Crypt32.lib") - using namespace std; using namespace winstd; -eap::module g_module; +eap::module g_module(eap::type_undefined); static int CredWrite() diff --git a/CredWrite/StdAfx.h b/CredWrite/StdAfx.h index 810573e6..33ee1450 100644 --- a/CredWrite/StdAfx.h +++ b/CredWrite/StdAfx.h @@ -20,17 +20,30 @@ #pragma once -#include "../include/Version.h" - -#include "../EAPMethods/include/EAP.h" -#include "../EAPMethods/include/PAP.h" +#include "../lib/PAP/include/Credentials.h" +#include "../lib/EAPBase/include/Module.h" +#include #include -#include -#include #include -#include #include +#include // Must include after +#include #include + +//#include "../include/Version.h" +// +//#include "../EAPMethods/include/EAP.h" +//#include "../EAPMethods/include/PAP.h" +// +//#include +//#include +//#include +//#include +// +//#include +//#include +// +//#include diff --git a/EAPMethods/Doxyfile b/Doxyfile similarity index 97% rename from EAPMethods/Doxyfile rename to Doxyfile index 9a2bda5d..68af5859 100644 --- a/EAPMethods/Doxyfile +++ b/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.7 +# Doxyfile 1.8.7 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "EAPModules" +PROJECT_NAME = "GÉANTLink" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -44,7 +44,7 @@ PROJECT_NUMBER = # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = "EAP Modules" +PROJECT_BRIEF = "EAP Supplicant for Windows" # With the PROJECT_LOGO tag one can specify an logo or icon that is included in # the documentation. The maximum height of the logo should not exceed 55 pixels @@ -718,7 +718,7 @@ WARN_IF_UNDOCUMENTED = YES # markup commands wrongly. # The default value is: YES. -WARN_IF_DOC_ERROR = YES +WARN_IF_DOC_ERROR = NO # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return @@ -726,7 +726,7 @@ WARN_IF_DOC_ERROR = YES # documentation, but not about the absence of documentation. # The default value is: NO. -WARN_NO_PARAMDOC = NO +WARN_NO_PARAMDOC = YES # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which @@ -789,7 +789,11 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = res +EXCLUDE = \ + lib\EAPBase_UI\res \ + lib\TLS_UI\res \ + lib\TTLS_UI\res \ + lib\WinStd # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded diff --git a/EAPMethods/.gitignore b/EAPMethods/.gitignore deleted file mode 100644 index 5df58667..00000000 --- a/EAPMethods/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/doc diff --git a/EAPMethods/EAPMethodEvents/EAPMethodEvents.props b/EAPMethods/EAPMethodEvents/EAPMethodEvents.props deleted file mode 100644 index 2dcbd893..00000000 --- a/EAPMethods/EAPMethodEvents/EAPMethodEvents.props +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/EAPMethods/EAPTTLS/EAPTTLS.rc b/EAPMethods/EAPTTLS/EAPTTLS.rc index 8d0ff957e5cc8e552c06f8221bec7153b9478519..5a67fc9ea423580bc384e53c88b206a7af42fa32 100644 GIT binary patch delta 36 qcmcbnaY18)0GqfzgB}p-Gh{O4F(fnOFqAT+Fr+f*Z`Nhg - - - - - - - - - - Create Create @@ -104,12 +94,24 @@ - - {47399d91-7eb9-41de-b521-514ba5db0c43} + + {ad6816a0-9600-4e01-8c49-39d03d1e791f} - + {d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b} + + {36b0cf8a-7794-46c3-8099-825ba962b4c7} + + + {4d40cb8a-812e-4f12-b23a-31af743878e8} + + + {ee0ef0d9-a475-4038-8637-5754724f65b0} + + + {47399d91-7eb9-41de-b521-514ba5db0c43} + diff --git a/EAPMethods/EAPTTLS/EAPTTLS.vcxproj.filters b/EAPMethods/EAPTTLS/EAPTTLS.vcxproj.filters index 63595775..c8b78e03 100644 --- a/EAPMethods/EAPTTLS/EAPTTLS.vcxproj.filters +++ b/EAPMethods/EAPTTLS/EAPTTLS.vcxproj.filters @@ -18,24 +18,6 @@ Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - @@ -44,18 +26,6 @@ Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - diff --git a/EAPMethods/EAPTTLS/StdAfx.h b/EAPMethods/EAPTTLS/StdAfx.h index 061f3745..5cb56715 100644 --- a/EAPMethods/EAPTTLS/StdAfx.h +++ b/EAPMethods/EAPTTLS/StdAfx.h @@ -20,31 +20,5 @@ #pragma once -#include "../../include/Version.h" - -#include "../include/EAP.h" -#include "../include/EAPSerial.h" -#include "../include/TLS.h" -#include "../include/TTLS.h" -#include "../include/EAPXML.h" -#include "../include/PAP.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#pragma comment(lib, "Crypt32.lib") +#include "../../lib/TTLS/include/Module.h" +#include "../../lib/TTLS/include/Session.h" diff --git a/EAPMethods/EAPTTLSUI/EAPTTLSUI.rc b/EAPMethods/EAPTTLSUI/EAPTTLSUI.rc index 3a7ae39e34e203a40b9346bb3c499929223c177e..5a664cf45f3809ff582720e82861db397383b81c 100644 GIT binary patch delta 44 ycmca(*kH6FiEZ*fP7d)LhD?Seh8Q4pWpHE&U~pncWGH4xoy^E3zPW@gLkIvG{R=Gs delta 16 XcmZoLx?{K@iEXkLm(b=JY#BlTG&Kc$ diff --git a/EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj b/EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj index f886e91d..fa44721b 100644 --- a/EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj +++ b/EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj @@ -79,33 +79,10 @@ - - - - - - - - - - - - - - - - - - - - - - - Create Create @@ -117,18 +94,39 @@ - - {47399d91-7eb9-41de-b521-514ba5db0c43} + + {ad6816a0-9600-4e01-8c49-39d03d1e791f} + + + {d4b54856-be1f-4937-a8f7-495125be76be} - + {d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b} + + {36b0cf8a-7794-46c3-8099-825ba962b4c7} + + + {3d309c2e-64ab-4bc4-a16d-468571a2bc1a} + + + {4d40cb8a-812e-4f12-b23a-31af743878e8} + + + {9a25c261-8ade-4938-8393-e857ef0e37e9} + + + {ee0ef0d9-a475-4038-8637-5754724f65b0} + + + {42f0f0f4-c928-4860-a4e4-94991c2c3d90} + + + {47399d91-7eb9-41de-b521-514ba5db0c43} + - - - diff --git a/EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj.filters b/EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj.filters index 07f53281..38ad857f 100644 --- a/EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj.filters +++ b/EAPMethods/EAPTTLSUI/EAPTTLSUI.vcxproj.filters @@ -13,97 +13,19 @@ {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 - - {51f0404d-9280-4fcc-8138-5d1f815ce568} - - - {9befee7a-5dff-41dd-b080-4e26ccb19a7f} - - - {0ec1840b-101c-415a-91c6-2c7eb4530c15} - Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files\wx - - - Header Files\wx - - - Header Files\wx - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - Source Files - - Source Files - - - Source Files\wx - - - Source Files\wx - - - Source Files\wx - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files - - Source Files - @@ -114,14 +36,5 @@ Source Files - - Resource Files\wx - - - Resource Files\wx - - - Resource Files\wx - \ No newline at end of file diff --git a/EAPMethods/EAPTTLSUI/StdAfx.h b/EAPMethods/EAPTTLSUI/StdAfx.h index aeba08bd..7e63e6f7 100644 --- a/EAPMethods/EAPTTLSUI/StdAfx.h +++ b/EAPMethods/EAPTTLSUI/StdAfx.h @@ -18,48 +18,6 @@ along with GÉANTLink. If not, see . */ -#define _CRT_SECURE_NO_WARNINGS - #pragma once -#include "../../include/Version.h" - -#include "../include/EAP.h" -#include "../include/EAP_UI.h" -#include "../include/EAPSerial.h" -#include "../include/EAPXML.h" -#include "../include/TLS.h" -#include "../include/TLS_UI.h" -#include "../include/TTLS.h" -#include "../include/TTLS_UI.h" -#include "../include/PAP.h" -#include "../include/PAP_UI.h" - -#include "../res/wxTLS_UI.h" -#include "../res/wxTTLS_UI.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#pragma comment(lib, "Crypt32.lib") +#include "../../lib/TTLS_UI/include/Module.h" diff --git a/EAPMethods/MSIBuild/Makefile b/EAPMethods/MSIBuild/Makefile index 5c19d7ef398d56ed61bee93cef0b7211c4ba6b2a..f5c59026069a86d8403cdd6ba0ce08e3ef467609 100644 GIT binary patch delta 50 zcmV-20L}llmjQ~50kBL9v(5`N1Cve?2$P^33X^^sTC)ZbSOv2J8K@bP)EE@A&@vPU Iv%os`5Wv6@)c^nh delta 708 zcmeC`Vca&Iaf1){9D11iY_Dk`45 zT1?X2mBE0)k-?C`4TudG%oubTTo^2YEE6Ehguw|Y=LTe1G8i)$fyFF=q#Mu_GoU&b zpdKTjS_=lt$+HEdC(jW#lFtFkIWhz=;Ii|fxTw1+&^!~ceU?Bo%z@@x0L^p+ngp`b z7$^p^(}KYnCf{-wVw3CiB!H$$fa!mxe3NVR LxHi|A_6Yz0EoP1= diff --git a/EAPMethods/build/Common.props b/EAPMethods/build/Common.props index 028593da..1754f6fa 100644 --- a/EAPMethods/build/Common.props +++ b/EAPMethods/build/Common.props @@ -8,11 +8,8 @@ - $(ProjectDir);..\EAPMethodEvents\temp\EAPMethodEvents.$(Platform).$(Configuration).$(PlatformToolset);..\include;..\..\lib\WinStd\include;%(AdditionalIncludeDirectories) + $(ProjectDir);..\..\lib\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\include;..\..\lib\WinStd\include;%(AdditionalIncludeDirectories) - - temp\EAPMethodEvents.$(Platform).$(Configuration).$(PlatformToolset);%(AdditionalIncludeDirectories) - \ No newline at end of file diff --git a/EAPMethods/include/EAP.h b/EAPMethods/include/EAP.h deleted file mode 100644 index 55b90c53..00000000 --- a/EAPMethods/include/EAP.h +++ /dev/null @@ -1,1583 +0,0 @@ -/* - 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 . -*/ - -#define IDR_EAP_KEY_PUBLIC 1 -#define IDR_EAP_KEY_PRIVATE 2 - -#if !defined(RC_INVOKED) && !defined(MIDL_PASS) - -#include -#include -#include -#include - -#include -extern "C" { -#include -} - -#include -#include -#include -#include - -#include -#include "EAPSerial.h" -#include "EAPXML.h" - - -namespace eap -{ - enum type_t; - - class session; - - class config; - class config_method; - template class config_provider; - template class config_providers; - typedef config_method config_pass; - - class credentials; - class credentials_pass; - - class module; - template class peer_base; - template class peer; -} - -namespace eapserial -{ - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_method &val); - inline size_t get_pk_size(const eap::config_method &val); - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_method &val); - - template inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_provider<_Tmeth> &val); - template inline size_t get_pk_size(const eap::config_provider<_Tmeth> &val); - template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_provider<_Tmeth> &val); - - template inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_providers<_Tprov> &val); - template inline size_t get_pk_size(const eap::config_providers<_Tprov> &val); - template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_providers<_Tprov> &val); - - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials &val); - inline size_t get_pk_size(const eap::credentials &val); - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials &val); - - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_pass &val); - inline size_t get_pk_size(const eap::credentials_pass &val); - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_pass &val); -} - -#pragma once - - -#define ETW_ERROR(kw, f, ...) m_ep.write(TRACE_LEVEL_ERROR , kw, _T(__FUNCTION__) _T(" ") f, ##__VA_ARGS__) -#define ETW_WARNING(kw, f, ...) m_ep.write(TRACE_LEVEL_WARNING , kw, _T(__FUNCTION__) _T(" ") f, ##__VA_ARGS__) -#define ETW_INFO(kw, f, ...) m_ep.write(TRACE_LEVEL_INFORMATION, kw, _T(__FUNCTION__) _T(" ") f, ##__VA_ARGS__) -#define ETW_VERBOSE(kw, f, ...) m_ep.write(TRACE_LEVEL_VERBOSE , kw, _T(__FUNCTION__) _T(" ") f, ##__VA_ARGS__) -#define ETW_FN_VOID winstd::event_fn_auto < &EAPMETHOD_TRACE_EVT_FN_CALL, &EAPMETHOD_TRACE_EVT_FN_RETURN > _event_auto(m_ep, __FUNCTION__) -#define ETW_FN_DWORD(res) winstd::event_fn_auto_ret _event_auto(m_ep, __FUNCTION__, res) -#define ETW_FN_HRESULT(res) winstd::event_fn_auto_ret _event_auto(m_ep, __FUNCTION__, res) - - -namespace eap -{ - /// - /// EAP method numbers - /// - /// \sa [Extensible Authentication Protocol (EAP) Registry (Chapter: Method Types)](https://www.iana.org/assignments/eap-numbers/eap-numbers.xhtml#eap-numbers-4) - /// - enum type_t { - type_tls = 13, - type_ttls = 21, - type_peap = 25, - type_mschapv2 = 26, - type_pap = 192, // Not actually an EAP method (moved to the Unassigned area) - }; - - - /// - /// EAP session - /// - class session - { - public: - /// - /// Constructs a session - /// - session(); - - /// - /// Destructs the session - /// - virtual ~session(); - - /// \name Session start/end - /// @{ - - /// - /// Starts an EAP authentication session on the peer EAPHost using the EAP method. - /// - /// \sa [EapPeerBeginSession function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363600.aspx) - /// - virtual DWORD begin( - _In_ DWORD dwFlags, - _In_ const EapAttributes *pAttributeArray, - _In_ HANDLE hTokenImpersonateUser, - _In_ DWORD dwConnectionDataSize, - _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, - _In_ DWORD dwUserDataSize, - _In_count_(dwUserDataSize) const BYTE *pUserData, - _In_ DWORD dwMaxSendPacketSize, - _Out_ EAP_ERROR **ppEapError); - - /// - /// Ends an EAP authentication session for the EAP method. - /// - /// \sa [EapPeerEndSession function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363604.aspx) - /// - virtual DWORD end(_Out_ EAP_ERROR **ppEapError); - - /// @} - - /// \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 DWORD process_request_packet( - _In_ DWORD dwReceivedPacketSize, - _In_bytecount_(dwReceivedPacketSize) const EapPacket *pReceivedPacket, - _Out_ EapPeerMethodOutput *pEapOutput, - _Out_ EAP_ERROR **ppEapError); - - /// - /// Obtains a response packet from the EAP method. - /// - /// \sa [EapPeerGetResponsePacket function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363610.aspx) - /// - virtual DWORD get_response_packet( - _Inout_ DWORD *pdwSendPacketSize, - _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, - _Out_ EAP_ERROR **ppEapError); - - /// - /// 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 DWORD get_result(_In_ EapPeerMethodResultReason reason, _Out_ EapPeerMethodResult *ppResult, _Out_ EAP_ERROR **ppEapError); - - /// @} - - /// \name UI interaction - /// @{ - - /// - /// Obtains the user interface context from the EAP method. - /// - /// \note This function is always followed by the `EapPeerInvokeInteractiveUI()` function, which is followed by the `EapPeerSetUIContext()` function. - /// - /// \sa [EapPeerGetUIContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363612.aspx) - /// - virtual DWORD get_ui_context( - _Out_ DWORD *pdwUIContextDataSize, - _Out_ BYTE **ppUIContextData, - _Out_ EAP_ERROR **ppEapError); - - /// - /// Provides a user interface context to the EAP method. - /// - /// \note This function is called after the UI has been raised through the `EapPeerGetUIContext()` function. - /// - /// \sa [EapPeerSetUIContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363626.aspx) - /// - virtual DWORD set_ui_context( - _In_ DWORD dwUIContextDataSize, - _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, - _In_ const EapPeerMethodOutput *pEapOutput, - _Out_ EAP_ERROR **ppEapError); - - /// @} - - /// \name Response attributes - /// @{ - - /// - /// Obtains an array of EAP response attributes from the EAP method. - /// - /// \sa [EapPeerGetResponseAttributes function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363609.aspx) - /// - virtual DWORD get_response_attributes(_Out_ EapAttributes *pAttribs, _Out_ EAP_ERROR **ppEapError); - - /// - /// Provides an updated array of EAP response attributes to the EAP method. - /// - /// \sa [EapPeerSetResponseAttributes function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363625.aspx) - /// - virtual DWORD set_response_attributes(const _In_ EapAttributes *pAttribs, _Out_ EapPeerMethodOutput *pEapOutput, _Out_ EAP_ERROR **ppEapError); - - /// @} - }; - - - /// - /// Base class for configuration storage - /// - class config - { - public: - /// - /// Constructs configuration - /// - /// \param[in] mod Reference of the EAP module to use for global services - /// - config(_In_ module &mod); - - /// - /// Copies configuration - /// - /// \param[in] other Configuration to copy from - /// - config(_In_ const config &other); - - /// - /// Moves configuration - /// - /// \param[in] other Configuration to move from - /// - config(_Inout_ config &&other); - - /// - /// Destructs configuration - /// - virtual ~config(); - - /// - /// Copies configuration - /// - /// \param[in] other Configuration to copy from - /// - /// \returns Reference to this object - /// - config& operator=(_In_ const config &other); - - /// - /// Moves configuration - /// - /// \param[in] other Configuration to move from - /// - /// \returns Reference to this object - /// - config& operator=(_Inout_ config &&other); - - /// - /// Clones this configuration - /// - /// \returns Pointer to cloned configuration - /// - virtual config* clone() const = 0; - - /// \name XML configuration management - /// @{ - - /// - /// Save configuration to XML document - /// - /// \param[in] pDoc XML document - /// \param[in] pConfigRoot Suggested root element for saving configuration - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const = 0; - - /// - /// Load configuration from XML document - /// - /// \param[in] pConfigRoot Root element for loading configuration - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) = 0; - - /// @} - - public: - module &m_module; ///< Reference of the EAP module - }; - - - /// - /// Base class for method configuration storage - /// - class config_method : public config - { - public: - /// - /// Constructs configuration - /// - /// \param[in] mod Reference of the EAP module to use for global services - /// - config_method(_In_ module &mod); - - /// - /// Copies configuration - /// - /// \param[in] other Configuration to copy from - /// - config_method(_In_ const config_method &other); - - /// - /// Moves configuration - /// - /// \param[in] other Configuration to move from - /// - config_method(_Inout_ config_method &&other); - - /// - /// Copies configuration - /// - /// \param[in] other Configuration to copy from - /// - /// \returns Reference to this object - /// - config_method& operator=(_In_ const config_method &other); - - /// - /// Moves configuration - /// - /// \param[in] other Configuration to move from - /// - /// \returns Reference to this object - /// - config_method& operator=(_Inout_ config_method &&other); - - /// \name XML configuration management - /// @{ - - /// - /// Save configuration to XML document - /// - /// \param[in] pDoc XML document - /// \param[in] pConfigRoot Suggested root element for saving configuration - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const; - - /// - /// Load configuration from XML document - /// - /// \param[in] pConfigRoot Root element for loading configuration - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError); - - /// @} - - /// - /// Returns EAP method type of this configuration - /// - /// \returns One of `eap::type_t` constants. - /// - virtual type_t get_method_id() = 0; - - public: - bool m_allow_save; ///< Are credentials allowed to be saved to Windows Credential Manager? - std::wstring m_anonymous_identity; ///< Anonymous identity - }; - - - /// - /// Provider configuration - /// - template - class config_provider : public config - { - public: - /// - /// Constructs configuration - /// - /// \param[in] mod Reference of the EAP module to use for global services - /// - config_provider(_In_ module &mod) : config(mod) - { - } - - /// - /// Copies configuration - /// - /// \param[in] other Configuration to copy from - /// - config_provider(_In_ const config_provider &other) : - m_id(other.m_id), - m_lbl_alt_credential(other.m_lbl_alt_credential), - m_lbl_alt_identity(other.m_lbl_alt_identity), - m_lbl_alt_password(other.m_lbl_alt_password), - m_methods(other.m_methods), - config(other) - { - } - - /// - /// Moves configuration - /// - /// \param[in] other Configuration to move from - /// - config_provider(_Inout_ config_provider &&other) : - m_id(std::move(other.m_id)), - m_lbl_alt_credential(std::move(other.m_lbl_alt_credential)), - m_lbl_alt_identity(std::move(other.m_lbl_alt_identity)), - m_lbl_alt_password(std::move(other.m_lbl_alt_password)), - m_methods(std::move(other.m_methods)), - config(std::move(other)) - { - } - - /// - /// Copies configuration - /// - /// \param[in] other Configuration to copy from - /// - /// \returns Reference to this object - /// - config_provider& operator=(_In_ const config_provider &other) - { - if (this != &other) { - (config&)*this = other; - m_id = other.m_id; - m_lbl_alt_credential = other.m_lbl_alt_credential; - m_lbl_alt_identity = other.m_lbl_alt_identity; - m_lbl_alt_password = other.m_lbl_alt_password; - m_methods = other.m_methods; - } - - return *this; - } - - /// - /// Moves configuration - /// - /// \param[in] other Configuration to move from - /// - /// \returns Reference to this object - /// - config_provider& operator=(_Inout_ config_provider &&other) - { - if (this != &other) { - (config&&)*this = std::move(other); - m_id = std::move(other.m_id); - m_lbl_alt_credential = std::move(other.m_lbl_alt_credential); - m_lbl_alt_identity = std::move(other.m_lbl_alt_identity); - m_lbl_alt_password = std::move(other.m_lbl_alt_password); - m_methods = std::move(other.m_methods); - } - - return *this; - } - - /// - /// Clones configuration - /// - /// \returns Pointer to cloned configuration - /// - virtual config* clone() const { return new config_provider<_Tmeth>(*this); } - - /// \name XML configuration management - /// @{ - - /// - /// Save configuration to XML document - /// - /// \param[in] pDoc XML document - /// \param[in] pConfigRoot Suggested root element for saving configuration - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const - { - const winstd::bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata"); - DWORD dwResult; - HRESULT hr; - - // - if (!m_id.empty()) - if ((dwResult = eapxml::put_element_value(pDoc, pConfigRoot, winstd::bstr(L"ID"), bstrNamespace, winstd::bstr(m_id))) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - // - winstd::com_obj pXmlElProviderInfo; - if ((dwResult = eapxml::create_element(pDoc, pConfigRoot, winstd::bstr(L"eap-metadata:ProviderInfo"), winstd::bstr(L"ProviderInfo"), bstrNamespace, &pXmlElProviderInfo)) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - // / - if (!m_lbl_alt_credential.empty()) - if ((dwResult = eapxml::put_element_value(pDoc, pXmlElProviderInfo, winstd::bstr(L"CredentialPrompt"), bstrNamespace, winstd::bstr(m_lbl_alt_credential))) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - // / - if (!m_lbl_alt_identity.empty()) - if ((dwResult = eapxml::put_element_value(pDoc, pXmlElProviderInfo, winstd::bstr(L"UserNameLabel"), bstrNamespace, winstd::bstr(m_lbl_alt_identity))) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - // / - if (!m_lbl_alt_password.empty()) - if ((dwResult = eapxml::put_element_value(pDoc, pXmlElProviderInfo, winstd::bstr(L"PasswordLabel"), bstrNamespace, winstd::bstr(m_lbl_alt_password))) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - // - winstd::com_obj pXmlElAuthenticationMethods; - if ((dwResult = eapxml::create_element(pDoc, pConfigRoot, winstd::bstr(L"eap-metadata:AuthenticationMethods"), winstd::bstr(L"AuthenticationMethods"), bstrNamespace, &pXmlElAuthenticationMethods)) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - for (std::list<_Tmeth>::const_iterator method = m_methods.cbegin(), method_end = m_methods.cend(); method != method_end; ++method) { - // - winstd::com_obj pXmlElAuthenticationMethod; - if ((dwResult = eapxml::create_element(pDoc, winstd::bstr(L"AuthenticationMethod"), bstrNamespace, &pXmlElAuthenticationMethod))) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - // /... - if ((dwResult = method->save(pDoc, pXmlElAuthenticationMethod, ppEapError)) != ERROR_SUCCESS) - return dwResult; - - if (FAILED(hr = pXmlElAuthenticationMethods->appendChild(pXmlElAuthenticationMethod, NULL))) { - *ppEapError = m_module.make_error(dwResult = HRESULT_CODE(hr), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error appending element."), NULL); - return dwResult; - } - } - - return dwResult; - } - - - /// - /// Load configuration from XML document - /// - /// \param[in] pConfigRoot Root element for loading configuration - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) - { - assert(pConfigRoot); - assert(ppEapError); - DWORD dwResult; - std::wstring lang; - LoadString(m_module.m_instance, 2, lang); - - // - m_id.clear(); - eapxml::get_element_value(pConfigRoot, winstd::bstr(L"eap-metadata:ID"), m_id); - - // - m_lbl_alt_credential.clear(); - m_lbl_alt_identity.clear(); - m_lbl_alt_password.clear(); - winstd::com_obj pXmlElProviderInfo; - if (eapxml::select_element(pConfigRoot, winstd::bstr(L"eap-metadata:ProviderInfo"), &pXmlElProviderInfo) == ERROR_SUCCESS) { - // - eapxml::get_element_localized(pXmlElProviderInfo, winstd::bstr(L"eap-metadata:CredentialPrompt"), lang.c_str(), m_lbl_alt_credential); - - // - eapxml::get_element_localized(pXmlElProviderInfo, winstd::bstr(L"eap-metadata:UserNameLabel"), lang.c_str(), m_lbl_alt_identity); - - // - eapxml::get_element_localized(pXmlElProviderInfo, winstd::bstr(L"eap-metadata:PasswordLabel"), lang.c_str(), m_lbl_alt_password); - } - - // Iterate authentication methods (). - m_methods.clear(); - winstd::com_obj pXmlListMethods; - if ((dwResult = eapxml::select_nodes(pConfigRoot, winstd::bstr(L"eap-metadata:AuthenticationMethods/eap-metadata:AuthenticationMethod"), &pXmlListMethods)) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult = ERROR_NOT_FOUND, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting / elements."), NULL); - return dwResult; - } - long lCount = 0; - pXmlListMethods->get_length(&lCount); - for (long i = 0; i < lCount; i++) { - winstd::com_obj pXmlElMethod; - pXmlListMethods->get_item(i, &pXmlElMethod); - - _Tmeth cfg(m_module); - - // Check EAP method type (). - DWORD dwMethodID; - if (eapxml::get_element_value(pXmlElMethod, winstd::bstr(L"eap-metadata:EAPMethod"), &dwMethodID) == ERROR_SUCCESS) { - if ((type_t)dwMethodID != cfg.get_method_id()) { - // Wrong type. - continue; - } - } - - // Load configuration. - dwResult = cfg.load(pXmlElMethod, ppEapError); - if (dwResult != ERROR_SUCCESS) - return dwResult; - - // Add configuration to the list. - m_methods.push_back(std::move(cfg)); - } - - return ERROR_SUCCESS; - } - - /// @} - - public: - std::wstring m_id; ///< Profile ID - winstd::tstring m_lbl_alt_credential; ///< Alternative label for credential prompt - winstd::tstring m_lbl_alt_identity; ///< Alternative label for identity prompt - winstd::tstring m_lbl_alt_password; ///< Alternative label for password prompt - std::list<_Tmeth> m_methods; ///< List of method configurations - }; - - - /// - /// Providers configuration - /// - template - class config_providers : public config - { - public: - /// - /// Constructs configuration - /// - /// \param[in] mod Reference of the EAP module to use for global services - /// - config_providers(_In_ module &mod) : config(mod) - { - } - - /// - /// Copies configuration - /// - /// \param[in] other Configuration to copy from - /// - config_providers(_In_ const config_providers &other) : - m_providers(other.m_providers), - config(other) - { - } - - /// - /// Moves configuration - /// - /// \param[in] other Configuration to move from - /// - config_providers(_Inout_ config_providers &&other) : - m_providers(std::move(other.m_providers)), - config(std::move(other)) - { - } - - /// - /// Copies configuration - /// - /// \param[in] other Configuration to copy from - /// - /// \returns Reference to this object - /// - config_providers& operator=(_In_ const config_providers &other) - { - if (this != &other) { - (config&)*this = other; - m_providers = other.m_providers; - } - - return *this; - } - - /// - /// Moves configuration - /// - /// \param[in] other Configuration to move from - /// - /// \returns Reference to this object - /// - config_providers& operator=(_Inout_ config_providers &&other) - { - if (this != &other) { - (config&&)*this = std::move(other); - m_providers = std::move(other.m_providers); - } - - return *this; - } - - /// - /// Clones configuration - /// - /// \returns Pointer to cloned configuration - /// - virtual config* clone() const { return new config_providers<_Tprov>(*this); } - - /// \name XML configuration management - /// @{ - - /// - /// Save configuration to XML document - /// - /// \param[in] pDoc XML document - /// \param[in] pConfigRoot Suggested root element for saving configuration - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const - { - const winstd::bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata"); - DWORD dwResult; - HRESULT hr; - - // Select node. - winstd::com_obj pXmlElIdentityProviderList; - if ((dwResult = eapxml::select_node(pConfigRoot, winstd::bstr(L"eap-metadata:EAPIdentityProviderList"), &pXmlElIdentityProviderList)) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult = ERROR_NOT_FOUND, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting element."), NULL); - return dwResult; - } - - for (std::list<_Tprov>::const_iterator provider = m_providers.cbegin(), provider_end = m_providers.cend(); provider != provider_end; ++provider) { - // - winstd::com_obj pXmlElIdentityProvider; - if ((dwResult = eapxml::create_element(pDoc, winstd::bstr(L"EAPIdentityProvider"), bstrNamespace, &pXmlElIdentityProvider))) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - // /... - if ((dwResult = provider->save(pDoc, pXmlElIdentityProvider, ppEapError)) != ERROR_SUCCESS) - return dwResult; - - if (FAILED(hr = pXmlElIdentityProviderList->appendChild(pXmlElIdentityProvider, NULL))) { - *ppEapError = m_module.make_error(dwResult = HRESULT_CODE(hr), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error appending element."), NULL); - return dwResult; - } - } - - return dwResult; - } - - - /// - /// Load configuration from XML document - /// - /// \param[in] pConfigRoot Root element for loading configuration - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) - { - assert(pConfigRoot); - assert(ppEapError); - DWORD dwResult; - - // Iterate authentication providers (). - winstd::com_obj pXmlListProviders; - if ((dwResult = eapxml::select_nodes(pConfigRoot, winstd::bstr(L"eap-metadata:EAPIdentityProviderList/eap-metadata:EAPIdentityProvider"), &pXmlListProviders)) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult = ERROR_NOT_FOUND, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting elements."), NULL); - return dwResult; - } - long lCount = 0; - pXmlListProviders->get_length(&lCount); - for (long i = 0; i < lCount; i++) { - winstd::com_obj pXmlElProvider; - pXmlListProviders->get_item(i, &pXmlElProvider); - - _Tprov prov(m_module); - - // Load provider. - dwResult = prov.load(pXmlElProvider, ppEapError); - if (dwResult != ERROR_SUCCESS) - return dwResult; - - // Add provider to the list. - m_providers.push_back(std::move(prov)); - } - - return dwResult; - } - - /// @} - - public: - std::list<_Tprov> m_providers; ///< List of provider configurations - }; - - - /// - /// Base class for method credential storage - /// - class credentials : public config - { - public: - /// - /// Constructs credentials - /// - /// \param[in] mod Reference of the EAP module to use for global services - /// - credentials(_In_ module &mod); - - /// - /// Copies credentials - /// - /// \param[in] other Credentials to copy from - /// - credentials(_In_ const credentials &other); - - /// - /// Moves credentials - /// - /// \param[in] other Credentials to move from - /// - credentials(_Inout_ credentials &&other); - - /// - /// Copies credentials - /// - /// \param[in] other Credentials to copy from - /// - /// \returns Reference to this object - /// - credentials& operator=(_In_ const credentials &other); - - /// - /// Moves credentials - /// - /// \param[in] other Configuration to move from - /// - /// \returns Reference to this object - /// - credentials& operator=(_Inout_ credentials &&other); - - /// - /// Resets credentials - /// - virtual void clear(); - - /// - /// Test credentials if blank - /// - virtual bool empty() const; - - /// \name XML credentials management - /// @{ - - /// - /// Save credentials to XML document - /// - /// \param[in] pDoc XML document - /// \param[in] pConfigRoot Suggested root element for saving credentials - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns Always returns \c ERROR_NOT_SUPPORTED, as credentials are non-exportable. - /// - virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const; - - /// @} - - /// \name Storage - /// @{ - - /// - /// Save credentials to Windows Credential Manager - /// - /// \param[in] pszTargetName The name in Windows Credential Manager to store credentials as - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const = 0; - - /// - /// Retrieve credentials from Windows Credential Manager - /// - /// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) = 0; - - /// - /// Return target suffix for Windows Credential Manager credential name - /// - virtual LPCTSTR target_suffix() const = 0; - - /// - /// Returns target name for Windows Credential Manager credential name - /// - /// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from - /// - /// \returns Final target name to store/retrieve credentials in Windows Credential Manager - /// - inline winstd::tstring target_name(_In_ LPCTSTR pszTargetName) const - { - winstd::tstring target_name(_T(PRODUCT_NAME_STR) _T("/")); - target_name += pszTargetName; - target_name += _T('/'); - target_name += target_suffix(); - assert(target_name.length() < CRED_MAX_GENERIC_TARGET_NAME_LENGTH); - return target_name; - } - - /// @} - - public: - std::wstring m_identity; ///< Identity (username\@domain, certificate name etc.) - }; - - - /// - /// Password based method credentials - /// - class credentials_pass : public credentials - { - public: - /// - /// Constructs credentials - /// - /// \param[in] mod Reference of the EAP module to use for global services - /// - credentials_pass(_In_ module &mod); - - /// - /// Copies credentials - /// - /// \param[in] other Credentials to copy from - /// - credentials_pass(_In_ const credentials_pass &other); - - /// - /// Moves credentials - /// - /// \param[in] other Credentials to move from - /// - credentials_pass(_Inout_ credentials_pass &&other); - - /// - /// Copies credentials - /// - /// \param[in] other Credentials to copy from - /// - /// \returns Reference to this object - /// - credentials_pass& operator=(_In_ const credentials_pass &other); - - /// - /// Moves credentials - /// - /// \param[in] other Credentials to move from - /// - /// \returns Reference to this object - /// - credentials_pass& operator=(_Inout_ credentials_pass &&other); - - /// - /// Resets credentials - /// - virtual void clear(); - - /// - /// Test credentials if blank - /// - virtual bool empty() const; - - /// \name XML configuration management - /// @{ - - /// - /// Load credentials from XML document - /// - /// \param[in] pConfigRoot Root element for loading credentials - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError); - - /// @} - - /// \name Storage - /// @{ - - /// - /// Save credentials to Windows Credential Manager - /// - /// \param[in] pszTargetName The name in Windows Credential Manager to store credentials as - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const; - - /// - /// Retrieve credentials from Windows Credential Manager - /// - /// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError); - - /// @} - - public: - winstd::sanitizing_wstring m_password; ///< Password - }; - - - /// - /// EAP module base class - /// - /// Provides basic services to EAP methods. - /// - class module - { - public: - module(); - virtual ~module(); - - /// - /// Allocate a EAP_ERROR and fill it according to dwErrorCode - /// - EAP_ERROR* make_error(_In_ DWORD dwErrorCode, _In_ DWORD dwReasonCode, _In_ LPCGUID pRootCauseGuid, _In_ LPCGUID pRepairGuid, _In_ LPCGUID pHelpLinkGuid, _In_z_ LPCWSTR pszRootCauseString, _In_z_ LPCWSTR pszRepairString) const; - - /// - /// Allocate BLOB - /// - BYTE* alloc_memory(_In_ size_t size); - - /// - /// Free BLOB allocated with this peer - /// - void free_memory(_In_ BYTE *ptr); - - /// - /// Free EAP_ERROR allocated with `make_error()` method - /// - void free_error_memory(_In_ EAP_ERROR *err); - - public: - HINSTANCE m_instance; ///< Windows module instance - - protected: - winstd::heap m_heap; ///< Heap - mutable winstd::event_provider m_ep; ///< Event Provider - }; - - - /// - /// EAP peer base class - /// - /// A group of methods all EAP peers must or should implement. - /// - template - class peer_base : public module - { - public: - /// - /// Configuration data type - /// - typedef config_providers > config_type; - - /// - /// Identity data type - /// - typedef _Tid identity_type; - - /// - /// Interactive request data type - /// - typedef _Tint interactive_request_type; - - /// - /// Interactive response data type - /// - typedef _Tintres interactive_response_type; - - public: - /// - /// Constructor - /// - peer_base() : module() {} - }; - - - /// - /// EAP peer base class - /// - /// A group of methods all EAP peers must or should implement. - /// - template - class peer : public peer_base<_Tcfg, _Tid, _Tint, _Tintres> - { - public: - peer() : peer_base<_Tcfg, _Tid, _Tint, _Tintres>() {} - - /// - /// Initializes an EAP peer method for EAPHost. - /// - /// \sa [EapPeerGetInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363613.aspx) - /// - virtual DWORD initialize(_Out_ EAP_ERROR **ppEapError) = 0; - - /// - /// Shuts down the EAP method and prepares to unload its corresponding DLL. - /// - /// \sa [EapPeerShutdown function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363627.aspx) - /// - virtual DWORD shutdown(_Out_ EAP_ERROR **ppEapError) = 0; - - /// - /// Returns the user data and user identity after being called by EAPHost. - /// - /// \sa [EapPeerGetIdentity function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363607.aspx) - /// - virtual DWORD get_identity( - _In_ DWORD dwFlags, - _In_ DWORD dwConnectionDataSize, - _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, - _In_ DWORD dwUserDataSize, - _In_count_(dwUserDataSize) const BYTE *pUserData, - _In_ HANDLE hTokenImpersonateUser, - _Out_ BOOL *pfInvokeUI, - _Out_ DWORD *pdwUserDataOutSize, - _Out_ BYTE **ppUserDataOut, - _Out_ WCHAR **ppwszIdentity, - _Out_ EAP_ERROR **ppEapError) = 0; - - /// - /// Defines the implementation of an EAP method-specific function that retrieves the properties of an EAP method given the connection and user data. - /// - /// \sa [EapPeerGetMethodProperties function](https://msdn.microsoft.com/en-us/library/windows/desktop/hh706636.aspx) - /// - virtual DWORD get_method_properties( - _In_ DWORD dwVersion, - _In_ DWORD dwFlags, - _In_ HANDLE hUserImpersonationToken, - _In_ DWORD dwEapConnDataSize, - _In_count_(dwEapConnDataSize) const BYTE *pEapConnData, - _In_ DWORD dwUserDataSize, - _In_count_(dwUserDataSize) const BYTE *pUserData, - _Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray, - _Out_ EAP_ERROR **ppEapError) const = 0; - - /// - /// Defines the implementation of an EAP method-specific function that obtains the EAP Single-Sign-On (SSO) credential input fields for an EAP method. - /// - /// \sa [EapPeerQueryCredentialInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363622.aspx) - /// - virtual DWORD query_credential_input_fields( - _In_ HANDLE hUserImpersonationToken, - _In_ DWORD dwFlags, - _In_ DWORD dwEapConnDataSize, - _In_count_(dwEapConnDataSize) const BYTE *pEapConnData, - _Out_ EAP_CONFIG_INPUT_FIELD_ARRAY *pEapConfigInputFieldsArray, - _Out_ EAP_ERROR **ppEapError) const - { - UNREFERENCED_PARAMETER(hUserImpersonationToken); - UNREFERENCED_PARAMETER(dwFlags); - UNREFERENCED_PARAMETER(dwEapConnDataSize); - UNREFERENCED_PARAMETER(pEapConnData); - UNREFERENCED_PARAMETER(pEapConfigInputFieldsArray); - UNREFERENCED_PARAMETER(ppEapError); - - DWORD dwResult = ERROR_NOT_SUPPORTED; - ETW_FN_DWORD(dwResult); - return dwResult; - } - - /// - /// Defines the implementation of an EAP method function that obtains the user BLOB data provided in an interactive Single-Sign-On (SSO) UI raised on the supplicant. - /// - /// \sa [EapPeerQueryUserBlobFromCredentialInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204697.aspx) - /// - virtual DWORD query_user_blob_from_credential_input_fields( - _In_ HANDLE hUserImpersonationToken, - _In_ DWORD dwFlags, - _In_ DWORD dwEapConnDataSize, - _In_count_(dwEapConnDataSize) const BYTE *pEapConnData, - _In_ const EAP_CONFIG_INPUT_FIELD_ARRAY *pEapConfigInputFieldArray, - _Inout_ DWORD *pdwUsersBlobSize, - _Inout_ BYTE **ppUserBlob, - _Out_ EAP_ERROR **ppEapError) const - { - UNREFERENCED_PARAMETER(hUserImpersonationToken); - UNREFERENCED_PARAMETER(dwFlags); - UNREFERENCED_PARAMETER(dwEapConnDataSize); - UNREFERENCED_PARAMETER(pEapConnData); - UNREFERENCED_PARAMETER(pEapConfigInputFieldArray); - UNREFERENCED_PARAMETER(pdwUsersBlobSize); - UNREFERENCED_PARAMETER(ppUserBlob); - UNREFERENCED_PARAMETER(ppEapError); - - DWORD dwResult = ERROR_NOT_SUPPORTED; - ETW_FN_DWORD(dwResult); - return dwResult; - } - - /// - /// Defines the implementation of an EAP method API that provides the input fields for interactive UI components to be raised on the supplicant. - /// - /// \sa [EapPeerQueryInteractiveUIInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204695.aspx) - /// - virtual DWORD query_interactive_ui_input_fields( - _In_ DWORD dwVersion, - _In_ DWORD dwFlags, - _In_ DWORD dwUIContextDataSize, - _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, - _Out_ EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, - _Out_ EAP_ERROR **ppEapError, - _Inout_ LPVOID *pvReserved) const - { - UNREFERENCED_PARAMETER(dwVersion); - UNREFERENCED_PARAMETER(dwFlags); - UNREFERENCED_PARAMETER(dwUIContextDataSize); - UNREFERENCED_PARAMETER(pUIContextData); - UNREFERENCED_PARAMETER(pEapInteractiveUIData); - UNREFERENCED_PARAMETER(ppEapError); - UNREFERENCED_PARAMETER(pvReserved); - - DWORD dwResult = ERROR_NOT_SUPPORTED; - ETW_FN_DWORD(dwResult); - return dwResult; - } - - /// - /// Converts user information into a user BLOB that can be consumed by EAPHost run-time functions. - /// - /// \sa [EapPeerQueryUIBlobFromInteractiveUIInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204696.aspx) - /// - virtual DWORD query_ui_blob_from_interactive_ui_input_fields( - _In_ DWORD dwVersion, - _In_ DWORD dwFlags, - _In_ DWORD dwUIContextDataSize, - _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, - _In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, - _Out_ DWORD *pdwDataFromInteractiveUISize, - _Out_ BYTE **ppDataFromInteractiveUI, - _Out_ EAP_ERROR **ppEapError, - _Inout_ LPVOID *ppvReserved) const - { - UNREFERENCED_PARAMETER(dwVersion); - UNREFERENCED_PARAMETER(dwFlags); - UNREFERENCED_PARAMETER(dwUIContextDataSize); - UNREFERENCED_PARAMETER(pUIContextData); - UNREFERENCED_PARAMETER(pEapInteractiveUIData); - UNREFERENCED_PARAMETER(pdwDataFromInteractiveUISize); - UNREFERENCED_PARAMETER(ppDataFromInteractiveUI); - UNREFERENCED_PARAMETER(ppEapError); - UNREFERENCED_PARAMETER(ppvReserved); - - DWORD dwResult = ERROR_NOT_SUPPORTED; - ETW_FN_DWORD(dwResult); - return dwResult; - } - }; -} - - -namespace eapserial -{ - /// - /// Packs a method configuration - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val Configuration to pack - /// - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_method &val) - { - pack(cursor, val.m_allow_save ); - pack(cursor, val.m_anonymous_identity); - } - - - /// - /// Returns packed size of a method configuration - /// - /// \param[in] val Configuration to pack - /// - /// \returns Size of data when packed (in bytes) - /// - inline size_t get_pk_size(const eap::config_method &val) - { - return - get_pk_size(val.m_allow_save ) + - get_pk_size(val.m_anonymous_identity); - } - - - /// - /// Unpacks a method configuration - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val Configuration to unpack to - /// - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_method &val) - { - unpack(cursor, val.m_allow_save ); - unpack(cursor, val.m_anonymous_identity); - } - - - /// - /// Packs a provider configuration - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val Configuration to pack - /// - template - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_provider<_Tmeth> &val) - { - pack(cursor, val.m_id ); - pack(cursor, val.m_lbl_alt_credential); - pack(cursor, val.m_lbl_alt_identity ); - pack(cursor, val.m_lbl_alt_password ); - pack(cursor, val.m_methods ); - } - - - /// - /// Returns packed size of a provider configuration - /// - /// \param[in] val Configuration to pack - /// - /// \returns Size of data when packed (in bytes) - /// - template - inline size_t get_pk_size(const eap::config_provider<_Tmeth> &val) - { - return - get_pk_size(val.m_id ) + - get_pk_size(val.m_lbl_alt_credential) + - get_pk_size(val.m_lbl_alt_identity ) + - get_pk_size(val.m_lbl_alt_password ) + - get_pk_size(val.m_methods ); - } - - - /// - /// Unpacks a provider configuration - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val Configuration to unpack to - /// - template - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_provider<_Tmeth> &val) - { - unpack(cursor, val.m_id ); - unpack(cursor, val.m_lbl_alt_credential); - unpack(cursor, val.m_lbl_alt_identity ); - unpack(cursor, val.m_lbl_alt_password ); - - std::list<_Tmeth>::size_type count = *(const std::list<_Tmeth>::size_type*&)cursor; - cursor += sizeof(std::list<_Tmeth>::size_type); - val.m_methods.clear(); - for (std::list<_Tmeth>::size_type i = 0; i < count; i++) { - _Tmeth el(val.m_module); - unpack(cursor, el); - val.m_methods.push_back(std::move(el)); - } - } - - - /// - /// Packs a providers configuration - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val Configuration to pack - /// - template - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_providers<_Tprov> &val) - { - pack(cursor, val.m_providers); - } - - - /// - /// Returns packed size of a providers configuration - /// - /// \param[in] val Configuration to pack - /// - /// \returns Size of data when packed (in bytes) - /// - template - inline size_t get_pk_size(const eap::config_providers<_Tprov> &val) - { - return get_pk_size(val.m_providers); - } - - - /// - /// Unpacks a providers configuration - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val Configuration to unpack to - /// - template - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_providers<_Tprov> &val) - { - std::list<_Tprov>::size_type count = *(const std::list<_Tprov>::size_type*&)cursor; - cursor += sizeof(std::list<_Tprov>::size_type); - val.m_providers.clear(); - for (std::list<_Tprov>::size_type i = 0; i < count; i++) { - _Tprov el(val.m_module); - unpack(cursor, el); - val.m_providers.push_back(std::move(el)); - } - } - - - /// - /// Packs a method credentials - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val Credentials to pack - /// - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials &val) - { - pack(cursor, (const eap::config&)val); - pack(cursor, val.m_identity ); - } - - - /// - /// Returns packed size of a method credentials - /// - /// \param[in] val Credentials to pack - /// - /// \returns Size of data when packed (in bytes) - /// - inline size_t get_pk_size(const eap::credentials &val) - { - return - get_pk_size((const eap::config&)val) + - get_pk_size(val.m_identity ); - } - - - /// - /// Unpacks a method credentials - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val Credentials to unpack to - /// - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials &val) - { - unpack(cursor, (eap::config&)val); - unpack(cursor, val.m_identity ); - } - - - /// - /// Packs a password based method credentials - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val Credentials to pack - /// - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_pass &val) - { - pack(cursor, (const eap::credentials&)val); - pack(cursor, val.m_password ); - } - - - /// - /// Returns packed size of a password based method credentials - /// - /// \param[in] val Credentials to pack - /// - /// \returns Size of data when packed (in bytes) - /// - inline size_t get_pk_size(const eap::credentials_pass &val) - { - return - get_pk_size((const eap::credentials&)val) + - get_pk_size(val.m_password ); - } - - - /// - /// Unpacks a password based method credentials - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val Credentials to unpack to - /// - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_pass &val) - { - unpack(cursor, (eap::credentials&)val); - unpack(cursor, val.m_password ); - } -} - -#endif diff --git a/EAPMethods/include/TTLS.h b/EAPMethods/include/TTLS.h deleted file mode 100644 index 0ba3fb2b..00000000 --- a/EAPMethods/include/TTLS.h +++ /dev/null @@ -1,405 +0,0 @@ -/* - 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 "EAP.h" -#include "EAPSerial.h" -#include "TLS.h" -#include "PAP.h" - -#include - - -namespace eap -{ - class config_ttls; - class credentials_ttls; - class session_ttls; - class peer_ttls; -} - -namespace eapserial -{ - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_ttls &val); - inline size_t get_pk_size(const eap::config_ttls &val); - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_ttls &val); -} - -#pragma once - - -namespace eap -{ - /// - /// TTLS configuration - /// - class config_ttls : public config_tls - { - public: - /// - /// Constructs configuration - /// - /// \param[in] mod Reference of the EAP module to use for global services - /// - config_ttls(_In_ module &mod); - - /// - /// Copies configuration - /// - /// \param[in] other Configuration to copy from - /// - config_ttls(const _In_ config_ttls &other); - - /// - /// Moves configuration - /// - /// \param[in] other Configuration to move from - /// - config_ttls(_Inout_ config_ttls &&other); - - /// - /// Destructs configuration - /// - virtual ~config_ttls(); - - /// - /// Copies configuration - /// - /// \param[in] other Configuration to copy from - /// - /// \returns Reference to this object - /// - config_ttls& operator=(const _In_ config_ttls &other); - - /// - /// Moves configuration - /// - /// \param[in] other Configuration to move from - /// - /// \returns Reference to this object - /// - config_ttls& operator=(_Inout_ config_ttls &&other); - - /// - /// Clones configuration - /// - /// \returns Pointer to cloned configuration - /// - virtual config* clone() const { return new config_ttls(*this); } - - /// \name XML configuration management - /// @{ - - /// - /// Save configuration to XML document - /// - /// \param[in] pDoc XML document - /// \param[in] pConfigRoot Suggested root element for saving configuration - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const; - - /// - /// Load configuration from XML document - /// - /// \param[in] pConfigRoot Root element for loading configuration - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError); - - /// @} - - /// - /// Returns EAP method type of this configuration - /// - /// \returns `eap::type_ttls` - /// - virtual eap::type_t get_method_id() { return eap::type_ttls; } - - public: - config_method *m_inner; ///< Inner authentication configuration - }; - - - /// - /// TTLS credentials - /// - class credentials_ttls : public credentials_tls - { - public: - /// - /// Constructs credentials - /// - /// \param[in] mod Reference of the EAP module to use for global services - /// - credentials_ttls(_In_ module &mod); - - /// - /// Copies credentials - /// - /// \param[in] other Credentials to copy from - /// - credentials_ttls(_In_ const credentials_ttls &other); - - /// - /// Moves credentials - /// - /// \param[in] other Credentials to move from - /// - credentials_ttls(_Inout_ credentials_ttls &&other); - - /// - /// Copies credentials - /// - /// \param[in] other Credentials to copy from - /// - /// \returns Reference to this object - /// - credentials_ttls& operator=(_In_ const credentials_ttls &other); - - /// - /// Moves credentials - /// - /// \param[in] other Credentials to move from - /// - /// \returns Reference to this object - /// - credentials_ttls& operator=(_Inout_ credentials_ttls &&other); - - /// - /// Clones credentials - /// - /// \returns Pointer to cloned credentials - /// - virtual config* clone() const { return new credentials_ttls(*this); } - - /// - /// Resets credentials - /// - virtual void clear(); - - /// - /// Test credentials if blank - /// - virtual bool empty() const; - - /// \name XML credentials management - /// @{ - - /// - /// Load credentials from XML document - /// - /// \param[in] pConfigRoot Root element for loading credentials - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError); - - /// @} - - /// \name Storage - /// @{ - - /// - /// Save credentials to Windows Credential Manager - /// - /// \param[in] pszTargetName The name in Windows Credential Manager to store credentials as - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const; - - /// - /// Retrieve credentials from Windows Credential Manager - /// - /// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError); - - /// @} - - public: - credentials *m_inner; ///< Inner credentials - }; - - - /// - /// TTLS session - /// - class session_ttls : public session - { - public: - /// - /// Constructor - /// - session_ttls(); - }; - - - /// - /// TTLS peer - /// - class peer_ttls : public peer - { - public: - /// - /// Constructor - /// - peer_ttls(); - - /// - /// Initializes an EAP peer method for EAPHost. - /// - /// \sa [EapPeerGetInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363613.aspx) - /// - virtual DWORD initialize(_Out_ EAP_ERROR **ppEapError); - - /// - /// Shuts down the EAP method and prepares to unload its corresponding DLL. - /// - /// \sa [EapPeerShutdown function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363627.aspx) - /// - virtual DWORD shutdown(_Out_ EAP_ERROR **ppEapError); - - /// - /// Returns the user data and user identity after being called by EAPHost. - /// - /// \sa [EapPeerGetIdentity function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363607.aspx) - /// - virtual DWORD get_identity( - _In_ DWORD dwFlags, - _In_ DWORD dwConnectionDataSize, - _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, - _In_ DWORD dwUserDataSize, - _In_count_(dwUserDataSize) const BYTE *pUserData, - _In_ HANDLE hTokenImpersonateUser, - _Out_ BOOL *pfInvokeUI, - _Out_ DWORD *pdwUserDataOutSize, - _Out_ BYTE **ppUserDataOut, - _Out_ WCHAR **ppwszIdentity, - _Out_ EAP_ERROR **ppEapError); - - /// - /// Defines the implementation of an EAP method-specific function that retrieves the properties of an EAP method given the connection and user data. - /// - /// \sa [EapPeerGetMethodProperties function](https://msdn.microsoft.com/en-us/library/windows/desktop/hh706636.aspx) - /// - virtual DWORD get_method_properties( - _In_ DWORD dwVersion, - _In_ DWORD dwFlags, - _In_ HANDLE hUserImpersonationToken, - _In_ DWORD dwEapConnDataSize, - _In_count_(dwEapConnDataSize) const BYTE *pEapConnData, - _In_ DWORD dwUserDataSize, - _In_count_(dwUserDataSize) const BYTE *pUserData, - _Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray, - _Out_ EAP_ERROR **ppEapError) const; - }; -} - - -namespace eapserial -{ - /// - /// Packs a TTLS based method configuration - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val Configuration to pack - /// - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_ttls &val) - { - pack(cursor, (const eap::config_tls&)val); - if (val.m_inner) { - if (dynamic_cast(val.m_inner)) { - pack(cursor, (unsigned char)eap::type_pap); - pack(cursor, (const eap::config_pap&)*val.m_inner); - } else { - assert(0); // Unsupported inner authentication method type. - pack(cursor, (unsigned char)0); - } - } else - pack(cursor, (unsigned char)0); - } - - - /// - /// Returns packed size of a TTLS based method configuration - /// - /// \param[in] val Configuration to pack - /// - /// \returns Size of data when packed (in bytes) - /// - inline size_t get_pk_size(const eap::config_ttls &val) - { - size_t size_inner = sizeof(unsigned char); - if (val.m_inner) { - if (dynamic_cast(val.m_inner)) - size_inner += get_pk_size((const eap::config_pap&)*val.m_inner); - else - assert(0); // Unsupported inner authentication method type. - } - - return - get_pk_size((const eap::config_tls&)val) + - size_inner; - } - - - /// - /// Unpacks a TTLS based method configuration - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val Configuration to unpack to - /// - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_ttls &val) - { - unpack(cursor, (eap::config_tls&)val); - - assert(!val.m_inner); - unsigned char eap_type; - unpack(cursor, eap_type); - switch (eap_type) { - case eap::type_pap: - val.m_inner = new eap::config_pap(val.m_module); - unpack(cursor, (eap::config_pap&)*val.m_inner); - break; - case 0 : break; - default : assert(0); // Unsupported inner authentication method type. - } - } -} diff --git a/EAPMethods/locale/EAPMethods.pot b/EAPMethods/locale/EAPMethods.pot index 0085aa5d..4961da6a 100644 --- a/EAPMethods/locale/EAPMethods.pot +++ b/EAPMethods/locale/EAPMethods.pot @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: EAPMethods\n" -"POT-Creation-Date: 2016-06-09 15:19+0200\n" +"POT-Creation-Date: 2016-06-10 12:06+0200\n" "PO-Revision-Date: 2016-06-02 12:27+0200\n" "Last-Translator: Simon Rozman \n" "Language-Team: Amebis, d. o. o., Kamnik \n" @@ -10,295 +10,332 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 1.8.8\n" -"X-Poedit-Basepath: ..\n" +"X-Poedit-Basepath: ../..\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "Language: en_US\n" "X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-KeywordsList: _\n" -"X-Poedit-SearchPath-0: res\n" -"X-Poedit-SearchPath-1: MSIBuild\n" -"X-Poedit-SearchPath-2: src\n" -"X-Poedit-SearchPath-3: include\n" +"X-Poedit-SearchPath-0: lib/EAPBase_UI\n" +"X-Poedit-SearchPath-1: lib/PAP_UI\n" +"X-Poedit-SearchPath-2: lib/TLS_UI\n" +"X-Poedit-SearchPath-3: lib/TTLS_UI\n" +"X-Poedit-SearchPath-4: EAPMethods\n" -#: res/wxEAP_UI.cpp:123 res/wxEAP_UI.cpp:200 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:123 lib/EAPBase_UI/res/wxEAP_UI.cpp:200 msgid "Client Credentials" msgstr "" -#: res/wxEAP_UI.cpp:134 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:134 msgid "Manage your credentials stored in Windows Credential Manager." msgstr "" -#: res/wxEAP_UI.cpp:144 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:144 msgid "Identity:" msgstr "" -#: res/wxEAP_UI.cpp:149 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:149 msgid "Enter your user name here (user@domain.org, DOMAINUser, etc.)" msgstr "" -#: res/wxEAP_UI.cpp:159 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:159 msgid "&Set Credentials..." msgstr "" -#: res/wxEAP_UI.cpp:160 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:160 msgid "Click here to set or modify your credentials" msgstr "" -#: res/wxEAP_UI.cpp:164 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:164 msgid "&Clear Credentials" msgstr "" -#: res/wxEAP_UI.cpp:165 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:165 msgid "" "Click to clear your credentials from Credential Manager.\n" "Note: You will be prompted to enter credentials when connecting." msgstr "" -#: res/wxEAP_UI.cpp:211 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:211 msgid "Please provide your user ID and password." msgstr "" -#: res/wxEAP_UI.cpp:221 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:221 msgid "User ID:" msgstr "" -#: res/wxEAP_UI.cpp:226 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:226 msgid "Enter your user name here (user@domain.org, DOMAIN\\User, etc.)" msgstr "" -#: res/wxEAP_UI.cpp:230 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:230 msgid "Password:" msgstr "" -#: res/wxEAP_UI.cpp:235 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:235 msgid "Enter your password here" msgstr "" -#: res/wxEAP_UI.cpp:242 res/wxTLS_UI.cpp:164 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:242 lib/TLS_UI/res/wxTLS_UI.cpp:164 msgid "&Remember" msgstr "" -#: res/wxEAP_UI.cpp:243 +#: lib/EAPBase_UI/res/wxEAP_UI.cpp:243 msgid "Check if you would like to save username and password" msgstr "" -#: res/wxTLS_UI.cpp:17 +#: lib/PAP_UI/src/PAP_UI.cpp:41 +msgid "This method requires no additional settings." +msgstr "" + +#: lib/TLS_UI/res/wxTLS_UI.cpp:17 msgid "Server Trust" msgstr "" -#: res/wxTLS_UI.cpp:28 +#: lib/TLS_UI/res/wxTLS_UI.cpp:28 msgid "Describe the servers you trust to prevent credential interception in case of man-in-the-middle attacks." msgstr "" -#: res/wxTLS_UI.cpp:35 +#: lib/TLS_UI/res/wxTLS_UI.cpp:35 msgid "Acceptable Certificate Authorities:" msgstr "" -#: res/wxTLS_UI.cpp:40 +#: lib/TLS_UI/res/wxTLS_UI.cpp:40 msgid "List of certificate authorities server's certificate must be issued by" msgstr "" -#: res/wxTLS_UI.cpp:47 +#: lib/TLS_UI/res/wxTLS_UI.cpp:47 msgid "Add CA from Store..." msgstr "" -#: res/wxTLS_UI.cpp:48 +#: lib/TLS_UI/res/wxTLS_UI.cpp:48 msgid "Adds a new certificate authority from the certificate store to the list" msgstr "" -#: res/wxTLS_UI.cpp:52 +#: lib/TLS_UI/res/wxTLS_UI.cpp:52 msgid "Add CA from File..." msgstr "" -#: res/wxTLS_UI.cpp:53 +#: lib/TLS_UI/res/wxTLS_UI.cpp:53 msgid "Adds a new certificate authority from the file to the list" msgstr "" -#: res/wxTLS_UI.cpp:57 +#: lib/TLS_UI/res/wxTLS_UI.cpp:57 msgid "&Remove CA" msgstr "" -#: res/wxTLS_UI.cpp:59 +#: lib/TLS_UI/res/wxTLS_UI.cpp:59 msgid "Removes selected certificate authorities from the list" msgstr "" -#: res/wxTLS_UI.cpp:72 +#: lib/TLS_UI/res/wxTLS_UI.cpp:72 msgid "Acceptable server &names:" msgstr "" -#: res/wxTLS_UI.cpp:77 +#: lib/TLS_UI/res/wxTLS_UI.cpp:77 msgid "A semicolon delimited list of acceptable server FQDN names; blank to skip name check; \"*\" wildchar allowed" msgstr "" -#: res/wxTLS_UI.cpp:81 +#: lib/TLS_UI/res/wxTLS_UI.cpp:81 msgid "(Example: foo.bar.com;*.domain.org)" msgstr "" -#: res/wxTLS_UI.cpp:120 +#: lib/TLS_UI/res/wxTLS_UI.cpp:120 msgid "TLS Client Certificate" msgstr "" -#: res/wxTLS_UI.cpp:131 +#: lib/TLS_UI/res/wxTLS_UI.cpp:131 msgid "Please select your client certificate to use for authentication." msgstr "" -#: res/wxTLS_UI.cpp:138 +#: lib/TLS_UI/res/wxTLS_UI.cpp:138 msgid "Co&nnect without providing a client certificate" msgstr "" -#: res/wxTLS_UI.cpp:139 +#: lib/TLS_UI/res/wxTLS_UI.cpp:139 msgid "Select if your server does not require you to provide a client certificate" msgstr "" -#: res/wxTLS_UI.cpp:146 +#: lib/TLS_UI/res/wxTLS_UI.cpp:146 msgid "Use the following &certificate:" msgstr "" -#: res/wxTLS_UI.cpp:147 +#: lib/TLS_UI/res/wxTLS_UI.cpp:147 msgid "Select if you need to provide a client certificate when connecting" msgstr "" -#: res/wxTLS_UI.cpp:154 +#: lib/TLS_UI/res/wxTLS_UI.cpp:154 msgid "Client certificate to use for authentication" msgstr "" -#: res/wxTLS_UI.cpp:165 +#: lib/TLS_UI/res/wxTLS_UI.cpp:165 msgid "Check if you would like to save certificate selection" msgstr "" -#: res/wxTTLS_UI.cpp:17 -msgid "Outer Identity" +#: lib/TLS_UI/src/TLS_UI.cpp:199 +#, c-format +msgid "Invalid character in host name found: %c" msgstr "" -#: res/wxTTLS_UI.cpp:28 -msgid "Select the user ID supplicant introduces itself as to authenticator:" +#: lib/TLS_UI/src/TLS_UI.cpp:199 +msgid "Validation conflict" msgstr "" -#: res/wxTTLS_UI.cpp:35 -msgid "&Same as inner identity" +#: lib/TLS_UI/src/TLS_UI.cpp:551 +msgid "Add Certificate" msgstr "" -#: res/wxTTLS_UI.cpp:36 -msgid "Use my true user name" +#: lib/TLS_UI/src/TLS_UI.cpp:552 +msgid "Certificate Files (*.cer;*.crt;*.der;*.p7b;*.pem)" msgstr "" -#: res/wxTTLS_UI.cpp:40 -msgid "Use &empty outer identity (RFC 4822)" +#: lib/TLS_UI/src/TLS_UI.cpp:553 +msgid "X.509 Certificate Files (*.cer;*.crt;*.der;*.pem)" msgstr "" -#: res/wxTTLS_UI.cpp:41 -msgid "Ommit my user name and use @mydomain.org only" +#: lib/TLS_UI/src/TLS_UI.cpp:554 +msgid "PKCS #7 Certificate Files (*.p7b)" msgstr "" -#: res/wxTTLS_UI.cpp:48 -msgid "&Custom outer identity:" +#: lib/TLS_UI/src/TLS_UI.cpp:555 +msgid "All Files (*.*)" msgstr "" -#: res/wxTTLS_UI.cpp:49 -msgid "Specify custom outer identity" +#: lib/TLS_UI/src/TLS_UI.cpp:571 +#, c-format +msgid "Invalid or unsupported certificate file %s" msgstr "" -#: res/wxTTLS_UI.cpp:54 -msgid "Custom outer identity to use" -msgstr "" +#: lib/TLS_UI/src/TLS_UI.cpp:571 +#, fuzzy +msgid "Error" +msgstr "Napaka pri nalaganju knjižnice MSI.DLL (%1!ld!)." -#: src/PAP_UI.cpp:41 -msgid "This method requires no additional settings." +#: lib/TTLS_UI/res/wxTTLS_UI.cpp:17 +msgid "Outer Identity" msgstr "" -#: src/TLS_UI.cpp:198 -#, c-format -msgid "Invalid character in host name found: %c" +#: lib/TTLS_UI/res/wxTTLS_UI.cpp:28 +msgid "Select the user ID supplicant introduces itself as to authenticator:" msgstr "" -#: src/TLS_UI.cpp:198 -msgid "Validation conflict" +#: lib/TTLS_UI/res/wxTTLS_UI.cpp:35 +msgid "&Same as inner identity" msgstr "" -#: src/TLS_UI.cpp:550 -msgid "Add Certificate" +#: lib/TTLS_UI/res/wxTTLS_UI.cpp:36 +msgid "Use my true user name" msgstr "" -#: src/TLS_UI.cpp:551 -msgid "Certificate Files (*.cer;*.crt;*.der;*.p7b;*.pem)" +#: lib/TTLS_UI/res/wxTTLS_UI.cpp:40 +msgid "Use &empty outer identity (RFC 4822)" msgstr "" -#: src/TLS_UI.cpp:552 -msgid "X.509 Certificate Files (*.cer;*.crt;*.der;*.pem)" +#: lib/TTLS_UI/res/wxTTLS_UI.cpp:41 +msgid "Ommit my user name and use @mydomain.org only" msgstr "" -#: src/TLS_UI.cpp:553 -msgid "PKCS #7 Certificate Files (*.p7b)" +#: lib/TTLS_UI/res/wxTTLS_UI.cpp:48 +msgid "&Custom outer identity:" msgstr "" -#: src/TLS_UI.cpp:554 -msgid "All Files (*.*)" +#: lib/TTLS_UI/res/wxTTLS_UI.cpp:49 +msgid "Specify custom outer identity" msgstr "" -#: src/TLS_UI.cpp:570 -#, c-format -msgid "Invalid or unsupported certificate file %s" +#: lib/TTLS_UI/res/wxTTLS_UI.cpp:54 +msgid "Custom outer identity to use" msgstr "" -#: src/TLS_UI.cpp:570 -#, fuzzy -msgid "Error" -msgstr "Napaka pri nalaganju knjižnice MSI.DLL (%1!ld!)." - -#: src/TTLS_UI.cpp:172 +#: lib/TTLS_UI/src/TTLS_UI.cpp:92 msgid "Outer Authentication" msgstr "" -#: src/TTLS_UI.cpp:185 +#: lib/TTLS_UI/src/TTLS_UI.cpp:105 msgid "Inner Authentication" msgstr "" -#: src/TTLS_UI.cpp:191 +#: lib/TTLS_UI/src/TTLS_UI.cpp:111 msgid "Select inner authentication method from the list" msgstr "" -#: src/TTLS_UI.cpp:192 +#: lib/TTLS_UI/src/TTLS_UI.cpp:112 msgid "PAP" msgstr "" -#: include/EAP_UI.h:272 +#: lib/EAPBase_UI/include/EAP_UI.h:217 msgid "" msgstr "" -#: include/EAP_UI.h:278 +#: lib/EAPBase_UI/include/EAP_UI.h:223 #, c-format msgid "" msgstr "" -#: include/EAP_UI.h:301 +#: lib/EAPBase_UI/include/EAP_UI.h:246 #, c-format msgid "Deleting credentials failed (error %u)." msgstr "" -#: include/EAP_UI.h:358 +#: lib/EAPBase_UI/include/EAP_UI.h:300 #, c-format msgid "Error reading credentials from Credential Manager: %ls (error %u)" msgstr "" -#: include/EAP_UI.h:361 +#: lib/EAPBase_UI/include/EAP_UI.h:303 #, c-format msgid "Reading credentials failed (error %u)." msgstr "" -#: include/EAP_UI.h:376 +#: lib/EAPBase_UI/include/EAP_UI.h:318 #, c-format msgid "Error writing credentials to Credential Manager: %ls (error %u)" msgstr "" -#: include/EAP_UI.h:379 +#: lib/EAPBase_UI/include/EAP_UI.h:321 #, c-format msgid "Writing credentials failed (error %u)." msgstr "" -#: res/wxEAP_UI.h:56 +#: lib/EAPBase_UI/res/wxEAP_UI.h:56 msgid "EAP Method Configuration" msgstr "" -#: res/wxEAP_UI.h:81 +#: lib/EAPBase_UI/res/wxEAP_UI.h:81 msgid "EAP Credentials" msgstr "" + +#: EAPMethods/MSIBuild/En.Win32.Debug.Feature-2.idtx:3 +#: EAPMethods/MSIBuild/En.Win32.Release.Feature-2.idtx:3 +#: EAPMethods/MSIBuild/En.x64.Debug.Feature-2.idtx:3 +#: EAPMethods/MSIBuild/En.x64.Release.Feature-2.idtx:3 +#, fuzzy +msgid "1252" +msgstr "1250" + +#: EAPMethods/MSIBuild/En.Win32.Debug.Feature-2.idtx:4 +#: EAPMethods/MSIBuild/En.Win32.Release.Feature-2.idtx:4 +#: EAPMethods/MSIBuild/En.x64.Debug.Feature-2.idtx:4 +#: EAPMethods/MSIBuild/En.x64.Release.Feature-2.idtx:4 +msgid "EAP Peer Methods" +msgstr "" + +#: EAPMethods/MSIBuild/En.Win32.Debug.Feature-2.idtx:4 +#: EAPMethods/MSIBuild/En.Win32.Release.Feature-2.idtx:4 +#: EAPMethods/MSIBuild/En.x64.Debug.Feature-2.idtx:4 +#: EAPMethods/MSIBuild/En.x64.Release.Feature-2.idtx:4 +msgid "Modules to support individual EAP methods" +msgstr "" + +#: EAPMethods/MSIBuild/En.Win32.Debug.Feature-2.idtx:5 +#: EAPMethods/MSIBuild/En.Win32.Release.Feature-2.idtx:5 +#: EAPMethods/MSIBuild/En.x64.Debug.Feature-2.idtx:5 +#: EAPMethods/MSIBuild/En.x64.Release.Feature-2.idtx:5 +msgid "TTLS" +msgstr "" + +#: EAPMethods/MSIBuild/En.Win32.Debug.Feature-2.idtx:5 +#: EAPMethods/MSIBuild/En.Win32.Release.Feature-2.idtx:5 +#: EAPMethods/MSIBuild/En.x64.Debug.Feature-2.idtx:5 +#: EAPMethods/MSIBuild/En.x64.Release.Feature-2.idtx:5 +msgid "Tunneled Transport Layer Security" +msgstr "" diff --git a/EAPMethods/src/EAP.cpp b/EAPMethods/src/EAP.cpp deleted file mode 100644 index 6fcc8f8e..00000000 --- a/EAPMethods/src/EAP.cpp +++ /dev/null @@ -1,727 +0,0 @@ -/* - 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 - -using namespace std; -using namespace winstd; - - -////////////////////////////////////////////////////////////////////// -// eap::session -////////////////////////////////////////////////////////////////////// - -eap::session::session() -{ -} - - -eap::session::~session() -{ -} - - -DWORD eap::session::begin( - _In_ DWORD dwFlags, - _In_ const EapAttributes *pAttributeArray, - _In_ HANDLE hTokenImpersonateUser, - _In_ DWORD dwConnectionDataSize, - _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, - _In_ DWORD dwUserDataSize, - _In_count_(dwUserDataSize) const BYTE *pUserData, - _In_ DWORD dwMaxSendPacketSize, - _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(dwFlags); - UNREFERENCED_PARAMETER(pAttributeArray); - UNREFERENCED_PARAMETER(hTokenImpersonateUser); - UNREFERENCED_PARAMETER(dwConnectionDataSize); - UNREFERENCED_PARAMETER(pConnectionData); - UNREFERENCED_PARAMETER(dwUserDataSize); - UNREFERENCED_PARAMETER(pUserData); - UNREFERENCED_PARAMETER(dwMaxSendPacketSize); - UNREFERENCED_PARAMETER(ppEapError); - - return ERROR_SUCCESS; -} - - -DWORD eap::session::end(_Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(ppEapError); - - return ERROR_SUCCESS; -} - - -DWORD eap::session::process_request_packet( - _In_ DWORD dwReceivedPacketSize, - _In_bytecount_(dwReceivedPacketSize) const EapPacket *pReceivedPacket, - _Out_ EapPeerMethodOutput *pEapOutput, - _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(dwReceivedPacketSize); - UNREFERENCED_PARAMETER(pReceivedPacket); - UNREFERENCED_PARAMETER(pEapOutput); - UNREFERENCED_PARAMETER(ppEapError); - - return ERROR_NOT_SUPPORTED; -} - - -DWORD eap::session::get_response_packet( - _Inout_ DWORD *pdwSendPacketSize, - _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, - _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(pdwSendPacketSize); - UNREFERENCED_PARAMETER(pSendPacket); - UNREFERENCED_PARAMETER(ppEapError); - - return ERROR_NOT_SUPPORTED; -} - - -DWORD eap::session::get_result(_In_ EapPeerMethodResultReason reason, _Out_ EapPeerMethodResult *ppResult, _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(reason); - UNREFERENCED_PARAMETER(ppResult); - UNREFERENCED_PARAMETER(ppEapError); - - return ERROR_NOT_SUPPORTED; -} - - -DWORD eap::session::get_ui_context( - _Out_ DWORD *pdwUIContextDataSize, - _Out_ BYTE **ppUIContextData, - _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(pdwUIContextDataSize); - UNREFERENCED_PARAMETER(ppUIContextData); - UNREFERENCED_PARAMETER(ppEapError); - - return ERROR_NOT_SUPPORTED; -} - - -DWORD eap::session::set_ui_context( - _In_ DWORD dwUIContextDataSize, - _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, - _In_ const EapPeerMethodOutput *pEapOutput, - _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(dwUIContextDataSize); - UNREFERENCED_PARAMETER(pUIContextData); - UNREFERENCED_PARAMETER(pEapOutput); - UNREFERENCED_PARAMETER(ppEapError); - - return ERROR_NOT_SUPPORTED; -} - - -DWORD eap::session::get_response_attributes(_Out_ EapAttributes *pAttribs, _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(pAttribs); - UNREFERENCED_PARAMETER(ppEapError); - - return ERROR_NOT_SUPPORTED; -} - - -DWORD eap::session::set_response_attributes(const _In_ EapAttributes *pAttribs, _Out_ EapPeerMethodOutput *pEapOutput, _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(pAttribs); - UNREFERENCED_PARAMETER(pEapOutput); - UNREFERENCED_PARAMETER(ppEapError); - - return ERROR_NOT_SUPPORTED; -} - - -////////////////////////////////////////////////////////////////////// -// eap::config -////////////////////////////////////////////////////////////////////// - -eap::config::config(_In_ module &mod) : - m_module(mod) -{ -} - - -eap::config::config(_In_ const config &other) : - m_module(other.m_module) -{ -} - - -eap::config::config(_Inout_ config &&other) : - m_module(other.m_module) -{ -} - - -eap::config::~config() -{ -} - - -eap::config& eap::config::operator=(_In_ const config &other) -{ - UNREFERENCED_PARAMETER(other); - assert(&m_module == &other.m_module); // Copy configuration within same module only! - return *this; -} - - -eap::config& eap::config::operator=(_Inout_ config &&other) -{ - UNREFERENCED_PARAMETER(other); - assert(&m_module == &other.m_module); // Copy configuration within same module only! - return *this; -} - - -////////////////////////////////////////////////////////////////////// -// eap::config_method -////////////////////////////////////////////////////////////////////// - -eap::config_method::config_method(_In_ module &mod) : - m_allow_save(true), - config(mod) -{ -} - - -eap::config_method::config_method(_In_ const config_method &other) : - m_allow_save(other.m_allow_save), - m_anonymous_identity(other.m_anonymous_identity), - config(other) -{ -} - - -eap::config_method::config_method(_Inout_ config_method &&other) : - m_allow_save(std::move(other.m_allow_save)), - m_anonymous_identity(std::move(other.m_anonymous_identity)), - config(std::move(other)) -{ -} - - -eap::config_method& eap::config_method::operator=(_In_ const config_method &other) -{ - if (this != &other) { - (config&)*this = other; - m_allow_save = other.m_allow_save; - m_anonymous_identity = other.m_anonymous_identity; - } - - return *this; -} - - -eap::config_method& eap::config_method::operator=(_Inout_ config_method &&other) -{ - if (this != &other) { - (config&&)*this = std::move(other); - m_allow_save = std::move(other.m_allow_save); - m_anonymous_identity = std::move(other.m_anonymous_identity); - } - - return *this; -} - - -DWORD eap::config_method::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const -{ - const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata"); - DWORD dwResult; - - // - com_obj pXmlElClientSideCredential; - if ((dwResult = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:ClientSideCredential"), bstr(L"ClientSideCredential"), bstrNamespace, &pXmlElClientSideCredential)) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - // / - if ((dwResult = eapxml::put_element_value(pDoc, pXmlElClientSideCredential, bstr(L"allow-save"), bstrNamespace, m_allow_save)) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - // / - if (!m_anonymous_identity.empty()) - if ((dwResult = eapxml::put_element_value(pDoc, pXmlElClientSideCredential, bstr(L"AnonymousIdentity"), bstrNamespace, bstr(m_anonymous_identity))) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - return ERROR_SUCCESS; -} - - -DWORD eap::config_method::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(ppEapError); - - m_allow_save = true; - m_anonymous_identity.clear(); - - // - com_obj pXmlElClientSideCredential; - if (eapxml::select_element(pConfigRoot, bstr(L"eap-metadata:ClientSideCredential"), &pXmlElClientSideCredential) == ERROR_SUCCESS) { - // - eapxml::get_element_value(pXmlElClientSideCredential, bstr(L"eap-metadata:allow-save"), &m_allow_save); - - // - eapxml::get_element_value(pXmlElClientSideCredential, bstr(L"eap-metadata:AnonymousIdentity"), m_anonymous_identity); - } - - return ERROR_SUCCESS; -} - - -////////////////////////////////////////////////////////////////////// -// eap::credentials -////////////////////////////////////////////////////////////////////// - -eap::credentials::credentials(_In_ module &mod) : config(mod) -{ -} - - -eap::credentials::credentials(_In_ const credentials &other) : - m_identity(other.m_identity), - config(other) -{ -} - - -eap::credentials::credentials(_Inout_ credentials &&other) : - m_identity(std::move(other.m_identity)), - config(std::move(other)) -{ -} - - -eap::credentials& eap::credentials::operator=(_In_ const credentials &other) -{ - if (this != &other) { - (config&)*this = other; - m_identity = other.m_identity; - } - - return *this; -} - - -eap::credentials& eap::credentials::operator=(_Inout_ credentials &&other) -{ - if (this != &other) { - (config&)*this = std::move(other); - m_identity = std::move(other.m_identity); - } - - return *this; -} - - -void eap::credentials::clear() -{ - m_identity.clear(); -} - - -bool eap::credentials::empty() const -{ - return m_identity.empty(); -} - - -DWORD eap::credentials::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const -{ - UNREFERENCED_PARAMETER(pDoc); - UNREFERENCED_PARAMETER(pConfigRoot); - UNREFERENCED_PARAMETER(ppEapError); - - // Yeah, right!? Credentials are non-exportable! - return ERROR_NOT_SUPPORTED; -} - - -////////////////////////////////////////////////////////////////////// -// eap::credentials_pass -////////////////////////////////////////////////////////////////////// - -eap::credentials_pass::credentials_pass(_In_ module &mod) : credentials(mod) -{ -} - - -eap::credentials_pass::credentials_pass(_In_ const credentials_pass &other) : - m_password(other.m_password), - credentials(other) -{ -} - - -eap::credentials_pass::credentials_pass(_Inout_ credentials_pass &&other) : - m_password(std::move(other.m_password)), - credentials(std::move(other)) -{ -} - - -eap::credentials_pass& eap::credentials_pass::operator=(_In_ const credentials_pass &other) -{ - if (this != &other) { - (credentials&)*this = other; - m_password = other.m_password; - } - - return *this; -} - - -eap::credentials_pass& eap::credentials_pass::operator=(_Inout_ credentials_pass &&other) -{ - if (this != &other) { - (credentials&)*this = std::move(other); - m_password = std::move(other.m_password); - } - - return *this; -} - - -void eap::credentials_pass::clear() -{ - credentials::clear(); - m_password.clear(); -} - - -bool eap::credentials_pass::empty() const -{ - return credentials::empty() && m_password.empty(); -} - - -DWORD eap::credentials_pass::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) -{ - assert(pConfigRoot); - UNREFERENCED_PARAMETER(ppEapError); - - eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:UserName"), m_identity); - - bstr pass; - if ((eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:Password"), &pass)) == ERROR_SUCCESS) - m_password = pass; - SecureZeroMemory((BSTR)pass, sizeof(OLECHAR)*pass.length()); - - return ERROR_SUCCESS; -} - - -DWORD eap::credentials_pass::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const -{ - assert(pszTargetName); - assert(ppEapError); - DWORD dwResult; - string password_enc; - - // Prepare cryptographics provider. - crypt_prov cp; - if (!cp.create(NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CryptAcquireContext failed."), NULL); - return dwResult; - } - - // Import the public key. - HRSRC res = FindResource(m_module.m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PUBLIC), RT_RCDATA); - assert(res); - HGLOBAL res_handle = LoadResource(m_module.m_instance, res); - assert(res_handle); - crypt_key key; - unique_ptr > keyinfo_data; - DWORD keyinfo_size = 0; - if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, (const BYTE*)::LockResource(res_handle), ::SizeofResource(m_module.m_instance, res), CRYPT_DECODE_ALLOC_FLAG, NULL, &keyinfo_data, &keyinfo_size)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CryptDecodeObjectEx failed."), NULL); - return dwResult; - } - - if (!key.import_public(cp, X509_ASN_ENCODING, keyinfo_data.get())) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Public key import failed."), NULL); - return dwResult; - } - - // Convert password to UTF-8. - sanitizing_string password_utf8; - WideCharToMultiByte(CP_UTF8, 0, m_password.c_str(), (int)m_password.length(), password_utf8, NULL, NULL); - - // Pre-allocate memory to allow space, as encryption will grow the data, and we need additional 16B at the end for MD5 hash. - DWORD dwBlockLen; - vector > password(password_utf8.length()); - memcpy(password.data(), password_utf8.c_str(), sizeof(char)*password_utf8.length()); - if (!CryptGetKeyParam(key, KP_BLOCKLEN, dwBlockLen, 0)) dwBlockLen = 0; - password.reserve((password.size() + dwBlockLen - 1) / dwBlockLen * dwBlockLen + 16); - - // Encrypt the password using our public key. Calculate MD5 hash and append it. - crypt_hash hash; - if (!hash.create(cp, CALG_MD5)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Creating MD5 hash failed."), NULL); - return dwResult; - } - if (!CryptEncrypt(key, hash, TRUE, 0, password)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Encrypting password failed."), NULL); - return dwResult; - } - vector hash_bin; - CryptGetHashParam(hash, HP_HASHVAL, hash_bin, 0); - password.insert(password.end(), hash_bin.begin(), hash_bin.end()); - - // Convert encrypted password to Base64, since CredProtectA() fail for binary strings. - string password_base64; - base64_enc enc; - enc.encode(password_base64, password.data(), password.size()); - - // Encrypt the password using user's key. - CRED_PROTECTION_TYPE cpt; - if (!CredProtectA(TRUE, password_base64.c_str(), (DWORD)password_base64.length(), password_enc, &cpt)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredProtect failed."), NULL); - return dwResult; - } - - tstring target(target_name(pszTargetName)); - - // Write credentials. - assert(password_enc.size()*sizeof(char) < CRED_MAX_CREDENTIAL_BLOB_SIZE); - assert(m_identity.length() < CRED_MAX_USERNAME_LENGTH ); - CREDENTIAL cred = { - 0, // Flags - CRED_TYPE_GENERIC, // Type - (LPTSTR)target.c_str(), // TargetName - _T(""), // Comment - { 0, 0 }, // LastWritten - (DWORD)password_enc.size()*sizeof(char), // CredentialBlobSize - (LPBYTE)password_enc.data(), // CredentialBlob - CRED_PERSIST_ENTERPRISE, // Persist - 0, // AttributeCount - NULL, // Attributes - NULL, // TargetAlias - (LPTSTR)m_identity.c_str() // UserName - }; - if (!CredWrite(&cred, 0)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredWrite failed."), NULL); - return dwResult; - } - - return ERROR_SUCCESS; -} - - -DWORD eap::credentials_pass::retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) -{ - assert(pszTargetName); - DWORD dwResult; - - // Read credentials. - unique_ptr > cred; - if (!CredRead(target_name(pszTargetName).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredRead failed."), NULL); - return dwResult; - } - - m_identity = cred->UserName; - - // Decrypt the password using user's key. - string password_base64; - if (!CredUnprotectA(TRUE, (LPCSTR)(cred->CredentialBlob), cred->CredentialBlobSize/sizeof(char), password_base64)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredUnprotect failed."), NULL); - return dwResult; - } - - // Convert Base64 to binary encrypted password, since CredProtectA() fail for binary strings. - vector > password; - base64_dec dec; - bool is_last; - dec.decode(password, is_last, password_base64.c_str(), password_base64.length()); - - // Prepare cryptographics provider. - crypt_prov cp; - if (!cp.create(NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CryptAcquireContext failed."), NULL); - return dwResult; - } - - // Create hash. - crypt_hash hash; - if (!hash.create(cp, CALG_MD5)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Creating MD5 hash failed."), NULL); - return dwResult; - } - DWORD dwHashSize, dwHashSizeSize = sizeof(dwHashSize); - CryptGetHashParam(hash, HP_HASHSIZE, (LPBYTE)&dwHashSize, &dwHashSizeSize, 0); - if (password.size() < dwHashSize) { - *ppEapError = m_module.make_error(dwResult = ERROR_INVALID_DATA, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Encrypted password too short."), NULL); - return dwResult; - } - - // Truncate hash from encrypted password. - vector hash_bin; - size_t enc_size = password.size() - dwHashSize; - hash_bin.assign(password.begin() + enc_size, password.end()); - password.resize(enc_size); - - // Import the private key. - HRSRC res = FindResource(m_module.m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PRIVATE), RT_RCDATA); - assert(res); - HGLOBAL res_handle = LoadResource(m_module.m_instance, res); - assert(res_handle); - crypt_key key; - unique_ptr > keyinfo_data; - DWORD keyinfo_size = 0; - if (!CryptDecodeObjectEx(X509_ASN_ENCODING, PKCS_RSA_PRIVATE_KEY, (const BYTE*)::LockResource(res_handle), ::SizeofResource(m_module.m_instance, res), CRYPT_DECODE_ALLOC_FLAG, NULL, &keyinfo_data, &keyinfo_size)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CryptDecodeObjectEx failed."), NULL); - return dwResult; - } - - if (!key.import(cp, keyinfo_data.get(), keyinfo_size, NULL, 0)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Private key import failed."), NULL); - return dwResult; - } - - // Decrypt the password using our private key. Calculate MD5 hash and verify it. - if (!CryptDecrypt(key, hash, TRUE, 0, password)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Decrypting password failed."), NULL); - return dwResult; - } - vector hash2_bin; - CryptGetHashParam(hash, HP_HASHVAL, hash2_bin, 0); - if (hash_bin != hash2_bin) { - *ppEapError = m_module.make_error(dwResult = ERROR_INVALID_DATA, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Invalid password data."), NULL); - return dwResult; - } - - // Convert password from UTF-8. - MultiByteToWideChar(CP_UTF8, 0, password.data(), (int)password.size(), m_password); - - return ERROR_SUCCESS; -} - - -////////////////////////////////////////////////////////////////////// -// eap::module -////////////////////////////////////////////////////////////////////// - -eap::module::module() : - m_instance(NULL) -{ - m_ep.create(&EAPMETHOD_TRACE_EVENT_PROVIDER); - m_ep.write(&EAPMETHOD_TRACE_EVT_MODULE_LOAD, event_data((BYTE)EAPMETHOD_TYPE), event_data::blank); - - m_heap.create(0, 0, 0); -} - - -eap::module::~module() -{ - m_ep.write(&EAPMETHOD_TRACE_EVT_MODULE_UNLOAD, event_data((BYTE)EAPMETHOD_TYPE), event_data::blank); -} - - -EAP_ERROR* eap::module::make_error(_In_ DWORD dwErrorCode, _In_ DWORD dwReasonCode, _In_ LPCGUID pRootCauseGuid, _In_ LPCGUID pRepairGuid, _In_ LPCGUID pHelpLinkGuid, _In_z_ LPCWSTR pszRootCauseString, _In_z_ LPCWSTR pszRepairString) const -{ - // Calculate memory size requirement. - SIZE_T - nRootCauseSize = pszRootCauseString != NULL && pszRootCauseString[0] ? (wcslen(pszRootCauseString) + 1)*sizeof(WCHAR) : 0, - nRepairStringSize = pszRepairString != NULL && pszRepairString [0] ? (wcslen(pszRepairString ) + 1)*sizeof(WCHAR) : 0, - nEapErrorSize = sizeof(EAP_ERROR) + nRootCauseSize + nRepairStringSize; - - EAP_ERROR *pError = (EAP_ERROR*)HeapAlloc(m_heap, 0, nEapErrorSize); - if (!pError) - return NULL; - BYTE *p = (BYTE*)(pError + 1); - - // Fill the error descriptor. - pError->dwWinError = dwErrorCode; - pError->type.eapType.type = EAPMETHOD_TYPE; - pError->type.eapType.dwVendorId = 0; - pError->type.eapType.dwVendorType = 0; - pError->type.dwAuthorId = 67532; - pError->dwReasonCode = dwReasonCode; - pError->rootCauseGuid = pRootCauseGuid != NULL ? *pRootCauseGuid : GUID_NULL; - pError->repairGuid = pRepairGuid != NULL ? *pRepairGuid : GUID_NULL; - pError->helpLinkGuid = pHelpLinkGuid != NULL ? *pHelpLinkGuid : GUID_NULL; - if (nRootCauseSize) { - pError->pRootCauseString = (LPWSTR)p; - memcpy(pError->pRootCauseString, pszRootCauseString, nRootCauseSize); - p += nRootCauseSize; - } else - pError->pRootCauseString = NULL; - if (nRepairStringSize) { - pError->pRepairString = (LPWSTR)p; - memcpy(pError->pRepairString, pszRepairString, nRepairStringSize); - p += nRepairStringSize; - } else - pError->pRepairString = NULL; - - // Write trace event. - vector evt_desc; - evt_desc.reserve(8); - evt_desc.push_back(event_data(pError->dwWinError)); - evt_desc.push_back(event_data(pError->type.eapType.type)); - evt_desc.push_back(event_data(pError->dwReasonCode)); - evt_desc.push_back(event_data(&(pError->rootCauseGuid), sizeof(GUID))); - evt_desc.push_back(event_data(&(pError->repairGuid), sizeof(GUID))); - evt_desc.push_back(event_data(&(pError->helpLinkGuid), sizeof(GUID))); - evt_desc.push_back(event_data(pError->pRootCauseString)); - evt_desc.push_back(event_data(pError->pRepairString)); - m_ep.write(&EAPMETHOD_TRACE_EAP_ERROR, (ULONG)evt_desc.size(), evt_desc.data()); - - return pError; -} - - -BYTE* eap::module::alloc_memory(_In_ size_t size) -{ - return (BYTE*)HeapAlloc(m_heap, 0, size); -} - - -void eap::module::free_memory(_In_ BYTE *ptr) -{ - ETW_FN_VOID; - - // Since we do security here and some of the BLOBs contain credentials, sanitize every memory block before freeing. - SecureZeroMemory(ptr, HeapSize(m_heap, 0, ptr)); - HeapFree(m_heap, 0, ptr); -} - - -void eap::module::free_error_memory(_In_ EAP_ERROR *err) -{ - ETW_FN_VOID; - - // pRootCauseString and pRepairString always trail the ppEapError to reduce number of (de)allocations. - HeapFree(m_heap, 0, err); -} diff --git a/EAPMethods/src/Main_UI.cpp b/EAPMethods/src/Main_UI.cpp index a8962f94..89be26df 100644 --- a/EAPMethods/src/Main_UI.cpp +++ b/EAPMethods/src/Main_UI.cpp @@ -20,6 +20,8 @@ #include +#pragma comment(lib, "msxml6.lib") + #if EAPMETHOD_TYPE==21 #define _EAPMETHOD_PEER_UI eap::peer_ttls_ui diff --git a/EAPMethods/src/TTLS.cpp b/EAPMethods/src/TTLS.cpp deleted file mode 100644 index c646d569..00000000 --- a/EAPMethods/src/TTLS.cpp +++ /dev/null @@ -1,375 +0,0 @@ -/* - 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 - -#pragma comment(lib, "Msi.lib") -#pragma comment(lib, "msxml6.lib") - -using namespace std; -using namespace winstd; - - -////////////////////////////////////////////////////////////////////// -// eap::config_ttls -////////////////////////////////////////////////////////////////////// - -eap::config_ttls::config_ttls(_In_ module &mod) : - m_inner(NULL), - config_tls(mod) -{ -} - - -eap::config_ttls::config_ttls(const _In_ config_ttls &other) : - m_inner(other.m_inner ? (config_method*)other.m_inner->clone() : NULL), - config_tls(other) -{ -} - - -eap::config_ttls::config_ttls(_Inout_ config_ttls &&other) : - m_inner(other.m_inner), - config_tls(std::move(other)) -{ - other.m_inner = NULL; -} - - -eap::config_ttls::~config_ttls() -{ - if (m_inner) - delete m_inner; -} - - -eap::config_ttls& eap::config_ttls::operator=(const _In_ config_ttls &other) -{ - if (this != &other) { - (config_tls&)*this = other; - if (m_inner) delete m_inner; - m_inner = other.m_inner ? (config_method*)other.m_inner->clone() : NULL; - } - - return *this; -} - - -eap::config_ttls& eap::config_ttls::operator=(_Inout_ config_ttls &&other) -{ - if (this != &other) { - (config_tls&&)*this = std::move(other); - if (m_inner) delete m_inner; - m_inner = other.m_inner; - other.m_inner = NULL; - } - - return *this; -} - - -DWORD eap::config_ttls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const -{ - const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata"); - DWORD dwResult; - - // - com_obj pXmlElInnerAuthenticationMethod; - if ((dwResult = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:InnerAuthenticationMethod"), bstr(L"InnerAuthenticationMethod"), bstrNamespace, &pXmlElInnerAuthenticationMethod)) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - if (dynamic_cast(m_inner)) { - // / - if ((dwResult = eapxml::put_element_value(pDoc, pXmlElInnerAuthenticationMethod, bstr(L"NonEAPAuthMethod"), bstrNamespace, bstr(L"PAP"))) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); - return dwResult; - } - - // /... - if ((dwResult = m_inner->save(pDoc, pXmlElInnerAuthenticationMethod, ppEapError)) != ERROR_SUCCESS) - return dwResult; - } else - return dwResult = ERROR_NOT_SUPPORTED; - - return config_tls::save(pDoc, pConfigRoot, ppEapError); -} - - -DWORD eap::config_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) -{ - assert(ppEapError); - DWORD dwResult; - - // Load inner authentication configuration (). - com_obj pXmlElInnerAuthenticationMethod; - if ((dwResult = eapxml::select_element(pConfigRoot, bstr(L"eap-metadata:InnerAuthenticationMethod"), &pXmlElInnerAuthenticationMethod)) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting element."), NULL); - return dwResult; - } - - // Determine inner authentication type ( and ). - //DWORD dwMethodID; - bstr bstrMethod; - /*if (eapxml::get_element_value(pXmlElInnerAuthenticationMethod, bstr(L"eap-metadata:EAPMethod"), &dwMethodID) == ERROR_SUCCESS && - dwMethodID == EAP_TYPE_MSCHAPV2) - { - // MSCHAPv2 - // TODO: Add MSCHAPv2 support. - return ERROR_NOT_SUPPORTED; - } else*/ if (eapxml::get_element_value(pXmlElInnerAuthenticationMethod, bstr(L"eap-metadata:NonEAPAuthMethod"), &bstrMethod) == ERROR_SUCCESS && - CompareStringEx(LOCALE_NAME_INVARIANT, NORM_IGNORECASE, bstrMethod, bstrMethod.length(), L"PAP", -1, NULL, NULL, 0) == CSTR_EQUAL) - { - // PAP - assert(!m_inner); - m_inner = new eap::config_pap(m_module); - if ((dwResult = m_inner->load(pXmlElInnerAuthenticationMethod, ppEapError)) != ERROR_SUCCESS) - return dwResult; - } else { - *ppEapError = m_module.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Unsupported inner authentication method."), NULL); - return dwResult; - } - - return config_tls::load(pConfigRoot, ppEapError); -} - - -////////////////////////////////////////////////////////////////////// -// eap::credentials_ttls -////////////////////////////////////////////////////////////////////// - -eap::credentials_ttls::credentials_ttls(_In_ module &mod) : credentials_tls(mod) -{ -} - - -eap::credentials_ttls::credentials_ttls(_In_ const credentials_ttls &other) : - m_inner(other.m_inner ? (credentials*)other.m_inner->clone() : NULL), - credentials_tls(other) -{ -} - - -eap::credentials_ttls::credentials_ttls(_Inout_ credentials_ttls &&other) : - m_inner(other.m_inner), - credentials_tls(std::move(other)) -{ - other.m_inner = NULL; -} - - -eap::credentials_ttls& eap::credentials_ttls::operator=(_In_ const credentials_ttls &other) -{ - if (this != &other) { - (credentials_tls&)*this = other; - - if (m_inner) delete m_inner; - m_inner = other.m_inner ? (credentials*)other.m_inner->clone() : NULL; - } - - return *this; -} - - -eap::credentials_ttls& eap::credentials_ttls::operator=(_Inout_ credentials_ttls &&other) -{ - if (this != &other) { - (credentials_tls&)*this = std::move(other); - - if (m_inner) delete m_inner; - m_inner = other.m_inner; - other.m_inner = NULL; - } - - return *this; -} - - - -void eap::credentials_ttls::clear() -{ - credentials_tls::clear(); - if (m_inner) - m_inner->clear(); -} - - -bool eap::credentials_ttls::empty() const -{ - return credentials_tls::empty() && (!m_inner || m_inner->empty()); -} - - - -DWORD eap::credentials_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) -{ - assert(pConfigRoot); - DWORD dwResult; - - if ((dwResult = credentials_tls::load(pConfigRoot, ppEapError)) != ERROR_SUCCESS) - return dwResult; - - if (m_inner) { - com_obj pXmlElInnerAuthenticationMethod; - if ((dwResult = eapxml::select_node(pConfigRoot, bstr(L"eap-metadata:InnerAuthenticationMethod"), &pXmlElInnerAuthenticationMethod)) != ERROR_SUCCESS) { - *ppEapError = m_module.make_error(dwResult = ERROR_NOT_FOUND, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting element."), NULL); - return dwResult; - } - - if ((dwResult = m_inner->load(pXmlElInnerAuthenticationMethod, ppEapError)) != ERROR_SUCCESS) - return dwResult; - } - - return ERROR_SUCCESS; -} - - -DWORD eap::credentials_ttls::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const -{ - DWORD dwResult; - - if ((dwResult = credentials_tls::store(pszTargetName, ppEapError)) != ERROR_SUCCESS) - return dwResult; - - if (m_inner) { - if ((dwResult = m_inner->store(pszTargetName, ppEapError)) != ERROR_SUCCESS) - return dwResult; - } - - return ERROR_SUCCESS; -} - - -DWORD eap::credentials_ttls::retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) -{ - DWORD dwResult; - - if ((dwResult = credentials_tls::retrieve(pszTargetName, ppEapError)) != ERROR_SUCCESS) - return dwResult; - - if (m_inner) { - if ((dwResult = m_inner->retrieve(pszTargetName, ppEapError)) != ERROR_SUCCESS) - return dwResult; - } - - return ERROR_SUCCESS; -} - - -////////////////////////////////////////////////////////////////////// -// eap::session_ttls -////////////////////////////////////////////////////////////////////// - -eap::session_ttls::session_ttls() : session() -{ -} - - -////////////////////////////////////////////////////////////////////// -// eap::peer_ttls -////////////////////////////////////////////////////////////////////// - -eap::peer_ttls::peer_ttls() : peer() -{ -} - - -DWORD eap::peer_ttls::initialize(_Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(ppEapError); - - // MSI's feature completeness check removed: It might invoke UI (prompt user for missing MSI), - // which would be disasterous in EapHost system service. -#if 0 - // Perform the Microsoft Installer's feature completeness check manually. - // If execution got this far in the first place (dependent DLLs are present and loadable). - // Furthermore, this increments program usage counter. - if (MsiQueryFeatureState(_T(PRODUCT_VERSION_GUID), _T("featEAPTTLS")) != INSTALLSTATE_UNKNOWN) - MsiUseFeature(_T(PRODUCT_VERSION_GUID), _T("featEAPTTLS")); -#endif - - return ERROR_SUCCESS; -} - - -DWORD eap::peer_ttls::shutdown(_Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(ppEapError); - return ERROR_SUCCESS; -} - - -DWORD eap::peer_ttls::get_identity( - _In_ DWORD dwFlags, - _In_ DWORD dwConnectionDataSize, - _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, - _In_ DWORD dwUserDataSize, - _In_count_(dwUserDataSize) const BYTE *pUserData, - _In_ HANDLE hTokenImpersonateUser, - _Out_ BOOL *pfInvokeUI, - _Out_ DWORD *pdwUserDataOutSize, - _Out_ BYTE **ppUserDataOut, - _Out_ WCHAR **ppwszIdentity, - _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(dwFlags); - UNREFERENCED_PARAMETER(dwConnectionDataSize); - UNREFERENCED_PARAMETER(pConnectionData); - UNREFERENCED_PARAMETER(dwUserDataSize); - UNREFERENCED_PARAMETER(pUserData); - UNREFERENCED_PARAMETER(hTokenImpersonateUser); - UNREFERENCED_PARAMETER(pfInvokeUI); - UNREFERENCED_PARAMETER(pdwUserDataOutSize); - UNREFERENCED_PARAMETER(ppUserDataOut); - UNREFERENCED_PARAMETER(ppwszIdentity); - UNREFERENCED_PARAMETER(ppEapError); - - DWORD dwResult = ERROR_NOT_SUPPORTED; - ETW_FN_DWORD(dwResult); - return dwResult; -} - - -DWORD eap::peer_ttls::get_method_properties( - _In_ DWORD dwVersion, - _In_ DWORD dwFlags, - _In_ HANDLE hUserImpersonationToken, - _In_ DWORD dwEapConnDataSize, - _In_count_(dwEapConnDataSize) const BYTE *pEapConnData, - _In_ DWORD dwUserDataSize, - _In_count_(dwUserDataSize) const BYTE *pUserData, - _Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray, - _Out_ EAP_ERROR **ppEapError) const -{ - UNREFERENCED_PARAMETER(dwVersion); - UNREFERENCED_PARAMETER(dwFlags); - UNREFERENCED_PARAMETER(hUserImpersonationToken); - UNREFERENCED_PARAMETER(dwEapConnDataSize); - UNREFERENCED_PARAMETER(pEapConnData); - UNREFERENCED_PARAMETER(dwUserDataSize); - UNREFERENCED_PARAMETER(pUserData); - UNREFERENCED_PARAMETER(pMethodPropertyArray); - UNREFERENCED_PARAMETER(ppEapError); - - DWORD dwResult = ERROR_NOT_SUPPORTED; - ETW_FN_DWORD(dwResult); - return dwResult; -} diff --git a/VS10Solution.sln b/VS10Solution.sln index e5761062..990d55bb 100644 --- a/VS10Solution.sln +++ b/VS10Solution.sln @@ -18,10 +18,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CredWrite", "CredWrite\CredWrite.vcxproj", "{2D3CE079-7EB1-4F47-B79E-F0310671ECCB}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EAPMethodEvents", "EAPMethods\EAPMethodEvents\EAPMethodEvents.vcxproj", "{D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Events", "lib\Events\build\Events.vcxproj", "{D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EAPTTLSUI", "EAPMethods\EAPTTLSUI\EAPTTLSUI.vcxproj", "{DD7A97CA-F18E-43B7-95C4-D06E6A291624}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EAPBase", "lib\EAPBase\build\EAPBase.vcxproj", "{AD6816A0-9600-4E01-8C49-39D03D1E791F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EAPBase_UI", "lib\EAPBase_UI\build\EAPBase_UI.vcxproj", "{D4B54856-BE1F-4937-A8F7-495125BE76BE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PAP", "lib\PAP\build\PAP.vcxproj", "{36B0CF8A-7794-46C3-8099-825BA962B4C7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TLS", "lib\TLS\build\TLS.vcxproj", "{4D40CB8A-812E-4F12-B23A-31AF743878E8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTLS", "lib\TTLS\build\TTLS.vcxproj", "{EE0EF0D9-A475-4038-8637-5754724F65B0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PAP_UI", "lib\PAP_UI\build\PAP_UI.vcxproj", "{3D309C2E-64AB-4BC4-A16D-468571A2BC1A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TLS_UI", "lib\TLS_UI\build\TLS_UI.vcxproj", "{9A25C261-8ADE-4938-8393-E857EF0E37E9}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TTLS_UI", "lib\TTLS_UI\build\TTLS_UI.vcxproj", "{42F0F0F4-C928-4860-A4E4-94991C2C3D90}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -70,15 +86,87 @@ Global {DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Release|Win32.Build.0 = Release|Win32 {DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Release|x64.ActiveCfg = Release|x64 {DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Release|x64.Build.0 = Release|x64 + {AD6816A0-9600-4E01-8C49-39D03D1E791F}.Debug|Win32.ActiveCfg = Debug|Win32 + {AD6816A0-9600-4E01-8C49-39D03D1E791F}.Debug|Win32.Build.0 = Debug|Win32 + {AD6816A0-9600-4E01-8C49-39D03D1E791F}.Debug|x64.ActiveCfg = Debug|x64 + {AD6816A0-9600-4E01-8C49-39D03D1E791F}.Debug|x64.Build.0 = Debug|x64 + {AD6816A0-9600-4E01-8C49-39D03D1E791F}.Release|Win32.ActiveCfg = Release|Win32 + {AD6816A0-9600-4E01-8C49-39D03D1E791F}.Release|Win32.Build.0 = Release|Win32 + {AD6816A0-9600-4E01-8C49-39D03D1E791F}.Release|x64.ActiveCfg = Release|x64 + {AD6816A0-9600-4E01-8C49-39D03D1E791F}.Release|x64.Build.0 = Release|x64 + {D4B54856-BE1F-4937-A8F7-495125BE76BE}.Debug|Win32.ActiveCfg = Debug|Win32 + {D4B54856-BE1F-4937-A8F7-495125BE76BE}.Debug|Win32.Build.0 = Debug|Win32 + {D4B54856-BE1F-4937-A8F7-495125BE76BE}.Debug|x64.ActiveCfg = Debug|x64 + {D4B54856-BE1F-4937-A8F7-495125BE76BE}.Debug|x64.Build.0 = Debug|x64 + {D4B54856-BE1F-4937-A8F7-495125BE76BE}.Release|Win32.ActiveCfg = Release|Win32 + {D4B54856-BE1F-4937-A8F7-495125BE76BE}.Release|Win32.Build.0 = Release|Win32 + {D4B54856-BE1F-4937-A8F7-495125BE76BE}.Release|x64.ActiveCfg = Release|x64 + {D4B54856-BE1F-4937-A8F7-495125BE76BE}.Release|x64.Build.0 = Release|x64 + {36B0CF8A-7794-46C3-8099-825BA962B4C7}.Debug|Win32.ActiveCfg = Debug|Win32 + {36B0CF8A-7794-46C3-8099-825BA962B4C7}.Debug|Win32.Build.0 = Debug|Win32 + {36B0CF8A-7794-46C3-8099-825BA962B4C7}.Debug|x64.ActiveCfg = Debug|x64 + {36B0CF8A-7794-46C3-8099-825BA962B4C7}.Debug|x64.Build.0 = Debug|x64 + {36B0CF8A-7794-46C3-8099-825BA962B4C7}.Release|Win32.ActiveCfg = Release|Win32 + {36B0CF8A-7794-46C3-8099-825BA962B4C7}.Release|Win32.Build.0 = Release|Win32 + {36B0CF8A-7794-46C3-8099-825BA962B4C7}.Release|x64.ActiveCfg = Release|x64 + {36B0CF8A-7794-46C3-8099-825BA962B4C7}.Release|x64.Build.0 = Release|x64 + {4D40CB8A-812E-4F12-B23A-31AF743878E8}.Debug|Win32.ActiveCfg = Debug|Win32 + {4D40CB8A-812E-4F12-B23A-31AF743878E8}.Debug|Win32.Build.0 = Debug|Win32 + {4D40CB8A-812E-4F12-B23A-31AF743878E8}.Debug|x64.ActiveCfg = Debug|x64 + {4D40CB8A-812E-4F12-B23A-31AF743878E8}.Debug|x64.Build.0 = Debug|x64 + {4D40CB8A-812E-4F12-B23A-31AF743878E8}.Release|Win32.ActiveCfg = Release|Win32 + {4D40CB8A-812E-4F12-B23A-31AF743878E8}.Release|Win32.Build.0 = Release|Win32 + {4D40CB8A-812E-4F12-B23A-31AF743878E8}.Release|x64.ActiveCfg = Release|x64 + {4D40CB8A-812E-4F12-B23A-31AF743878E8}.Release|x64.Build.0 = Release|x64 + {EE0EF0D9-A475-4038-8637-5754724F65B0}.Debug|Win32.ActiveCfg = Debug|Win32 + {EE0EF0D9-A475-4038-8637-5754724F65B0}.Debug|Win32.Build.0 = Debug|Win32 + {EE0EF0D9-A475-4038-8637-5754724F65B0}.Debug|x64.ActiveCfg = Debug|x64 + {EE0EF0D9-A475-4038-8637-5754724F65B0}.Debug|x64.Build.0 = Debug|x64 + {EE0EF0D9-A475-4038-8637-5754724F65B0}.Release|Win32.ActiveCfg = Release|Win32 + {EE0EF0D9-A475-4038-8637-5754724F65B0}.Release|Win32.Build.0 = Release|Win32 + {EE0EF0D9-A475-4038-8637-5754724F65B0}.Release|x64.ActiveCfg = Release|x64 + {EE0EF0D9-A475-4038-8637-5754724F65B0}.Release|x64.Build.0 = Release|x64 + {3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Debug|Win32.ActiveCfg = Debug|Win32 + {3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Debug|Win32.Build.0 = Debug|Win32 + {3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Debug|x64.ActiveCfg = Debug|x64 + {3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Debug|x64.Build.0 = Debug|x64 + {3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Release|Win32.ActiveCfg = Release|Win32 + {3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Release|Win32.Build.0 = Release|Win32 + {3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Release|x64.ActiveCfg = Release|x64 + {3D309C2E-64AB-4BC4-A16D-468571A2BC1A}.Release|x64.Build.0 = Release|x64 + {9A25C261-8ADE-4938-8393-E857EF0E37E9}.Debug|Win32.ActiveCfg = Debug|Win32 + {9A25C261-8ADE-4938-8393-E857EF0E37E9}.Debug|Win32.Build.0 = Debug|Win32 + {9A25C261-8ADE-4938-8393-E857EF0E37E9}.Debug|x64.ActiveCfg = Debug|x64 + {9A25C261-8ADE-4938-8393-E857EF0E37E9}.Debug|x64.Build.0 = Debug|x64 + {9A25C261-8ADE-4938-8393-E857EF0E37E9}.Release|Win32.ActiveCfg = Release|Win32 + {9A25C261-8ADE-4938-8393-E857EF0E37E9}.Release|Win32.Build.0 = Release|Win32 + {9A25C261-8ADE-4938-8393-E857EF0E37E9}.Release|x64.ActiveCfg = Release|x64 + {9A25C261-8ADE-4938-8393-E857EF0E37E9}.Release|x64.Build.0 = Release|x64 + {42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Debug|Win32.ActiveCfg = Debug|Win32 + {42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Debug|Win32.Build.0 = Debug|Win32 + {42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Debug|x64.ActiveCfg = Debug|x64 + {42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Debug|x64.Build.0 = Debug|x64 + {42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|Win32.ActiveCfg = Release|Win32 + {42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|Win32.Build.0 = Release|Win32 + {42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|x64.ActiveCfg = Release|x64 + {42F0F0F4-C928-4860-A4E4-94991C2C3D90}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {331B6077-E3E2-4867-B93E-9D3F57280DE7} = {60BAAC3D-DC98-4C19-BC40-1A86963DE86C} - {D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B} = {60BAAC3D-DC98-4C19-BC40-1A86963DE86C} {DD7A97CA-F18E-43B7-95C4-D06E6A291624} = {60BAAC3D-DC98-4C19-BC40-1A86963DE86C} {47399D91-7EB9-41DE-B521-514BA5DB0C43} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393} + {D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393} + {AD6816A0-9600-4E01-8C49-39D03D1E791F} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393} + {D4B54856-BE1F-4937-A8F7-495125BE76BE} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393} + {36B0CF8A-7794-46C3-8099-825BA962B4C7} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393} + {4D40CB8A-812E-4F12-B23A-31AF743878E8} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393} + {EE0EF0D9-A475-4038-8637-5754724F65B0} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393} + {3D309C2E-64AB-4BC4-A16D-468571A2BC1A} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393} + {9A25C261-8ADE-4938-8393-E857EF0E37E9} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393} + {42F0F0F4-C928-4860-A4E4-94991C2C3D90} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393} {2D3CE079-7EB1-4F47-B79E-F0310671ECCB} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4} EndGlobalSection EndGlobal diff --git a/include/MSIBuildCfg.mak b/include/MSIBuildCfg.mak index aa4abfb8309e8c6b6f2efd572a1d3220af037d92..a3bd4a7b48a6fe90d8d370787cfdeda0423fe500 100644 GIT binary patch delta 33 ocmaFk_{eEPmx5ppLncEKLkxo}Lm5LVLmorPRm%=2)Bmf=*1i=6R diff --git a/EAPMethods/EAPMethodEvents/.gitignore b/lib/EAPBase/build/.gitignore similarity index 100% rename from EAPMethods/EAPMethodEvents/.gitignore rename to lib/EAPBase/build/.gitignore diff --git a/lib/EAPBase/build/EAPBase.props b/lib/EAPBase/build/EAPBase.props new file mode 100644 index 00000000..4997b714 --- /dev/null +++ b/lib/EAPBase/build/EAPBase.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/EAPBase/build/EAPBase.vcxproj b/lib/EAPBase/build/EAPBase.vcxproj new file mode 100644 index 00000000..ca023e89 --- /dev/null +++ b/lib/EAPBase/build/EAPBase.vcxproj @@ -0,0 +1,111 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {AD6816A0-9600-4E01-8C49-39D03D1E791F} + EAPBase + + + + 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/EAPBase/build/EAPBase.vcxproj.filters b/lib/EAPBase/build/EAPBase.vcxproj.filters new file mode 100644 index 00000000..9dadc8e1 --- /dev/null +++ b/lib/EAPBase/build/EAPBase.vcxproj.filters @@ -0,0 +1,56 @@ + + + + + {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 + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/lib/EAPBase/include/Config.h b/lib/EAPBase/include/Config.h new file mode 100644 index 00000000..b66701c8 --- /dev/null +++ b/lib/EAPBase/include/Config.h @@ -0,0 +1,850 @@ +/* + 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 +{ + /// + /// Base class for configuration storage + /// + class config; + + /// + /// Base class for method configuration storage + /// + class config_method; + + /// + /// Provider configuration + /// + template class config_provider; + + /// + /// Providers configuration + /// + template class config_providers; + + /// + /// Password based method configuration + /// + typedef config_method config_pass; +} + +namespace eapserial +{ + /// + /// Packs a method configuration + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val Configuration to pack + /// + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_method &val); + + /// + /// Returns packed size of a method configuration + /// + /// \param[in] val Configuration to pack + /// + /// \returns Size of data when packed (in bytes) + /// + inline size_t get_pk_size(const eap::config_method &val); + + /// + /// Unpacks a method configuration + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val Configuration to unpack to + /// + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_method &val); + + /// + /// Packs a provider configuration + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val Configuration to pack + /// + template inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_provider<_Tmeth> &val); + + /// + /// Returns packed size of a provider configuration + /// + /// \param[in] val Configuration to pack + /// + /// \returns Size of data when packed (in bytes) + /// + template inline size_t get_pk_size(const eap::config_provider<_Tmeth> &val); + + /// + /// Unpacks a provider configuration + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val Configuration to unpack to + /// + template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_provider<_Tmeth> &val); + + /// + /// Packs a providers configuration + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val Configuration to pack + /// + template inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_providers<_Tprov> &val); + + /// + /// Returns packed size of a providers configuration + /// + /// \param[in] val Configuration to pack + /// + /// \returns Size of data when packed (in bytes) + /// + template inline size_t get_pk_size(const eap::config_providers<_Tprov> &val); + + /// + /// Unpacks a providers configuration + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val Configuration to unpack to + /// + template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_providers<_Tprov> &val); +} + +#pragma once + +#include "Module.h" +#include "EAPSerial.h" +#include "EAPXML.h" + +#include +#include + +#include +#include // Must include after +#include + +#include +#include + + +namespace eap +{ + class config + { + public: + /// + /// Constructs configuration + /// + /// \param[in] mod Reference of the EAP module to use for global services + /// + config(_In_ module &mod); + + /// + /// Copies configuration + /// + /// \param[in] other Configuration to copy from + /// + config(_In_ const config &other); + + /// + /// Moves configuration + /// + /// \param[in] other Configuration to move from + /// + config(_Inout_ config &&other); + + /// + /// Destructs configuration + /// + virtual ~config(); + + /// + /// Copies configuration + /// + /// \param[in] other Configuration to copy from + /// + /// \returns Reference to this object + /// + config& operator=(_In_ const config &other); + + /// + /// Moves configuration + /// + /// \param[in] other Configuration to move from + /// + /// \returns Reference to this object + /// + config& operator=(_Inout_ config &&other); + + /// + /// Clones this configuration + /// + /// \returns Pointer to cloned configuration + /// + virtual config* clone() const = 0; + + /// \name XML configuration management + /// @{ + + /// + /// Save configuration to XML document + /// + /// \param[in] pDoc XML document + /// \param[in] pConfigRoot Suggested root element for saving configuration + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const = 0; + + /// + /// Load configuration from XML document + /// + /// \param[in] pConfigRoot Root element for loading configuration + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) = 0; + + /// @} + + public: + module &m_module; ///< Reference of the EAP module + }; + + + class config_method : public config + { + public: + /// + /// Constructs configuration + /// + /// \param[in] mod Reference of the EAP module to use for global services + /// + config_method(_In_ module &mod); + + /// + /// Copies configuration + /// + /// \param[in] other Configuration to copy from + /// + config_method(_In_ const config_method &other); + + /// + /// Moves configuration + /// + /// \param[in] other Configuration to move from + /// + config_method(_Inout_ config_method &&other); + + /// + /// Copies configuration + /// + /// \param[in] other Configuration to copy from + /// + /// \returns Reference to this object + /// + config_method& operator=(_In_ const config_method &other); + + /// + /// Moves configuration + /// + /// \param[in] other Configuration to move from + /// + /// \returns Reference to this object + /// + config_method& operator=(_Inout_ config_method &&other); + + /// \name XML configuration management + /// @{ + + /// + /// Save configuration to XML document + /// + /// \param[in] pDoc XML document + /// \param[in] pConfigRoot Suggested root element for saving configuration + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const; + + /// + /// Load configuration from XML document + /// + /// \param[in] pConfigRoot Root element for loading configuration + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError); + + /// @} + + /// + /// Returns EAP method type of this configuration + /// + /// \returns One of `eap::type_t` constants. + /// + virtual type_t get_method_id() = 0; + + public: + bool m_allow_save; ///< Are credentials allowed to be saved to Windows Credential Manager? + std::wstring m_anonymous_identity; ///< Anonymous identity + }; + + + template + class config_provider : public config + { + public: + /// + /// Constructs configuration + /// + /// \param[in] mod Reference of the EAP module to use for global services + /// + config_provider(_In_ module &mod) : config(mod) + { + } + + /// + /// Copies configuration + /// + /// \param[in] other Configuration to copy from + /// + config_provider(_In_ const config_provider &other) : + m_id(other.m_id), + m_lbl_alt_credential(other.m_lbl_alt_credential), + m_lbl_alt_identity(other.m_lbl_alt_identity), + m_lbl_alt_password(other.m_lbl_alt_password), + m_methods(other.m_methods), + config(other) + { + } + + /// + /// Moves configuration + /// + /// \param[in] other Configuration to move from + /// + config_provider(_Inout_ config_provider &&other) : + m_id(std::move(other.m_id)), + m_lbl_alt_credential(std::move(other.m_lbl_alt_credential)), + m_lbl_alt_identity(std::move(other.m_lbl_alt_identity)), + m_lbl_alt_password(std::move(other.m_lbl_alt_password)), + m_methods(std::move(other.m_methods)), + config(std::move(other)) + { + } + + /// + /// Copies configuration + /// + /// \param[in] other Configuration to copy from + /// + /// \returns Reference to this object + /// + config_provider& operator=(_In_ const config_provider &other) + { + if (this != &other) { + (config&)*this = other; + m_id = other.m_id; + m_lbl_alt_credential = other.m_lbl_alt_credential; + m_lbl_alt_identity = other.m_lbl_alt_identity; + m_lbl_alt_password = other.m_lbl_alt_password; + m_methods = other.m_methods; + } + + return *this; + } + + /// + /// Moves configuration + /// + /// \param[in] other Configuration to move from + /// + /// \returns Reference to this object + /// + config_provider& operator=(_Inout_ config_provider &&other) + { + if (this != &other) { + (config&&)*this = std::move(other); + m_id = std::move(other.m_id); + m_lbl_alt_credential = std::move(other.m_lbl_alt_credential); + m_lbl_alt_identity = std::move(other.m_lbl_alt_identity); + m_lbl_alt_password = std::move(other.m_lbl_alt_password); + m_methods = std::move(other.m_methods); + } + + return *this; + } + + /// + /// Clones configuration + /// + /// \returns Pointer to cloned configuration + /// + virtual config* clone() const { return new config_provider<_Tmeth>(*this); } + + /// \name XML configuration management + /// @{ + + /// + /// Save configuration to XML document + /// + /// \param[in] pDoc XML document + /// \param[in] pConfigRoot Suggested root element for saving configuration + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const + { + const winstd::bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata"); + DWORD dwResult; + HRESULT hr; + + // + if (!m_id.empty()) + if ((dwResult = eapxml::put_element_value(pDoc, pConfigRoot, winstd::bstr(L"ID"), bstrNamespace, winstd::bstr(m_id))) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + // + winstd::com_obj pXmlElProviderInfo; + if ((dwResult = eapxml::create_element(pDoc, pConfigRoot, winstd::bstr(L"eap-metadata:ProviderInfo"), winstd::bstr(L"ProviderInfo"), bstrNamespace, &pXmlElProviderInfo)) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + // / + if (!m_lbl_alt_credential.empty()) + if ((dwResult = eapxml::put_element_value(pDoc, pXmlElProviderInfo, winstd::bstr(L"CredentialPrompt"), bstrNamespace, winstd::bstr(m_lbl_alt_credential))) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + // / + if (!m_lbl_alt_identity.empty()) + if ((dwResult = eapxml::put_element_value(pDoc, pXmlElProviderInfo, winstd::bstr(L"UserNameLabel"), bstrNamespace, winstd::bstr(m_lbl_alt_identity))) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + // / + if (!m_lbl_alt_password.empty()) + if ((dwResult = eapxml::put_element_value(pDoc, pXmlElProviderInfo, winstd::bstr(L"PasswordLabel"), bstrNamespace, winstd::bstr(m_lbl_alt_password))) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + // + winstd::com_obj pXmlElAuthenticationMethods; + if ((dwResult = eapxml::create_element(pDoc, pConfigRoot, winstd::bstr(L"eap-metadata:AuthenticationMethods"), winstd::bstr(L"AuthenticationMethods"), bstrNamespace, &pXmlElAuthenticationMethods)) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + for (std::list<_Tmeth>::const_iterator method = m_methods.cbegin(), method_end = m_methods.cend(); method != method_end; ++method) { + // + winstd::com_obj pXmlElAuthenticationMethod; + if ((dwResult = eapxml::create_element(pDoc, winstd::bstr(L"AuthenticationMethod"), bstrNamespace, &pXmlElAuthenticationMethod))) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + // /... + if ((dwResult = method->save(pDoc, pXmlElAuthenticationMethod, ppEapError)) != ERROR_SUCCESS) + return dwResult; + + if (FAILED(hr = pXmlElAuthenticationMethods->appendChild(pXmlElAuthenticationMethod, NULL))) { + *ppEapError = m_module.make_error(dwResult = HRESULT_CODE(hr), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error appending element."), NULL); + return dwResult; + } + } + + return dwResult; + } + + + /// + /// Load configuration from XML document + /// + /// \param[in] pConfigRoot Root element for loading configuration + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) + { + assert(pConfigRoot); + assert(ppEapError); + DWORD dwResult; + std::wstring lang; + LoadString(m_module.m_instance, 2, lang); + + // + m_id.clear(); + eapxml::get_element_value(pConfigRoot, winstd::bstr(L"eap-metadata:ID"), m_id); + + // + m_lbl_alt_credential.clear(); + m_lbl_alt_identity.clear(); + m_lbl_alt_password.clear(); + winstd::com_obj pXmlElProviderInfo; + if (eapxml::select_element(pConfigRoot, winstd::bstr(L"eap-metadata:ProviderInfo"), &pXmlElProviderInfo) == ERROR_SUCCESS) { + // + eapxml::get_element_localized(pXmlElProviderInfo, winstd::bstr(L"eap-metadata:CredentialPrompt"), lang.c_str(), m_lbl_alt_credential); + + // + eapxml::get_element_localized(pXmlElProviderInfo, winstd::bstr(L"eap-metadata:UserNameLabel"), lang.c_str(), m_lbl_alt_identity); + + // + eapxml::get_element_localized(pXmlElProviderInfo, winstd::bstr(L"eap-metadata:PasswordLabel"), lang.c_str(), m_lbl_alt_password); + } + + // Iterate authentication methods (). + m_methods.clear(); + winstd::com_obj pXmlListMethods; + if ((dwResult = eapxml::select_nodes(pConfigRoot, winstd::bstr(L"eap-metadata:AuthenticationMethods/eap-metadata:AuthenticationMethod"), &pXmlListMethods)) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult = ERROR_NOT_FOUND, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting / elements."), NULL); + return dwResult; + } + long lCount = 0; + pXmlListMethods->get_length(&lCount); + for (long i = 0; i < lCount; i++) { + winstd::com_obj pXmlElMethod; + pXmlListMethods->get_item(i, &pXmlElMethod); + + _Tmeth cfg(m_module); + + // Check EAP method type (). + DWORD dwMethodID; + if (eapxml::get_element_value(pXmlElMethod, winstd::bstr(L"eap-metadata:EAPMethod"), &dwMethodID) == ERROR_SUCCESS) { + if ((type_t)dwMethodID != cfg.get_method_id()) { + // Wrong type. + continue; + } + } + + // Load configuration. + dwResult = cfg.load(pXmlElMethod, ppEapError); + if (dwResult != ERROR_SUCCESS) + return dwResult; + + // Add configuration to the list. + m_methods.push_back(std::move(cfg)); + } + + return ERROR_SUCCESS; + } + + /// @} + + public: + std::wstring m_id; ///< Profile ID + winstd::tstring m_lbl_alt_credential; ///< Alternative label for credential prompt + winstd::tstring m_lbl_alt_identity; ///< Alternative label for identity prompt + winstd::tstring m_lbl_alt_password; ///< Alternative label for password prompt + std::list<_Tmeth> m_methods; ///< List of method configurations + }; + + + template + class config_providers : public config + { + public: + /// + /// Constructs configuration + /// + /// \param[in] mod Reference of the EAP module to use for global services + /// + config_providers(_In_ module &mod) : config(mod) + { + } + + /// + /// Copies configuration + /// + /// \param[in] other Configuration to copy from + /// + config_providers(_In_ const config_providers &other) : + m_providers(other.m_providers), + config(other) + { + } + + /// + /// Moves configuration + /// + /// \param[in] other Configuration to move from + /// + config_providers(_Inout_ config_providers &&other) : + m_providers(std::move(other.m_providers)), + config(std::move(other)) + { + } + + /// + /// Copies configuration + /// + /// \param[in] other Configuration to copy from + /// + /// \returns Reference to this object + /// + config_providers& operator=(_In_ const config_providers &other) + { + if (this != &other) { + (config&)*this = other; + m_providers = other.m_providers; + } + + return *this; + } + + /// + /// Moves configuration + /// + /// \param[in] other Configuration to move from + /// + /// \returns Reference to this object + /// + config_providers& operator=(_Inout_ config_providers &&other) + { + if (this != &other) { + (config&&)*this = std::move(other); + m_providers = std::move(other.m_providers); + } + + return *this; + } + + /// + /// Clones configuration + /// + /// \returns Pointer to cloned configuration + /// + virtual config* clone() const { return new config_providers<_Tprov>(*this); } + + /// \name XML configuration management + /// @{ + + /// + /// Save configuration to XML document + /// + /// \param[in] pDoc XML document + /// \param[in] pConfigRoot Suggested root element for saving configuration + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const + { + const winstd::bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata"); + DWORD dwResult; + HRESULT hr; + + // Select node. + winstd::com_obj pXmlElIdentityProviderList; + if ((dwResult = eapxml::select_node(pConfigRoot, winstd::bstr(L"eap-metadata:EAPIdentityProviderList"), &pXmlElIdentityProviderList)) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult = ERROR_NOT_FOUND, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting element."), NULL); + return dwResult; + } + + for (std::list<_Tprov>::const_iterator provider = m_providers.cbegin(), provider_end = m_providers.cend(); provider != provider_end; ++provider) { + // + winstd::com_obj pXmlElIdentityProvider; + if ((dwResult = eapxml::create_element(pDoc, winstd::bstr(L"EAPIdentityProvider"), bstrNamespace, &pXmlElIdentityProvider))) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + // /... + if ((dwResult = provider->save(pDoc, pXmlElIdentityProvider, ppEapError)) != ERROR_SUCCESS) + return dwResult; + + if (FAILED(hr = pXmlElIdentityProviderList->appendChild(pXmlElIdentityProvider, NULL))) { + *ppEapError = m_module.make_error(dwResult = HRESULT_CODE(hr), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error appending element."), NULL); + return dwResult; + } + } + + return dwResult; + } + + + /// + /// Load configuration from XML document + /// + /// \param[in] pConfigRoot Root element for loading configuration + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) + { + assert(pConfigRoot); + assert(ppEapError); + DWORD dwResult; + + // Iterate authentication providers (). + winstd::com_obj pXmlListProviders; + if ((dwResult = eapxml::select_nodes(pConfigRoot, winstd::bstr(L"eap-metadata:EAPIdentityProviderList/eap-metadata:EAPIdentityProvider"), &pXmlListProviders)) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult = ERROR_NOT_FOUND, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting elements."), NULL); + return dwResult; + } + long lCount = 0; + pXmlListProviders->get_length(&lCount); + for (long i = 0; i < lCount; i++) { + winstd::com_obj pXmlElProvider; + pXmlListProviders->get_item(i, &pXmlElProvider); + + _Tprov prov(m_module); + + // Load provider. + dwResult = prov.load(pXmlElProvider, ppEapError); + if (dwResult != ERROR_SUCCESS) + return dwResult; + + // Add provider to the list. + m_providers.push_back(std::move(prov)); + } + + return dwResult; + } + + /// @} + + public: + std::list<_Tprov> m_providers; ///< List of provider configurations + }; +} + + +namespace eapserial +{ + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_method &val) + { + pack(cursor, val.m_allow_save ); + pack(cursor, val.m_anonymous_identity); + } + + + inline size_t get_pk_size(const eap::config_method &val) + { + return + get_pk_size(val.m_allow_save ) + + get_pk_size(val.m_anonymous_identity); + } + + + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_method &val) + { + unpack(cursor, val.m_allow_save ); + unpack(cursor, val.m_anonymous_identity); + } + + + template + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_provider<_Tmeth> &val) + { + pack(cursor, val.m_id ); + pack(cursor, val.m_lbl_alt_credential); + pack(cursor, val.m_lbl_alt_identity ); + pack(cursor, val.m_lbl_alt_password ); + pack(cursor, val.m_methods ); + } + + + template + inline size_t get_pk_size(const eap::config_provider<_Tmeth> &val) + { + return + get_pk_size(val.m_id ) + + get_pk_size(val.m_lbl_alt_credential) + + get_pk_size(val.m_lbl_alt_identity ) + + get_pk_size(val.m_lbl_alt_password ) + + get_pk_size(val.m_methods ); + } + + + template + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_provider<_Tmeth> &val) + { + unpack(cursor, val.m_id ); + unpack(cursor, val.m_lbl_alt_credential); + unpack(cursor, val.m_lbl_alt_identity ); + unpack(cursor, val.m_lbl_alt_password ); + + std::list<_Tmeth>::size_type count = *(const std::list<_Tmeth>::size_type*&)cursor; + cursor += sizeof(std::list<_Tmeth>::size_type); + val.m_methods.clear(); + for (std::list<_Tmeth>::size_type i = 0; i < count; i++) { + _Tmeth el(val.m_module); + unpack(cursor, el); + val.m_methods.push_back(std::move(el)); + } + } + + + template + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_providers<_Tprov> &val) + { + pack(cursor, val.m_providers); + } + + + template + inline size_t get_pk_size(const eap::config_providers<_Tprov> &val) + { + return get_pk_size(val.m_providers); + } + + + template + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_providers<_Tprov> &val) + { + std::list<_Tprov>::size_type count = *(const std::list<_Tprov>::size_type*&)cursor; + cursor += sizeof(std::list<_Tprov>::size_type); + val.m_providers.clear(); + for (std::list<_Tprov>::size_type i = 0; i < count; i++) { + _Tprov el(val.m_module); + unpack(cursor, el); + val.m_providers.push_back(std::move(el)); + } + } +} diff --git a/EAPMethods/include/TLS.h b/lib/EAPBase/include/Credentials.h similarity index 55% rename from EAPMethods/include/TLS.h rename to lib/EAPBase/include/Credentials.h index e514af25..e0f617d4 100644 --- a/EAPMethods/include/TLS.h +++ b/lib/EAPBase/include/Credentials.h @@ -18,137 +18,219 @@ along with GÉANTLink. If not, see . */ -#include "EAP.h" -#include "EAPSerial.h" +#include namespace eap { - class config_tls; - class credentials_tls; + /// + /// Base class for method credential storage + /// + class credentials; + + /// + /// Password based method credentials + /// + class credentials_pass; } namespace eapserial { - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_tls &val); - inline size_t get_pk_size(const eap::config_tls &val); - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_tls &val); + /// + /// Packs a method credentials + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val Credentials to pack + /// + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials &val); + + /// + /// Returns packed size of a method credentials + /// + /// \param[in] val Credentials to pack + /// + /// \returns Size of data when packed (in bytes) + /// + inline size_t get_pk_size(const eap::credentials &val); + + /// + /// Unpacks a method credentials + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val Credentials to unpack to + /// + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials &val); + + /// + /// Packs a password based method credentials + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val Credentials to pack + /// + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_pass &val); + + /// + /// Returns packed size of a password based method credentials + /// + /// \param[in] val Credentials to pack + /// + /// \returns Size of data when packed (in bytes) + /// + inline size_t get_pk_size(const eap::credentials_pass &val); - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_tls &val); - inline size_t get_pk_size(const eap::credentials_tls &val); - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_tls &val); + /// + /// Unpacks a password based method credentials + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val Credentials to unpack to + /// + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_pass &val); } #pragma once +#include "Config.h" +#include "Module.h" +#include "EAPSerial.h" + +#include "../../../include/Version.h" + +#include + +#include +#include // Must include after +#include +#include + +#include + namespace eap { - /// - /// TLS configuration - /// - class config_tls : public config_method + class credentials : public config { public: /// - /// Constructs configuration + /// Constructs credentials /// /// \param[in] mod Reference of the EAP module to use for global services /// - config_tls(_In_ module &mod); + credentials(_In_ module &mod); /// - /// Copies configuration + /// Copies credentials /// - /// \param[in] other Configuration to copy from + /// \param[in] other Credentials to copy from /// - config_tls(_In_ const config_tls &other); + credentials(_In_ const credentials &other); /// - /// Moves configuration + /// Moves credentials /// - /// \param[in] other Configuration to move from + /// \param[in] other Credentials to move from /// - config_tls(_Inout_ config_tls &&other); + credentials(_Inout_ credentials &&other); /// - /// Copies configuration + /// Copies credentials /// - /// \param[in] other Configuration to copy from + /// \param[in] other Credentials to copy from /// /// \returns Reference to this object /// - config_tls& operator=(_In_ const config_tls &other); + credentials& operator=(_In_ const credentials &other); /// - /// Moves configuration + /// Moves credentials /// /// \param[in] other Configuration to move from /// /// \returns Reference to this object /// - config_tls& operator=(_Inout_ config_tls &&other); + credentials& operator=(_Inout_ credentials &&other); /// - /// Clones configuration + /// Resets credentials /// - /// \returns Pointer to cloned configuration + virtual void clear(); + + /// + /// Test credentials if blank /// - virtual config* clone() const { return new config_tls(*this); } + virtual bool empty() const; - /// \name XML configuration management + /// \name XML credentials management /// @{ /// - /// Save configuration to XML document + /// Save credentials to XML document /// /// \param[in] pDoc XML document - /// \param[in] pConfigRoot Suggested root element for saving configuration + /// \param[in] pConfigRoot Suggested root element for saving credentials /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. /// + /// \returns Always returns \c ERROR_NOT_SUPPORTED, as credentials are non-exportable. + /// + virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const; + + /// @} + + /// \name Storage + /// @{ + + /// + /// Save credentials to Windows Credential Manager + /// + /// \param[in] pszTargetName The name in Windows Credential Manager to store credentials as + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// /// \returns /// - \c ERROR_SUCCESS if succeeded /// - error code otherwise /// - virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const; + virtual DWORD store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const = 0; /// - /// Load configuration from XML document + /// Retrieve credentials from Windows Credential Manager /// - /// \param[in] pConfigRoot Root element for loading configuration - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. /// /// \returns /// - \c ERROR_SUCCESS if succeeded /// - error code otherwise /// - virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError); + virtual DWORD retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) = 0; - /// @} - - /// - /// Returns EAP method type of this configuration /// - /// \returns `eap::type_tls` + /// Return target suffix for Windows Credential Manager credential name /// - virtual eap::type_t get_method_id() { return eap::type_tls; } + virtual LPCTSTR target_suffix() const = 0; /// - /// Adds CA to the list of trusted root CA's + /// Returns target name for Windows Credential Manager credential name + /// + /// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from /// - /// \sa [CertCreateCertificateContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376033.aspx) + /// \returns Final target name to store/retrieve credentials in Windows Credential Manager /// - bool add_trusted_ca(_In_ DWORD dwCertEncodingType, _In_ const BYTE *pbCertEncoded, _In_ DWORD cbCertEncoded); + inline winstd::tstring target_name(_In_ LPCTSTR pszTargetName) const + { + winstd::tstring target_name(_T(PRODUCT_NAME_STR) _T("/")); + target_name += pszTargetName; + target_name += _T('/'); + target_name += target_suffix(); + assert(target_name.length() < CRED_MAX_GENERIC_TARGET_NAME_LENGTH); + return target_name; + } + + /// @} public: - std::list m_trusted_root_ca; ///< Trusted root CAs - std::list m_server_names; ///< Acceptable authenticating server names + std::wstring m_identity; ///< Identity (username\@domain, certificate name etc.) }; - /// - /// TLS credentials - /// - class credentials_tls : public credentials + class credentials_pass : public credentials { public: /// @@ -156,21 +238,21 @@ namespace eap /// /// \param[in] mod Reference of the EAP module to use for global services /// - credentials_tls(_In_ module &mod); + credentials_pass(_In_ module &mod); /// /// Copies credentials /// /// \param[in] other Credentials to copy from /// - credentials_tls(_In_ const credentials_tls &other); + credentials_pass(_In_ const credentials_pass &other); /// /// Moves credentials /// /// \param[in] other Credentials to move from /// - credentials_tls(_Inout_ credentials_tls &&other); + credentials_pass(_Inout_ credentials_pass &&other); /// /// Copies credentials @@ -179,7 +261,7 @@ namespace eap /// /// \returns Reference to this object /// - credentials_tls& operator=(_In_ const credentials_tls &other); + credentials_pass& operator=(_In_ const credentials_pass &other); /// /// Moves credentials @@ -188,14 +270,7 @@ namespace eap /// /// \returns Reference to this object /// - credentials_tls& operator=(_Inout_ credentials_tls &&other); - - /// - /// Clones credentials - /// - /// \returns Pointer to cloned credentials - /// - virtual config* clone() const { return new credentials_tls(*this); } + credentials_pass& operator=(_Inout_ credentials_pass &&other); /// /// Resets credentials @@ -207,7 +282,7 @@ namespace eap /// virtual bool empty() const; - /// \name XML credentials management + /// \name XML configuration management /// @{ /// @@ -251,102 +326,56 @@ namespace eap /// virtual DWORD retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError); - /// - /// Return target suffix for Windows Credential Manager credential name - /// - virtual LPCTSTR target_suffix() const { return _T("TLS"); } - /// @} public: - std::vector m_cert_hash; ///< Client certificate hash (certificates are kept in Personal Certificate Storage) + winstd::sanitizing_wstring m_password; ///< Password }; } namespace eapserial { - /// - /// Packs a TLS method configuration - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val Configuration to pack - /// - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_tls &val) + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials &val) { - pack(cursor, (const eap::config_method&)val); - pack(cursor, val.m_trusted_root_ca ); - pack(cursor, val.m_server_names ); + pack(cursor, (const eap::config&)val); + pack(cursor, val.m_identity ); } - /// - /// Returns packed size of a TLS method configuration - /// - /// \param[in] val Configuration to pack - /// - /// \returns Size of data when packed (in bytes) - /// - inline size_t get_pk_size(const eap::config_tls &val) + inline size_t get_pk_size(const eap::credentials &val) { return - get_pk_size((const eap::config_method&)val) + - get_pk_size(val.m_trusted_root_ca ) + - get_pk_size(val.m_server_names ); + get_pk_size((const eap::config&)val) + + get_pk_size(val.m_identity ); } - /// - /// Unpacks a TLS method configuration - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val Configuration to unpack to - /// - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_tls &val) + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials &val) { - unpack(cursor, (eap::config_method&)val ); - unpack(cursor, val.m_trusted_root_ca); - unpack(cursor, val.m_server_names ); + unpack(cursor, (eap::config&)val); + unpack(cursor, val.m_identity ); } - /// - /// Packs a TLS method credentials - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val Credentials to pack - /// - inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_tls &val) + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_pass &val) { pack(cursor, (const eap::credentials&)val); - pack(cursor, val.m_cert_hash ); + pack(cursor, val.m_password ); } - /// - /// Returns packed size of a TLS method credentials - /// - /// \param[in] val Credentials to pack - /// - /// \returns Size of data when packed (in bytes) - /// - inline size_t get_pk_size(const eap::credentials_tls &val) + inline size_t get_pk_size(const eap::credentials_pass &val) { return get_pk_size((const eap::credentials&)val) + - get_pk_size(val.m_cert_hash ); + get_pk_size(val.m_password ); } - /// - /// Unpacks a TLS method credentials - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val Credentials to unpack to - /// - inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_tls &val) + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_pass &val) { unpack(cursor, (eap::credentials&)val); - unpack(cursor, val.m_cert_hash ); + unpack(cursor, val.m_password ); } } diff --git a/lib/EAPBase/include/EAP.h b/lib/EAPBase/include/EAP.h new file mode 100644 index 00000000..de29cf47 --- /dev/null +++ b/lib/EAPBase/include/EAP.h @@ -0,0 +1,52 @@ +/* + 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 . +*/ + +#define IDR_EAP_KEY_PUBLIC 1 +#define IDR_EAP_KEY_PRIVATE 2 + +#if !defined(RC_INVOKED) && !defined(MIDL_PASS) + +namespace eap +{ + /// + /// EAP method numbers + /// + /// \sa [Extensible Authentication Protocol (EAP) Registry (Chapter: Method Types)](https://www.iana.org/assignments/eap-numbers/eap-numbers.xhtml#eap-numbers-4) + /// + enum type_t; +} + + +#pragma once + + +namespace eap +{ + enum type_t { + type_undefined = 0, ///< Undefined EAP type + type_tls = 13, ///< EAP-TLS + type_ttls = 21, ///< EAP-TTLS + type_peap = 25, ///< EAP-PEAP + type_mschapv2 = 26, ///< EAP-MSCHAPv2 + type_pap = 192, ///< PAP (Not actually an EAP method; Moved to the Unassigned area) + }; +} + +#endif diff --git a/EAPMethods/include/EAPSerial.h b/lib/EAPBase/include/EAPSerial.h similarity index 96% rename from EAPMethods/include/EAPSerial.h rename to lib/EAPBase/include/EAPSerial.h index eeec53fa..8e0be3cb 100644 --- a/EAPMethods/include/EAPSerial.h +++ b/lib/EAPBase/include/EAPSerial.h @@ -20,34 +20,162 @@ #include +#include + #include #include #include namespace eapserial { + /// + /// Packs a primitive data + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val Variable with data to pack + /// template inline void pack(_Inout_ unsigned char *&cursor, _In_ const T &val); + + /// + /// Returns packed size of a primitive data + /// + /// \param[in] val Data to pack + /// + /// \returns Size of data when packed (in bytes) + /// template inline size_t get_pk_size(_In_ const T &val); + + /// + /// Unpacks a primitive data + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val Variable to receive unpacked value + /// template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ T &val); + /// + /// Packs a string + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val String to pack + /// template inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val); + + /// + /// Returns packed size of a string + /// + /// \param[in] val String to pack + /// + /// \returns Size of data when packed (in bytes) + /// template inline size_t get_pk_size(const std::basic_string<_Elem, _Traits, _Ax> &val); + + /// + /// Unpacks a string + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val String to unpack to + /// template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::basic_string<_Elem, _Traits, _Ax> &val); + /// + /// Packs a wide string + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val String to pack + /// template inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::basic_string &val); + + /// + /// Returns packed size of a wide string + /// + /// \param[in] val String to pack + /// + /// \returns Size of data when packed (in bytes) + /// template inline size_t get_pk_size(const std::basic_string &val); + + /// + /// Unpacks a wide string + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val String to unpack to + /// template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::basic_string &val); + /// + /// Packs a vector + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val Vector to pack + /// template inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::vector<_Ty, _Ax> &val); + + /// + /// Returns packed size of a vector + /// + /// \param[in] val Vector to pack + /// + /// \returns Size of data when packed (in bytes) + /// template inline size_t get_pk_size(const std::vector<_Ty, _Ax> &val); + + /// + /// Unpacks a vector + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val Vector to unpack to + /// template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::vector<_Ty, _Ax> &val); + /// + /// Packs a list + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val List to pack + /// template inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::list<_Ty, _Ax> &val); + + /// + /// Returns packed size of a list + /// + /// \param[in] val List to pack + /// + /// \returns Size of data when packed (in bytes) + /// template inline size_t get_pk_size(const std::list<_Ty, _Ax> &val); + + /// + /// Unpacks a list + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val List to unpack to + /// template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::list<_Ty, _Ax> &val); + /// + /// Packs a certificate context + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val Certificate context to pack + /// inline void pack(_Inout_ unsigned char *&cursor, _In_ const winstd::cert_context &val); + + /// + /// Returns packed size of a certificate context + /// + /// \param[in] val Certificate context to pack + /// + /// \returns Size of data when packed (in bytes) + /// inline size_t get_pk_size(const winstd::cert_context &val); + + /// + /// Unpacks a certificate context + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val Certificate context to unpack to + /// inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ winstd::cert_context &val); } @@ -56,12 +184,6 @@ namespace eapserial namespace eapserial { - /// - /// Packs a primitive data - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val Variable with data to pack - /// template inline void pack(_Inout_ unsigned char *&cursor, _In_ const T &val) { @@ -70,13 +192,6 @@ namespace eapserial } - /// - /// Returns packed size of a primitive data - /// - /// \param[in] val Data to pack - /// - /// \returns Size of data when packed (in bytes) - /// template inline size_t get_pk_size(_In_ const T &val) { @@ -85,12 +200,6 @@ namespace eapserial } - /// - /// Unpacks a primitive data - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val Variable to receive unpacked value - /// template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ T &val) { @@ -99,12 +208,6 @@ namespace eapserial } - /// - /// Packs a string - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val String to pack - /// template inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val) { @@ -118,13 +221,6 @@ namespace eapserial } - /// - /// Returns packed size of a string - /// - /// \param[in] val String to pack - /// - /// \returns Size of data when packed (in bytes) - /// template inline size_t get_pk_size(const std::basic_string<_Elem, _Traits, _Ax> &val) { @@ -132,12 +228,6 @@ namespace eapserial } - /// - /// Unpacks a string - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val String to unpack to - /// template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::basic_string<_Elem, _Traits, _Ax> &val) { @@ -149,12 +239,6 @@ namespace eapserial } - /// - /// Packs a wide string - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val String to pack - /// template inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::basic_string &val) { @@ -164,13 +248,6 @@ namespace eapserial } - /// - /// Returns packed size of a wide string - /// - /// \param[in] val String to pack - /// - /// \returns Size of data when packed (in bytes) - /// template inline size_t get_pk_size(const std::basic_string &val) { @@ -178,12 +255,6 @@ namespace eapserial } - /// - /// Unpacks a wide string - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val String to unpack to - /// template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::basic_string &val) { @@ -193,12 +264,6 @@ namespace eapserial } - /// - /// Packs a vector - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val Vector to pack - /// template inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::vector<_Ty, _Ax> &val) { @@ -213,13 +278,6 @@ namespace eapserial } - /// - /// Returns packed size of a vector - /// - /// \param[in] val Vector to pack - /// - /// \returns Size of data when packed (in bytes) - /// template inline size_t get_pk_size(const std::vector<_Ty, _Ax> &val) { @@ -232,12 +290,6 @@ namespace eapserial } - /// - /// Unpacks a vector - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val Vector to unpack to - /// template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::vector<_Ty, _Ax> &val) { @@ -256,12 +308,6 @@ namespace eapserial } - /// - /// Packs a list - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val List to pack - /// template inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::list<_Ty, _Ax> &val) { @@ -276,13 +322,6 @@ namespace eapserial } - /// - /// Returns packed size of a list - /// - /// \param[in] val List to pack - /// - /// \returns Size of data when packed (in bytes) - /// template inline size_t get_pk_size(const std::list<_Ty, _Ax> &val) { @@ -295,12 +334,6 @@ namespace eapserial } - /// - /// Unpacks a list - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val List to unpack to - /// template inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::list<_Ty, _Ax> &val) { @@ -318,12 +351,6 @@ namespace eapserial } - /// - /// Packs a certificate context - /// - /// \param[inout] cursor Memory cursor - /// \param[in] val Certificate context to pack - /// inline void pack(_Inout_ unsigned char *&cursor, _In_ const winstd::cert_context &val) { *(DWORD*&)cursor = val->dwCertEncodingType; @@ -337,25 +364,12 @@ namespace eapserial } - /// - /// Returns packed size of a certificate context - /// - /// \param[in] val Certificate context to pack - /// - /// \returns Size of data when packed (in bytes) - /// inline size_t get_pk_size(const winstd::cert_context &val) { return sizeof(DWORD) + sizeof(DWORD) + val->cbCertEncoded; } - /// - /// Unpacks a certificate context - /// - /// \param[inout] cursor Memory cursor - /// \param[out] val Certificate context to unpack to - /// inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ winstd::cert_context &val) { DWORD dwCertEncodingType = *(DWORD*&)cursor; diff --git a/EAPMethods/include/EAPXML.h b/lib/EAPBase/include/EAPXML.h similarity index 97% rename from EAPMethods/include/EAPXML.h rename to lib/EAPBase/include/EAPXML.h index 1dc68e74..42d5eff6 100644 --- a/EAPMethods/include/EAPXML.h +++ b/lib/EAPBase/include/EAPXML.h @@ -18,11 +18,9 @@ along with GÉANTLink. If not, see . */ -#include -#include -#include -#include #include +#include +#include #include #include @@ -54,6 +52,12 @@ namespace eapxml #pragma once +#include +#include +#include + +#include + namespace eapxml { diff --git a/lib/EAPBase/include/Module.h b/lib/EAPBase/include/Module.h new file mode 100644 index 00000000..28826f1e --- /dev/null +++ b/lib/EAPBase/include/Module.h @@ -0,0 +1,313 @@ +/* + 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 . +*/ + +#define ETW_ERROR(kw, f, ...) m_ep.write(TRACE_LEVEL_ERROR , kw, _T(__FUNCTION__) _T(" ") f, ##__VA_ARGS__) +#define ETW_WARNING(kw, f, ...) m_ep.write(TRACE_LEVEL_WARNING , kw, _T(__FUNCTION__) _T(" ") f, ##__VA_ARGS__) +#define ETW_INFO(kw, f, ...) m_ep.write(TRACE_LEVEL_INFORMATION, kw, _T(__FUNCTION__) _T(" ") f, ##__VA_ARGS__) +#define ETW_VERBOSE(kw, f, ...) m_ep.write(TRACE_LEVEL_VERBOSE , kw, _T(__FUNCTION__) _T(" ") f, ##__VA_ARGS__) +#define ETW_FN_VOID winstd::event_fn_auto < &EAPMETHOD_TRACE_EVT_FN_CALL, &EAPMETHOD_TRACE_EVT_FN_RETURN > _event_auto(m_ep, __FUNCTION__) +#define ETW_FN_DWORD(res) winstd::event_fn_auto_ret _event_auto(m_ep, __FUNCTION__, res) +#define ETW_FN_HRESULT(res) winstd::event_fn_auto_ret _event_auto(m_ep, __FUNCTION__, res) + +namespace eap +{ + /// + /// EAP module base class + /// + /// Provides basic services to EAP methods. + /// + class module; + + /// + /// EAP peer base class + /// + /// A group of methods all EAP peers must or should implement. + /// + template class peer_base; + + /// + /// EAP peer base class + /// + /// A group of methods all EAP peers must or should implement. + /// + template class peer; +} + +#pragma once + +#include "EAP.h" + +#include +#include + +#include +#include // Must include after +#include + +#include // Must include after + + +namespace eap +{ + class module + { + public: + /// + /// Constructs a module for the given EAP type + /// + module(_In_ type_t eap_method); + + /// + /// Destructs the module + /// + virtual ~module(); + + /// + /// Allocate a EAP_ERROR and fill it according to dwErrorCode + /// + EAP_ERROR* make_error(_In_ DWORD dwErrorCode, _In_ DWORD dwReasonCode, _In_ LPCGUID pRootCauseGuid, _In_ LPCGUID pRepairGuid, _In_ LPCGUID pHelpLinkGuid, _In_z_ LPCWSTR pszRootCauseString, _In_z_ LPCWSTR pszRepairString) const; + + /// + /// Allocate BLOB + /// + BYTE* alloc_memory(_In_ size_t size); + + /// + /// Free BLOB allocated with this peer + /// + void free_memory(_In_ BYTE *ptr); + + /// + /// Free EAP_ERROR allocated with `make_error()` method + /// + void free_error_memory(_In_ EAP_ERROR *err); + + public: + HINSTANCE m_instance; ///< Windows module instance + const type_t m_eap_method; ///< EAP method type + + protected: + winstd::heap m_heap; ///< Heap + mutable winstd::event_provider m_ep; ///< Event Provider + }; + + + template + class peer_base : public module + { + public: + /// + /// Configuration data type + /// + typedef config_providers > config_type; + + /// + /// Identity data type + /// + typedef _Tid identity_type; + + /// + /// Interactive request data type + /// + typedef _Tint interactive_request_type; + + /// + /// Interactive response data type + /// + typedef _Tintres interactive_response_type; + + public: + /// + /// Constructs a EAP peer module for the given EAP type + /// + peer_base(_In_ type_t eap_method) : module(eap_method) {} + }; + + + template + class peer : public peer_base<_Tcfg, _Tid, _Tint, _Tintres> + { + public: + /// + /// Constructs a EAP peer module for the given EAP type + /// + peer(_In_ type_t eap_method) : peer_base<_Tcfg, _Tid, _Tint, _Tintres>(eap_method) {} + + /// + /// Initializes an EAP peer method for EAPHost. + /// + /// \sa [EapPeerGetInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363613.aspx) + /// + virtual DWORD initialize(_Out_ EAP_ERROR **ppEapError) = 0; + + /// + /// Shuts down the EAP method and prepares to unload its corresponding DLL. + /// + /// \sa [EapPeerShutdown function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363627.aspx) + /// + virtual DWORD shutdown(_Out_ EAP_ERROR **ppEapError) = 0; + + /// + /// Returns the user data and user identity after being called by EAPHost. + /// + /// \sa [EapPeerGetIdentity function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363607.aspx) + /// + virtual DWORD get_identity( + _In_ DWORD dwFlags, + _In_ DWORD dwConnectionDataSize, + _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, + _In_ DWORD dwUserDataSize, + _In_count_(dwUserDataSize) const BYTE *pUserData, + _In_ HANDLE hTokenImpersonateUser, + _Out_ BOOL *pfInvokeUI, + _Out_ DWORD *pdwUserDataOutSize, + _Out_ BYTE **ppUserDataOut, + _Out_ WCHAR **ppwszIdentity, + _Out_ EAP_ERROR **ppEapError) = 0; + + /// + /// Defines the implementation of an EAP method-specific function that retrieves the properties of an EAP method given the connection and user data. + /// + /// \sa [EapPeerGetMethodProperties function](https://msdn.microsoft.com/en-us/library/windows/desktop/hh706636.aspx) + /// + virtual DWORD get_method_properties( + _In_ DWORD dwVersion, + _In_ DWORD dwFlags, + _In_ HANDLE hUserImpersonationToken, + _In_ DWORD dwEapConnDataSize, + _In_count_(dwEapConnDataSize) const BYTE *pEapConnData, + _In_ DWORD dwUserDataSize, + _In_count_(dwUserDataSize) const BYTE *pUserData, + _Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray, + _Out_ EAP_ERROR **ppEapError) const = 0; + + /// + /// Defines the implementation of an EAP method-specific function that obtains the EAP Single-Sign-On (SSO) credential input fields for an EAP method. + /// + /// \sa [EapPeerQueryCredentialInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363622.aspx) + /// + virtual DWORD query_credential_input_fields( + _In_ HANDLE hUserImpersonationToken, + _In_ DWORD dwFlags, + _In_ DWORD dwEapConnDataSize, + _In_count_(dwEapConnDataSize) const BYTE *pEapConnData, + _Out_ EAP_CONFIG_INPUT_FIELD_ARRAY *pEapConfigInputFieldsArray, + _Out_ EAP_ERROR **ppEapError) const + { + UNREFERENCED_PARAMETER(hUserImpersonationToken); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(dwEapConnDataSize); + UNREFERENCED_PARAMETER(pEapConnData); + UNREFERENCED_PARAMETER(pEapConfigInputFieldsArray); + UNREFERENCED_PARAMETER(ppEapError); + + DWORD dwResult = ERROR_NOT_SUPPORTED; + ETW_FN_DWORD(dwResult); + return dwResult; + } + + /// + /// Defines the implementation of an EAP method function that obtains the user BLOB data provided in an interactive Single-Sign-On (SSO) UI raised on the supplicant. + /// + /// \sa [EapPeerQueryUserBlobFromCredentialInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204697.aspx) + /// + virtual DWORD query_user_blob_from_credential_input_fields( + _In_ HANDLE hUserImpersonationToken, + _In_ DWORD dwFlags, + _In_ DWORD dwEapConnDataSize, + _In_count_(dwEapConnDataSize) const BYTE *pEapConnData, + _In_ const EAP_CONFIG_INPUT_FIELD_ARRAY *pEapConfigInputFieldArray, + _Inout_ DWORD *pdwUsersBlobSize, + _Inout_ BYTE **ppUserBlob, + _Out_ EAP_ERROR **ppEapError) const + { + UNREFERENCED_PARAMETER(hUserImpersonationToken); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(dwEapConnDataSize); + UNREFERENCED_PARAMETER(pEapConnData); + UNREFERENCED_PARAMETER(pEapConfigInputFieldArray); + UNREFERENCED_PARAMETER(pdwUsersBlobSize); + UNREFERENCED_PARAMETER(ppUserBlob); + UNREFERENCED_PARAMETER(ppEapError); + + DWORD dwResult = ERROR_NOT_SUPPORTED; + ETW_FN_DWORD(dwResult); + return dwResult; + } + + /// + /// Defines the implementation of an EAP method API that provides the input fields for interactive UI components to be raised on the supplicant. + /// + /// \sa [EapPeerQueryInteractiveUIInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204695.aspx) + /// + virtual DWORD query_interactive_ui_input_fields( + _In_ DWORD dwVersion, + _In_ DWORD dwFlags, + _In_ DWORD dwUIContextDataSize, + _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, + _Out_ EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, + _Out_ EAP_ERROR **ppEapError, + _Inout_ LPVOID *pvReserved) const + { + UNREFERENCED_PARAMETER(dwVersion); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(dwUIContextDataSize); + UNREFERENCED_PARAMETER(pUIContextData); + UNREFERENCED_PARAMETER(pEapInteractiveUIData); + UNREFERENCED_PARAMETER(ppEapError); + UNREFERENCED_PARAMETER(pvReserved); + + DWORD dwResult = ERROR_NOT_SUPPORTED; + ETW_FN_DWORD(dwResult); + return dwResult; + } + + /// + /// Converts user information into a user BLOB that can be consumed by EAPHost run-time functions. + /// + /// \sa [EapPeerQueryUIBlobFromInteractiveUIInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204696.aspx) + /// + virtual DWORD query_ui_blob_from_interactive_ui_input_fields( + _In_ DWORD dwVersion, + _In_ DWORD dwFlags, + _In_ DWORD dwUIContextDataSize, + _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, + _In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, + _Out_ DWORD *pdwDataFromInteractiveUISize, + _Out_ BYTE **ppDataFromInteractiveUI, + _Out_ EAP_ERROR **ppEapError, + _Inout_ LPVOID *ppvReserved) const + { + UNREFERENCED_PARAMETER(dwVersion); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(dwUIContextDataSize); + UNREFERENCED_PARAMETER(pUIContextData); + UNREFERENCED_PARAMETER(pEapInteractiveUIData); + UNREFERENCED_PARAMETER(pdwDataFromInteractiveUISize); + UNREFERENCED_PARAMETER(ppDataFromInteractiveUI); + UNREFERENCED_PARAMETER(ppEapError); + UNREFERENCED_PARAMETER(ppvReserved); + + DWORD dwResult = ERROR_NOT_SUPPORTED; + ETW_FN_DWORD(dwResult); + return dwResult; + } + }; +} diff --git a/lib/EAPBase/include/Session.h b/lib/EAPBase/include/Session.h new file mode 100644 index 00000000..19a49dc0 --- /dev/null +++ b/lib/EAPBase/include/Session.h @@ -0,0 +1,164 @@ +/* + 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 +{ + /// + /// EAP session + /// + class session; +} + +#pragma once + +#include +#include // Must include after +extern "C" { +#include +} +#include + + +namespace eap +{ + class session + { + public: + /// + /// Constructs a session + /// + session(); + + /// + /// Destructs the session + /// + virtual ~session(); + + /// \name Session start/end + /// @{ + + /// + /// Starts an EAP authentication session on the peer EAPHost using the EAP method. + /// + /// \sa [EapPeerBeginSession function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363600.aspx) + /// + virtual DWORD begin( + _In_ DWORD dwFlags, + _In_ const EapAttributes *pAttributeArray, + _In_ HANDLE hTokenImpersonateUser, + _In_ DWORD dwConnectionDataSize, + _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, + _In_ DWORD dwUserDataSize, + _In_count_(dwUserDataSize) const BYTE *pUserData, + _In_ DWORD dwMaxSendPacketSize, + _Out_ EAP_ERROR **ppEapError); + + /// + /// Ends an EAP authentication session for the EAP method. + /// + /// \sa [EapPeerEndSession function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363604.aspx) + /// + virtual DWORD end(_Out_ EAP_ERROR **ppEapError); + + /// @} + + /// \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 DWORD process_request_packet( + _In_ DWORD dwReceivedPacketSize, + _In_bytecount_(dwReceivedPacketSize) const EapPacket *pReceivedPacket, + _Out_ EapPeerMethodOutput *pEapOutput, + _Out_ EAP_ERROR **ppEapError); + + /// + /// Obtains a response packet from the EAP method. + /// + /// \sa [EapPeerGetResponsePacket function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363610.aspx) + /// + virtual DWORD get_response_packet( + _Inout_ DWORD *pdwSendPacketSize, + _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, + _Out_ EAP_ERROR **ppEapError); + + /// + /// 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 DWORD get_result(_In_ EapPeerMethodResultReason reason, _Out_ EapPeerMethodResult *ppResult, _Out_ EAP_ERROR **ppEapError); + + /// @} + + /// \name UI interaction + /// @{ + + /// + /// Obtains the user interface context from the EAP method. + /// + /// \note This function is always followed by the `EapPeerInvokeInteractiveUI()` function, which is followed by the `EapPeerSetUIContext()` function. + /// + /// \sa [EapPeerGetUIContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363612.aspx) + /// + virtual DWORD get_ui_context( + _Out_ DWORD *pdwUIContextDataSize, + _Out_ BYTE **ppUIContextData, + _Out_ EAP_ERROR **ppEapError); + + /// + /// Provides a user interface context to the EAP method. + /// + /// \note This function is called after the UI has been raised through the `EapPeerGetUIContext()` function. + /// + /// \sa [EapPeerSetUIContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363626.aspx) + /// + virtual DWORD set_ui_context( + _In_ DWORD dwUIContextDataSize, + _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, + _In_ const EapPeerMethodOutput *pEapOutput, + _Out_ EAP_ERROR **ppEapError); + + /// @} + + /// \name Response attributes + /// @{ + + /// + /// Obtains an array of EAP response attributes from the EAP method. + /// + /// \sa [EapPeerGetResponseAttributes function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363609.aspx) + /// + virtual DWORD get_response_attributes(_Out_ EapAttributes *pAttribs, _Out_ EAP_ERROR **ppEapError); + + /// + /// Provides an updated array of EAP response attributes to the EAP method. + /// + /// \sa [EapPeerSetResponseAttributes function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363625.aspx) + /// + virtual DWORD set_response_attributes(const _In_ EapAttributes *pAttribs, _Out_ EapPeerMethodOutput *pEapOutput, _Out_ EAP_ERROR **ppEapError); + + /// @} + }; +} diff --git a/lib/EAPBase/src/Config.cpp b/lib/EAPBase/src/Config.cpp new file mode 100644 index 00000000..aef550f3 --- /dev/null +++ b/lib/EAPBase/src/Config.cpp @@ -0,0 +1,168 @@ +/* + 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 +////////////////////////////////////////////////////////////////////// + +eap::config::config(_In_ module &mod) : + m_module(mod) +{ +} + + +eap::config::config(_In_ const config &other) : + m_module(other.m_module) +{ +} + + +eap::config::config(_Inout_ config &&other) : + m_module(other.m_module) +{ +} + + +eap::config::~config() +{ +} + + +eap::config& eap::config::operator=(_In_ const config &other) +{ + UNREFERENCED_PARAMETER(other); + assert(&m_module == &other.m_module); // Copy configuration within same module only! + return *this; +} + + +eap::config& eap::config::operator=(_Inout_ config &&other) +{ + UNREFERENCED_PARAMETER(other); + assert(&m_module == &other.m_module); // Copy configuration within same module only! + return *this; +} + + +////////////////////////////////////////////////////////////////////// +// eap::config_method +////////////////////////////////////////////////////////////////////// + +eap::config_method::config_method(_In_ module &mod) : + m_allow_save(true), + config(mod) +{ +} + + +eap::config_method::config_method(_In_ const config_method &other) : + m_allow_save(other.m_allow_save), + m_anonymous_identity(other.m_anonymous_identity), + config(other) +{ +} + + +eap::config_method::config_method(_Inout_ config_method &&other) : + m_allow_save(std::move(other.m_allow_save)), + m_anonymous_identity(std::move(other.m_anonymous_identity)), + config(std::move(other)) +{ +} + + +eap::config_method& eap::config_method::operator=(_In_ const config_method &other) +{ + if (this != &other) { + (config&)*this = other; + m_allow_save = other.m_allow_save; + m_anonymous_identity = other.m_anonymous_identity; + } + + return *this; +} + + +eap::config_method& eap::config_method::operator=(_Inout_ config_method &&other) +{ + if (this != &other) { + (config&&)*this = std::move(other); + m_allow_save = std::move(other.m_allow_save); + m_anonymous_identity = std::move(other.m_anonymous_identity); + } + + return *this; +} + + +DWORD eap::config_method::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const +{ + const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata"); + DWORD dwResult; + + // + com_obj pXmlElClientSideCredential; + if ((dwResult = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:ClientSideCredential"), bstr(L"ClientSideCredential"), bstrNamespace, &pXmlElClientSideCredential)) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + // / + if ((dwResult = eapxml::put_element_value(pDoc, pXmlElClientSideCredential, bstr(L"allow-save"), bstrNamespace, m_allow_save)) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + // / + if (!m_anonymous_identity.empty()) + if ((dwResult = eapxml::put_element_value(pDoc, pXmlElClientSideCredential, bstr(L"AnonymousIdentity"), bstrNamespace, bstr(m_anonymous_identity))) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + return ERROR_SUCCESS; +} + + +DWORD eap::config_method::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(ppEapError); + + m_allow_save = true; + m_anonymous_identity.clear(); + + // + com_obj pXmlElClientSideCredential; + if (eapxml::select_element(pConfigRoot, bstr(L"eap-metadata:ClientSideCredential"), &pXmlElClientSideCredential) == ERROR_SUCCESS) { + // + eapxml::get_element_value(pXmlElClientSideCredential, bstr(L"eap-metadata:allow-save"), &m_allow_save); + + // + eapxml::get_element_value(pXmlElClientSideCredential, bstr(L"eap-metadata:AnonymousIdentity"), m_anonymous_identity); + } + + return ERROR_SUCCESS; +} diff --git a/lib/EAPBase/src/Credentials.cpp b/lib/EAPBase/src/Credentials.cpp new file mode 100644 index 00000000..48ae02f1 --- /dev/null +++ b/lib/EAPBase/src/Credentials.cpp @@ -0,0 +1,355 @@ +/* + 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" + +#pragma comment(lib, "Crypt32.lib") + +using namespace std; +using namespace winstd; + + +////////////////////////////////////////////////////////////////////// +// eap::credentials +////////////////////////////////////////////////////////////////////// + +eap::credentials::credentials(_In_ module &mod) : config(mod) +{ +} + + +eap::credentials::credentials(_In_ const credentials &other) : + m_identity(other.m_identity), + config(other) +{ +} + + +eap::credentials::credentials(_Inout_ credentials &&other) : + m_identity(std::move(other.m_identity)), + config(std::move(other)) +{ +} + + +eap::credentials& eap::credentials::operator=(_In_ const credentials &other) +{ + if (this != &other) { + (config&)*this = other; + m_identity = other.m_identity; + } + + return *this; +} + + +eap::credentials& eap::credentials::operator=(_Inout_ credentials &&other) +{ + if (this != &other) { + (config&)*this = std::move(other); + m_identity = std::move(other.m_identity); + } + + return *this; +} + + +void eap::credentials::clear() +{ + m_identity.clear(); +} + + +bool eap::credentials::empty() const +{ + return m_identity.empty(); +} + + +DWORD eap::credentials::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const +{ + UNREFERENCED_PARAMETER(pDoc); + UNREFERENCED_PARAMETER(pConfigRoot); + UNREFERENCED_PARAMETER(ppEapError); + + // Yeah, right!? Credentials are non-exportable! + return ERROR_NOT_SUPPORTED; +} + + +////////////////////////////////////////////////////////////////////// +// eap::credentials_pass +////////////////////////////////////////////////////////////////////// + +eap::credentials_pass::credentials_pass(_In_ module &mod) : credentials(mod) +{ +} + + +eap::credentials_pass::credentials_pass(_In_ const credentials_pass &other) : + m_password(other.m_password), + credentials(other) +{ +} + + +eap::credentials_pass::credentials_pass(_Inout_ credentials_pass &&other) : + m_password(std::move(other.m_password)), + credentials(std::move(other)) +{ +} + + +eap::credentials_pass& eap::credentials_pass::operator=(_In_ const credentials_pass &other) +{ + if (this != &other) { + (credentials&)*this = other; + m_password = other.m_password; + } + + return *this; +} + + +eap::credentials_pass& eap::credentials_pass::operator=(_Inout_ credentials_pass &&other) +{ + if (this != &other) { + (credentials&)*this = std::move(other); + m_password = std::move(other.m_password); + } + + return *this; +} + + +void eap::credentials_pass::clear() +{ + credentials::clear(); + m_password.clear(); +} + + +bool eap::credentials_pass::empty() const +{ + return credentials::empty() && m_password.empty(); +} + + +DWORD eap::credentials_pass::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) +{ + assert(pConfigRoot); + UNREFERENCED_PARAMETER(ppEapError); + + eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:UserName"), m_identity); + + bstr pass; + if ((eapxml::get_element_value(pConfigRoot, bstr(L"eap-metadata:Password"), &pass)) == ERROR_SUCCESS) + m_password = pass; + SecureZeroMemory((BSTR)pass, sizeof(OLECHAR)*pass.length()); + + return ERROR_SUCCESS; +} + + +DWORD eap::credentials_pass::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const +{ + assert(pszTargetName); + assert(ppEapError); + DWORD dwResult; + string password_enc; + + // Prepare cryptographics provider. + crypt_prov cp; + if (!cp.create(NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CryptAcquireContext failed."), NULL); + return dwResult; + } + + // Import the public key. + HRSRC res = FindResource(m_module.m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PUBLIC), RT_RCDATA); + assert(res); + HGLOBAL res_handle = LoadResource(m_module.m_instance, res); + assert(res_handle); + crypt_key key; + unique_ptr > keyinfo_data; + DWORD keyinfo_size = 0; + if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, (const BYTE*)::LockResource(res_handle), ::SizeofResource(m_module.m_instance, res), CRYPT_DECODE_ALLOC_FLAG, NULL, &keyinfo_data, &keyinfo_size)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CryptDecodeObjectEx failed."), NULL); + return dwResult; + } + + if (!key.import_public(cp, X509_ASN_ENCODING, keyinfo_data.get())) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Public key import failed."), NULL); + return dwResult; + } + + // Convert password to UTF-8. + sanitizing_string password_utf8; + WideCharToMultiByte(CP_UTF8, 0, m_password.c_str(), (int)m_password.length(), password_utf8, NULL, NULL); + + // Pre-allocate memory to allow space, as encryption will grow the data, and we need additional 16B at the end for MD5 hash. + DWORD dwBlockLen; + vector > password(password_utf8.length()); + memcpy(password.data(), password_utf8.c_str(), sizeof(char)*password_utf8.length()); + if (!CryptGetKeyParam(key, KP_BLOCKLEN, dwBlockLen, 0)) dwBlockLen = 0; + password.reserve((password.size() + dwBlockLen - 1) / dwBlockLen * dwBlockLen + 16); + + // Encrypt the password using our public key. Calculate MD5 hash and append it. + crypt_hash hash; + if (!hash.create(cp, CALG_MD5)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Creating MD5 hash failed."), NULL); + return dwResult; + } + if (!CryptEncrypt(key, hash, TRUE, 0, password)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Encrypting password failed."), NULL); + return dwResult; + } + vector hash_bin; + CryptGetHashParam(hash, HP_HASHVAL, hash_bin, 0); + password.insert(password.end(), hash_bin.begin(), hash_bin.end()); + + // Convert encrypted password to Base64, since CredProtectA() fail for binary strings. + string password_base64; + base64_enc enc; + enc.encode(password_base64, password.data(), password.size()); + + // Encrypt the password using user's key. + CRED_PROTECTION_TYPE cpt; + if (!CredProtectA(TRUE, password_base64.c_str(), (DWORD)password_base64.length(), password_enc, &cpt)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredProtect failed."), NULL); + return dwResult; + } + + tstring target(target_name(pszTargetName)); + + // Write credentials. + assert(password_enc.size()*sizeof(char) < CRED_MAX_CREDENTIAL_BLOB_SIZE); + assert(m_identity.length() < CRED_MAX_USERNAME_LENGTH ); + CREDENTIAL cred = { + 0, // Flags + CRED_TYPE_GENERIC, // Type + (LPTSTR)target.c_str(), // TargetName + _T(""), // Comment + { 0, 0 }, // LastWritten + (DWORD)password_enc.size()*sizeof(char), // CredentialBlobSize + (LPBYTE)password_enc.data(), // CredentialBlob + CRED_PERSIST_ENTERPRISE, // Persist + 0, // AttributeCount + NULL, // Attributes + NULL, // TargetAlias + (LPTSTR)m_identity.c_str() // UserName + }; + if (!CredWrite(&cred, 0)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredWrite failed."), NULL); + return dwResult; + } + + return ERROR_SUCCESS; +} + + +DWORD eap::credentials_pass::retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) +{ + assert(pszTargetName); + DWORD dwResult; + + // Read credentials. + unique_ptr > cred; + if (!CredRead(target_name(pszTargetName).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredRead failed."), NULL); + return dwResult; + } + + m_identity = cred->UserName; + + // Decrypt the password using user's key. + string password_base64; + if (!CredUnprotectA(TRUE, (LPCSTR)(cred->CredentialBlob), cred->CredentialBlobSize/sizeof(char), password_base64)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredUnprotect failed."), NULL); + return dwResult; + } + + // Convert Base64 to binary encrypted password, since CredProtectA() fail for binary strings. + vector > password; + base64_dec dec; + bool is_last; + dec.decode(password, is_last, password_base64.c_str(), password_base64.length()); + + // Prepare cryptographics provider. + crypt_prov cp; + if (!cp.create(NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CryptAcquireContext failed."), NULL); + return dwResult; + } + + // Create hash. + crypt_hash hash; + if (!hash.create(cp, CALG_MD5)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Creating MD5 hash failed."), NULL); + return dwResult; + } + DWORD dwHashSize, dwHashSizeSize = sizeof(dwHashSize); + CryptGetHashParam(hash, HP_HASHSIZE, (LPBYTE)&dwHashSize, &dwHashSizeSize, 0); + if (password.size() < dwHashSize) { + *ppEapError = m_module.make_error(dwResult = ERROR_INVALID_DATA, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Encrypted password too short."), NULL); + return dwResult; + } + + // Truncate hash from encrypted password. + vector hash_bin; + size_t enc_size = password.size() - dwHashSize; + hash_bin.assign(password.begin() + enc_size, password.end()); + password.resize(enc_size); + + // Import the private key. + HRSRC res = FindResource(m_module.m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PRIVATE), RT_RCDATA); + assert(res); + HGLOBAL res_handle = LoadResource(m_module.m_instance, res); + assert(res_handle); + crypt_key key; + unique_ptr > keyinfo_data; + DWORD keyinfo_size = 0; + if (!CryptDecodeObjectEx(X509_ASN_ENCODING, PKCS_RSA_PRIVATE_KEY, (const BYTE*)::LockResource(res_handle), ::SizeofResource(m_module.m_instance, res), CRYPT_DECODE_ALLOC_FLAG, NULL, &keyinfo_data, &keyinfo_size)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CryptDecodeObjectEx failed."), NULL); + return dwResult; + } + + if (!key.import(cp, keyinfo_data.get(), keyinfo_size, NULL, 0)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Private key import failed."), NULL); + return dwResult; + } + + // Decrypt the password using our private key. Calculate MD5 hash and verify it. + if (!CryptDecrypt(key, hash, TRUE, 0, password)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Decrypting password failed."), NULL); + return dwResult; + } + vector hash2_bin; + CryptGetHashParam(hash, HP_HASHVAL, hash2_bin, 0); + if (hash_bin != hash2_bin) { + *ppEapError = m_module.make_error(dwResult = ERROR_INVALID_DATA, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Invalid password data."), NULL); + return dwResult; + } + + // Convert password from UTF-8. + MultiByteToWideChar(CP_UTF8, 0, password.data(), (int)password.size(), m_password); + + return ERROR_SUCCESS; +} diff --git a/lib/EAPBase/src/Module.cpp b/lib/EAPBase/src/Module.cpp new file mode 100644 index 00000000..7f21016d --- /dev/null +++ b/lib/EAPBase/src/Module.cpp @@ -0,0 +1,123 @@ +/* + 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::module +////////////////////////////////////////////////////////////////////// + +eap::module::module(type_t eap_method) : + m_eap_method(eap_method), + m_instance(NULL) +{ + m_ep.create(&EAPMETHOD_TRACE_EVENT_PROVIDER); + m_ep.write(&EAPMETHOD_TRACE_EVT_MODULE_LOAD, event_data((BYTE)m_eap_method), event_data::blank); + + m_heap.create(0, 0, 0); +} + + +eap::module::~module() +{ + m_ep.write(&EAPMETHOD_TRACE_EVT_MODULE_UNLOAD, event_data((BYTE)m_eap_method), event_data::blank); +} + + +EAP_ERROR* eap::module::make_error(_In_ DWORD dwErrorCode, _In_ DWORD dwReasonCode, _In_ LPCGUID pRootCauseGuid, _In_ LPCGUID pRepairGuid, _In_ LPCGUID pHelpLinkGuid, _In_z_ LPCWSTR pszRootCauseString, _In_z_ LPCWSTR pszRepairString) const +{ + // Calculate memory size requirement. + SIZE_T + nRootCauseSize = pszRootCauseString != NULL && pszRootCauseString[0] ? (wcslen(pszRootCauseString) + 1)*sizeof(WCHAR) : 0, + nRepairStringSize = pszRepairString != NULL && pszRepairString [0] ? (wcslen(pszRepairString ) + 1)*sizeof(WCHAR) : 0, + nEapErrorSize = sizeof(EAP_ERROR) + nRootCauseSize + nRepairStringSize; + + EAP_ERROR *pError = (EAP_ERROR*)HeapAlloc(m_heap, 0, nEapErrorSize); + if (!pError) + return NULL; + BYTE *p = (BYTE*)(pError + 1); + + // Fill the error descriptor. + pError->dwWinError = dwErrorCode; + pError->type.eapType.type = (BYTE)m_eap_method; + pError->type.eapType.dwVendorId = 0; + pError->type.eapType.dwVendorType = 0; + pError->type.dwAuthorId = 67532; + pError->dwReasonCode = dwReasonCode; + pError->rootCauseGuid = pRootCauseGuid != NULL ? *pRootCauseGuid : GUID_NULL; + pError->repairGuid = pRepairGuid != NULL ? *pRepairGuid : GUID_NULL; + pError->helpLinkGuid = pHelpLinkGuid != NULL ? *pHelpLinkGuid : GUID_NULL; + if (nRootCauseSize) { + pError->pRootCauseString = (LPWSTR)p; + memcpy(pError->pRootCauseString, pszRootCauseString, nRootCauseSize); + p += nRootCauseSize; + } else + pError->pRootCauseString = NULL; + if (nRepairStringSize) { + pError->pRepairString = (LPWSTR)p; + memcpy(pError->pRepairString, pszRepairString, nRepairStringSize); + p += nRepairStringSize; + } else + pError->pRepairString = NULL; + + // Write trace event. + vector evt_desc; + evt_desc.reserve(8); + evt_desc.push_back(event_data(pError->dwWinError)); + evt_desc.push_back(event_data(pError->type.eapType.type)); + evt_desc.push_back(event_data(pError->dwReasonCode)); + evt_desc.push_back(event_data(&(pError->rootCauseGuid), sizeof(GUID))); + evt_desc.push_back(event_data(&(pError->repairGuid), sizeof(GUID))); + evt_desc.push_back(event_data(&(pError->helpLinkGuid), sizeof(GUID))); + evt_desc.push_back(event_data(pError->pRootCauseString)); + evt_desc.push_back(event_data(pError->pRepairString)); + m_ep.write(&EAPMETHOD_TRACE_EAP_ERROR, (ULONG)evt_desc.size(), evt_desc.data()); + + return pError; +} + + +BYTE* eap::module::alloc_memory(_In_ size_t size) +{ + return (BYTE*)HeapAlloc(m_heap, 0, size); +} + + +void eap::module::free_memory(_In_ BYTE *ptr) +{ + ETW_FN_VOID; + + // Since we do security here and some of the BLOBs contain credentials, sanitize every memory block before freeing. + SecureZeroMemory(ptr, HeapSize(m_heap, 0, ptr)); + HeapFree(m_heap, 0, ptr); +} + + +void eap::module::free_error_memory(_In_ EAP_ERROR *err) +{ + ETW_FN_VOID; + + // pRootCauseString and pRepairString always trail the ppEapError to reduce number of (de)allocations. + HeapFree(m_heap, 0, err); +} diff --git a/lib/EAPBase/src/Session.cpp b/lib/EAPBase/src/Session.cpp new file mode 100644 index 00000000..c42b3138 --- /dev/null +++ b/lib/EAPBase/src/Session.cpp @@ -0,0 +1,156 @@ +/* + 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::session +////////////////////////////////////////////////////////////////////// + +eap::session::session() +{ +} + + +eap::session::~session() +{ +} + + +DWORD eap::session::begin( + _In_ DWORD dwFlags, + _In_ const EapAttributes *pAttributeArray, + _In_ HANDLE hTokenImpersonateUser, + _In_ DWORD dwConnectionDataSize, + _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, + _In_ DWORD dwUserDataSize, + _In_count_(dwUserDataSize) const BYTE *pUserData, + _In_ DWORD dwMaxSendPacketSize, + _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(pAttributeArray); + UNREFERENCED_PARAMETER(hTokenImpersonateUser); + UNREFERENCED_PARAMETER(dwConnectionDataSize); + UNREFERENCED_PARAMETER(pConnectionData); + UNREFERENCED_PARAMETER(dwUserDataSize); + UNREFERENCED_PARAMETER(pUserData); + UNREFERENCED_PARAMETER(dwMaxSendPacketSize); + UNREFERENCED_PARAMETER(ppEapError); + + return ERROR_SUCCESS; +} + + +DWORD eap::session::end(_Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(ppEapError); + + return ERROR_SUCCESS; +} + + +DWORD eap::session::process_request_packet( + _In_ DWORD dwReceivedPacketSize, + _In_bytecount_(dwReceivedPacketSize) const EapPacket *pReceivedPacket, + _Out_ EapPeerMethodOutput *pEapOutput, + _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(dwReceivedPacketSize); + UNREFERENCED_PARAMETER(pReceivedPacket); + UNREFERENCED_PARAMETER(pEapOutput); + UNREFERENCED_PARAMETER(ppEapError); + + return ERROR_NOT_SUPPORTED; +} + + +DWORD eap::session::get_response_packet( + _Inout_ DWORD *pdwSendPacketSize, + _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, + _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(pdwSendPacketSize); + UNREFERENCED_PARAMETER(pSendPacket); + UNREFERENCED_PARAMETER(ppEapError); + + return ERROR_NOT_SUPPORTED; +} + + +DWORD eap::session::get_result(_In_ EapPeerMethodResultReason reason, _Out_ EapPeerMethodResult *ppResult, _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(reason); + UNREFERENCED_PARAMETER(ppResult); + UNREFERENCED_PARAMETER(ppEapError); + + return ERROR_NOT_SUPPORTED; +} + + +DWORD eap::session::get_ui_context( + _Out_ DWORD *pdwUIContextDataSize, + _Out_ BYTE **ppUIContextData, + _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(pdwUIContextDataSize); + UNREFERENCED_PARAMETER(ppUIContextData); + UNREFERENCED_PARAMETER(ppEapError); + + return ERROR_NOT_SUPPORTED; +} + + +DWORD eap::session::set_ui_context( + _In_ DWORD dwUIContextDataSize, + _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, + _In_ const EapPeerMethodOutput *pEapOutput, + _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(dwUIContextDataSize); + UNREFERENCED_PARAMETER(pUIContextData); + UNREFERENCED_PARAMETER(pEapOutput); + UNREFERENCED_PARAMETER(ppEapError); + + return ERROR_NOT_SUPPORTED; +} + + +DWORD eap::session::get_response_attributes(_Out_ EapAttributes *pAttribs, _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(pAttribs); + UNREFERENCED_PARAMETER(ppEapError); + + return ERROR_NOT_SUPPORTED; +} + + +DWORD eap::session::set_response_attributes(const _In_ EapAttributes *pAttribs, _Out_ EapPeerMethodOutput *pEapOutput, _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(pAttribs); + UNREFERENCED_PARAMETER(pEapOutput); + UNREFERENCED_PARAMETER(ppEapError); + + return ERROR_NOT_SUPPORTED; +} diff --git a/lib/EAPBase/src/StdAfx.cpp b/lib/EAPBase/src/StdAfx.cpp new file mode 100644 index 00000000..4af5ec17 --- /dev/null +++ b/lib/EAPBase/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/EAPBase/src/StdAfx.h b/lib/EAPBase/src/StdAfx.h new file mode 100644 index 00000000..438ad9ec --- /dev/null +++ b/lib/EAPBase/src/StdAfx.h @@ -0,0 +1,35 @@ +/* + 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/Module.h" +#include "../include/Session.h" + +#include "../include/EAP.h" +#include "../include/EAPSerial.h" +#include "../include/EAPXML.h" + +#include +#include + +#include diff --git a/lib/EAPBase_UI/build/.gitignore b/lib/EAPBase_UI/build/.gitignore new file mode 100644 index 00000000..9c8716a0 --- /dev/null +++ b/lib/EAPBase_UI/build/.gitignore @@ -0,0 +1,2 @@ +/temp +/*.user diff --git a/lib/EAPBase_UI/build/EAPBase_UI.props b/lib/EAPBase_UI/build/EAPBase_UI.props new file mode 100644 index 00000000..4997b714 --- /dev/null +++ b/lib/EAPBase_UI/build/EAPBase_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/EAPBase_UI/build/EAPBase_UI.vcxproj b/lib/EAPBase_UI/build/EAPBase_UI.vcxproj new file mode 100644 index 00000000..1fed951b --- /dev/null +++ b/lib/EAPBase_UI/build/EAPBase_UI.vcxproj @@ -0,0 +1,108 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {D4B54856-BE1F-4937-A8F7-495125BE76BE} + EAPBase_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/EAPBase_UI/build/EAPBase_UI.vcxproj.filters b/lib/EAPBase_UI/build/EAPBase_UI.vcxproj.filters new file mode 100644 index 00000000..48623246 --- /dev/null +++ b/lib/EAPBase_UI/build/EAPBase_UI.vcxproj.filters @@ -0,0 +1,47 @@ + + + + + {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 + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/EAPMethods/include/EAP_UI.h b/lib/EAPBase_UI/include/EAP_UI.h similarity index 73% rename from EAPMethods/include/EAP_UI.h rename to lib/EAPBase_UI/include/EAP_UI.h index 855c1cf8..f615070f 100644 --- a/EAPMethods/include/EAP_UI.h +++ b/lib/EAPBase_UI/include/EAP_UI.h @@ -18,117 +18,66 @@ along with GÉANTLink. If not, see . */ -#include "EAP.h" -#include "../res/wxEAP_UI.h" - -#include - -#include #include -#include -#include +#include +#include -namespace eap -{ - template class peer_ui; -} +/// +/// EAP configuration dialog +/// template class wxEAPConfigDialog; + +/// +/// EAP credentials dialog +/// class wxEAPCredentialsDialog; + +/// +/// EAP dialog banner +/// class wxEAPBannerPanel; + +/// +/// Base template for credentials configuration panel +/// template class wxEAPCredentialsConfigPanel; + +/// +/// Base template for all credential panels +/// template class wxCredentialsPanel; + +/// +/// Password credentials panel +/// class wxPasswordCredentialsPanel; +/// +/// Sets icon from resource +/// inline bool wxSetIconFromResource(wxStaticBitmap *bmp, wxIcon &icon, HINSTANCE hinst, PCWSTR pszName); #pragma once +#include // Fixes `CreateDialog` name collision +#include "../res/wxEAP_UI.h" -namespace eap -{ - /// - /// EAP UI peer base abstract class template - /// - /// A group of methods all EAP UI peers must or should implement. - /// - template - class peer_ui : public peer_base<_Tcfg, _Tid, _Tint, _Tintres> - { - public: - /// - /// Constructor - /// - peer_ui() : peer_base<_Tcfg, _Tid, _Tint, _Tintres>() {} - - /// - /// Raises the EAP method's specific connection configuration user interface dialog on the client. - /// - /// \sa [EapPeerInvokeConfigUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363614.aspx) - /// - /// \param[in] hwndParent Parent window - /// \param[inout] cfg Configuration to edit - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD invoke_config_ui( - _In_ HWND hwndParent, - _Inout_ config_type &cfg, - _Out_ EAP_ERROR **ppEapError) = 0; - - /// - /// Raises a custom interactive user interface dialog to obtain user identity information for the EAP method on the client. - /// - /// \sa [EapPeerInvokeIdentityUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363615.aspx) - /// - /// \param[in] hwndParent Parent window - /// \param[in] dwFlags Flags passed to `EapPeerInvokeIdentityUI()` call - /// \param[inout] cfg Configuration - /// \param[inout] usr User data to edit - /// \param[out] ppwszIdentity Pointer to user identity. Free using `module::free_memory()`. - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD invoke_identity_ui( - _In_ HWND hwndParent, - _In_ DWORD dwFlags, - _Inout_ config_type &cfg, - _Inout_ identity_type &usr, - _Out_ LPWSTR *ppwszIdentity, - _Out_ EAP_ERROR **ppEapError) = 0; - - /// - /// Raises a custom interactive user interface dialog for the EAP method on the client. - /// - /// \sa [EapPeerInvokeInteractiveUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363616.aspx) - /// - /// \param[in] hwndParent Parent window - /// \param[in] req Interactive request - /// \param[out] res Interactive response - /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. - /// - /// \returns - /// - \c ERROR_SUCCESS if succeeded - /// - error code otherwise - /// - virtual DWORD invoke_interactive_ui( - _In_ HWND hwndParent, - _In_ const interactive_request_type &req, - _Out_ interactive_response_type &res, - _Out_ EAP_ERROR **ppEapError) = 0; - }; -} +#include "../../EAPBase/include/Config.h" +#include "../../EAPBase/include/Credentials.h" + +#include +#include +#include + +#include + +#include + +#include +#include -/// -/// EAP configuration dialog -/// template class wxEAPConfigDialog : public wxEAPConfigDialogBase { @@ -198,9 +147,6 @@ class wxEAPConfigDialog : public wxEAPConfigDialogBase }; -/// -/// EAP credentials dialog -/// class wxEAPCredentialsDialog : public wxEAPCredentialsDialogBase { public: @@ -221,9 +167,6 @@ class wxEAPCredentialsDialog : public wxEAPCredentialsDialogBase }; -/// -/// EAP dialog banner -/// class wxEAPBannerPanel : public wxEAPBannerPanelBase { public: @@ -239,9 +182,6 @@ class wxEAPBannerPanel : public wxEAPBannerPanelBase }; -/// -/// Base template for credentials configuration panel -/// template class wxEAPCredentialsConfigPanel : public wxEAPCredentialsConfigPanelBase { @@ -318,9 +258,6 @@ class wxEAPCredentialsConfigPanel : public wxEAPCredentialsConfigPanelBase }; -/// -/// Base template for all credential panels -/// template class wxCredentialsPanel : public _Tbase { @@ -396,9 +333,6 @@ class wxCredentialsPanel : public _Tbase }; -/// -/// Password credentials panel -/// class wxPasswordCredentialsPanel : public wxCredentialsPanel { public: @@ -427,9 +361,6 @@ class wxPasswordCredentialsPanel : public wxCredentialsPanel. +*/ + +namespace eap +{ + /// + /// EAP UI peer base abstract class template + /// + /// A group of methods all EAP UI peers must or should implement. + /// + template class peer_ui; +} + +#pragma once + +#include "../../EAPBase/include/Module.h" + + +namespace eap +{ + template + class peer_ui : public peer_base<_Tcfg, _Tid, _Tint, _Tintres> + { + public: + /// + /// Constructs a EAP UI peer module for the given EAP type + /// + peer_ui(_In_ type_t eap_method) : peer_base<_Tcfg, _Tid, _Tint, _Tintres>(eap_method) {} + + /// + /// Raises the EAP method's specific connection configuration user interface dialog on the client. + /// + /// \sa [EapPeerInvokeConfigUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363614.aspx) + /// + /// \param[in] hwndParent Parent window + /// \param[inout] cfg Configuration to edit + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD invoke_config_ui( + _In_ HWND hwndParent, + _Inout_ config_type &cfg, + _Out_ EAP_ERROR **ppEapError) = 0; + + /// + /// Raises a custom interactive user interface dialog to obtain user identity information for the EAP method on the client. + /// + /// \sa [EapPeerInvokeIdentityUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363615.aspx) + /// + /// \param[in] hwndParent Parent window + /// \param[in] dwFlags Flags passed to `EapPeerInvokeIdentityUI()` call + /// \param[inout] cfg Configuration + /// \param[inout] usr User data to edit + /// \param[out] ppwszIdentity Pointer to user identity. Free using `module::free_memory()`. + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD invoke_identity_ui( + _In_ HWND hwndParent, + _In_ DWORD dwFlags, + _Inout_ config_type &cfg, + _Inout_ identity_type &usr, + _Out_ LPWSTR *ppwszIdentity, + _Out_ EAP_ERROR **ppEapError) = 0; + + /// + /// Raises a custom interactive user interface dialog for the EAP method on the client. + /// + /// \sa [EapPeerInvokeInteractiveUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363616.aspx) + /// + /// \param[in] hwndParent Parent window + /// \param[in] req Interactive request + /// \param[out] res Interactive response + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD invoke_interactive_ui( + _In_ HWND hwndParent, + _In_ const interactive_request_type &req, + _Out_ interactive_response_type &res, + _Out_ EAP_ERROR **ppEapError) = 0; + }; +} diff --git a/EAPMethods/res/wxEAP_UI.cpp b/lib/EAPBase_UI/res/wxEAP_UI.cpp similarity index 100% rename from EAPMethods/res/wxEAP_UI.cpp rename to lib/EAPBase_UI/res/wxEAP_UI.cpp diff --git a/EAPMethods/res/wxEAP_UI.fbp b/lib/EAPBase_UI/res/wxEAP_UI.fbp similarity index 100% rename from EAPMethods/res/wxEAP_UI.fbp rename to lib/EAPBase_UI/res/wxEAP_UI.fbp diff --git a/EAPMethods/res/wxEAP_UI.h b/lib/EAPBase_UI/res/wxEAP_UI.h similarity index 100% rename from EAPMethods/res/wxEAP_UI.h rename to lib/EAPBase_UI/res/wxEAP_UI.h diff --git a/EAPMethods/src/EAP_UI.cpp b/lib/EAPBase_UI/src/EAP_UI.cpp similarity index 96% rename from EAPMethods/src/EAP_UI.cpp rename to lib/EAPBase_UI/src/EAP_UI.cpp index 8ea8ae2d..e6805b0a 100644 --- a/EAPMethods/src/EAP_UI.cpp +++ b/lib/EAPBase_UI/src/EAP_UI.cpp @@ -18,7 +18,7 @@ along with GÉANTLink. If not, see . */ -#include +#include "StdAfx.h" ////////////////////////////////////////////////////////////////////// diff --git a/lib/EAPBase_UI/src/StdAfx.cpp b/lib/EAPBase_UI/src/StdAfx.cpp new file mode 100644 index 00000000..4af5ec17 --- /dev/null +++ b/lib/EAPBase_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/EAPBase_UI/src/StdAfx.h b/lib/EAPBase_UI/src/StdAfx.h new file mode 100644 index 00000000..5a4804eb --- /dev/null +++ b/lib/EAPBase_UI/src/StdAfx.h @@ -0,0 +1,26 @@ +/* + 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/EAP_UI.h" +#include "../include/Module.h" diff --git a/lib/Events/MSIBuild/.gitignore b/lib/Events/MSIBuild/.gitignore new file mode 100644 index 00000000..80ea6766 --- /dev/null +++ b/lib/Events/MSIBuild/.gitignore @@ -0,0 +1,9 @@ +/*-1.idt +/*-2.idt +/*-2.idtx +/*.Binary-1 +/*.Binary-2 +/*.Icon-1 +/*.Icon-2 +/*.lst +/*.msm diff --git a/lib/Events/MSIBuild/Makefile b/lib/Events/MSIBuild/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..f57317b647a26e0bf5a6b4abee76270bb9931644 GIT binary patch literal 6888 zcmds+Yfl?T6o$`NSL%P*KtBX2m}`KfX;fn{MKu?JDME^bjBUUQF$9|udi#In=$A2C7{zn@qYOhR+ax5!dG zWh7em(ejxZZ^|Va_tDqz5!$Y^W9L3b!``C*g0?g6HQHL-C0lna9k{bE71~gSHarkt!1y!*5Enx z*UW$A{gjcz_sFJb>z++FPHB+Mx~=pQ^s;L3g7hjXlTk-_m%T5zAGu_(WcS$p#zU5O zWi3UQyc4{1=tzRU4r7$Tr{_o>xnK6&{%2UBK?I!9_UhXFLi9woZOdfBPqv1CD~zJd z*x|m-(*{?_lpXt?Ht81%c|o>mxUH{ZYZ5&tjMn6vkcW6abz61ZTJl7PX zzXo~t+?CDBrUP^*Ue0E?2rG;ITF7@i`xIls{EoSFxK3cNF|KpJ^5|?4FL~roc^>oV zNLivy%lj@X3E2xqS;d=We7J!3A{#;`Zy&mTl@~Siow?0F*b4q#CVI}?_I3L2Gh&{Y ztisMi9(RfM68fdNgzlu@7QM@~?h-W{#LWVu7m2G~WD7_w@}!oaLs2U!Md3OlD9W`W z1s3gJYqBaN%&hfCTw7-b$%w+d3}(G2f5WVukL41kVeC;L3Qj!RWS1I|k)SQ$FRdJJ zeT^Hk@9d>#>?&)^2s73Dy0=s=-;2yRe7&i6lxiT4rRvx{_3)te3a?^t#Un|a8ft?f zZyiiz=BRG8UW-@1@YH5T5%&0zUvY}8Hs;^Q>~s7@R?QK0$1!h=IXk=~7n7dvdD7Zl zb`PxM4RMH8EAep-AF0Y}F|Q7JBL>@b$+mmqW@ePh0{Kd7#xAkAfR}P$mEU@k7Ur9N z%;EK3v8{QQW{-Gx=8ky&Y=Bt2u^6vk9q{L|u_E(&1PZO}xk{%0OpiryCb6vhW63<> z2zVkG>e$!eGIv#v9qysNk;KC?FkAOvvalE3&m|MH@-BDjIjzO2v^!*2ooKC)tIAsW zub*5~W=`208kX5Psdu)GZ|4E6#9AW*qo&L(=KFz5U$)_p7UN9D419ZTrII=Oom`sn zUEQqdD*5iN5I;@xb&hNuMPi;kUxBA--vy2%@j8B<@%x|5Z^CEyf?ikG$X?KY0mbya z$b*znml(Z(9gFmu0n4bPTV(b^I0xEkp5{TMN>*RzX`Kbx8{`YzXR+0+-H!UH@=Y4G zinPITO{#aWJae1g=fW{buBY?7onaQpVXgkPc(u4-bXRHC(b z9nP*ZQt3f+VYUtKtBkbk4&15wXq>;?Wu1H941$Fo%Dtg#$sX(f;om`6O0hT7gSEm8 zvMlw~_`XEe>ts}O(ci-=%0$~>xIJ6jb7Aykc3C_wzD~Zc!oxa?NLy5I{^l*e@SC2G z=GaT=B=dmXUzK0=$!2|>oqa}1b*av8v)GU0Ih%PjYFhVd=Xe)SU6)?On(KacRI$JOtYQI+m+cSgK%Moe#!q*j z3GWK|1iUik%o1wbr^XWLIb1jkTVbyd{wtyL=msmQZ2#Ey&%)H(>0>zUxOwUrT2?qo IxO(pRAN`z>Q2+n{ literal 0 HcmV?d00001 diff --git a/lib/Events/build/.gitignore b/lib/Events/build/.gitignore new file mode 100644 index 00000000..9c8716a0 --- /dev/null +++ b/lib/Events/build/.gitignore @@ -0,0 +1,2 @@ +/temp +/*.user diff --git a/EAPMethods/EAPMethodEvents/EAPMethodEvents.vcxproj.filters b/lib/Events/build/Events.filters similarity index 88% rename from EAPMethods/EAPMethodEvents/EAPMethodEvents.vcxproj.filters rename to lib/Events/build/Events.filters index 157e5825..9c555764 100644 --- a/EAPMethods/EAPMethodEvents/EAPMethodEvents.vcxproj.filters +++ b/lib/Events/build/Events.filters @@ -15,12 +15,12 @@ - + Resource Files - + Resource Files diff --git a/lib/Events/build/Events.props b/lib/Events/build/Events.props new file mode 100644 index 00000000..8c69f93e --- /dev/null +++ b/lib/Events/build/Events.props @@ -0,0 +1,16 @@ + + + + + + + + ..\..\..\output\$(Platform).$(Configuration)\ + + + + temp\Events.$(Platform).$(Configuration).$(PlatformToolset);%(AdditionalIncludeDirectories) + + + + \ No newline at end of file diff --git a/EAPMethods/EAPMethodEvents/EAPMethodEvents.rc b/lib/Events/build/Events.rc similarity index 97% rename from EAPMethods/EAPMethodEvents/EAPMethodEvents.rc rename to lib/Events/build/Events.rc index 47173b2e7cf5c138738bc35a1470630b99378be9..a1897889d22c0a67364618fb2a0b85448c7d5d67 100644 GIT binary patch delta 56 zcmaE-_Cjrg0Gq5ngB}pV$V`SjhGd2uhEj$UhExXq$+~RaoMk{(9zzL3@#f=f%Xt7| ChYcG5 delta 62 zcmaE%_D*es0Gn(KLkxo+5Q6AThCGI3h8%`ch7^WWkjP|Rwr+k$h5!a%AisnmgCU {D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B} Win32Proj - EAPMethodEvents + Events @@ -51,27 +51,27 @@ - - - + + + - - - + + + - - - + + + - - - + + + @@ -79,7 +79,7 @@ - + Document mc.exe "%(Identity)" -u -b -e "h" -h "$(IntDir)." -r "$(IntDir)." mc.exe "%(Identity)" -u -b -e "h" -h "$(IntDir)." -r "$(IntDir)." @@ -89,14 +89,14 @@ Compiling manifest... Compiling manifest... Compiling manifest... - $(IntDir)EAPMethodETW.h;$(IntDir)EAPMethodETW.rc;$(IntDir)EAPMethodETW_MSG00001.bin;$(IntDir)EAPMethodETWTEMP.BIN;%(Outputs) - $(IntDir)EAPMethodETW.h;$(IntDir)EAPMethodETW.rc;$(IntDir)EAPMethodETW_MSG00001.bin;$(IntDir)EAPMethodETWTEMP.BIN;%(Outputs) - $(IntDir)EAPMethodETW.h;$(IntDir)EAPMethodETW.rc;$(IntDir)EAPMethodETW_MSG00001.bin;$(IntDir)EAPMethodETWTEMP.BIN;%(Outputs) - $(IntDir)EAPMethodETW.h;$(IntDir)EAPMethodETW.rc;$(IntDir)EAPMethodETW_MSG00001.bin;$(IntDir)EAPMethodETWTEMP.BIN;%(Outputs) + $(IntDir)EventsETW.h;$(IntDir)EventsETW.rc;$(IntDir)EventsETW_MSG00001.bin;$(IntDir)EventsETWTEMP.BIN;%(Outputs) + $(IntDir)EventsETW.h;$(IntDir)EventsETW.rc;$(IntDir)EventsETW_MSG00001.bin;$(IntDir)EventsETWTEMP.BIN;%(Outputs) + $(IntDir)EventsETW.h;$(IntDir)EventsETW.rc;$(IntDir)EventsETW_MSG00001.bin;$(IntDir)EventsETWTEMP.BIN;%(Outputs) + $(IntDir)EventsETW.h;$(IntDir)EventsETW.rc;$(IntDir)EventsETW_MSG00001.bin;$(IntDir)EventsETWTEMP.BIN;%(Outputs) - + diff --git a/EAPMethods/res/EAPMethodETW.man b/lib/Events/res/EventsETW.man similarity index 98% rename from EAPMethods/res/EAPMethodETW.man rename to lib/Events/res/EventsETW.man index d12a0ae8502e18c6b48290be5bdff828bb898fe2..5565d5b2405e4cdabd8c4b87f176718d0ebdf2ee 100644 GIT binary patch delta 20 ccmez3b-`;x3G?JT%zBfzFpF)z!#qO~0A+&+%K!iX delta 56 vcmccM^~GyL2{XSVLjZ#>Ln=cFLk2@WL(1erW_K)NhLd%q#Ww$84p9UEyVMUK diff --git a/lib/PAP/build/.gitignore b/lib/PAP/build/.gitignore new file mode 100644 index 00000000..9c8716a0 --- /dev/null +++ b/lib/PAP/build/.gitignore @@ -0,0 +1,2 @@ +/temp +/*.user diff --git a/lib/PAP/build/PAP.props b/lib/PAP/build/PAP.props new file mode 100644 index 00000000..4997b714 --- /dev/null +++ b/lib/PAP/build/PAP.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/PAP/build/PAP.vcxproj b/lib/PAP/build/PAP.vcxproj new file mode 100644 index 00000000..32555400 --- /dev/null +++ b/lib/PAP/build/PAP.vcxproj @@ -0,0 +1,99 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {36B0CF8A-7794-46C3-8099-825BA962B4C7} + PAP + + + + 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/PAP/build/PAP.vcxproj.filters b/lib/PAP/build/PAP.vcxproj.filters new file mode 100644 index 00000000..3761eecc --- /dev/null +++ b/lib/PAP/build/PAP.vcxproj.filters @@ -0,0 +1,35 @@ + + + + + {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 + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/EAPMethods/include/PAP.h b/lib/PAP/include/Config.h similarity index 66% rename from EAPMethods/include/PAP.h rename to lib/PAP/include/Config.h index 81bb98e9..d0aee18c 100644 --- a/EAPMethods/include/PAP.h +++ b/lib/PAP/include/Config.h @@ -18,13 +18,14 @@ along with GÉANTLink. If not, see . */ -#include "EAP.h" - +#include namespace eap { + /// + /// PAP configuration + /// class config_pap; - class credentials_pap; } namespace eapserial @@ -36,12 +37,15 @@ namespace eapserial #pragma once +#include "../../EAPBase/include/Config.h" + +#include +#include +#include + namespace eap { - /// - /// PAP configuration - /// class config_pap : public config_pass { public: @@ -98,70 +102,6 @@ namespace eap /// virtual eap::type_t get_method_id() { return eap::type_pap; } }; - - - /// - /// PAP credentials - /// - class credentials_pap : public credentials_pass - { - public: - /// - /// Constructs credentials - /// - /// \param[in] mod Reference of the EAP module to use for global services - /// - credentials_pap(_In_ module &mod); - - /// - /// Copies credentials - /// - /// \param[in] other Credentials to copy from - /// - credentials_pap(_In_ const credentials_pap &other); - - /// - /// Moves credentials - /// - /// \param[in] other Credentials to move from - /// - credentials_pap(_Inout_ credentials_pap &&other); - - /// - /// Copies credentials - /// - /// \param[in] other Credentials to copy from - /// - /// \returns Reference to this object - /// - credentials_pap& operator=(_In_ const credentials_pap &other); - - /// - /// Moves credentials - /// - /// \param[in] other Credentials to move from - /// - /// \returns Reference to this object - /// - credentials_pap& operator=(_Inout_ credentials_pap &&other); - - /// - /// Clones credentials - /// - /// \returns Pointer to cloned credentials - /// - virtual config* clone() const { return new credentials_pap(*this); } - - /// \name Storage - /// @{ - - /// - /// Return target suffix for Windows Credential Manager credential name - /// - virtual LPCTSTR target_suffix() const { return _T("PAP"); } - - /// @} - }; } diff --git a/lib/PAP/include/Credentials.h b/lib/PAP/include/Credentials.h new file mode 100644 index 00000000..40402e8e --- /dev/null +++ b/lib/PAP/include/Credentials.h @@ -0,0 +1,102 @@ +/* + 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/include/EAP.h" + + +namespace eap +{ + /// + /// PAP credentials + /// + class credentials_pap; +} + +#pragma once + +#include "../../EAPBase/include/Credentials.h" + +#include +#include +#include + + +namespace eap +{ + class credentials_pap : public credentials_pass + { + public: + /// + /// Constructs credentials + /// + /// \param[in] mod Reference of the EAP module to use for global services + /// + credentials_pap(_In_ module &mod); + + /// + /// Copies credentials + /// + /// \param[in] other Credentials to copy from + /// + credentials_pap(_In_ const credentials_pap &other); + + /// + /// Moves credentials + /// + /// \param[in] other Credentials to move from + /// + credentials_pap(_Inout_ credentials_pap &&other); + + /// + /// Copies credentials + /// + /// \param[in] other Credentials to copy from + /// + /// \returns Reference to this object + /// + credentials_pap& operator=(_In_ const credentials_pap &other); + + /// + /// Moves credentials + /// + /// \param[in] other Credentials to move from + /// + /// \returns Reference to this object + /// + credentials_pap& operator=(_Inout_ credentials_pap &&other); + + /// + /// Clones credentials + /// + /// \returns Pointer to cloned credentials + /// + virtual config* clone() const { return new credentials_pap(*this); } + + /// \name Storage + /// @{ + + /// + /// Return target suffix for Windows Credential Manager credential name + /// + virtual LPCTSTR target_suffix() const { return _T("PAP"); } + + /// @} + }; +} diff --git a/lib/PAP/src/Config.cpp b/lib/PAP/src/Config.cpp new file mode 100644 index 00000000..4f6175a7 --- /dev/null +++ b/lib/PAP/src/Config.cpp @@ -0,0 +1,62 @@ +/* + 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::config_pap +////////////////////////////////////////////////////////////////////// + +eap::config_pap::config_pap(_In_ module &mod) : config_pass(mod) +{ +} + + +eap::config_pap::config_pap(_In_ const config_pap &other) : + config_pass(other) +{ +} + + +eap::config_pap::config_pap(_Inout_ config_pap &&other) : + config_pass(std::move(other)) +{ +} + + +eap::config_pap& eap::config_pap::operator=(_In_ const config_pap &other) +{ + if (this != &other) + (config_pass&)*this = other; + + return *this; +} + + +eap::config_pap& eap::config_pap::operator=(_Inout_ config_pap &&other) +{ + if (this != &other) + (config_pass&&)*this = std::move(other); + + return *this; +} + + diff --git a/lib/PAP/src/Credentials.cpp b/lib/PAP/src/Credentials.cpp new file mode 100644 index 00000000..ef1337b9 --- /dev/null +++ b/lib/PAP/src/Credentials.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_pap +////////////////////////////////////////////////////////////////////// + +eap::credentials_pap::credentials_pap(_In_ module &mod) : credentials_pass(mod) +{ +} + + +eap::credentials_pap::credentials_pap(_In_ const credentials_pap &other) : + credentials_pass(other) +{ +} + + +eap::credentials_pap::credentials_pap(_Inout_ credentials_pap &&other) : + credentials_pass(std::move(other)) +{ +} + + +eap::credentials_pap& eap::credentials_pap::operator=(_In_ const credentials_pap &other) +{ + if (this != &other) + (credentials_pass&)*this = other; + + return *this; +} + + +eap::credentials_pap& eap::credentials_pap::operator=(_Inout_ credentials_pap &&other) +{ + if (this != &other) + (credentials_pass&&)*this = std::move(other); + + return *this; +} diff --git a/EAPMethods/src/PAP.cpp b/lib/PAP/src/PAP.cpp similarity index 64% rename from EAPMethods/src/PAP.cpp rename to lib/PAP/src/PAP.cpp index c4006aca..ef1337b9 100644 --- a/EAPMethods/src/PAP.cpp +++ b/lib/PAP/src/PAP.cpp @@ -18,46 +18,7 @@ along with GÉANTLink. If not, see . */ -#include - - -////////////////////////////////////////////////////////////////////// -// eap::config_pap -////////////////////////////////////////////////////////////////////// - -eap::config_pap::config_pap(_In_ module &mod) : config_pass(mod) -{ -} - - -eap::config_pap::config_pap(_In_ const config_pap &other) : - config_pass(other) -{ -} - - -eap::config_pap::config_pap(_Inout_ config_pap &&other) : - config_pass(std::move(other)) -{ -} - - -eap::config_pap& eap::config_pap::operator=(_In_ const config_pap &other) -{ - if (this != &other) - (config_pass&)*this = other; - - return *this; -} - - -eap::config_pap& eap::config_pap::operator=(_Inout_ config_pap &&other) -{ - if (this != &other) - (config_pass&&)*this = std::move(other); - - return *this; -} +#include "StdAfx.h" ////////////////////////////////////////////////////////////////////// diff --git a/lib/PAP/src/StdAfx.cpp b/lib/PAP/src/StdAfx.cpp new file mode 100644 index 00000000..4af5ec17 --- /dev/null +++ b/lib/PAP/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/PAP/src/StdAfx.h b/lib/PAP/src/StdAfx.h new file mode 100644 index 00000000..65b8ccf3 --- /dev/null +++ b/lib/PAP/src/StdAfx.h @@ -0,0 +1,24 @@ +/* + 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" diff --git a/lib/PAP_UI/build/.gitignore b/lib/PAP_UI/build/.gitignore new file mode 100644 index 00000000..9c8716a0 --- /dev/null +++ b/lib/PAP_UI/build/.gitignore @@ -0,0 +1,2 @@ +/temp +/*.user diff --git a/lib/PAP_UI/build/PAP_UI.props b/lib/PAP_UI/build/PAP_UI.props new file mode 100644 index 00000000..4997b714 --- /dev/null +++ b/lib/PAP_UI/build/PAP_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/PAP_UI/build/PAP_UI.vcxproj b/lib/PAP_UI/build/PAP_UI.vcxproj new file mode 100644 index 00000000..9f128e9b --- /dev/null +++ b/lib/PAP_UI/build/PAP_UI.vcxproj @@ -0,0 +1,102 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {3D309C2E-64AB-4BC4-A16D-468571A2BC1A} + PAP_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/PAP_UI/build/PAP_UI.vcxproj.filters b/lib/PAP_UI/build/PAP_UI.vcxproj.filters new file mode 100644 index 00000000..9b71eac7 --- /dev/null +++ b/lib/PAP_UI/build/PAP_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/EAPMethods/include/PAP_UI.h b/lib/PAP_UI/include/PAP_UI.h similarity index 83% rename from EAPMethods/include/PAP_UI.h rename to lib/PAP_UI/include/PAP_UI.h index 524f9e25..87131366 100644 --- a/EAPMethods/include/PAP_UI.h +++ b/lib/PAP_UI/include/PAP_UI.h @@ -18,17 +18,28 @@ along with GÉANTLink. If not, see . */ -#include "PAP.h" +#include "../../EAPBase_UI/include/EAP_UI.h" +#include "../../PAP/include/Config.h" +#include "../../PAP/include/Credentials.h" +/// +/// PAP credentials configuration panel +/// typedef wxEAPCredentialsConfigPanel wxPAPCredentialsConfigPanel; + +/// +/// PAP configuration panel +/// class wxPAPConfigPanel; #pragma once +#include +#include + +#include + -/// -/// PAP configuration panel -/// class wxPAPConfigPanel : public wxPanel { public: diff --git a/EAPMethods/src/PAP_UI.cpp b/lib/PAP_UI/src/PAP_UI.cpp similarity index 96% rename from EAPMethods/src/PAP_UI.cpp rename to lib/PAP_UI/src/PAP_UI.cpp index 5b1b900b..2f315fad 100644 --- a/EAPMethods/src/PAP_UI.cpp +++ b/lib/PAP_UI/src/PAP_UI.cpp @@ -18,7 +18,7 @@ along with GÉANTLink. If not, see . */ -#include +#include "StdAfx.h" ////////////////////////////////////////////////////////////////////// diff --git a/lib/PAP_UI/src/StdAfx.cpp b/lib/PAP_UI/src/StdAfx.cpp new file mode 100644 index 00000000..4af5ec17 --- /dev/null +++ b/lib/PAP_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/PAP_UI/src/StdAfx.h b/lib/PAP_UI/src/StdAfx.h new file mode 100644 index 00000000..21911e6c --- /dev/null +++ b/lib/PAP_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/PAP_UI.h" diff --git a/lib/TLS/build/.gitignore b/lib/TLS/build/.gitignore new file mode 100644 index 00000000..9c8716a0 --- /dev/null +++ b/lib/TLS/build/.gitignore @@ -0,0 +1,2 @@ +/temp +/*.user diff --git a/lib/TLS/build/TLS.props b/lib/TLS/build/TLS.props new file mode 100644 index 00000000..4997b714 --- /dev/null +++ b/lib/TLS/build/TLS.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/TLS/build/TLS.vcxproj b/lib/TLS/build/TLS.vcxproj new file mode 100644 index 00000000..15f4e4c3 --- /dev/null +++ b/lib/TLS/build/TLS.vcxproj @@ -0,0 +1,99 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {4D40CB8A-812E-4F12-B23A-31AF743878E8} + TLS + + + + 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/TLS/build/TLS.vcxproj.filters b/lib/TLS/build/TLS.vcxproj.filters new file mode 100644 index 00000000..3761eecc --- /dev/null +++ b/lib/TLS/build/TLS.vcxproj.filters @@ -0,0 +1,35 @@ + + + + + {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 + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/lib/TLS/include/Config.h b/lib/TLS/include/Config.h new file mode 100644 index 00000000..35192246 --- /dev/null +++ b/lib/TLS/include/Config.h @@ -0,0 +1,198 @@ +/* + 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 +{ + /// + /// TLS configuration + /// + class config_tls; +} + +namespace eapserial +{ + /// + /// Packs a TLS method configuration + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val Configuration to pack + /// + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_tls &val); + + /// + /// Returns packed size of a TLS method configuration + /// + /// \param[in] val Configuration to pack + /// + /// \returns Size of data when packed (in bytes) + /// + inline size_t get_pk_size(const eap::config_tls &val); + + /// + /// Unpacks a TLS method configuration + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val Configuration to unpack to + /// + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_tls &val); +} + +#pragma once + +#include "../../EAPBase/include/Config.h" + +#include + +#include + +#include +#include + + +namespace eap +{ + class config_tls : public config_method + { + public: + /// + /// Constructs configuration + /// + /// \param[in] mod Reference of the EAP module to use for global services + /// + config_tls(_In_ module &mod); + + /// + /// Copies configuration + /// + /// \param[in] other Configuration to copy from + /// + config_tls(_In_ const config_tls &other); + + /// + /// Moves configuration + /// + /// \param[in] other Configuration to move from + /// + config_tls(_Inout_ config_tls &&other); + + /// + /// Copies configuration + /// + /// \param[in] other Configuration to copy from + /// + /// \returns Reference to this object + /// + config_tls& operator=(_In_ const config_tls &other); + + /// + /// Moves configuration + /// + /// \param[in] other Configuration to move from + /// + /// \returns Reference to this object + /// + config_tls& operator=(_Inout_ config_tls &&other); + + /// + /// Clones configuration + /// + /// \returns Pointer to cloned configuration + /// + virtual config* clone() const { return new config_tls(*this); } + + /// \name XML configuration management + /// @{ + + /// + /// Save configuration to XML document + /// + /// \param[in] pDoc XML document + /// \param[in] pConfigRoot Suggested root element for saving configuration + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const; + + /// + /// Load configuration from XML document + /// + /// \param[in] pConfigRoot Root element for loading configuration + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError); + + /// @} + + /// + /// Returns EAP method type of this configuration + /// + /// \returns `eap::type_tls` + /// + virtual eap::type_t get_method_id() { return eap::type_tls; } + + /// + /// Adds CA to the list of trusted root CA's + /// + /// \sa [CertCreateCertificateContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376033.aspx) + /// + bool add_trusted_ca(_In_ DWORD dwCertEncodingType, _In_ const BYTE *pbCertEncoded, _In_ DWORD cbCertEncoded); + + public: + std::list m_trusted_root_ca; ///< Trusted root CAs + std::list m_server_names; ///< Acceptable authenticating server names + }; +} + + +namespace eapserial +{ + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_tls &val) + { + pack(cursor, (const eap::config_method&)val); + pack(cursor, val.m_trusted_root_ca ); + pack(cursor, val.m_server_names ); + } + + + inline size_t get_pk_size(const eap::config_tls &val) + { + return + get_pk_size((const eap::config_method&)val) + + get_pk_size(val.m_trusted_root_ca ) + + get_pk_size(val.m_server_names ); + } + + + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_tls &val) + { + unpack(cursor, (eap::config_method&)val ); + unpack(cursor, val.m_trusted_root_ca); + unpack(cursor, val.m_server_names ); + } +} diff --git a/lib/TLS/include/Credentials.h b/lib/TLS/include/Credentials.h new file mode 100644 index 00000000..2fe35d16 --- /dev/null +++ b/lib/TLS/include/Credentials.h @@ -0,0 +1,207 @@ +/* + 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 +{ + /// + /// TLS credentials + /// + class credentials_tls; +} + +namespace eapserial +{ + /// + /// Packs a TLS method credentials + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val Credentials to pack + /// + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_tls &val); + + /// + /// Returns packed size of a TLS method credentials + /// + /// \param[in] val Credentials to pack + /// + /// \returns Size of data when packed (in bytes) + /// + inline size_t get_pk_size(const eap::credentials_tls &val); + + /// + /// Unpacks a TLS method credentials + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val Credentials to unpack to + /// + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_tls &val); +} + +#pragma once + +#include "../../EAPBase/include/Credentials.h" + +#include +#include + + +namespace eap +{ + class credentials_tls : public credentials + { + public: + /// + /// Constructs credentials + /// + /// \param[in] mod Reference of the EAP module to use for global services + /// + credentials_tls(_In_ module &mod); + + /// + /// Copies credentials + /// + /// \param[in] other Credentials to copy from + /// + credentials_tls(_In_ const credentials_tls &other); + + /// + /// Moves credentials + /// + /// \param[in] other Credentials to move from + /// + credentials_tls(_Inout_ credentials_tls &&other); + + /// + /// Copies credentials + /// + /// \param[in] other Credentials to copy from + /// + /// \returns Reference to this object + /// + credentials_tls& operator=(_In_ const credentials_tls &other); + + /// + /// Moves credentials + /// + /// \param[in] other Credentials to move from + /// + /// \returns Reference to this object + /// + credentials_tls& operator=(_Inout_ credentials_tls &&other); + + /// + /// Clones credentials + /// + /// \returns Pointer to cloned credentials + /// + virtual config* clone() const { return new credentials_tls(*this); } + + /// + /// Resets credentials + /// + virtual void clear(); + + /// + /// Test credentials if blank + /// + virtual bool empty() const; + + /// \name XML credentials management + /// @{ + + /// + /// Load credentials from XML document + /// + /// \param[in] pConfigRoot Root element for loading credentials + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError); + + /// @} + + /// \name Storage + /// @{ + + /// + /// Save credentials to Windows Credential Manager + /// + /// \param[in] pszTargetName The name in Windows Credential Manager to store credentials as + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const; + + /// + /// Retrieve credentials from Windows Credential Manager + /// + /// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError); + + /// + /// Return target suffix for Windows Credential Manager credential name + /// + virtual LPCTSTR target_suffix() const { return _T("TLS"); } + + /// @} + + public: + std::vector m_cert_hash; ///< Client certificate hash (certificates are kept in Personal Certificate Storage) + }; +} + + +namespace eapserial +{ + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_tls &val) + { + pack(cursor, (const eap::credentials&)val); + pack(cursor, val.m_cert_hash ); + } + + + inline size_t get_pk_size(const eap::credentials_tls &val) + { + return + get_pk_size((const eap::credentials&)val) + + get_pk_size(val.m_cert_hash ); + } + + + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_tls &val) + { + unpack(cursor, (eap::credentials&)val); + unpack(cursor, val.m_cert_hash ); + } +} diff --git a/EAPMethods/src/TLS.cpp b/lib/TLS/src/Config.cpp similarity index 66% rename from EAPMethods/src/TLS.cpp rename to lib/TLS/src/Config.cpp index da4f3759..cae31d09 100644 --- a/EAPMethods/src/TLS.cpp +++ b/lib/TLS/src/Config.cpp @@ -18,7 +18,7 @@ along with GÉANTLink. If not, see . */ -#include +#include "StdAfx.h" using namespace std; using namespace winstd; @@ -199,131 +199,3 @@ bool eap::config_tls::add_trusted_ca(_In_ DWORD dwCertEncodingType, _In_ const } } } - - -////////////////////////////////////////////////////////////////////// -// eap::credentials_tls -////////////////////////////////////////////////////////////////////// - -eap::credentials_tls::credentials_tls(_In_ module &mod) : credentials(mod) -{ -} - - -eap::credentials_tls::credentials_tls(_In_ const credentials_tls &other) : - m_cert_hash(other.m_cert_hash), - credentials(other) -{ -} - - -eap::credentials_tls::credentials_tls(_Inout_ credentials_tls &&other) : - m_cert_hash(std::move(m_cert_hash)), - credentials(std::move(other)) -{ -} - - -eap::credentials_tls& eap::credentials_tls::operator=(_In_ const credentials_tls &other) -{ - if (this != &other) { - (credentials&)*this = other; - m_cert_hash = other.m_cert_hash; - } - - return *this; -} - - -eap::credentials_tls& eap::credentials_tls::operator=(_Inout_ credentials_tls &&other) -{ - if (this != &other) { - (credentials&)*this = std::move(other); - m_cert_hash = std::move(other.m_cert_hash); - } - - return *this; -} - - - -void eap::credentials_tls::clear() -{ - credentials::clear(); - m_cert_hash.clear(); -} - - -bool eap::credentials_tls::empty() const -{ - return credentials::empty() && m_cert_hash.empty(); -} - - - -DWORD eap::credentials_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) -{ - assert(pConfigRoot); - UNREFERENCED_PARAMETER(ppEapError); - - eapxml::get_element_hex(pConfigRoot, bstr(L"CertHash"), m_cert_hash); - - return ERROR_SUCCESS; -} - - -DWORD eap::credentials_tls::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const -{ - assert(pszTargetName); - assert(ppEapError); - DWORD dwResult; - - tstring target(target_name(pszTargetName)); - - // Write credentials. - assert(m_cert_hash.size()*sizeof(char) < CRED_MAX_CREDENTIAL_BLOB_SIZE); - assert(m_identity.length() < CRED_MAX_USERNAME_LENGTH ); - CREDENTIAL cred = { - 0, // Flags - CRED_TYPE_GENERIC, // Type - (LPTSTR)target.c_str(), // TargetName - _T(""), // Comment - { 0, 0 }, // LastWritten - (DWORD)m_cert_hash.size()*sizeof(char), // CredentialBlobSize - (LPBYTE)m_cert_hash.data(), // CredentialBlob - CRED_PERSIST_ENTERPRISE, // Persist - 0, // AttributeCount - NULL, // Attributes - NULL, // TargetAlias - (LPTSTR)m_identity.c_str() // UserName - }; - if (!CredWrite(&cred, 0)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredWrite failed."), NULL); - return dwResult; - } - - return ERROR_SUCCESS; -} - - -DWORD eap::credentials_tls::retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) -{ - assert(pszTargetName && _tcslen(pszTargetName) < CRED_MAX_GENERIC_TARGET_NAME_LENGTH); - DWORD dwResult; - - // Read credentials. - unique_ptr > cred; - if (!CredRead(target_name(pszTargetName).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) { - *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredRead failed."), NULL); - return dwResult; - } - - if (cred->UserName) - m_identity = cred->UserName; - else - m_identity.clear(); - - m_cert_hash.assign(cred->CredentialBlob, cred->CredentialBlob + cred->CredentialBlobSize); - - return ERROR_SUCCESS; -} diff --git a/lib/TLS/src/Credentials.cpp b/lib/TLS/src/Credentials.cpp new file mode 100644 index 00000000..1c627c84 --- /dev/null +++ b/lib/TLS/src/Credentials.cpp @@ -0,0 +1,152 @@ +/* + 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_tls +////////////////////////////////////////////////////////////////////// + +eap::credentials_tls::credentials_tls(_In_ module &mod) : credentials(mod) +{ +} + + +eap::credentials_tls::credentials_tls(_In_ const credentials_tls &other) : + m_cert_hash(other.m_cert_hash), + credentials(other) +{ +} + + +eap::credentials_tls::credentials_tls(_Inout_ credentials_tls &&other) : + m_cert_hash(std::move(m_cert_hash)), + credentials(std::move(other)) +{ +} + + +eap::credentials_tls& eap::credentials_tls::operator=(_In_ const credentials_tls &other) +{ + if (this != &other) { + (credentials&)*this = other; + m_cert_hash = other.m_cert_hash; + } + + return *this; +} + + +eap::credentials_tls& eap::credentials_tls::operator=(_Inout_ credentials_tls &&other) +{ + if (this != &other) { + (credentials&)*this = std::move(other); + m_cert_hash = std::move(other.m_cert_hash); + } + + return *this; +} + + + +void eap::credentials_tls::clear() +{ + credentials::clear(); + m_cert_hash.clear(); +} + + +bool eap::credentials_tls::empty() const +{ + return credentials::empty() && m_cert_hash.empty(); +} + + + +DWORD eap::credentials_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) +{ + assert(pConfigRoot); + UNREFERENCED_PARAMETER(ppEapError); + + eapxml::get_element_hex(pConfigRoot, bstr(L"CertHash"), m_cert_hash); + + return ERROR_SUCCESS; +} + + +DWORD eap::credentials_tls::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const +{ + assert(pszTargetName); + assert(ppEapError); + DWORD dwResult; + + tstring target(target_name(pszTargetName)); + + // Write credentials. + assert(m_cert_hash.size()*sizeof(char) < CRED_MAX_CREDENTIAL_BLOB_SIZE); + assert(m_identity.length() < CRED_MAX_USERNAME_LENGTH ); + CREDENTIAL cred = { + 0, // Flags + CRED_TYPE_GENERIC, // Type + (LPTSTR)target.c_str(), // TargetName + _T(""), // Comment + { 0, 0 }, // LastWritten + (DWORD)m_cert_hash.size()*sizeof(char), // CredentialBlobSize + (LPBYTE)m_cert_hash.data(), // CredentialBlob + CRED_PERSIST_ENTERPRISE, // Persist + 0, // AttributeCount + NULL, // Attributes + NULL, // TargetAlias + (LPTSTR)m_identity.c_str() // UserName + }; + if (!CredWrite(&cred, 0)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredWrite failed."), NULL); + return dwResult; + } + + return ERROR_SUCCESS; +} + + +DWORD eap::credentials_tls::retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) +{ + assert(pszTargetName && _tcslen(pszTargetName) < CRED_MAX_GENERIC_TARGET_NAME_LENGTH); + DWORD dwResult; + + // Read credentials. + unique_ptr > cred; + if (!CredRead(target_name(pszTargetName).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) { + *ppEapError = m_module.make_error(dwResult = GetLastError(), 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" CredRead failed."), NULL); + return dwResult; + } + + if (cred->UserName) + m_identity = cred->UserName; + else + m_identity.clear(); + + m_cert_hash.assign(cred->CredentialBlob, cred->CredentialBlob + cred->CredentialBlobSize); + + return ERROR_SUCCESS; +} diff --git a/lib/TLS/src/StdAfx.cpp b/lib/TLS/src/StdAfx.cpp new file mode 100644 index 00000000..4af5ec17 --- /dev/null +++ b/lib/TLS/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/TLS/src/StdAfx.h b/lib/TLS/src/StdAfx.h new file mode 100644 index 00000000..81cf762c --- /dev/null +++ b/lib/TLS/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 "../../EAPBase/include/EAPXML.h" + +#include diff --git a/lib/TLS_UI/build/.gitignore b/lib/TLS_UI/build/.gitignore new file mode 100644 index 00000000..9c8716a0 --- /dev/null +++ b/lib/TLS_UI/build/.gitignore @@ -0,0 +1,2 @@ +/temp +/*.user diff --git a/lib/TLS_UI/build/TLS_UI.props b/lib/TLS_UI/build/TLS_UI.props new file mode 100644 index 00000000..4997b714 --- /dev/null +++ b/lib/TLS_UI/build/TLS_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/TLS_UI/build/TLS_UI.vcxproj b/lib/TLS_UI/build/TLS_UI.vcxproj new file mode 100644 index 00000000..75501a77 --- /dev/null +++ b/lib/TLS_UI/build/TLS_UI.vcxproj @@ -0,0 +1,107 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {9A25C261-8ADE-4938-8393-E857EF0E37E9} + TLS_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/TLS_UI/build/TLS_UI.vcxproj.filters b/lib/TLS_UI/build/TLS_UI.vcxproj.filters new file mode 100644 index 00000000..3b783f02 --- /dev/null +++ b/lib/TLS_UI/build/TLS_UI.vcxproj.filters @@ -0,0 +1,44 @@ + + + + + {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 + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/EAPMethods/include/TLS_UI.h b/lib/TLS_UI/include/TLS_UI.h similarity index 90% rename from EAPMethods/include/TLS_UI.h rename to lib/TLS_UI/include/TLS_UI.h index bfb7301b..8407018f 100644 --- a/EAPMethods/include/TLS_UI.h +++ b/lib/TLS_UI/include/TLS_UI.h @@ -18,36 +18,86 @@ along with GÉANTLink. If not, see . */ -#include "TLS.h" -#include "../res/wxTLS_UI.h" +#include "../../EAPBase_UI/include/EAP_UI.h" +#include "../../TLS/include/Config.h" +#include "../../TLS/include/Credentials.h" -#include -#include +#include + +#include +#include // Must include after -#include +/// +/// Helper class for auto-destroyable certificates used in wxWidget's item containers +/// class wxCertificateClientData; + +/// +/// Helper class for auto-destroyable certificates used in wxWidget's item containers +/// class wxCertificateSelectionClientData; + +/// +/// Validator for host name +/// class wxHostNameValidator; + +/// +/// Validator for FQDN +/// class wxFQDNValidator; + +/// +/// Validator for FQDN lists +/// class wxFQDNListValidator; +/// +/// EAPTLS credential panel +/// class wxEAPTLSCredentialsPanel; + +/// +/// EAPTLS server trust configuration panel +/// class wxEAPTLSServerTrustPanel; + +/// +/// TLS credentials configuration panel +/// typedef wxEAPCredentialsConfigPanel wxEAPTLSCredentialsConfigPanel; + +/// +/// EAPTLS configuration panel +/// class wxEAPTLSConfigPanel; namespace eap { + /// + /// Helper function to compile human-readable certificate name for UI display + /// void get_cert_title(PCCERT_CONTEXT cert, winstd::tstring &title); } #pragma once +#include "../res/wxTLS_UI.h" + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + -/// -/// Helper class for auto-destroyable certificates used in wxWidget's item containers -/// class wxCertificateClientData : public wxClientData { public: @@ -66,9 +116,6 @@ class wxCertificateClientData : public wxClientData }; -/// -/// Helper class for auto-destroyable certificates used in wxWidget's item containers -/// class wxCertificateSelectionClientData : public wxClientData { public: @@ -108,9 +155,6 @@ class wxCertificateSelectionClientData : public wxClientData }; -/// -/// Validator for host name -/// class wxHostNameValidator : public wxValidator { wxDECLARE_DYNAMIC_CLASS(wxHostNameValidator); @@ -157,9 +201,6 @@ class wxHostNameValidator : public wxValidator }; -/// -/// Validator for FQDN -/// class wxFQDNValidator : public wxValidator { wxDECLARE_DYNAMIC_CLASS(wxFQDNValidator); @@ -206,9 +247,6 @@ class wxFQDNValidator : public wxValidator }; -/// -/// Validator for FQDN lists -/// class wxFQDNListValidator : public wxValidator { wxDECLARE_DYNAMIC_CLASS(wxFQDNListValidator); @@ -255,9 +293,6 @@ class wxFQDNListValidator : public wxValidator }; -/// -/// EAPTLS credential panel -/// class wxEAPTLSCredentialsPanel : public wxCredentialsPanel { public: @@ -279,9 +314,6 @@ class wxEAPTLSCredentialsPanel : public wxCredentialsPanel. +*/ + +#include "StdAfx.h" diff --git a/lib/TLS_UI/src/StdAfx.h b/lib/TLS_UI/src/StdAfx.h new file mode 100644 index 00000000..28e370bb --- /dev/null +++ b/lib/TLS_UI/src/StdAfx.h @@ -0,0 +1,32 @@ +/* + 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/Version.h" + +#include "../include/TLS_UI.h" + +#include +#include + +#include diff --git a/EAPMethods/src/TLS_UI.cpp b/lib/TLS_UI/src/TLS_UI.cpp similarity index 96% rename from EAPMethods/src/TLS_UI.cpp rename to lib/TLS_UI/src/TLS_UI.cpp index 64aecb00..05061e7f 100644 --- a/EAPMethods/src/TLS_UI.cpp +++ b/lib/TLS_UI/src/TLS_UI.cpp @@ -18,9 +18,10 @@ along with GÉANTLink. If not, see . */ -#include +#include "StdAfx.h" #pragma comment(lib, "Cryptui.lib") +#pragma comment(lib, "Crypt32.lib") ////////////////////////////////////////////////////////////////////// diff --git a/lib/TTLS/build/.gitignore b/lib/TTLS/build/.gitignore new file mode 100644 index 00000000..9c8716a0 --- /dev/null +++ b/lib/TTLS/build/.gitignore @@ -0,0 +1,2 @@ +/temp +/*.user diff --git a/lib/TTLS/build/TTLS.props b/lib/TTLS/build/TTLS.props new file mode 100644 index 00000000..4997b714 --- /dev/null +++ b/lib/TTLS/build/TTLS.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/TTLS/build/TTLS.vcxproj b/lib/TTLS/build/TTLS.vcxproj new file mode 100644 index 00000000..04f57600 --- /dev/null +++ b/lib/TTLS/build/TTLS.vcxproj @@ -0,0 +1,108 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {EE0EF0D9-A475-4038-8637-5754724F65B0} + TTLS + + + + 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/TTLS/build/TTLS.vcxproj.filters b/lib/TTLS/build/TTLS.vcxproj.filters new file mode 100644 index 00000000..e8c5b2dc --- /dev/null +++ b/lib/TTLS/build/TTLS.vcxproj.filters @@ -0,0 +1,47 @@ + + + + + {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 + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/lib/TTLS/include/Config.h b/lib/TTLS/include/Config.h new file mode 100644 index 00000000..5b1dd802 --- /dev/null +++ b/lib/TTLS/include/Config.h @@ -0,0 +1,216 @@ +/* + 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 +{ + /// + /// TTLS configuration + /// + class config_ttls; +} + +namespace eapserial +{ + /// + /// Packs a TTLS based method configuration + /// + /// \param[inout] cursor Memory cursor + /// \param[in] val Configuration to pack + /// + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_ttls &val); + + /// + /// Returns packed size of a TTLS based method configuration + /// + /// \param[in] val Configuration to pack + /// + /// \returns Size of data when packed (in bytes) + /// + inline size_t get_pk_size(const eap::config_ttls &val); + + /// + /// Unpacks a TTLS based method configuration + /// + /// \param[inout] cursor Memory cursor + /// \param[out] val Configuration to unpack to + /// + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_ttls &val); +} + +#pragma once + +#include "../../TLS/include/Config.h" +#include "../../PAP/include/Config.h" + +#include +#include + + +namespace eap { + class config_ttls : public config_tls + { + public: + /// + /// Constructs configuration + /// + /// \param[in] mod Reference of the EAP module to use for global services + /// + config_ttls(_In_ module &mod); + + /// + /// Copies configuration + /// + /// \param[in] other Configuration to copy from + /// + config_ttls(const _In_ config_ttls &other); + + /// + /// Moves configuration + /// + /// \param[in] other Configuration to move from + /// + config_ttls(_Inout_ config_ttls &&other); + + /// + /// Destructs configuration + /// + virtual ~config_ttls(); + + /// + /// Copies configuration + /// + /// \param[in] other Configuration to copy from + /// + /// \returns Reference to this object + /// + config_ttls& operator=(const _In_ config_ttls &other); + + /// + /// Moves configuration + /// + /// \param[in] other Configuration to move from + /// + /// \returns Reference to this object + /// + config_ttls& operator=(_Inout_ config_ttls &&other); + + /// + /// Clones configuration + /// + /// \returns Pointer to cloned configuration + /// + virtual config* clone() const { return new config_ttls(*this); } + + /// \name XML configuration management + /// @{ + + /// + /// Save configuration to XML document + /// + /// \param[in] pDoc XML document + /// \param[in] pConfigRoot Suggested root element for saving configuration + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const; + + /// + /// Load configuration from XML document + /// + /// \param[in] pConfigRoot Root element for loading configuration + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError); + + /// @} + + /// + /// Returns EAP method type of this configuration + /// + /// \returns `eap::type_ttls` + /// + virtual eap::type_t get_method_id() { return eap::type_ttls; } + + public: + config_method *m_inner; ///< Inner authentication configuration + }; +} + + +namespace eapserial +{ + inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_ttls &val) + { + pack(cursor, (const eap::config_tls&)val); + if (val.m_inner) { + if (dynamic_cast(val.m_inner)) { + pack(cursor, (unsigned char)eap::type_pap); + pack(cursor, (const eap::config_pap&)*val.m_inner); + } else { + assert(0); // Unsupported inner authentication method type. + pack(cursor, (unsigned char)0); + } + } else + pack(cursor, (unsigned char)0); + } + + + inline size_t get_pk_size(const eap::config_ttls &val) + { + size_t size_inner = sizeof(unsigned char); + if (val.m_inner) { + if (dynamic_cast(val.m_inner)) + size_inner += get_pk_size((const eap::config_pap&)*val.m_inner); + else + assert(0); // Unsupported inner authentication method type. + } + + return + get_pk_size((const eap::config_tls&)val) + + size_inner; + } + + + inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_ttls &val) + { + unpack(cursor, (eap::config_tls&)val); + + assert(!val.m_inner); + unsigned char eap_type; + unpack(cursor, eap_type); + switch (eap_type) { + case eap::type_pap: + val.m_inner = new eap::config_pap(val.m_module); + unpack(cursor, (eap::config_pap&)*val.m_inner); + break; + case 0 : break; + default : assert(0); // Unsupported inner authentication method type. + } + } +} diff --git a/lib/TTLS/include/Credentials.h b/lib/TTLS/include/Credentials.h new file mode 100644 index 00000000..876fd56f --- /dev/null +++ b/lib/TTLS/include/Credentials.h @@ -0,0 +1,144 @@ +/* + 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 +{ + /// + /// TTLS credentials + /// + class credentials_ttls; +} + +#pragma once + +#include "../../TLS/include/Credentials.h" + + +namespace eap +{ + class credentials_ttls : public credentials_tls + { + public: + /// + /// Constructs credentials + /// + /// \param[in] mod Reference of the EAP module to use for global services + /// + credentials_ttls(_In_ module &mod); + + /// + /// Copies credentials + /// + /// \param[in] other Credentials to copy from + /// + credentials_ttls(_In_ const credentials_ttls &other); + + /// + /// Moves credentials + /// + /// \param[in] other Credentials to move from + /// + credentials_ttls(_Inout_ credentials_ttls &&other); + + /// + /// Copies credentials + /// + /// \param[in] other Credentials to copy from + /// + /// \returns Reference to this object + /// + credentials_ttls& operator=(_In_ const credentials_ttls &other); + + /// + /// Moves credentials + /// + /// \param[in] other Credentials to move from + /// + /// \returns Reference to this object + /// + credentials_ttls& operator=(_Inout_ credentials_ttls &&other); + + /// + /// Clones credentials + /// + /// \returns Pointer to cloned credentials + /// + virtual config* clone() const { return new credentials_ttls(*this); } + + /// + /// Resets credentials + /// + virtual void clear(); + + /// + /// Test credentials if blank + /// + virtual bool empty() const; + + /// \name XML credentials management + /// @{ + + /// + /// Load credentials from XML document + /// + /// \param[in] pConfigRoot Root element for loading credentials + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError); + + /// @} + + /// \name Storage + /// @{ + + /// + /// Save credentials to Windows Credential Manager + /// + /// \param[in] pszTargetName The name in Windows Credential Manager to store credentials as + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const; + + /// + /// Retrieve credentials from Windows Credential Manager + /// + /// \param[in] pszTargetName The name in Windows Credential Manager to retrieve credentials from + /// \param[out] ppEapError Pointer to error descriptor in case of failure. Free using `module::free_error_memory()`. + /// + /// \returns + /// - \c ERROR_SUCCESS if succeeded + /// - error code otherwise + /// + virtual DWORD retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError); + + /// @} + + public: + credentials *m_inner; ///< Inner credentials + }; +} diff --git a/lib/TTLS/include/Module.h b/lib/TTLS/include/Module.h new file mode 100644 index 00000000..2c66f9f1 --- /dev/null +++ b/lib/TTLS/include/Module.h @@ -0,0 +1,94 @@ +/* + 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 +{ + /// + /// TTLS peer + /// + class peer_ttls; +} + +#pragma once + +#include "Config.h" +#include "Credentials.h" +#include "../../EAPBase/include/Module.h" + + +namespace eap +{ + class peer_ttls : public peer + { + public: + /// + /// Constructs a EAP TTLS peer module + /// + peer_ttls(); + + /// + /// Initializes an EAP peer method for EAPHost. + /// + /// \sa [EapPeerGetInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363613.aspx) + /// + virtual DWORD initialize(_Out_ EAP_ERROR **ppEapError); + + /// + /// Shuts down the EAP method and prepares to unload its corresponding DLL. + /// + /// \sa [EapPeerShutdown function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363627.aspx) + /// + virtual DWORD shutdown(_Out_ EAP_ERROR **ppEapError); + + /// + /// Returns the user data and user identity after being called by EAPHost. + /// + /// \sa [EapPeerGetIdentity function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363607.aspx) + /// + virtual DWORD get_identity( + _In_ DWORD dwFlags, + _In_ DWORD dwConnectionDataSize, + _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, + _In_ DWORD dwUserDataSize, + _In_count_(dwUserDataSize) const BYTE *pUserData, + _In_ HANDLE hTokenImpersonateUser, + _Out_ BOOL *pfInvokeUI, + _Out_ DWORD *pdwUserDataOutSize, + _Out_ BYTE **ppUserDataOut, + _Out_ WCHAR **ppwszIdentity, + _Out_ EAP_ERROR **ppEapError); + + /// + /// Defines the implementation of an EAP method-specific function that retrieves the properties of an EAP method given the connection and user data. + /// + /// \sa [EapPeerGetMethodProperties function](https://msdn.microsoft.com/en-us/library/windows/desktop/hh706636.aspx) + /// + virtual DWORD get_method_properties( + _In_ DWORD dwVersion, + _In_ DWORD dwFlags, + _In_ HANDLE hUserImpersonationToken, + _In_ DWORD dwEapConnDataSize, + _In_count_(dwEapConnDataSize) const BYTE *pEapConnData, + _In_ DWORD dwUserDataSize, + _In_count_(dwUserDataSize) const BYTE *pUserData, + _Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray, + _Out_ EAP_ERROR **ppEapError) const; + }; +} diff --git a/lib/TTLS/include/Session.h b/lib/TTLS/include/Session.h new file mode 100644 index 00000000..09dad640 --- /dev/null +++ b/lib/TTLS/include/Session.h @@ -0,0 +1,44 @@ +/* + 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 +{ + /// + /// TTLS session + /// + class session_ttls; +} + +#pragma once + +#include "../../EAPBase/include/Session.h" + + +namespace eap +{ + class session_ttls : public session + { + public: + /// + /// Constructor + /// + session_ttls(); + }; +} diff --git a/lib/TTLS/src/Config.cpp b/lib/TTLS/src/Config.cpp new file mode 100644 index 00000000..bd324458 --- /dev/null +++ b/lib/TTLS/src/Config.cpp @@ -0,0 +1,149 @@ +/* + 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_ttls +////////////////////////////////////////////////////////////////////// + +eap::config_ttls::config_ttls(_In_ module &mod) : + m_inner(NULL), + config_tls(mod) +{ +} + + +eap::config_ttls::config_ttls(const _In_ config_ttls &other) : + m_inner(other.m_inner ? (config_method*)other.m_inner->clone() : NULL), + config_tls(other) +{ +} + + +eap::config_ttls::config_ttls(_Inout_ config_ttls &&other) : + m_inner(other.m_inner), + config_tls(std::move(other)) +{ + other.m_inner = NULL; +} + + +eap::config_ttls::~config_ttls() +{ + if (m_inner) + delete m_inner; +} + + +eap::config_ttls& eap::config_ttls::operator=(const _In_ config_ttls &other) +{ + if (this != &other) { + (config_tls&)*this = other; + if (m_inner) delete m_inner; + m_inner = other.m_inner ? (config_method*)other.m_inner->clone() : NULL; + } + + return *this; +} + + +eap::config_ttls& eap::config_ttls::operator=(_Inout_ config_ttls &&other) +{ + if (this != &other) { + (config_tls&&)*this = std::move(other); + if (m_inner) delete m_inner; + m_inner = other.m_inner; + other.m_inner = NULL; + } + + return *this; +} + + +DWORD eap::config_ttls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) const +{ + const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata"); + DWORD dwResult; + + // + com_obj pXmlElInnerAuthenticationMethod; + if ((dwResult = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:InnerAuthenticationMethod"), bstr(L"InnerAuthenticationMethod"), bstrNamespace, &pXmlElInnerAuthenticationMethod)) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + if (dynamic_cast(m_inner)) { + // / + if ((dwResult = eapxml::put_element_value(pDoc, pXmlElInnerAuthenticationMethod, bstr(L"NonEAPAuthMethod"), bstrNamespace, bstr(L"PAP"))) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return dwResult; + } + + // /... + if ((dwResult = m_inner->save(pDoc, pXmlElInnerAuthenticationMethod, ppEapError)) != ERROR_SUCCESS) + return dwResult; + } else + return dwResult = ERROR_NOT_SUPPORTED; + + return config_tls::save(pDoc, pConfigRoot, ppEapError); +} + + +DWORD eap::config_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) +{ + assert(ppEapError); + DWORD dwResult; + + // Load inner authentication configuration (). + com_obj pXmlElInnerAuthenticationMethod; + if ((dwResult = eapxml::select_element(pConfigRoot, bstr(L"eap-metadata:InnerAuthenticationMethod"), &pXmlElInnerAuthenticationMethod)) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting element."), NULL); + return dwResult; + } + + // Determine inner authentication type ( and ). + //DWORD dwMethodID; + bstr bstrMethod; + /*if (eapxml::get_element_value(pXmlElInnerAuthenticationMethod, bstr(L"eap-metadata:EAPMethod"), &dwMethodID) == ERROR_SUCCESS && + dwMethodID == EAP_TYPE_MSCHAPV2) + { + // MSCHAPv2 + // TODO: Add MSCHAPv2 support. + return ERROR_NOT_SUPPORTED; + } else*/ if (eapxml::get_element_value(pXmlElInnerAuthenticationMethod, bstr(L"eap-metadata:NonEAPAuthMethod"), &bstrMethod) == ERROR_SUCCESS && + CompareStringEx(LOCALE_NAME_INVARIANT, NORM_IGNORECASE, bstrMethod, bstrMethod.length(), L"PAP", -1, NULL, NULL, 0) == CSTR_EQUAL) + { + // PAP + assert(!m_inner); + m_inner = new eap::config_pap(m_module); + if ((dwResult = m_inner->load(pXmlElInnerAuthenticationMethod, ppEapError)) != ERROR_SUCCESS) + return dwResult; + } else { + *ppEapError = m_module.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Unsupported inner authentication method."), NULL); + return dwResult; + } + + return config_tls::load(pConfigRoot, ppEapError); +} diff --git a/lib/TTLS/src/Credentials.cpp b/lib/TTLS/src/Credentials.cpp new file mode 100644 index 00000000..8ef08a7a --- /dev/null +++ b/lib/TTLS/src/Credentials.cpp @@ -0,0 +1,146 @@ +/* + 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_ttls +////////////////////////////////////////////////////////////////////// + +eap::credentials_ttls::credentials_ttls(_In_ module &mod) : credentials_tls(mod) +{ +} + + +eap::credentials_ttls::credentials_ttls(_In_ const credentials_ttls &other) : + m_inner(other.m_inner ? (credentials*)other.m_inner->clone() : NULL), + credentials_tls(other) +{ +} + + +eap::credentials_ttls::credentials_ttls(_Inout_ credentials_ttls &&other) : + m_inner(other.m_inner), + credentials_tls(std::move(other)) +{ + other.m_inner = NULL; +} + + +eap::credentials_ttls& eap::credentials_ttls::operator=(_In_ const credentials_ttls &other) +{ + if (this != &other) { + (credentials_tls&)*this = other; + + if (m_inner) delete m_inner; + m_inner = other.m_inner ? (credentials*)other.m_inner->clone() : NULL; + } + + return *this; +} + + +eap::credentials_ttls& eap::credentials_ttls::operator=(_Inout_ credentials_ttls &&other) +{ + if (this != &other) { + (credentials_tls&)*this = std::move(other); + + if (m_inner) delete m_inner; + m_inner = other.m_inner; + other.m_inner = NULL; + } + + return *this; +} + + + +void eap::credentials_ttls::clear() +{ + credentials_tls::clear(); + if (m_inner) + m_inner->clear(); +} + + +bool eap::credentials_ttls::empty() const +{ + return credentials_tls::empty() && (!m_inner || m_inner->empty()); +} + + + +DWORD eap::credentials_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError) +{ + assert(pConfigRoot); + DWORD dwResult; + + if ((dwResult = credentials_tls::load(pConfigRoot, ppEapError)) != ERROR_SUCCESS) + return dwResult; + + if (m_inner) { + com_obj pXmlElInnerAuthenticationMethod; + if ((dwResult = eapxml::select_node(pConfigRoot, bstr(L"eap-metadata:InnerAuthenticationMethod"), &pXmlElInnerAuthenticationMethod)) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult = ERROR_NOT_FOUND, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error selecting element."), NULL); + return dwResult; + } + + if ((dwResult = m_inner->load(pXmlElInnerAuthenticationMethod, ppEapError)) != ERROR_SUCCESS) + return dwResult; + } + + return ERROR_SUCCESS; +} + + +DWORD eap::credentials_ttls::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const +{ + DWORD dwResult; + + if ((dwResult = credentials_tls::store(pszTargetName, ppEapError)) != ERROR_SUCCESS) + return dwResult; + + if (m_inner) { + if ((dwResult = m_inner->store(pszTargetName, ppEapError)) != ERROR_SUCCESS) + return dwResult; + } + + return ERROR_SUCCESS; +} + + +DWORD eap::credentials_ttls::retrieve(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) +{ + DWORD dwResult; + + if ((dwResult = credentials_tls::retrieve(pszTargetName, ppEapError)) != ERROR_SUCCESS) + return dwResult; + + if (m_inner) { + if ((dwResult = m_inner->retrieve(pszTargetName, ppEapError)) != ERROR_SUCCESS) + return dwResult; + } + + return ERROR_SUCCESS; +} diff --git a/lib/TTLS/src/Module.cpp b/lib/TTLS/src/Module.cpp new file mode 100644 index 00000000..fe13c46f --- /dev/null +++ b/lib/TTLS/src/Module.cpp @@ -0,0 +1,116 @@ +/* + 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::peer_ttls +////////////////////////////////////////////////////////////////////// + +eap::peer_ttls::peer_ttls() : peer(type_ttls) +{ +} + + +DWORD eap::peer_ttls::initialize(_Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(ppEapError); + + // MSI's feature completeness check removed: It might invoke UI (prompt user for missing MSI), + // which would be disasterous in EapHost system service. +#if 0 + // Perform the Microsoft Installer's feature completeness check manually. + // If execution got this far in the first place (dependent DLLs are present and loadable). + // Furthermore, this increments program usage counter. + if (MsiQueryFeatureState(_T(PRODUCT_VERSION_GUID), _T("featEAPTTLS")) != INSTALLSTATE_UNKNOWN) + MsiUseFeature(_T(PRODUCT_VERSION_GUID), _T("featEAPTTLS")); +#endif + + return ERROR_SUCCESS; +} + + +DWORD eap::peer_ttls::shutdown(_Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(ppEapError); + return ERROR_SUCCESS; +} + + +DWORD eap::peer_ttls::get_identity( + _In_ DWORD dwFlags, + _In_ DWORD dwConnectionDataSize, + _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, + _In_ DWORD dwUserDataSize, + _In_count_(dwUserDataSize) const BYTE *pUserData, + _In_ HANDLE hTokenImpersonateUser, + _Out_ BOOL *pfInvokeUI, + _Out_ DWORD *pdwUserDataOutSize, + _Out_ BYTE **ppUserDataOut, + _Out_ WCHAR **ppwszIdentity, + _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(dwConnectionDataSize); + UNREFERENCED_PARAMETER(pConnectionData); + UNREFERENCED_PARAMETER(dwUserDataSize); + UNREFERENCED_PARAMETER(pUserData); + UNREFERENCED_PARAMETER(hTokenImpersonateUser); + UNREFERENCED_PARAMETER(pfInvokeUI); + UNREFERENCED_PARAMETER(pdwUserDataOutSize); + UNREFERENCED_PARAMETER(ppUserDataOut); + UNREFERENCED_PARAMETER(ppwszIdentity); + UNREFERENCED_PARAMETER(ppEapError); + + DWORD dwResult = ERROR_NOT_SUPPORTED; + ETW_FN_DWORD(dwResult); + return dwResult; +} + + +DWORD eap::peer_ttls::get_method_properties( + _In_ DWORD dwVersion, + _In_ DWORD dwFlags, + _In_ HANDLE hUserImpersonationToken, + _In_ DWORD dwEapConnDataSize, + _In_count_(dwEapConnDataSize) const BYTE *pEapConnData, + _In_ DWORD dwUserDataSize, + _In_count_(dwUserDataSize) const BYTE *pUserData, + _Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray, + _Out_ EAP_ERROR **ppEapError) const +{ + UNREFERENCED_PARAMETER(dwVersion); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(hUserImpersonationToken); + UNREFERENCED_PARAMETER(dwEapConnDataSize); + UNREFERENCED_PARAMETER(pEapConnData); + UNREFERENCED_PARAMETER(dwUserDataSize); + UNREFERENCED_PARAMETER(pUserData); + UNREFERENCED_PARAMETER(pMethodPropertyArray); + UNREFERENCED_PARAMETER(ppEapError); + + DWORD dwResult = ERROR_NOT_SUPPORTED; + ETW_FN_DWORD(dwResult); + return dwResult; +} diff --git a/lib/TTLS/src/Session.cpp b/lib/TTLS/src/Session.cpp new file mode 100644 index 00000000..209e9155 --- /dev/null +++ b/lib/TTLS/src/Session.cpp @@ -0,0 +1,33 @@ +/* + 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::session_ttls +////////////////////////////////////////////////////////////////////// + +eap::session_ttls::session_ttls() : session() +{ +} diff --git a/lib/TTLS/src/StdAfx.cpp b/lib/TTLS/src/StdAfx.cpp new file mode 100644 index 00000000..4af5ec17 --- /dev/null +++ b/lib/TTLS/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/TTLS/src/StdAfx.h b/lib/TTLS/src/StdAfx.h new file mode 100644 index 00000000..46d55cc4 --- /dev/null +++ b/lib/TTLS/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/Module.h" +#include "../include/Session.h" + +#include "../../EAPBase/include/EAPXML.h" diff --git a/lib/TTLS_UI/build/.gitignore b/lib/TTLS_UI/build/.gitignore new file mode 100644 index 00000000..9c8716a0 --- /dev/null +++ b/lib/TTLS_UI/build/.gitignore @@ -0,0 +1,2 @@ +/temp +/*.user diff --git a/lib/TTLS_UI/build/TTLS_UI.props b/lib/TTLS_UI/build/TTLS_UI.props new file mode 100644 index 00000000..4997b714 --- /dev/null +++ b/lib/TTLS_UI/build/TTLS_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/TTLS_UI/build/TTLS_UI.vcxproj b/lib/TTLS_UI/build/TTLS_UI.vcxproj new file mode 100644 index 00000000..38e4e119 --- /dev/null +++ b/lib/TTLS_UI/build/TTLS_UI.vcxproj @@ -0,0 +1,109 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {42F0F0F4-C928-4860-A4E4-94991C2C3D90} + TTLS_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/TTLS_UI/build/TTLS_UI.vcxproj.filters b/lib/TTLS_UI/build/TTLS_UI.vcxproj.filters new file mode 100644 index 00000000..3378275d --- /dev/null +++ b/lib/TTLS_UI/build/TTLS_UI.vcxproj.filters @@ -0,0 +1,50 @@ + + + + + {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 + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/EAPMethods/include/TTLS_UI.h b/lib/TTLS_UI/include/Module.h similarity index 61% rename from EAPMethods/include/TTLS_UI.h rename to lib/TTLS_UI/include/Module.h index 3b739c52..68fed558 100644 --- a/EAPMethods/include/TTLS_UI.h +++ b/lib/TTLS_UI/include/Module.h @@ -18,37 +18,28 @@ along with GÉANTLink. If not, see . */ -#include "TTLS.h" -#include "EAP_UI.h" -#include "../res/wxEAP_UI.h" -#include "../res/wxTTLS_UI.h" -#include "../res/wxTLS_UI.h" - namespace eap { + /// + /// TTLS UI peer + /// class peer_ttls_ui; } -class wxEAPTTLSConfigPanel; -class wxEAPTTLSConfig; - #pragma once -#include -#include -#include +#include "../../TTLS/include/Config.h" +#include "../../TTLS/include/Credentials.h" +#include "../../EAPBase_UI/include/Module.h" namespace eap { - /// - /// TTLS UI peer - /// class peer_ttls_ui : public peer_ui { public: /// - /// Constructor + /// Constructs a EAP TTLS UI peer module /// peer_ttls_ui(); @@ -115,67 +106,3 @@ namespace eap _Out_ EAP_ERROR **ppEapError); }; } - - -/// -/// EAPTTLS configuration panel -/// -class wxEAPTTLSConfigPanel : public wxEAPTTLSConfigPanelBase -{ -public: - /// - /// Constructs a configuration panel - /// - wxEAPTTLSConfigPanel(eap::config_ttls &cfg, wxWindow* parent); - -protected: - /// \cond internal - virtual bool TransferDataToWindow(); - virtual bool TransferDataFromWindow(); - virtual void OnOuterIdentityCustom(wxCommandEvent& event); - /// \endcond - -protected: - eap::config_ttls &m_cfg; ///< TLS configuration - winstd::library m_shell32; ///< shell32.dll resource library reference - wxIcon m_icon; ///< Panel icon -}; - - -/// -/// EAPTTLS configuration -/// -class wxEAPTTLSConfig : public wxScrolledWindow -{ -public: - /// - /// Constructs a configuration panel - /// - /// \param[inout] cfg Configuration data - /// \param[in] pszCredTarget Target name of credentials in Windows Credential Manager. Can be further decorated to create final target name. - /// \param[in] parent Parent window - /// - wxEAPTTLSConfig(eap::config_ttls &cfg, LPCTSTR pszCredTarget, wxWindow* parent); - - /// - /// Destructs the configuration panel - /// - virtual ~wxEAPTTLSConfig(); - -protected: - /// \cond internal - virtual bool TransferDataToWindow(); - virtual bool TransferDataFromWindow(); - virtual void OnInitDialog(wxInitDialogEvent& event); - /// \endcond - -protected: - eap::config_ttls &m_cfg; ///< TTLS configuration - wxStaticText *m_outer_title; ///< Outer authentication title - wxEAPTTLSConfigPanel *m_outer_identity; ///< Outer identity configuration panel - wxEAPTLSConfigPanel *m_tls; ///< TLS configuration panel - wxStaticText *m_inner_title; ///< Inner authentication title - wxChoicebook *m_inner_type; ///< Inner authentication type - - eap::config_pap m_cfg_pap; ///< Temporary PAP configuration -}; diff --git a/lib/TTLS_UI/include/TTLS_UI.h b/lib/TTLS_UI/include/TTLS_UI.h new file mode 100644 index 00000000..599db2d6 --- /dev/null +++ b/lib/TTLS_UI/include/TTLS_UI.h @@ -0,0 +1,104 @@ +/* + 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 . +*/ + +/// +/// EAPTTLS configuration panel +/// +class wxEAPTTLSConfigPanel; + +/// +/// EAPTTLS configuration +/// +class wxEAPTTLSConfig; + +#pragma once + +#include "../res/wxTTLS_UI.h" + +#include "../../TLS_UI/include/TLS_UI.h" + +#include "../../TTLS/include/Config.h" + +#include + +#include +#include +#include +#include + +#include + + +class wxEAPTTLSConfigPanel : public wxEAPTTLSConfigPanelBase +{ +public: + /// + /// Constructs a configuration panel + /// + wxEAPTTLSConfigPanel(eap::config_ttls &cfg, wxWindow* parent); + +protected: + /// \cond internal + virtual bool TransferDataToWindow(); + virtual bool TransferDataFromWindow(); + virtual void OnOuterIdentityCustom(wxCommandEvent& event); + /// \endcond + +protected: + eap::config_ttls &m_cfg; ///< TLS configuration + winstd::library m_shell32; ///< shell32.dll resource library reference + wxIcon m_icon; ///< Panel icon +}; + + +class wxEAPTTLSConfig : public wxScrolledWindow +{ +public: + /// + /// Constructs a configuration panel + /// + /// \param[inout] cfg Configuration data + /// \param[in] pszCredTarget Target name of credentials in Windows Credential Manager. Can be further decorated to create final target name. + /// \param[in] parent Parent window + /// + wxEAPTTLSConfig(eap::config_ttls &cfg, LPCTSTR pszCredTarget, wxWindow* parent); + + /// + /// Destructs the configuration panel + /// + virtual ~wxEAPTTLSConfig(); + +protected: + /// \cond internal + virtual bool TransferDataToWindow(); + virtual bool TransferDataFromWindow(); + virtual void OnInitDialog(wxInitDialogEvent& event); + /// \endcond + +protected: + eap::config_ttls &m_cfg; ///< TTLS configuration + wxStaticText *m_outer_title; ///< Outer authentication title + wxEAPTTLSConfigPanel *m_outer_identity; ///< Outer identity configuration panel + wxEAPTLSConfigPanel *m_tls; ///< TLS configuration panel + wxStaticText *m_inner_title; ///< Inner authentication title + wxChoicebook *m_inner_type; ///< Inner authentication type + + eap::config_pap m_cfg_pap; ///< Temporary PAP configuration +}; diff --git a/EAPMethods/res/wxTTLS_UI.cpp b/lib/TTLS_UI/res/wxTTLS_UI.cpp similarity index 100% rename from EAPMethods/res/wxTTLS_UI.cpp rename to lib/TTLS_UI/res/wxTTLS_UI.cpp diff --git a/EAPMethods/res/wxTTLS_UI.fbp b/lib/TTLS_UI/res/wxTTLS_UI.fbp similarity index 100% rename from EAPMethods/res/wxTTLS_UI.fbp rename to lib/TTLS_UI/res/wxTTLS_UI.fbp diff --git a/EAPMethods/res/wxTTLS_UI.h b/lib/TTLS_UI/res/wxTTLS_UI.h similarity index 100% rename from EAPMethods/res/wxTTLS_UI.h rename to lib/TTLS_UI/res/wxTTLS_UI.h diff --git a/lib/TTLS_UI/src/Module.cpp b/lib/TTLS_UI/src/Module.cpp new file mode 100644 index 00000000..1b031611 --- /dev/null +++ b/lib/TTLS_UI/src/Module.cpp @@ -0,0 +1,101 @@ +/* + 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::peer_ttls_ui +////////////////////////////////////////////////////////////////////// + +eap::peer_ttls_ui::peer_ttls_ui() : peer_ui(type_ttls) +{ +} + + +DWORD eap::peer_ttls_ui::invoke_config_ui( + _In_ HWND hwndParent, + _Inout_ config_type &cfg, + _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(ppEapError); + + // Initialize application. + new wxApp(); + wxEntryStart(m_instance); + + int result; + { + // Create wxWidget-approved parent window. + wxWindow parent; + parent.SetHWND((WXHWND)hwndParent); + parent.AdoptAttributesFromHWND(); + wxTopLevelWindows.Append(&parent); + + // Create and launch configuration dialog. + wxEAPConfigDialog dlg(cfg, &parent); + result = dlg.ShowModal(); + + wxTopLevelWindows.DeleteObject(&parent); + parent.SetHWND((WXHWND)NULL); + } + + // Clean-up and return. + wxEntryCleanup(); + return result == wxID_OK ? ERROR_SUCCESS : ERROR_CANCELLED; +} + + +DWORD eap::peer_ttls_ui::invoke_identity_ui( + _In_ HWND hwndParent, + _In_ DWORD dwFlags, + _Inout_ config_type &cfg, + _Inout_ identity_type &usr, + _Out_ LPWSTR *ppwszIdentity, + _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(cfg); + UNREFERENCED_PARAMETER(usr); + UNREFERENCED_PARAMETER(ppwszIdentity); + UNREFERENCED_PARAMETER(ppEapError); + + InitCommonControls(); + MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" credential prompt goes here!"), _T(PRODUCT_NAME_STR) _T(" Credentials"), MB_OK); + + return ERROR_SUCCESS; +} + + +DWORD eap::peer_ttls_ui::invoke_interactive_ui( + _In_ HWND hwndParent, + _In_ const interactive_request_type &req, + _Out_ interactive_response_type &res, + _Out_ EAP_ERROR **ppEapError) +{ + UNREFERENCED_PARAMETER(req); + UNREFERENCED_PARAMETER(res); + UNREFERENCED_PARAMETER(ppEapError); + + InitCommonControls(); + MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" interactive UI goes here!"), _T(PRODUCT_NAME_STR) _T(" Prompt"), MB_OK); + + return ERROR_SUCCESS; +} diff --git a/lib/TTLS_UI/src/StdAfx.cpp b/lib/TTLS_UI/src/StdAfx.cpp new file mode 100644 index 00000000..4af5ec17 --- /dev/null +++ b/lib/TTLS_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/TTLS_UI/src/StdAfx.h b/lib/TTLS_UI/src/StdAfx.h new file mode 100644 index 00000000..6eb96e1e --- /dev/null +++ b/lib/TTLS_UI/src/StdAfx.h @@ -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 . +*/ + +#pragma once + +#define _CRT_SECURE_NO_WARNINGS // Prevent warnings from wxWidgets headers + +#include "../include/Module.h" +#include "../include/TTLS_UI.h" + +#include "../../PAP_UI/include/PAP_UI.h" + +#include diff --git a/EAPMethods/src/TTLS_UI.cpp b/lib/TTLS_UI/src/TTLS_UI.cpp similarity index 70% rename from EAPMethods/src/TTLS_UI.cpp rename to lib/TTLS_UI/src/TTLS_UI.cpp index e1e46154..0241ba3c 100644 --- a/EAPMethods/src/TTLS_UI.cpp +++ b/lib/TTLS_UI/src/TTLS_UI.cpp @@ -18,87 +18,7 @@ along with GÉANTLink. If not, see . */ -#include - - -////////////////////////////////////////////////////////////////////// -// eap::peer_ttls_ui -////////////////////////////////////////////////////////////////////// - -eap::peer_ttls_ui::peer_ttls_ui() : peer_ui() -{ -} - - -DWORD eap::peer_ttls_ui::invoke_config_ui( - _In_ HWND hwndParent, - _Inout_ config_type &cfg, - _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(ppEapError); - - // Initialize application. - new wxApp(); - wxEntryStart(m_instance); - - int result; - { - // Create wxWidget-approved parent window. - wxWindow parent; - parent.SetHWND((WXHWND)hwndParent); - parent.AdoptAttributesFromHWND(); - wxTopLevelWindows.Append(&parent); - - // Create and launch configuration dialog. - wxEAPConfigDialog dlg(cfg, &parent); - result = dlg.ShowModal(); - - wxTopLevelWindows.DeleteObject(&parent); - parent.SetHWND((WXHWND)NULL); - } - - // Clean-up and return. - wxEntryCleanup(); - return result == wxID_OK ? ERROR_SUCCESS : ERROR_CANCELLED; -} - - -DWORD eap::peer_ttls_ui::invoke_identity_ui( - _In_ HWND hwndParent, - _In_ DWORD dwFlags, - _Inout_ config_type &cfg, - _Inout_ identity_type &usr, - _Out_ LPWSTR *ppwszIdentity, - _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(dwFlags); - UNREFERENCED_PARAMETER(cfg); - UNREFERENCED_PARAMETER(usr); - UNREFERENCED_PARAMETER(ppwszIdentity); - UNREFERENCED_PARAMETER(ppEapError); - - InitCommonControls(); - MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" credential prompt goes here!"), _T(PRODUCT_NAME_STR) _T(" Credentials"), MB_OK); - - return ERROR_SUCCESS; -} - - -DWORD eap::peer_ttls_ui::invoke_interactive_ui( - _In_ HWND hwndParent, - _In_ const interactive_request_type &req, - _Out_ interactive_response_type &res, - _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(req); - UNREFERENCED_PARAMETER(res); - UNREFERENCED_PARAMETER(ppEapError); - - InitCommonControls(); - MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" interactive UI goes here!"), _T(PRODUCT_NAME_STR) _T(" Prompt"), MB_OK); - - return ERROR_SUCCESS; -} +#include "StdAfx.h" ////////////////////////////////////////////////////////////////////// diff --git a/lib/WinStd b/lib/WinStd index bc0967ed..e4f5b63a 160000 --- a/lib/WinStd +++ b/lib/WinStd @@ -1 +1 @@ -Subproject commit bc0967edc39c192f97eb7e1b972ddddde9a5b054 +Subproject commit e4f5b63a85bba6364327b2b7161f934b0f80287a diff --git a/output/Setup/.gitignore b/output/Setup/.gitignore index 1ab3819b..3bbfc5e0 100644 --- a/output/Setup/.gitignore +++ b/output/Setup/.gitignore @@ -1,2 +1,4 @@ /GEANTLink32.msi /GEANTLink64.msi +/GEANTLink32D.msi +/GEANTLink64D.msi