eap::type_t >> winstd::eap_type_t

This commit is contained in:
Simon Rozman 2016-08-04 12:08:20 +02:00
parent 22a87bf90d
commit a102b43a19
17 changed files with 49 additions and 61 deletions

View File

@ -23,7 +23,7 @@
using namespace std; using namespace std;
using namespace winstd; using namespace winstd;
eap::peer_base<eap::config_method_pap, eap::credentials_pap, void, void> g_module(eap::type_undefined); eap::peer_base<eap::config_method_pap, eap::credentials_pap, void, void> g_module(eap_type_undefined);
static int CredWrite() static int CredWrite()

View File

@ -251,9 +251,9 @@ namespace eap
/// ///
/// Returns EAP method type of this configuration /// Returns EAP method type of this configuration
/// ///
/// \returns One of `eap::type_t` constants. /// \returns One of `winstd::eap_type_t` constants.
/// ///
virtual type_t get_method_id() const = 0; virtual winstd::eap_type_t get_method_id() const = 0;
}; };

View File

@ -28,6 +28,7 @@
#if !defined(RC_INVOKED) && !defined(MIDL_PASS) #if !defined(RC_INVOKED) && !defined(MIDL_PASS)
#include <WinStd/Crypt.h> #include <WinStd/Crypt.h>
#include <WinStd/EAP.h>
#include <sal.h> #include <sal.h>
@ -38,13 +39,6 @@
namespace eap 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;
/// ///
/// Output BLOB cursor /// Output BLOB cursor
/// ///
@ -316,7 +310,7 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ winstd::cert_contex
/// \param[inout] cursor Memory cursor /// \param[inout] cursor Memory cursor
/// \param[in] val EAP method type to pack /// \param[in] val EAP method type to pack
/// ///
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const eap::type_t &val); inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const winstd::eap_type_t &val);
/// ///
/// Returns packed size of an EAP method type /// Returns packed size of an EAP method type
@ -325,7 +319,7 @@ inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const eap::type_t &
/// ///
/// \returns Size of data when packed (in bytes) /// \returns Size of data when packed (in bytes)
/// ///
inline size_t pksizeof(const eap::type_t &val); inline size_t pksizeof(const winstd::eap_type_t &val);
/// ///
/// Unpacks an EAP method type /// Unpacks an EAP method type
@ -333,22 +327,13 @@ inline size_t pksizeof(const eap::type_t &val);
/// \param[inout] cursor Memory cursor /// \param[inout] cursor Memory cursor
/// \param[out] val EAP method type to unpack to /// \param[out] val EAP method type to unpack to
/// ///
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::type_t &val); inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ winstd::eap_type_t &val);
#pragma once #pragma once
namespace eap 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)
};
struct cursor_out struct cursor_out
{ {
typedef unsigned char *ptr_type; typedef unsigned char *ptr_type;
@ -680,23 +665,23 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ winstd::cert_contex
} }
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const eap::type_t &val) inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const winstd::eap_type_t &val)
{ {
cursor << (unsigned char)val; cursor << (unsigned char)val;
} }
inline size_t pksizeof(_In_ const eap::type_t &val) inline size_t pksizeof(_In_ const winstd::eap_type_t &val)
{ {
return pksizeof((unsigned char)val); return pksizeof((unsigned char)val);
} }
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::type_t &val) inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ winstd::eap_type_t &val)
{ {
unsigned char t; unsigned char t;
cursor >> t; cursor >> t;
val = (eap::type_t)t; val = (winstd::eap_type_t)t;
} }
#endif #endif

View File

@ -66,7 +66,7 @@ namespace eap
/// ///
/// Constructs a module for the given EAP type /// Constructs a module for the given EAP type
/// ///
module(_In_ type_t eap_method); module(_In_ winstd::eap_type_t eap_method);
/// ///
/// Destructs the module /// Destructs the module
@ -649,7 +649,7 @@ namespace eap
public: public:
HINSTANCE m_instance; ///< Windows module instance HINSTANCE m_instance; ///< Windows module instance
const type_t m_eap_method; ///< EAP method type const winstd::eap_type_t m_eap_method; ///< EAP method type
protected: protected:
winstd::heap m_heap; ///< Heap winstd::heap m_heap; ///< Heap
@ -685,7 +685,7 @@ namespace eap
/// ///
/// Constructs a EAP peer module for the given EAP type /// Constructs a EAP peer module for the given EAP type
/// ///
peer_base(_In_ type_t eap_method) : module(eap_method) {} peer_base(_In_ winstd::eap_type_t eap_method) : module(eap_method) {}
/// ///
/// Makes a new method config for the given method type /// Makes a new method config for the given method type
@ -704,7 +704,7 @@ namespace eap
/// ///
/// Constructs a EAP peer module for the given EAP type /// Constructs a EAP peer module for the given EAP type
/// ///
peer(_In_ type_t eap_method) : peer_base<_Tmeth, _Tcred, _Tint, _Tintres>(eap_method) {} peer(_In_ winstd::eap_type_t eap_method) : peer_base<_Tmeth, _Tcred, _Tint, _Tintres>(eap_method) {}
/// ///
/// Initializes an EAP peer method for EAPHost. /// Initializes an EAP peer method for EAPHost.

View File

@ -429,7 +429,7 @@ bool eap::config_provider::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR *
// Check EAP method type (<EAPMethod>). // Check EAP method type (<EAPMethod>).
DWORD dwMethodID; DWORD dwMethodID;
if (eapxml::get_element_value(pXmlElMethod, bstr(L"eap-metadata:EAPMethod"), &dwMethodID) == ERROR_SUCCESS) { if (eapxml::get_element_value(pXmlElMethod, bstr(L"eap-metadata:EAPMethod"), &dwMethodID) == ERROR_SUCCESS) {
if ((type_t)dwMethodID != cfg->get_method_id()) { if ((eap_type_t)dwMethodID != cfg->get_method_id()) {
// Wrong type. // Wrong type.
continue; continue;
} }

View File

@ -28,7 +28,7 @@ using namespace winstd;
// eap::module // eap::module
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
eap::module::module(type_t eap_method) : eap::module::module(eap_type_t eap_method) :
m_eap_method(eap_method), m_eap_method(eap_method),
m_instance(NULL) m_instance(NULL)
{ {

View File

@ -42,7 +42,7 @@ namespace eap
/// ///
/// Constructs a EAP UI peer module for the given EAP type /// Constructs a EAP UI peer module for the given EAP type
/// ///
peer_ui(_In_ type_t eap_method) : peer_base<_Tmeth, _Tcred, _Tint, _Tintres>(eap_method) {} peer_ui(_In_ winstd::eap_type_t eap_method) : peer_base<_Tmeth, _Tcred, _Tint, _Tintres>(eap_method) {}
/// ///
/// Raises the EAP method's specific connection configuration user interface dialog on the client. /// Raises the EAP method's specific connection configuration user interface dialog on the client.

View File

@ -94,6 +94,6 @@ namespace eap
/// ///
/// \returns `eap::type_pap` /// \returns `eap::type_pap`
/// ///
virtual eap::type_t get_method_id() const; virtual winstd::eap_type_t get_method_id() const;
}; };
} }

View File

@ -20,6 +20,9 @@
#include "StdAfx.h" #include "StdAfx.h"
using namespace std;
using namespace winstd;
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// eap::config_method_pap // eap::config_method_pap
@ -66,7 +69,7 @@ eap::config* eap::config_method_pap::clone() const
} }
eap::type_t eap::config_method_pap::get_method_id() const eap_type_t eap::config_method_pap::get_method_id() const
{ {
return eap::type_pap; return eap_type_pap;
} }

View File

@ -164,7 +164,7 @@ namespace eap
/// ///
/// \returns `eap::type_tls` /// \returns `eap::type_tls`
/// ///
virtual eap::type_t get_method_id() const; virtual winstd::eap_type_t get_method_id() const;
/// ///
/// Adds CA to the list of trusted root CA's /// Adds CA to the list of trusted root CA's

View File

@ -281,9 +281,9 @@ void eap::config_method_tls::operator>>(_Inout_ cursor_in &cursor)
} }
eap::type_t eap::config_method_tls::get_method_id() const eap_type_t eap::config_method_tls::get_method_id() const
{ {
return type_tls; return eap_type_tls;
} }

View File

@ -148,7 +148,7 @@ namespace eap {
/// ///
/// \returns `eap::type_ttls` /// \returns `eap::type_ttls`
/// ///
virtual eap::type_t get_method_id() const; virtual winstd::eap_type_t get_method_id() const;
/// ///
/// Generates public identity using current configuration and given credentials /// Generates public identity using current configuration and given credentials

View File

@ -206,14 +206,14 @@ void eap::config_method_ttls::operator<<(_Inout_ cursor_out &cursor) const
if (m_inner) { if (m_inner) {
if (dynamic_cast<config_method_pap*>(m_inner.get())) { if (dynamic_cast<config_method_pap*>(m_inner.get())) {
cursor << type_pap; cursor << eap_type_pap;
cursor << *m_inner; cursor << *m_inner;
} else { } else {
assert(0); // Unsupported inner authentication method type. assert(0); // Unsupported inner authentication method type.
cursor << type_undefined; cursor << eap_type_undefined;
} }
} else } else
cursor << type_undefined; cursor << eap_type_undefined;
cursor << m_anonymous_identity; cursor << m_anonymous_identity;
} }
@ -225,14 +225,14 @@ size_t eap::config_method_ttls::get_pk_size() const
if (m_inner) { if (m_inner) {
if (dynamic_cast<config_method_pap*>(m_inner.get())) { if (dynamic_cast<config_method_pap*>(m_inner.get())) {
size_inner = size_inner =
pksizeof(type_pap) + pksizeof(eap_type_pap) +
pksizeof(*m_inner); pksizeof(*m_inner);
} else { } else {
assert(0); // Unsupported inner authentication method type. assert(0); // Unsupported inner authentication method type.
size_inner = pksizeof(type_undefined); size_inner = pksizeof(eap_type_undefined);
} }
} else } else
size_inner = pksizeof(type_undefined); size_inner = pksizeof(eap_type_undefined);
return return
config_method::get_pk_size() + config_method::get_pk_size() +
@ -247,10 +247,10 @@ void eap::config_method_ttls::operator>>(_Inout_ cursor_in &cursor)
config_method::operator>>(cursor); config_method::operator>>(cursor);
cursor >> m_outer; cursor >> m_outer;
type_t eap_type; eap_type_t eap_type;
cursor >> eap_type; cursor >> eap_type;
switch (eap_type) { switch (eap_type) {
case type_pap: case eap_type_pap:
m_inner.reset(new config_method_pap(m_module)); m_inner.reset(new config_method_pap(m_module));
cursor >> *m_inner; cursor >> *m_inner;
break; break;
@ -263,9 +263,9 @@ void eap::config_method_ttls::operator>>(_Inout_ cursor_in &cursor)
} }
eap::type_t eap::config_method_ttls::get_method_id() const eap_type_t eap::config_method_ttls::get_method_id() const
{ {
return type_ttls; return eap_type_ttls;
} }

View File

@ -167,14 +167,14 @@ void eap::credentials_ttls::operator<<(_Inout_ cursor_out &cursor) const
cursor << m_outer; cursor << m_outer;
if (m_inner) { if (m_inner) {
if (dynamic_cast<credentials_pap*>(m_inner.get())) { if (dynamic_cast<credentials_pap*>(m_inner.get())) {
cursor << type_pap; cursor << eap_type_pap;
cursor << *m_inner; cursor << *m_inner;
} else { } else {
assert(0); // Unsupported inner authentication method type. assert(0); // Unsupported inner authentication method type.
cursor << type_undefined; cursor << eap_type_undefined;
} }
} else } else
cursor << type_undefined; cursor << eap_type_undefined;
} }
@ -184,14 +184,14 @@ size_t eap::credentials_ttls::get_pk_size() const
if (m_inner) { if (m_inner) {
if (dynamic_cast<credentials_pap*>(m_inner.get())) { if (dynamic_cast<credentials_pap*>(m_inner.get())) {
size_inner = size_inner =
pksizeof(type_pap) + pksizeof(eap_type_pap) +
pksizeof(*m_inner); pksizeof(*m_inner);
} else { } else {
assert(0); // Unsupported inner authentication method type. assert(0); // Unsupported inner authentication method type.
size_inner = pksizeof(type_undefined); size_inner = pksizeof(eap_type_undefined);
} }
} else } else
size_inner = pksizeof(type_undefined); size_inner = pksizeof(eap_type_undefined);
return return
credentials::get_pk_size() + credentials::get_pk_size() +
@ -205,10 +205,10 @@ void eap::credentials_ttls::operator>>(_Inout_ cursor_in &cursor)
credentials::operator>>(cursor); credentials::operator>>(cursor);
cursor >> m_outer; cursor >> m_outer;
type_t eap_type; eap_type_t eap_type;
cursor >> eap_type; cursor >> eap_type;
switch (eap_type) { switch (eap_type) {
case type_pap: case eap_type_pap:
m_inner.reset(new credentials_pap(m_module)); m_inner.reset(new credentials_pap(m_module));
cursor >> *m_inner; cursor >> *m_inner;
break; break;

View File

@ -28,7 +28,7 @@ using namespace winstd;
// eap::peer_ttls // eap::peer_ttls
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
eap::peer_ttls::peer_ttls() : peer<config_method_ttls, credentials_ttls, bool, bool>(type_ttls) eap::peer_ttls::peer_ttls() : peer<config_method_ttls, credentials_ttls, bool, bool>(eap_type_ttls)
{ {
} }

View File

@ -25,7 +25,7 @@
// eap::peer_ttls_ui // eap::peer_ttls_ui
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
eap::peer_ttls_ui::peer_ttls_ui() : peer_ui<eap::config_method_ttls, eap::credentials_ttls, bool, bool>(type_ttls) eap::peer_ttls_ui::peer_ttls_ui() : peer_ui<eap::config_method_ttls, eap::credentials_ttls, bool, bool>(winstd::eap_type_ttls)
{ {
} }

@ -1 +1 @@
Subproject commit 431c7d99603d0457d586d7d722e3cad27ff42dd4 Subproject commit 4b63d60b01c7f579f4da2d5d61bb766813884a9f