diff --git a/lib/EAPBase/include/Method.h b/lib/EAPBase/include/Method.h index 21d1e6d..d2c8c9e 100644 --- a/lib/EAPBase/include/Method.h +++ b/lib/EAPBase/include/Method.h @@ -130,6 +130,55 @@ namespace eap /// @} + /// \name User 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 void get_ui_context( + _Inout_ BYTE **ppUIContextData, + _Inout_ DWORD *pdwUIContextDataSize); + + /// + /// 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 void set_ui_context( + _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, + _In_ DWORD dwUIContextDataSize, + _In_ const EapPeerMethodOutput *pEapOutput); + + /// @} + + /// \name EAP 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 void get_response_attributes(_Inout_ EapAttributes *pAttribs); + + /// + /// 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 void set_response_attributes( + _In_ const EapAttributes *pAttribs, + _Inout_ EapPeerMethodOutput *pEapOutput); + + /// @} + public: module &m_module; ///< EAP module config_method &m_cfg; ///< Connection configuration diff --git a/lib/EAPBase/src/Method.cpp b/lib/EAPBase/src/Method.cpp index dec8775..7d7ded8 100644 --- a/lib/EAPBase/src/Method.cpp +++ b/lib/EAPBase/src/Method.cpp @@ -109,6 +109,55 @@ void eap::method::get_result( } +void eap::method::get_ui_context( + _Inout_ BYTE **ppUIContextData, + _Inout_ DWORD *pdwUIContextDataSize) +{ + assert(ppUIContextData); + assert(pdwUIContextDataSize); + + // Default implementation returns blank context data. + *ppUIContextData = NULL; + *pdwUIContextDataSize = 0; +} + + +void eap::method::set_ui_context( + _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, + _In_ DWORD dwUIContextDataSize, + _In_ const EapPeerMethodOutput *pEapOutput) +{ + UNREFERENCED_PARAMETER(pUIContextData); + UNREFERENCED_PARAMETER(dwUIContextDataSize); + UNREFERENCED_PARAMETER(pEapOutput); + + // Default implementation does nothing with context data. +} + + +void eap::method::get_response_attributes(_Inout_ EapAttributes *pAttribs) +{ + assert(pAttribs); + + // Default implementation returns no EAP attributes. + pAttribs->dwNumberOfAttributes = 0; + pAttribs->pAttribs = NULL; +} + + +void eap::method::set_response_attributes( + _In_ const EapAttributes *pAttribs, + _Inout_ EapPeerMethodOutput *pEapOutput) +{ + UNREFERENCED_PARAMETER(pAttribs); + assert(pEapOutput); + + // Default implementation discards the EAP attributes. + pEapOutput->action = EapPeerMethodResponseActionDiscard; + pEapOutput->fAllowNotifications = FALSE; +} + + ////////////////////////////////////////////////////////////////////// // eap::method_noneap ////////////////////////////////////////////////////////////////////// diff --git a/lib/TTLS/include/Method.h b/lib/TTLS/include/Method.h index db362ee..8dad218 100644 --- a/lib/TTLS/include/Method.h +++ b/lib/TTLS/include/Method.h @@ -119,6 +119,55 @@ namespace eap /// @} + /// \name User 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 void get_ui_context( + _Inout_ BYTE **ppUIContextData, + _Inout_ DWORD *pdwUIContextDataSize); + + /// + /// 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 void set_ui_context( + _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, + _In_ DWORD dwUIContextDataSize, + _In_ const EapPeerMethodOutput *pEapOutput); + + /// @} + + /// \name EAP 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 void get_response_attributes(_Inout_ EapAttributes *pAttribs); + + /// + /// 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 void set_response_attributes( + _In_ const EapAttributes *pAttribs, + _Inout_ EapPeerMethodOutput *pEapOutput); + + /// @} + protected: /// /// Generates master session key diff --git a/lib/TTLS/src/Method.cpp b/lib/TTLS/src/Method.cpp index 785b7e9..5e617f8 100644 --- a/lib/TTLS/src/Method.cpp +++ b/lib/TTLS/src/Method.cpp @@ -144,6 +144,49 @@ void eap::method_ttls::get_result( } +void eap::method_ttls::get_ui_context( + _Inout_ BYTE **ppUIContextData, + _Inout_ DWORD *pdwUIContextDataSize) +{ + UNREFERENCED_PARAMETER(ppUIContextData); + UNREFERENCED_PARAMETER(pdwUIContextDataSize); + + throw win_runtime_error(ERROR_NOT_SUPPORTED, __FUNCTION__ " Not supported."); +} + + +void eap::method_ttls::set_ui_context( + _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, + _In_ DWORD dwUIContextDataSize, + _In_ const EapPeerMethodOutput *pEapOutput) +{ + UNREFERENCED_PARAMETER(pUIContextData); + UNREFERENCED_PARAMETER(dwUIContextDataSize); + UNREFERENCED_PARAMETER(pEapOutput); + + throw win_runtime_error(ERROR_NOT_SUPPORTED, __FUNCTION__ " Not supported."); +} + + +void eap::method_ttls::get_response_attributes(_Inout_ EapAttributes *pAttribs) +{ + UNREFERENCED_PARAMETER(pAttribs); + + throw win_runtime_error(ERROR_NOT_SUPPORTED, __FUNCTION__ " Not supported."); +} + + +void eap::method_ttls::set_response_attributes( + _In_ const EapAttributes *pAttribs, + _Inout_ EapPeerMethodOutput *pEapOutput) +{ + UNREFERENCED_PARAMETER(pAttribs); + UNREFERENCED_PARAMETER(pEapOutput); + + throw win_runtime_error(ERROR_NOT_SUPPORTED, __FUNCTION__ " Not supported."); +} + + void eap::method_ttls::derive_msk() { const unsigned char *_key_block; diff --git a/lib/TTLS/src/Module.cpp b/lib/TTLS/src/Module.cpp index f2d8798..a544b6d 100644 --- a/lib/TTLS/src/Module.cpp +++ b/lib/TTLS/src/Module.cpp @@ -241,7 +241,7 @@ void eap::peer_ttls::end_session(_In_ EAP_SESSION_HANDLE hSession) assert(hSession); // End the session. - session *s = static_cast(hSession); + auto s = static_cast(hSession); //s->end(ppEapError); delete s; } @@ -272,7 +272,7 @@ void eap::peer_ttls::get_result( _In_ EapPeerMethodResultReason reason, _Inout_ EapPeerMethodResult *ppResult) { - session *s = static_cast(hSession); + auto s = static_cast(hSession); s->m_method->get_result(reason, ppResult); s->m_eap_attr_desc.dwNumberOfAttributes = (DWORD)s->m_method->m_eap_attr.size(); @@ -308,11 +308,7 @@ void eap::peer_ttls::get_ui_context( _Inout_ BYTE **ppUIContextData, _Inout_ DWORD *pdwUIContextDataSize) { - UNREFERENCED_PARAMETER(hSession); - UNREFERENCED_PARAMETER(ppUIContextData); - UNREFERENCED_PARAMETER(pdwUIContextDataSize); - - throw win_runtime_error(ERROR_NOT_SUPPORTED, __FUNCTION__ " Not supported."); + static_cast(hSession)->m_method->get_ui_context(ppUIContextData, pdwUIContextDataSize); } @@ -322,12 +318,7 @@ void eap::peer_ttls::set_ui_context( _In_ DWORD dwUIContextDataSize, _In_ const EapPeerMethodOutput *pEapOutput) { - UNREFERENCED_PARAMETER(hSession); - UNREFERENCED_PARAMETER(pUIContextData); - UNREFERENCED_PARAMETER(dwUIContextDataSize); - UNREFERENCED_PARAMETER(pEapOutput); - - throw win_runtime_error(ERROR_NOT_SUPPORTED, __FUNCTION__ " Not supported."); + static_cast(hSession)->m_method->set_ui_context(pUIContextData, dwUIContextDataSize, pEapOutput); } @@ -335,10 +326,7 @@ void eap::peer_ttls::get_response_attributes( _In_ EAP_SESSION_HANDLE hSession, _Inout_ EapAttributes *pAttribs) { - UNREFERENCED_PARAMETER(hSession); - UNREFERENCED_PARAMETER(pAttribs); - - throw win_runtime_error(ERROR_NOT_SUPPORTED, __FUNCTION__ " Not supported."); + static_cast(hSession)->m_method->get_response_attributes(pAttribs); } @@ -347,11 +335,7 @@ void eap::peer_ttls::set_response_attributes( _In_ const EapAttributes *pAttribs, _Inout_ EapPeerMethodOutput *pEapOutput) { - UNREFERENCED_PARAMETER(hSession); - UNREFERENCED_PARAMETER(pAttribs); - UNREFERENCED_PARAMETER(pEapOutput); - - throw win_runtime_error(ERROR_NOT_SUPPORTED, __FUNCTION__ " Not supported."); + static_cast(hSession)->m_method->set_response_attributes(pAttribs, pEapOutput); }