config_method::m_preshared moved to heap, which in turn required shift to virtual methods for packing/unpacking BLOBs
This commit is contained in:
parent
3e82e988d4
commit
ce0bbc5b45
@ -69,81 +69,6 @@ namespace eapserial
|
||||
/// \param[out] val Configuration to unpack to
|
||||
///
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config &val);
|
||||
|
||||
///
|
||||
/// Packs a method configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
template <class _Tcred> inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_method<_Tcred> &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a method configuration
|
||||
///
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
template <class _Tcred> inline size_t get_pk_size(const eap::config_method<_Tcred> &val);
|
||||
|
||||
///
|
||||
/// Unpacks a method configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Configuration to unpack to
|
||||
///
|
||||
template <class _Tcred> inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_method<_Tcred> &val);
|
||||
|
||||
///
|
||||
/// Packs a provider configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
template <class _Tmeth> 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 <class _Tmeth> 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 <class _Tmeth> 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 <class _Tprov> 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 <class _Tprov> 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 <class _Tprov> inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_providers<_Tprov> &val);
|
||||
}
|
||||
|
||||
#pragma once
|
||||
@ -246,10 +171,37 @@ namespace eap
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name BLOB management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Packs a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ unsigned char *&cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
virtual size_t get_pk_size() const;
|
||||
|
||||
///
|
||||
/// Unpacks a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ const unsigned char *&cursor);
|
||||
|
||||
/// @}
|
||||
|
||||
public:
|
||||
module &m_module; ///< Reference of the EAP module
|
||||
};
|
||||
|
||||
class credentials;
|
||||
|
||||
template <class _Tcred>
|
||||
class config_method : public config
|
||||
@ -268,8 +220,6 @@ namespace eap
|
||||
///
|
||||
config_method(_In_ module &mod) :
|
||||
m_allow_save(true),
|
||||
m_use_preshared(false),
|
||||
m_preshared(mod),
|
||||
config(mod)
|
||||
{
|
||||
}
|
||||
@ -283,8 +233,7 @@ namespace eap
|
||||
config_method(_In_ const config_method<_Tcred> &other) :
|
||||
m_allow_save(other.m_allow_save),
|
||||
m_anonymous_identity(other.m_anonymous_identity),
|
||||
m_use_preshared(other.m_use_preshared),
|
||||
m_preshared(other.m_preshared),
|
||||
m_preshared(other.m_preshared ? (credentials*)other.m_preshared->clone() : nullptr),
|
||||
config(other)
|
||||
{
|
||||
}
|
||||
@ -298,7 +247,6 @@ namespace eap
|
||||
config_method(_Inout_ config_method<_Tcred> &&other) :
|
||||
m_allow_save(std::move(other.m_allow_save)),
|
||||
m_anonymous_identity(std::move(other.m_anonymous_identity)),
|
||||
m_use_preshared(std::move(other.m_use_preshared)),
|
||||
m_preshared(std::move(other.m_preshared)),
|
||||
config(std::move(other))
|
||||
{
|
||||
@ -318,8 +266,7 @@ namespace eap
|
||||
(config&)*this = other;
|
||||
m_allow_save = other.m_allow_save;
|
||||
m_anonymous_identity = other.m_anonymous_identity;
|
||||
m_use_preshared = other.m_use_preshared;
|
||||
m_preshared = other.m_preshared;
|
||||
m_preshared.reset(other.m_preshared ? (credentials*)other.m_preshared->clone() : nullptr);
|
||||
}
|
||||
|
||||
return *this;
|
||||
@ -339,7 +286,6 @@ namespace eap
|
||||
(config&&)*this = std::move(other);
|
||||
m_allow_save = std::move(other.m_allow_save);
|
||||
m_anonymous_identity = std::move(other.m_anonymous_identity);
|
||||
m_use_preshared = std::move(other.m_use_preshared);
|
||||
m_preshared = std::move(other.m_preshared);
|
||||
}
|
||||
|
||||
@ -393,8 +339,8 @@ namespace eap
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_use_preshared)
|
||||
if (!m_preshared.save(pDoc, pXmlElClientSideCredential, ppEapError))
|
||||
if (m_preshared)
|
||||
if (!m_preshared->save(pDoc, pXmlElClientSideCredential, ppEapError))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -420,8 +366,7 @@ namespace eap
|
||||
return false;
|
||||
|
||||
m_allow_save = true;
|
||||
m_use_preshared = false;
|
||||
m_preshared.clear();
|
||||
m_preshared.reset(nullptr);
|
||||
m_anonymous_identity.clear();
|
||||
|
||||
// <ClientSideCredential>
|
||||
@ -437,14 +382,17 @@ namespace eap
|
||||
eapxml::get_element_value(pXmlElClientSideCredential, winstd::bstr(L"eap-metadata:AnonymousIdentity"), m_anonymous_identity);
|
||||
m_module.log_config((xpath + L"/AnonymousIdentity").c_str(), m_anonymous_identity.c_str());
|
||||
|
||||
if (!m_preshared.load(pXmlElClientSideCredential, ppEapError)) {
|
||||
std::unique_ptr<credentials> preshared(make_credentials());
|
||||
assert(preshared);
|
||||
if (preshared->load(pXmlElClientSideCredential, ppEapError)) {
|
||||
m_preshared = std::move(preshared);
|
||||
} else {
|
||||
// This is not really an error - merely an indication pre-shared credentials are unavailable.
|
||||
if (*ppEapError) {
|
||||
m_module.free_error_memory(*ppEapError);
|
||||
*ppEapError = NULL;
|
||||
}
|
||||
} else
|
||||
m_use_preshared = true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -452,6 +400,73 @@ namespace eap
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name BLOB management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Packs a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ unsigned char *&cursor) const
|
||||
{
|
||||
eap::config::pack(cursor);
|
||||
eapserial::pack(cursor, m_allow_save );
|
||||
eapserial::pack(cursor, m_anonymous_identity);
|
||||
if (m_preshared) {
|
||||
eapserial::pack(cursor, true);
|
||||
m_preshared->pack(cursor);
|
||||
} else
|
||||
eapserial::pack(cursor, false);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
virtual size_t get_pk_size() const
|
||||
{
|
||||
return
|
||||
eap::config::get_pk_size() +
|
||||
eapserial::get_pk_size(m_allow_save ) +
|
||||
eapserial::get_pk_size(m_anonymous_identity) +
|
||||
(m_preshared ?
|
||||
eapserial::get_pk_size(true) +
|
||||
m_preshared->get_pk_size() :
|
||||
eapserial::get_pk_size(false));
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unpacks a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ const unsigned char *&cursor)
|
||||
{
|
||||
eap::config::unpack(cursor);
|
||||
eapserial::unpack(cursor, m_allow_save );
|
||||
eapserial::unpack(cursor, m_anonymous_identity);
|
||||
|
||||
bool use_preshared;
|
||||
eapserial::unpack(cursor, use_preshared);
|
||||
if (use_preshared) {
|
||||
m_preshared.reset(make_credentials());
|
||||
assert(m_preshared);
|
||||
m_preshared->unpack(cursor);
|
||||
} else
|
||||
m_preshared.reset(nullptr);
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
///
|
||||
/// Makes new set of credentials for the given method type
|
||||
///
|
||||
virtual credentials* make_credentials() const = 0;
|
||||
|
||||
///
|
||||
/// Returns EAP method type of this configuration
|
||||
///
|
||||
@ -460,10 +475,9 @@ namespace eap
|
||||
virtual type_t get_method_id() const = 0;
|
||||
|
||||
public:
|
||||
bool m_allow_save; ///< Are credentials allowed to be saved to Windows Credential Manager?
|
||||
std::wstring m_anonymous_identity; ///< Anonymous identity
|
||||
bool m_use_preshared; ///< Does configuration use pre-shared credentials?
|
||||
_Tcred m_preshared; ///< Pre-shared credentials
|
||||
bool m_allow_save; ///< Are credentials allowed to be saved to Windows Credential Manager?
|
||||
std::wstring m_anonymous_identity; ///< Anonymous identity
|
||||
std::unique_ptr<credentials> m_preshared; ///< Pre-shared credentials
|
||||
};
|
||||
|
||||
|
||||
@ -830,6 +844,82 @@ namespace eap
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name BLOB management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Packs a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ unsigned char *&cursor) const
|
||||
{
|
||||
eap::config::pack(cursor);
|
||||
eapserial::pack(cursor, m_read_only );
|
||||
eapserial::pack(cursor, m_id );
|
||||
eapserial::pack(cursor, m_name );
|
||||
eapserial::pack(cursor, m_help_email );
|
||||
eapserial::pack(cursor, m_help_web );
|
||||
eapserial::pack(cursor, m_help_phone );
|
||||
eapserial::pack(cursor, m_lbl_alt_credential);
|
||||
eapserial::pack(cursor, m_lbl_alt_identity );
|
||||
eapserial::pack(cursor, m_lbl_alt_password );
|
||||
eapserial::pack(cursor, m_methods );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
virtual size_t get_pk_size() const
|
||||
{
|
||||
return
|
||||
eap::config::get_pk_size() +
|
||||
eapserial::get_pk_size(m_read_only ) +
|
||||
eapserial::get_pk_size(m_id ) +
|
||||
eapserial::get_pk_size(m_name ) +
|
||||
eapserial::get_pk_size(m_help_email ) +
|
||||
eapserial::get_pk_size(m_help_web ) +
|
||||
eapserial::get_pk_size(m_help_phone ) +
|
||||
eapserial::get_pk_size(m_lbl_alt_credential) +
|
||||
eapserial::get_pk_size(m_lbl_alt_identity ) +
|
||||
eapserial::get_pk_size(m_lbl_alt_password ) +
|
||||
eapserial::get_pk_size(m_methods );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unpacks a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ const unsigned char *&cursor)
|
||||
{
|
||||
eap::config::unpack(cursor);
|
||||
eapserial::unpack(cursor, m_read_only );
|
||||
eapserial::unpack(cursor, m_id );
|
||||
eapserial::unpack(cursor, m_name );
|
||||
eapserial::unpack(cursor, m_help_email );
|
||||
eapserial::unpack(cursor, m_help_web );
|
||||
eapserial::unpack(cursor, m_help_phone );
|
||||
eapserial::unpack(cursor, m_lbl_alt_credential);
|
||||
eapserial::unpack(cursor, m_lbl_alt_identity );
|
||||
eapserial::unpack(cursor, m_lbl_alt_password );
|
||||
|
||||
std::list<_Tmeth>::size_type count;
|
||||
eapserial::unpack(cursor, count);
|
||||
m_methods.clear();
|
||||
for (std::list<_Tmeth>::size_type i = 0; i < count; i++) {
|
||||
_Tmeth el(m_module);
|
||||
el.unpack(cursor);
|
||||
m_methods.push_back(std::move(el));
|
||||
}
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
public:
|
||||
bool m_read_only; ///< Is profile read-only
|
||||
std::wstring m_id; ///< Profile ID
|
||||
@ -1018,6 +1108,55 @@ namespace eap
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name BLOB management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Packs a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ unsigned char *&cursor) const
|
||||
{
|
||||
eap::config::pack(cursor);
|
||||
eapserial::pack(cursor, m_providers);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
virtual size_t get_pk_size() const
|
||||
{
|
||||
return
|
||||
eap::config::get_pk_size() +
|
||||
eapserial::get_pk_size(m_providers);
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Unpacks a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ const unsigned char *&cursor)
|
||||
{
|
||||
eap::config::unpack(cursor);
|
||||
|
||||
std::list<_Tprov>::size_type count = *(const std::list<_Tprov>::size_type*&)cursor;
|
||||
eapserial::unpack(cursor, count);
|
||||
m_providers.clear();
|
||||
for (std::list<_Tprov>::size_type i = 0; i < count; i++) {
|
||||
_Tprov el(m_module);
|
||||
el.unpack(cursor);
|
||||
m_providers.push_back(std::move(el));
|
||||
}
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
public:
|
||||
std::list<_Tprov> m_providers; ///< List of provider configurations
|
||||
};
|
||||
@ -1028,148 +1167,18 @@ namespace eapserial
|
||||
{
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config &val)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(cursor);
|
||||
UNREFERENCED_PARAMETER(val );
|
||||
val.pack(cursor);
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(const eap::config &val)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(val);
|
||||
return 0;
|
||||
return val.get_pk_size();
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config &val)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(cursor);
|
||||
UNREFERENCED_PARAMETER(val );
|
||||
}
|
||||
|
||||
|
||||
template <class _Tcred>
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_method<_Tcred> &val)
|
||||
{
|
||||
pack(cursor, (const eap::config&)val );
|
||||
pack(cursor, val.m_allow_save );
|
||||
pack(cursor, val.m_anonymous_identity);
|
||||
pack(cursor, val.m_use_preshared );
|
||||
pack(cursor, val.m_preshared );
|
||||
}
|
||||
|
||||
|
||||
template <class _Tcred>
|
||||
inline size_t get_pk_size(const eap::config_method<_Tcred> &val)
|
||||
{
|
||||
return
|
||||
get_pk_size((const eap::config&)val ) +
|
||||
get_pk_size(val.m_allow_save ) +
|
||||
get_pk_size(val.m_anonymous_identity) +
|
||||
get_pk_size(val.m_use_preshared ) +
|
||||
get_pk_size(val.m_preshared );
|
||||
}
|
||||
|
||||
|
||||
template <class _Tcred>
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_method<_Tcred> &val)
|
||||
{
|
||||
unpack(cursor, (eap::config&)val );
|
||||
unpack(cursor, val.m_allow_save );
|
||||
unpack(cursor, val.m_anonymous_identity);
|
||||
unpack(cursor, val.m_use_preshared );
|
||||
unpack(cursor, val.m_preshared );
|
||||
}
|
||||
|
||||
|
||||
template <class _Tmeth>
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_provider<_Tmeth> &val)
|
||||
{
|
||||
pack(cursor, (const eap::config&)val );
|
||||
pack(cursor, val.m_read_only );
|
||||
pack(cursor, val.m_id );
|
||||
pack(cursor, val.m_name );
|
||||
pack(cursor, val.m_help_email );
|
||||
pack(cursor, val.m_help_web );
|
||||
pack(cursor, val.m_help_phone );
|
||||
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 <class _Tmeth>
|
||||
inline size_t get_pk_size(const eap::config_provider<_Tmeth> &val)
|
||||
{
|
||||
return
|
||||
get_pk_size((const eap::config&)val ) +
|
||||
get_pk_size(val.m_read_only ) +
|
||||
get_pk_size(val.m_id ) +
|
||||
get_pk_size(val.m_name ) +
|
||||
get_pk_size(val.m_help_email ) +
|
||||
get_pk_size(val.m_help_web ) +
|
||||
get_pk_size(val.m_help_phone ) +
|
||||
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 <class _Tmeth>
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_provider<_Tmeth> &val)
|
||||
{
|
||||
unpack(cursor, (eap::config&)val );
|
||||
unpack(cursor, val.m_read_only );
|
||||
unpack(cursor, val.m_id );
|
||||
unpack(cursor, val.m_name );
|
||||
unpack(cursor, val.m_help_email );
|
||||
unpack(cursor, val.m_help_web );
|
||||
unpack(cursor, val.m_help_phone );
|
||||
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 <class _Tprov>
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_providers<_Tprov> &val)
|
||||
{
|
||||
pack(cursor, (const eap::config&)val);
|
||||
pack(cursor, val.m_providers );
|
||||
}
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
inline size_t get_pk_size(const eap::config_providers<_Tprov> &val)
|
||||
{
|
||||
return
|
||||
get_pk_size((const eap::config&)val) +
|
||||
get_pk_size(val.m_providers );
|
||||
}
|
||||
|
||||
|
||||
template <class _Tprov>
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_providers<_Tprov> &val)
|
||||
{
|
||||
unpack(cursor, (eap::config&)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));
|
||||
}
|
||||
val.unpack(cursor);
|
||||
}
|
||||
}
|
||||
|
@ -33,59 +33,6 @@ namespace eap
|
||||
class credentials_pass;
|
||||
}
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
///
|
||||
/// 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);
|
||||
|
||||
///
|
||||
/// 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"
|
||||
@ -339,6 +286,32 @@ namespace eap
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name BLOB management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Packs a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ unsigned char *&cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
virtual size_t get_pk_size() const;
|
||||
|
||||
///
|
||||
/// Unpacks a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ const unsigned char *&cursor);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Storage
|
||||
/// @{
|
||||
|
||||
@ -383,49 +356,3 @@ namespace eap
|
||||
/// \endcond
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials &val)
|
||||
{
|
||||
pack(cursor, (const eap::config&)val);
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(const eap::credentials &val)
|
||||
{
|
||||
return get_pk_size((const eap::config&)val);
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials &val)
|
||||
{
|
||||
unpack(cursor, (eap::config&)val);
|
||||
}
|
||||
|
||||
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_pass &val)
|
||||
{
|
||||
pack(cursor, (const eap::credentials&)val);
|
||||
pack(cursor, val.m_identity );
|
||||
pack(cursor, val.m_password );
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(const eap::credentials_pass &val)
|
||||
{
|
||||
return
|
||||
get_pk_size((const eap::credentials&)val) +
|
||||
get_pk_size(val.m_identity ) +
|
||||
get_pk_size(val.m_password );
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_pass &val)
|
||||
{
|
||||
unpack(cursor, (eap::credentials&)val);
|
||||
unpack(cursor, val.m_identity );
|
||||
unpack(cursor, val.m_password );
|
||||
}
|
||||
}
|
||||
|
@ -403,8 +403,7 @@ namespace eapserial
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::vector<_Ty, _Ax> &val)
|
||||
{
|
||||
std::vector<_Ty, _Ax>::size_type count = val.size();
|
||||
*(std::vector<_Ty, _Ax>::size_type*&)cursor = count;
|
||||
cursor += sizeof(std::vector<_Ty, _Ax>::size_type);
|
||||
pack(cursor, count);
|
||||
|
||||
// Since we do not know wheter vector elements are primitives or objects, iterate instead of memcpy.
|
||||
// For performance critical vectors of flat opaque data types write specialized template instantiation.
|
||||
@ -418,8 +417,9 @@ namespace eapserial
|
||||
{
|
||||
// Since we do not know wheter vector elements are primitives or objects, iterate instead of sizeof().
|
||||
// For performance critical vectors of flat opaque data types write specialized template instantiation.
|
||||
size_t size = sizeof(std::vector<_Ty, _Ax>::size_type);
|
||||
for (std::vector<_Ty, _Ax>::size_type i = 0, count = val.size(); i < count; i++)
|
||||
std::vector<_Ty, _Ax>::size_type count = val.size();
|
||||
size_t size = get_pk_size(count);
|
||||
for (std::vector<_Ty, _Ax>::size_type i = 0; i < count; i++)
|
||||
size += get_pk_size(val[i]);
|
||||
return size;
|
||||
}
|
||||
@ -428,8 +428,8 @@ namespace eapserial
|
||||
template<class _Ty, class _Ax>
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::vector<_Ty, _Ax> &val)
|
||||
{
|
||||
std::vector<_Ty, _Ax>::size_type count = *(const std::vector<_Ty, _Ax>::size_type*&)cursor;
|
||||
cursor += sizeof(std::vector<_Ty, _Ax>::size_type);
|
||||
std::vector<_Ty, _Ax>::size_type count;
|
||||
unpack(cursor, count);
|
||||
|
||||
// Since we do not know wheter vector elements are primitives or objects, iterate instead of assign().
|
||||
// For performance critical vectors of flat opaque data types write specialized template instantiation.
|
||||
@ -447,8 +447,7 @@ namespace eapserial
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const std::list<_Ty, _Ax> &val)
|
||||
{
|
||||
std::list<_Ty, _Ax>::size_type count = val.size();
|
||||
*(std::list<_Ty, _Ax>::size_type*&)cursor = count;
|
||||
cursor += sizeof(std::list<_Ty, _Ax>::size_type);
|
||||
pack(cursor, count);
|
||||
|
||||
// Since we do not know wheter list elements are primitives or objects, iterate instead of memcpy.
|
||||
// For performance critical vectors of flat opaque data types write specialized template instantiation.
|
||||
@ -462,7 +461,8 @@ namespace eapserial
|
||||
{
|
||||
// Since we do not know wheter list elements are primitives or objects, iterate instead of sizeof().
|
||||
// For performance critical vectors of flat opaque data types write specialized template instantiation.
|
||||
size_t size = sizeof(std::list<_Ty, _Ax>::size_type);
|
||||
std::list<_Ty, _Ax>::size_type count = val.size();
|
||||
size_t size = get_pk_size(count);
|
||||
for (std::list<_Ty, _Ax>::const_iterator i = val.cbegin(), i_end = val.cend(); i != i_end; ++i)
|
||||
size += get_pk_size(*i);
|
||||
return size;
|
||||
@ -472,8 +472,8 @@ namespace eapserial
|
||||
template<class _Ty, class _Ax>
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ std::list<_Ty, _Ax> &val)
|
||||
{
|
||||
std::list<_Ty, _Ax>::size_type count = *(const std::list<_Ty, _Ax>::size_type*&)cursor;
|
||||
cursor += sizeof(std::list<_Ty, _Ax>::size_type);
|
||||
std::list<_Ty, _Ax>::size_type count;
|
||||
unpack(cursor, count);
|
||||
|
||||
// Since we do not know wheter list elements are primitives or objects, iterate instead of assign().
|
||||
// For performance critical vectors of flat opaque data types write specialized template instantiation.
|
||||
@ -489,37 +489,36 @@ namespace eapserial
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const winstd::cert_context &val)
|
||||
{
|
||||
if (val) {
|
||||
*(DWORD*&)cursor = val->dwCertEncodingType;
|
||||
cursor += sizeof(DWORD);
|
||||
|
||||
*(DWORD*&)cursor = val->cbCertEncoded;
|
||||
cursor += sizeof(DWORD);
|
||||
|
||||
pack(cursor, (unsigned int)val->dwCertEncodingType);
|
||||
pack(cursor, (unsigned int)val->cbCertEncoded );
|
||||
memcpy(cursor, val->pbCertEncoded, val->cbCertEncoded);
|
||||
cursor += val->cbCertEncoded;
|
||||
} else {
|
||||
*(DWORD*&)cursor = 0;
|
||||
cursor += sizeof(DWORD);
|
||||
|
||||
*(DWORD*&)cursor = 0;
|
||||
cursor += sizeof(DWORD);
|
||||
pack(cursor, (unsigned int)0);
|
||||
pack(cursor, (unsigned int)0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(const winstd::cert_context &val)
|
||||
{
|
||||
return sizeof(DWORD) + sizeof(DWORD) + (val ? val->cbCertEncoded : 0);
|
||||
return
|
||||
val ?
|
||||
get_pk_size((unsigned int)val->dwCertEncodingType) +
|
||||
get_pk_size((unsigned int)val->cbCertEncoded ) +
|
||||
val->cbCertEncoded :
|
||||
get_pk_size((unsigned int)0) +
|
||||
get_pk_size((unsigned int)0);
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ winstd::cert_context &val)
|
||||
{
|
||||
DWORD dwCertEncodingType = *(DWORD*&)cursor;
|
||||
cursor += sizeof(DWORD);
|
||||
DWORD dwCertEncodingType;
|
||||
unpack(cursor, (unsigned int&)dwCertEncodingType);
|
||||
|
||||
DWORD dwCertEncodedSize = *(DWORD*&)cursor;
|
||||
cursor += sizeof(DWORD);
|
||||
DWORD dwCertEncodedSize;
|
||||
unpack(cursor, (unsigned int&)dwCertEncodedSize);
|
||||
|
||||
if (dwCertEncodedSize) {
|
||||
val.create(dwCertEncodingType, (BYTE*)cursor, dwCertEncodedSize);
|
||||
|
@ -79,3 +79,21 @@ bool eap::config::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapErr
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void eap::config::pack(_Inout_ unsigned char *&cursor) const
|
||||
{
|
||||
UNREFERENCED_PARAMETER(cursor);
|
||||
}
|
||||
|
||||
|
||||
size_t eap::config::get_pk_size() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void eap::config::unpack(_Inout_ const unsigned char *&cursor)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(cursor);
|
||||
}
|
||||
|
@ -233,6 +233,31 @@ bool eap::credentials_pass::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_pass::pack(_Inout_ unsigned char *&cursor) const
|
||||
{
|
||||
eap::credentials::pack(cursor);
|
||||
eapserial::pack(cursor, m_identity);
|
||||
eapserial::pack(cursor, m_password);
|
||||
}
|
||||
|
||||
|
||||
size_t eap::credentials_pass::get_pk_size() const
|
||||
{
|
||||
return
|
||||
eap::credentials::get_pk_size() +
|
||||
eapserial::get_pk_size(m_identity) +
|
||||
eapserial::get_pk_size(m_password);
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_pass::unpack(_Inout_ const unsigned char *&cursor)
|
||||
{
|
||||
eap::credentials::unpack(cursor);
|
||||
eapserial::unpack(cursor, m_identity);
|
||||
eapserial::unpack(cursor, m_password);
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials_pass::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
assert(pszTargetName);
|
||||
|
@ -345,7 +345,7 @@ public:
|
||||
m_prov(prov),
|
||||
m_cfg(cfg),
|
||||
m_target(pszCredTarget),
|
||||
m_cred(m_cfg.m_module),
|
||||
m_cred(cfg.make_credentials()),
|
||||
wxEAPCredentialsConfigPanelBase(parent)
|
||||
{
|
||||
// Load and set icon.
|
||||
@ -366,12 +366,11 @@ protected:
|
||||
m_preshared_set ->Enable(false);
|
||||
}
|
||||
|
||||
if (!m_cfg.m_use_preshared) {
|
||||
if (!m_cfg.m_preshared) {
|
||||
m_own->SetValue(true);
|
||||
m_cred.clear();
|
||||
} else {
|
||||
m_preshared->SetValue(true);
|
||||
m_cred = m_cfg.m_preshared;
|
||||
m_cred.reset((eap::credentials*)m_cfg.m_preshared->clone());
|
||||
}
|
||||
|
||||
return wxEAPCredentialsConfigPanelBase::TransferDataToWindow();
|
||||
@ -384,12 +383,7 @@ protected:
|
||||
|
||||
if (!m_prov.m_read_only) {
|
||||
// This is not a provider-locked configuration. Save the data.
|
||||
if (m_own->GetValue()) {
|
||||
m_cfg.m_use_preshared = false;
|
||||
} else {
|
||||
m_cfg.m_use_preshared = true;
|
||||
m_cfg.m_preshared = m_cred;
|
||||
}
|
||||
m_cfg.m_preshared.reset(m_own->GetValue() ? nullptr : (eap::credentials*)m_cred->clone());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -404,7 +398,7 @@ protected:
|
||||
if (m_cfg.m_allow_save) {
|
||||
bool has_own;
|
||||
std::unique_ptr<CREDENTIAL, winstd::CredFree_delete<CREDENTIAL> > cred;
|
||||
if (CredRead(m_cred.target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) {
|
||||
if (CredRead(m_cred->target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0, (PCREDENTIAL*)&cred)) {
|
||||
m_own_identity->SetValue(cred->UserName && cred->UserName[0] != 0 ? cred->UserName : _("<blank>"));
|
||||
has_own = true;
|
||||
} else if ((dwResult = GetLastError()) == ERROR_NOT_FOUND) {
|
||||
@ -432,7 +426,7 @@ protected:
|
||||
m_own_clear ->Enable(false);
|
||||
}
|
||||
|
||||
m_preshared_identity->SetValue(!m_cred.empty() ? m_cred.get_name() : _("<blank>"));
|
||||
m_preshared_identity->SetValue(!m_cred->empty() ? m_cred->get_name() : _("<blank>"));
|
||||
|
||||
if (!m_prov.m_read_only) {
|
||||
// This is not a provider-locked configuration. Selectively enable/disable controls.
|
||||
@ -453,7 +447,7 @@ protected:
|
||||
|
||||
wxEAPCredentialsDialog<_Tprov> dlg(m_prov, this);
|
||||
|
||||
_wxT *panel = new _wxT(m_prov, m_cred, m_target.c_str(), &dlg, true);
|
||||
_wxT *panel = new _wxT(m_prov, (typename _Tmeth::credentials_type&)*m_cred, m_target.c_str(), &dlg, true);
|
||||
|
||||
dlg.AddContents((wxPanel**)&panel, 1);
|
||||
dlg.ShowModal();
|
||||
@ -464,7 +458,7 @@ protected:
|
||||
{
|
||||
UNREFERENCED_PARAMETER(event);
|
||||
|
||||
if (!CredDelete(m_cred.target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0))
|
||||
if (!CredDelete(m_cred->target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0))
|
||||
wxLogError(_("Deleting credentials failed (error %u)."), GetLastError());
|
||||
}
|
||||
|
||||
@ -475,7 +469,7 @@ protected:
|
||||
|
||||
wxEAPCredentialsDialog<_Tprov> dlg(m_prov, this);
|
||||
|
||||
_wxT *panel = new _wxT(m_prov, m_cred, _T(""), &dlg, true);
|
||||
_wxT *panel = new _wxT(m_prov, (typename _Tmeth::credentials_type&)*m_cred, _T(""), &dlg, true);
|
||||
|
||||
dlg.AddContents((wxPanel**)&panel, 1);
|
||||
dlg.ShowModal();
|
||||
@ -491,7 +485,7 @@ protected:
|
||||
winstd::tstring m_target; ///< Credential Manager target
|
||||
|
||||
private:
|
||||
typename _Tmeth::credentials_type m_cred; ///< Temporary credential data
|
||||
std::unique_ptr<eap::credentials> m_cred; ///< Temporary credential data
|
||||
};
|
||||
|
||||
|
||||
|
@ -28,34 +28,6 @@ namespace eap
|
||||
class config_method_pap;
|
||||
}
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
///
|
||||
/// Packs a PAP 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_method_pap &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a PAP 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_method_pap &val);
|
||||
|
||||
///
|
||||
/// Unpacks a PAP 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_method_pap &val);
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Credentials.h"
|
||||
@ -117,6 +89,11 @@ namespace eap
|
||||
///
|
||||
virtual config* clone() const;
|
||||
|
||||
///
|
||||
/// Makes new set of credentials for the given method type
|
||||
///
|
||||
virtual credentials* make_credentials() const;
|
||||
|
||||
///
|
||||
/// Returns EAP method type of this configuration
|
||||
///
|
||||
@ -125,24 +102,3 @@ namespace eap
|
||||
virtual eap::type_t get_method_id() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_method_pap &val)
|
||||
{
|
||||
pack(cursor, (const eap::config_method<eap::credentials_pap>&)val);
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(const eap::config_method_pap &val)
|
||||
{
|
||||
return get_pk_size((const eap::config_method<eap::credentials_pap>&)val);
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_method_pap &val)
|
||||
{
|
||||
unpack(cursor, (eap::config_method<eap::credentials_pap>&)val);
|
||||
}
|
||||
}
|
||||
|
@ -29,34 +29,6 @@ namespace eap
|
||||
class credentials_pap;
|
||||
}
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
///
|
||||
/// Packs a PAP method credentials
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Credentials to pack
|
||||
///
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_pap &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a PAP 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_pap &val);
|
||||
|
||||
///
|
||||
/// Unpacks a PAP 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_pap &val);
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../EAPBase/include/Credentials.h"
|
||||
@ -129,24 +101,3 @@ namespace eap
|
||||
/// @}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_pap &val)
|
||||
{
|
||||
pack(cursor, (const eap::credentials_pass&)val);
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(const eap::credentials_pap &val)
|
||||
{
|
||||
return get_pk_size((const eap::credentials_pass&)val);
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_pap &val)
|
||||
{
|
||||
unpack(cursor, (eap::credentials_pass&)val);
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,12 @@ eap::config* eap::config_method_pap::clone() const
|
||||
}
|
||||
|
||||
|
||||
eap::credentials* eap::config_method_pap::make_credentials() const
|
||||
{
|
||||
return new credentials_pap(m_module);
|
||||
}
|
||||
|
||||
|
||||
eap::type_t eap::config_method_pap::get_method_id() const
|
||||
{
|
||||
return eap::type_pap;
|
||||
|
@ -38,34 +38,6 @@ namespace eap
|
||||
winstd::tstring get_cert_title(PCCERT_CONTEXT cert);
|
||||
}
|
||||
|
||||
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_method_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_method_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_method_tls &val);
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Credentials.h"
|
||||
@ -161,6 +133,37 @@ namespace eap
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name BLOB management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Packs a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ unsigned char *&cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
virtual size_t get_pk_size() const;
|
||||
|
||||
///
|
||||
/// Unpacks a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ const unsigned char *&cursor);
|
||||
|
||||
/// @}
|
||||
|
||||
///
|
||||
/// Makes new set of credentials for the given method type
|
||||
///
|
||||
virtual credentials* make_credentials() const;
|
||||
|
||||
///
|
||||
/// Returns EAP method type of this configuration
|
||||
///
|
||||
@ -180,31 +183,3 @@ namespace eap
|
||||
std::list<std::string> m_server_names; ///< Acceptable authenticating server names
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_method_tls &val)
|
||||
{
|
||||
pack(cursor, (const eap::config_method<eap::credentials_tls>&)val);
|
||||
pack(cursor, val.m_trusted_root_ca);
|
||||
pack(cursor, val.m_server_names );
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(const eap::config_method_tls &val)
|
||||
{
|
||||
return
|
||||
get_pk_size((const eap::config_method<eap::credentials_tls>&)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_method_tls &val)
|
||||
{
|
||||
unpack(cursor, (eap::config_method<eap::credentials_tls>&)val);
|
||||
unpack(cursor, val.m_trusted_root_ca);
|
||||
unpack(cursor, val.m_server_names );
|
||||
}
|
||||
}
|
||||
|
@ -28,34 +28,6 @@ namespace eap
|
||||
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"
|
||||
@ -158,6 +130,32 @@ namespace eap
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name BLOB management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Packs a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ unsigned char *&cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
virtual size_t get_pk_size() const;
|
||||
|
||||
///
|
||||
/// Unpacks a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ const unsigned char *&cursor);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Storage
|
||||
/// @{
|
||||
|
||||
@ -217,28 +215,3 @@ namespace eap
|
||||
/// \endcond
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_tls &val)
|
||||
{
|
||||
unpack(cursor, (eap::credentials&)val);
|
||||
unpack(cursor, val.m_cert );
|
||||
}
|
||||
}
|
||||
|
@ -256,6 +256,37 @@ bool eap::config_method_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
|
||||
}
|
||||
|
||||
|
||||
void eap::config_method_tls::pack(_Inout_ unsigned char *&cursor) const
|
||||
{
|
||||
eap::config_method<eap::credentials_tls>::pack(cursor);
|
||||
eapserial::pack(cursor, m_trusted_root_ca);
|
||||
eapserial::pack(cursor, m_server_names );
|
||||
}
|
||||
|
||||
|
||||
size_t eap::config_method_tls::get_pk_size() const
|
||||
{
|
||||
return
|
||||
eap::config_method<eap::credentials_tls>::get_pk_size() +
|
||||
eapserial::get_pk_size(m_trusted_root_ca) +
|
||||
eapserial::get_pk_size(m_server_names );
|
||||
}
|
||||
|
||||
|
||||
void eap::config_method_tls::unpack(_Inout_ const unsigned char *&cursor)
|
||||
{
|
||||
eap::config_method<eap::credentials_tls>::unpack(cursor);
|
||||
eapserial::unpack(cursor, m_trusted_root_ca);
|
||||
eapserial::unpack(cursor, m_server_names );
|
||||
}
|
||||
|
||||
|
||||
eap::credentials* eap::config_method_tls::make_credentials() const
|
||||
{
|
||||
return new credentials_tls(m_module);
|
||||
}
|
||||
|
||||
|
||||
eap::type_t eap::config_method_tls::get_method_id() const
|
||||
{
|
||||
return eap::type_tls;
|
||||
|
@ -167,6 +167,28 @@ bool eap::credentials_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR *
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_tls::pack(_Inout_ unsigned char *&cursor) const
|
||||
{
|
||||
eap::credentials::pack(cursor);
|
||||
eapserial::pack(cursor, m_cert);
|
||||
}
|
||||
|
||||
|
||||
size_t eap::credentials_tls::get_pk_size() const
|
||||
{
|
||||
return
|
||||
eap::credentials::get_pk_size() +
|
||||
eapserial::get_pk_size(m_cert);
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_tls::unpack(_Inout_ const unsigned char *&cursor)
|
||||
{
|
||||
eap::credentials::unpack(cursor);
|
||||
eapserial::unpack(cursor, m_cert);
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials_tls::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
assert(pszTargetName);
|
||||
|
@ -28,34 +28,6 @@ namespace eap
|
||||
class config_method_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_method_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_method_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_method_ttls &val);
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../TLS/include/Config.h"
|
||||
@ -147,6 +119,30 @@ namespace eap {
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name BLOB management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Packs a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ unsigned char *&cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
virtual size_t get_pk_size() const;
|
||||
|
||||
///
|
||||
/// Unpacks a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ const unsigned char *&cursor);
|
||||
|
||||
///
|
||||
/// Returns EAP method type of this configuration
|
||||
///
|
||||
@ -158,61 +154,3 @@ namespace eap {
|
||||
std::unique_ptr<config> m_inner; ///< Inner authentication configuration
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_method_ttls &val)
|
||||
{
|
||||
pack(cursor, (const eap::config_method_tls&)val);
|
||||
if (val.m_inner) {
|
||||
if (dynamic_cast<eap::config_method_pap*>(val.m_inner.get())) {
|
||||
pack(cursor, eap::type_pap);
|
||||
pack(cursor, (const eap::config_method_pap&)*val.m_inner);
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
pack(cursor, eap::type_undefined);
|
||||
}
|
||||
} else
|
||||
pack(cursor, eap::type_undefined);
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(const eap::config_method_ttls &val)
|
||||
{
|
||||
size_t size_inner;
|
||||
if (val.m_inner) {
|
||||
if (dynamic_cast<eap::config_method_pap*>(val.m_inner.get())) {
|
||||
size_inner =
|
||||
get_pk_size(eap::type_pap) +
|
||||
get_pk_size((const eap::config_method_pap&)*val.m_inner);
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
size_inner = get_pk_size(eap::type_undefined);
|
||||
}
|
||||
} else
|
||||
size_inner = get_pk_size(eap::type_undefined);
|
||||
|
||||
return
|
||||
get_pk_size((const eap::config_method_tls&)val) +
|
||||
size_inner;
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::config_method_ttls &val)
|
||||
{
|
||||
unpack(cursor, (eap::config_method_tls&)val);
|
||||
|
||||
eap::type_t eap_type;
|
||||
unpack(cursor, eap_type);
|
||||
switch (eap_type) {
|
||||
case eap::type_pap:
|
||||
val.m_inner.reset(new eap::config_method_pap(val.m_module));
|
||||
unpack(cursor, (eap::config_method_pap&)*val.m_inner);
|
||||
break;
|
||||
default:
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
val.m_inner.reset(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,34 +26,6 @@ namespace eap
|
||||
class credentials_ttls;
|
||||
}
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
///
|
||||
/// Packs a TTLS based method credentials
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_ttls &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a TTLS based method credentials
|
||||
///
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
inline size_t get_pk_size(const eap::credentials_ttls &val);
|
||||
|
||||
///
|
||||
/// Unpacks a TTLS based method credentials
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Configuration to unpack to
|
||||
///
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_ttls &val);
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../TLS/include/Credentials.h"
|
||||
@ -153,6 +125,30 @@ namespace eap
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name BLOB management
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// Packs a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ unsigned char *&cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
virtual size_t get_pk_size() const;
|
||||
|
||||
///
|
||||
/// Unpacks a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ const unsigned char *&cursor);
|
||||
|
||||
/// \name Storage
|
||||
/// @{
|
||||
|
||||
@ -186,61 +182,3 @@ namespace eap
|
||||
std::unique_ptr<credentials> m_inner; ///< Inner credentials
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::credentials_ttls &val)
|
||||
{
|
||||
pack(cursor, (const eap::credentials_tls&)val);
|
||||
if (val.m_inner) {
|
||||
if (dynamic_cast<eap::credentials_pap*>(val.m_inner.get())) {
|
||||
pack(cursor, eap::type_pap);
|
||||
pack(cursor, (const eap::credentials_pap&)*val.m_inner);
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
pack(cursor, eap::type_undefined);
|
||||
}
|
||||
} else
|
||||
pack(cursor, eap::type_undefined);
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(const eap::credentials_ttls &val)
|
||||
{
|
||||
size_t size_inner;
|
||||
if (val.m_inner) {
|
||||
if (dynamic_cast<eap::credentials_pap*>(val.m_inner.get())) {
|
||||
size_inner =
|
||||
get_pk_size(eap::type_pap) +
|
||||
get_pk_size((const eap::credentials_pap&)*val.m_inner);
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
size_inner = get_pk_size(eap::type_undefined);
|
||||
}
|
||||
} else
|
||||
size_inner = get_pk_size(eap::type_undefined);
|
||||
|
||||
return
|
||||
get_pk_size((const eap::credentials_tls&)val) +
|
||||
size_inner;
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ const unsigned char *&cursor, _Out_ eap::credentials_ttls &val)
|
||||
{
|
||||
unpack(cursor, (eap::credentials_tls&)val);
|
||||
|
||||
eap::type_t eap_type;
|
||||
unpack(cursor, eap_type);
|
||||
switch (eap_type) {
|
||||
case eap::type_pap:
|
||||
val.m_inner.reset(new eap::credentials_pap(val.m_module));
|
||||
unpack(cursor, (eap::credentials_pap&)*val.m_inner);
|
||||
break;
|
||||
default:
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
val.m_inner.reset(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -158,6 +158,61 @@ bool eap::config_method_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERRO
|
||||
}
|
||||
|
||||
|
||||
void eap::config_method_ttls::pack(_Inout_ unsigned char *&cursor) const
|
||||
{
|
||||
eap::config_method_tls::pack(cursor);
|
||||
if (m_inner) {
|
||||
if (dynamic_cast<eap::config_method_pap*>(m_inner.get())) {
|
||||
eapserial::pack(cursor, eap::type_pap);
|
||||
m_inner->pack(cursor);
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
eapserial::pack(cursor, eap::type_undefined);
|
||||
}
|
||||
} else
|
||||
eapserial::pack(cursor, eap::type_undefined);
|
||||
}
|
||||
|
||||
|
||||
size_t eap::config_method_ttls::get_pk_size() const
|
||||
{
|
||||
size_t size_inner;
|
||||
if (m_inner) {
|
||||
if (dynamic_cast<eap::config_method_pap*>(m_inner.get())) {
|
||||
size_inner =
|
||||
eapserial::get_pk_size(eap::type_pap) +
|
||||
m_inner->get_pk_size();
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
size_inner = eapserial::get_pk_size(eap::type_undefined);
|
||||
}
|
||||
} else
|
||||
size_inner = eapserial::get_pk_size(eap::type_undefined);
|
||||
|
||||
return
|
||||
eap::config_method_tls::get_pk_size() +
|
||||
size_inner;
|
||||
}
|
||||
|
||||
|
||||
void eap::config_method_ttls::unpack(_Inout_ const unsigned char *&cursor)
|
||||
{
|
||||
eap::config_method_tls::unpack(cursor);
|
||||
|
||||
eap::type_t eap_type;
|
||||
eapserial::unpack(cursor, eap_type);
|
||||
switch (eap_type) {
|
||||
case eap::type_pap:
|
||||
m_inner.reset(new eap::config_method_pap(m_module));
|
||||
m_inner->unpack(cursor);
|
||||
break;
|
||||
default:
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
m_inner.reset(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
eap::type_t eap::config_method_ttls::get_method_id() const
|
||||
{
|
||||
return eap::type_ttls;
|
||||
|
@ -149,6 +149,61 @@ bool eap::credentials_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_ttls::pack(_Inout_ unsigned char *&cursor) const
|
||||
{
|
||||
eap::credentials_tls::pack(cursor);
|
||||
if (m_inner) {
|
||||
if (dynamic_cast<eap::credentials_pap*>(m_inner.get())) {
|
||||
eapserial::pack(cursor, eap::type_pap);
|
||||
m_inner->pack(cursor);
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
eapserial::pack(cursor, eap::type_undefined);
|
||||
}
|
||||
} else
|
||||
eapserial::pack(cursor, eap::type_undefined);
|
||||
}
|
||||
|
||||
|
||||
size_t eap::credentials_ttls::get_pk_size() const
|
||||
{
|
||||
size_t size_inner;
|
||||
if (m_inner) {
|
||||
if (dynamic_cast<eap::credentials_pap*>(m_inner.get())) {
|
||||
size_inner =
|
||||
eapserial::get_pk_size(eap::type_pap) +
|
||||
m_inner->get_pk_size();
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
size_inner = eapserial::get_pk_size(eap::type_undefined);
|
||||
}
|
||||
} else
|
||||
size_inner = eapserial::get_pk_size(eap::type_undefined);
|
||||
|
||||
return
|
||||
eap::credentials_tls::get_pk_size() +
|
||||
size_inner;
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_ttls::unpack(_Inout_ const unsigned char *&cursor)
|
||||
{
|
||||
eap::credentials_tls::unpack(cursor);
|
||||
|
||||
eap::type_t eap_type;
|
||||
eapserial::unpack(cursor, eap_type);
|
||||
switch (eap_type) {
|
||||
case eap::type_pap:
|
||||
m_inner.reset(new eap::credentials_pap(m_module));
|
||||
m_inner->unpack(cursor);
|
||||
break;
|
||||
default:
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
m_inner.reset(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool eap::credentials_ttls::store(_In_ LPCTSTR pszTargetName, _Out_ EAP_ERROR **ppEapError) const
|
||||
{
|
||||
if (!credentials_tls::store(pszTargetName, ppEapError))
|
||||
|
Loading…
x
Reference in New Issue
Block a user