eap::peer_ttls::get_method_properties() implemented

This commit is contained in:
Simon Rozman 2016-08-03 13:50:12 +02:00
parent b32b63631a
commit cb24fbd6a3
4 changed files with 97 additions and 8 deletions

View File

@ -296,7 +296,7 @@ DWORD APIENTRY EapPeerBeginSession(
// Allocate new session. // Allocate new session.
unique_ptr<_EAPMETHOD_SESSION> session(new _EAPMETHOD_SESSION(g_peer)); unique_ptr<_EAPMETHOD_SESSION> session(new _EAPMETHOD_SESSION(g_peer));
if (!session) { if (!session) {
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_OUTOFMEMORY, _T(" Error allocating memory for EAP session."))); g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_OUTOFMEMORY, _T(__FUNCTION__) _T(" Error allocating memory for EAP session.")));
return dwResult; return dwResult;
} }

View File

@ -40,6 +40,11 @@ namespace eap
/// A group of methods all EAP peers must or should implement. /// A group of methods all EAP peers must or should implement.
/// ///
template <class _Tmeth, class _Tcred, class _Tint, class _Tintres> class peer; template <class _Tmeth, class _Tcred, class _Tint, class _Tintres> class peer;
///
/// EAP_METHOD_PROPERTY helper
///
class method_property;
} }
#pragma once #pragma once
@ -763,7 +768,7 @@ namespace eap
_In_ const config_providers &cfg, _In_ const config_providers &cfg,
_In_ const credentials_type &cred, _In_ const credentials_type &cred,
_Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray, _Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray,
_Out_ EAP_ERROR **ppEapError) const = 0; _Out_ EAP_ERROR **ppEapError) = 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. /// Defines the implementation of an EAP method-specific function that obtains the EAP Single-Sign-On (SSO) credential input fields for an EAP method.
@ -889,4 +894,53 @@ namespace eap
return false; return false;
} }
}; };
class method_property : public EAP_METHOD_PROPERTY
{
public:
///
/// Constructs a BOOL method property
///
/// \param[in] type EAP method property type
/// \param[in] value Property value
///
inline method_property(_In_ EAP_METHOD_PROPERTY_TYPE type, _In_ BOOL value)
{
eapMethodPropertyType = type;
eapMethodPropertyValueType = empvtBool;
eapMethodPropertyValue.empvBool.length = sizeof(BOOL);
eapMethodPropertyValue.empvBool.value = value;
}
///
/// Constructs a DWORD method property
///
/// \param[in] type EAP method property type
/// \param[in] value Property value
///
inline method_property(_In_ EAP_METHOD_PROPERTY_TYPE type, _In_ DWORD value)
{
eapMethodPropertyType = type;
eapMethodPropertyValueType = empvtDword;
eapMethodPropertyValue.empvDword.length = sizeof(DWORD);
eapMethodPropertyValue.empvDword.value = value;
}
///
/// Constructs a Unicode string method property
///
/// \param[in] type EAP method property type
/// \param[in] value Property value
///
inline method_property(_In_ EAP_METHOD_PROPERTY_TYPE type, _In_z_ LPCWSTR value)
{
eapMethodPropertyType = type;
eapMethodPropertyValueType = empvtString;
eapMethodPropertyValue.empvString.length = (DWORD)(sizeof(WCHAR)*(wcslen(value) + 1));
eapMethodPropertyValue.empvString.value = (BYTE*)value;
}
};
} }

View File

@ -100,6 +100,6 @@ namespace eap
_In_ const config_providers &cfg, _In_ const config_providers &cfg,
_In_ const credentials_type &cred, _In_ const credentials_type &cred,
_Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray, _Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray,
_Out_ EAP_ERROR **ppEapError) const; _Out_ EAP_ERROR **ppEapError);
}; };
} }

View File

@ -209,16 +209,51 @@ bool eap::peer_ttls::get_method_properties(
_In_ const config_providers &cfg, _In_ const config_providers &cfg,
_In_ const credentials_type &cred, _In_ const credentials_type &cred,
_Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray, _Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray,
_Out_ EAP_ERROR **ppEapError) const _Out_ EAP_ERROR **ppEapError)
{ {
UNREFERENCED_PARAMETER(dwVersion); UNREFERENCED_PARAMETER(dwVersion);
UNREFERENCED_PARAMETER(dwFlags); UNREFERENCED_PARAMETER(dwFlags);
UNREFERENCED_PARAMETER(hUserImpersonationToken); UNREFERENCED_PARAMETER(hUserImpersonationToken);
UNREFERENCED_PARAMETER(cfg); UNREFERENCED_PARAMETER(cfg);
UNREFERENCED_PARAMETER(cred); UNREFERENCED_PARAMETER(cred);
UNREFERENCED_PARAMETER(pMethodPropertyArray); assert(pMethodPropertyArray);
UNREFERENCED_PARAMETER(ppEapError); assert(ppEapError);
*ppEapError = make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported.")); vector<EAP_METHOD_PROPERTY> properties;
return false; properties.reserve(20);
properties.push_back(eap::method_property(emptPropCipherSuiteNegotiation, TRUE));
properties.push_back(eap::method_property(emptPropMutualAuth, TRUE));
properties.push_back(eap::method_property(emptPropIntegrity, TRUE));
properties.push_back(eap::method_property(emptPropReplayProtection, TRUE));
properties.push_back(eap::method_property(emptPropConfidentiality, TRUE));
properties.push_back(eap::method_property(emptPropKeyDerivation, TRUE));
properties.push_back(eap::method_property(emptPropKeyStrength128, TRUE));
properties.push_back(eap::method_property(emptPropDictionaryAttackResistance, TRUE));
properties.push_back(eap::method_property(emptPropFastReconnect, TRUE));
properties.push_back(eap::method_property(emptPropCryptoBinding, TRUE));
properties.push_back(eap::method_property(emptPropSessionIndependence, TRUE));
properties.push_back(eap::method_property(emptPropFragmentation, TRUE));
properties.push_back(eap::method_property(emptPropStandalone, TRUE));
properties.push_back(eap::method_property(emptPropMppeEncryption, TRUE));
properties.push_back(eap::method_property(emptPropTunnelMethod, TRUE));
properties.push_back(eap::method_property(emptPropSupportsConfig, TRUE));
properties.push_back(eap::method_property(emptPropMachineAuth, TRUE));
properties.push_back(eap::method_property(emptPropUserAuth, TRUE));
properties.push_back(eap::method_property(emptPropIdentityPrivacy, TRUE));
properties.push_back(eap::method_property(emptPropSharedStateEquivalence, TRUE));
// Allocate property array.
DWORD dwCount = (DWORD)properties.size();
pMethodPropertyArray->pMethodProperty = (EAP_METHOD_PROPERTY*)alloc_memory(sizeof(EAP_METHOD_PROPERTY) * dwCount);
if (!pMethodPropertyArray->pMethodProperty) {
*ppEapError = make_error(ERROR_OUTOFMEMORY, _T(__FUNCTION__) _T(" Error allocating memory for propery array."));
return false;
}
// Copy properties.
memcpy(pMethodPropertyArray->pMethodProperty, properties.data(), sizeof(EAP_METHOD_PROPERTY) * dwCount);
pMethodPropertyArray->dwNumberOfProperties = dwCount;
return true;
} }