pack() => operator <<, unpack() => operator >>, get_pk_size() => pksizeof()
This commit is contained in:
parent
51428d290f
commit
627b20aabc
@ -45,33 +45,30 @@ namespace eap
|
||||
class config_providers;
|
||||
}
|
||||
|
||||
namespace eapserial
|
||||
{
|
||||
///
|
||||
/// Packs a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
inline void pack(_Inout_ cursor_out &cursor, _In_ const eap::config &val);
|
||||
///
|
||||
/// Packs a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const eap::config &val);
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
///
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
inline size_t get_pk_size(const eap::config &val);
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
///
|
||||
/// \param[in] val Configuration to pack
|
||||
///
|
||||
/// \returns Size of data when packed (in bytes)
|
||||
///
|
||||
inline size_t pksizeof(const eap::config &val);
|
||||
|
||||
///
|
||||
/// Unpacks a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Configuration to unpack to
|
||||
///
|
||||
inline void unpack(_Inout_ cursor_in &cursor, _Out_ eap::config &val);
|
||||
}
|
||||
///
|
||||
/// Unpacks a configuration
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
/// \param[out] val Configuration to unpack to
|
||||
///
|
||||
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::config &val);
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -181,7 +178,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
|
||||
virtual void operator<<(_Inout_ cursor_out &cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
@ -195,7 +192,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
|
||||
virtual void operator>>(_Inout_ cursor_in &cursor);
|
||||
|
||||
/// @}
|
||||
|
||||
@ -288,7 +285,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
|
||||
virtual void operator<<(_Inout_ cursor_out &cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
@ -302,7 +299,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
|
||||
virtual void operator>>(_Inout_ cursor_in &cursor);
|
||||
|
||||
/// @}
|
||||
|
||||
@ -412,7 +409,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
|
||||
virtual void operator<<(_Inout_ cursor_out &cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
@ -426,7 +423,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
|
||||
virtual void operator>>(_Inout_ cursor_in &cursor);
|
||||
|
||||
/// @}
|
||||
|
||||
@ -531,7 +528,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
|
||||
virtual void operator<<(_Inout_ cursor_out &cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
@ -545,7 +542,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
|
||||
virtual void operator>>(_Inout_ cursor_in &cursor);
|
||||
|
||||
/// @}
|
||||
|
||||
@ -555,22 +552,19 @@ namespace eap
|
||||
}
|
||||
|
||||
|
||||
namespace eapserial
|
||||
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const eap::config &val)
|
||||
{
|
||||
inline void pack(_Inout_ cursor_out &cursor, _In_ const eap::config &val)
|
||||
{
|
||||
val.pack(cursor);
|
||||
}
|
||||
|
||||
|
||||
inline size_t get_pk_size(const eap::config &val)
|
||||
{
|
||||
return val.get_pk_size();
|
||||
}
|
||||
|
||||
|
||||
inline void unpack(_Inout_ cursor_in &cursor, _Out_ eap::config &val)
|
||||
{
|
||||
val.unpack(cursor);
|
||||
}
|
||||
val.operator<<(cursor);
|
||||
}
|
||||
|
||||
|
||||
inline size_t pksizeof(const eap::config &val)
|
||||
{
|
||||
return val.get_pk_size();
|
||||
}
|
||||
|
||||
|
||||
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::config &val)
|
||||
{
|
||||
val.operator>>(cursor);
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
|
||||
virtual void operator<<(_Inout_ cursor_out &cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
@ -307,7 +307,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
|
||||
virtual void operator>>(_Inout_ cursor_in &cursor);
|
||||
|
||||
/// @}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -561,13 +561,13 @@ namespace eap
|
||||
if (!decrypt_md5(cp, pDataIn, dwDataInSize, data, ppEapError))
|
||||
return false;
|
||||
|
||||
eapserial::cursor_in cursor = { data.data(), data.data() + data.size() };
|
||||
eapserial::unpack(cursor, record);
|
||||
cursor_in cursor = { data.data(), data.data() + data.size() };
|
||||
cursor >> record;
|
||||
#else
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
|
||||
eapserial::cursor_in cursor = { pDataIn, pDataIn + dwDataInSize };
|
||||
eapserial::unpack(cursor, record);
|
||||
cursor_in cursor = { pDataIn, pDataIn + dwDataInSize };
|
||||
cursor >> record;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
@ -596,11 +596,11 @@ namespace eap
|
||||
#if EAP_ENCRYPT_BLOBS
|
||||
// Allocate BLOB.
|
||||
std::vector<unsigned char, winstd::sanitizing_allocator<unsigned char> > data;
|
||||
data.resize(eapserial::get_pk_size(record));
|
||||
data.resize(pksizeof(record));
|
||||
|
||||
// Pack to BLOB.
|
||||
eapserial::cursor_out cursor = { data.data(), data.data() + data.size() };
|
||||
eapserial::pack(cursor, record);
|
||||
cursor_out cursor = { data.data(), data.data() + data.size() };
|
||||
cursor << record;
|
||||
data.resize(cursor.ptr - &data.front());
|
||||
|
||||
// Prepare cryptographics provider.
|
||||
@ -629,7 +629,7 @@ namespace eap
|
||||
// Allocate BLOB.
|
||||
assert(ppDataOut);
|
||||
assert(pdwDataOutSize);
|
||||
*pdwDataOutSize = (DWORD)eapserial::get_pk_size(record);
|
||||
*pdwDataOutSize = (DWORD)pksizeof(record);
|
||||
*ppDataOut = alloc_memory(*pdwDataOutSize);
|
||||
if (!*ppDataOut) {
|
||||
log_error(*ppEapError = g_peer.make_error(ERROR_OUTOFMEMORY, tstring_printf(_T(__FUNCTION__) _T(" Error allocating memory for BLOB (%uB)."), *pdwDataOutSize).c_str()));
|
||||
@ -637,8 +637,8 @@ namespace eap
|
||||
}
|
||||
|
||||
// Pack to BLOB.
|
||||
eapserial::cursor_out cursor = { *ppDataOut, *ppDataOut + *pdwDataOutSize };
|
||||
eapserial::pack(cursor, record);
|
||||
cursor_out cursor = { *ppDataOut, *ppDataOut + *pdwDataOutSize };
|
||||
cursor << record;
|
||||
*pdwDataOutSize = cursor.ptr - *ppDataOut;
|
||||
#endif
|
||||
|
||||
|
@ -81,7 +81,7 @@ bool eap::config::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapErr
|
||||
}
|
||||
|
||||
|
||||
void eap::config::pack(_Inout_ eapserial::cursor_out &cursor) const
|
||||
void eap::config::operator<<(_Inout_ cursor_out &cursor) const
|
||||
{
|
||||
UNREFERENCED_PARAMETER(cursor);
|
||||
}
|
||||
@ -93,7 +93,7 @@ size_t eap::config::get_pk_size() const
|
||||
}
|
||||
|
||||
|
||||
void eap::config::unpack(_Inout_ eapserial::cursor_in &cursor)
|
||||
void eap::config::operator>>(_Inout_ cursor_in &cursor)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(cursor);
|
||||
}
|
||||
@ -120,10 +120,10 @@ eap::config_method::config_method(_In_ const config_method &other) :
|
||||
|
||||
|
||||
eap::config_method::config_method(_Inout_ config_method &&other) :
|
||||
m_allow_save(move(other.m_allow_save)),
|
||||
m_anonymous_identity(move(other.m_anonymous_identity)),
|
||||
m_preshared(move(other.m_preshared)),
|
||||
config(move(other))
|
||||
m_allow_save(std::move(other.m_allow_save)),
|
||||
m_anonymous_identity(std::move(other.m_anonymous_identity)),
|
||||
m_preshared(std::move(other.m_preshared)),
|
||||
config(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
@ -144,10 +144,10 @@ eap::config_method& eap::config_method::operator=(_In_ const config_method &othe
|
||||
eap::config_method& eap::config_method::operator=(_Inout_ config_method &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&&)*this = move(other);
|
||||
m_allow_save = move(other.m_allow_save);
|
||||
m_anonymous_identity = move(other.m_anonymous_identity);
|
||||
m_preshared = move(other.m_preshared);
|
||||
(config&&)*this = std::move(other);
|
||||
m_allow_save = std::move(other.m_allow_save);
|
||||
m_anonymous_identity = std::move(other.m_anonymous_identity);
|
||||
m_preshared = std::move(other.m_preshared);
|
||||
}
|
||||
|
||||
return *this;
|
||||
@ -222,7 +222,7 @@ bool eap::config_method::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **p
|
||||
unique_ptr<credentials> preshared(make_credentials());
|
||||
assert(preshared);
|
||||
if (preshared->load(pXmlElClientSideCredential, ppEapError)) {
|
||||
m_preshared = move(preshared);
|
||||
m_preshared = std::move(preshared);
|
||||
} else {
|
||||
// This is not really an error - merely an indication pre-shared credentials are unavailable.
|
||||
if (*ppEapError) {
|
||||
@ -236,44 +236,44 @@ bool eap::config_method::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **p
|
||||
}
|
||||
|
||||
|
||||
void eap::config_method::pack(_Inout_ eapserial::cursor_out &cursor) const
|
||||
void eap::config_method::operator<<(_Inout_ cursor_out &cursor) const
|
||||
{
|
||||
config::pack(cursor);
|
||||
eapserial::pack(cursor, m_allow_save );
|
||||
eapserial::pack(cursor, m_anonymous_identity);
|
||||
config::operator<<(cursor);
|
||||
cursor << m_allow_save ;
|
||||
cursor << m_anonymous_identity;
|
||||
if (m_preshared) {
|
||||
eapserial::pack(cursor, true);
|
||||
m_preshared->pack(cursor);
|
||||
cursor << true;
|
||||
cursor << *m_preshared;
|
||||
} else
|
||||
eapserial::pack(cursor, false);
|
||||
cursor << false;
|
||||
}
|
||||
|
||||
|
||||
size_t eap::config_method::get_pk_size() const
|
||||
{
|
||||
return
|
||||
config::get_pk_size() +
|
||||
eapserial::get_pk_size(m_allow_save ) +
|
||||
eapserial::get_pk_size(m_anonymous_identity) +
|
||||
config::get_pk_size() +
|
||||
pksizeof(m_allow_save ) +
|
||||
pksizeof(m_anonymous_identity) +
|
||||
(m_preshared ?
|
||||
eapserial::get_pk_size(true) +
|
||||
m_preshared->get_pk_size() :
|
||||
eapserial::get_pk_size(false));
|
||||
pksizeof(true ) +
|
||||
pksizeof(*m_preshared) :
|
||||
pksizeof(false ));
|
||||
}
|
||||
|
||||
|
||||
void eap::config_method::unpack(_Inout_ eapserial::cursor_in &cursor)
|
||||
void eap::config_method::operator>>(_Inout_ cursor_in &cursor)
|
||||
{
|
||||
config::unpack(cursor);
|
||||
eapserial::unpack(cursor, m_allow_save );
|
||||
eapserial::unpack(cursor, m_anonymous_identity);
|
||||
config::operator>>(cursor);
|
||||
cursor >> m_allow_save ;
|
||||
cursor >> m_anonymous_identity;
|
||||
|
||||
bool use_preshared;
|
||||
eapserial::unpack(cursor, use_preshared);
|
||||
cursor >> use_preshared;
|
||||
if (use_preshared) {
|
||||
m_preshared.reset(make_credentials());
|
||||
assert(m_preshared);
|
||||
m_preshared->unpack(cursor);
|
||||
cursor >> *m_preshared;
|
||||
} else
|
||||
m_preshared.reset(nullptr);
|
||||
}
|
||||
@ -303,22 +303,22 @@ eap::config_provider::config_provider(_In_ const config_provider &other) :
|
||||
config(other)
|
||||
{
|
||||
for (list<unique_ptr<config_method> >::const_iterator method = other.m_methods.cbegin(), method_end = other.m_methods.cend(); method != method_end; ++method)
|
||||
m_methods.push_back(move(unique_ptr<config_method>(*method ? (config_method*)method->get()->clone() : nullptr)));
|
||||
m_methods.push_back(std::move(unique_ptr<config_method>(*method ? (config_method*)method->get()->clone() : nullptr)));
|
||||
}
|
||||
|
||||
|
||||
eap::config_provider::config_provider(_Inout_ config_provider &&other) :
|
||||
m_read_only(move(other.m_read_only)),
|
||||
m_id(move(other.m_id)),
|
||||
m_name(move(other.m_name)),
|
||||
m_help_email(move(other.m_help_email)),
|
||||
m_help_web(move(other.m_help_web)),
|
||||
m_help_phone(move(other.m_help_phone)),
|
||||
m_lbl_alt_credential(move(other.m_lbl_alt_credential)),
|
||||
m_lbl_alt_identity(move(other.m_lbl_alt_identity)),
|
||||
m_lbl_alt_password(move(other.m_lbl_alt_password)),
|
||||
m_methods(move(other.m_methods)),
|
||||
config(move(other))
|
||||
m_read_only(std::move(other.m_read_only)),
|
||||
m_id(std::move(other.m_id)),
|
||||
m_name(std::move(other.m_name)),
|
||||
m_help_email(std::move(other.m_help_email)),
|
||||
m_help_web(std::move(other.m_help_web)),
|
||||
m_help_phone(std::move(other.m_help_phone)),
|
||||
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))
|
||||
{
|
||||
}
|
||||
|
||||
@ -339,7 +339,7 @@ eap::config_provider& eap::config_provider::operator=(_In_ const config_provider
|
||||
|
||||
m_methods.clear();
|
||||
for (list<unique_ptr<config_method> >::const_iterator method = other.m_methods.cbegin(), method_end = other.m_methods.cend(); method != method_end; ++method)
|
||||
m_methods.push_back(move(unique_ptr<config_method>(*method ? (config_method*)method->get()->clone() : nullptr)));
|
||||
m_methods.push_back(std::move(unique_ptr<config_method>(*method ? (config_method*)method->get()->clone() : nullptr)));
|
||||
}
|
||||
|
||||
return *this;
|
||||
@ -349,17 +349,17 @@ eap::config_provider& eap::config_provider::operator=(_In_ const config_provider
|
||||
eap::config_provider& eap::config_provider::operator=(_Inout_ config_provider &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&&)*this = move(other);
|
||||
m_read_only = move(m_read_only);
|
||||
m_id = move(other.m_id);
|
||||
m_name = move(other.m_name);
|
||||
m_help_email = move(other.m_help_email);
|
||||
m_help_web = move(other.m_help_web);
|
||||
m_help_phone = move(other.m_help_phone);
|
||||
m_lbl_alt_credential = move(other.m_lbl_alt_credential);
|
||||
m_lbl_alt_identity = move(other.m_lbl_alt_identity);
|
||||
m_lbl_alt_password = move(other.m_lbl_alt_password);
|
||||
m_methods = move(other.m_methods);
|
||||
(config&&)*this = std::move(other);
|
||||
m_read_only = std::move(m_read_only);
|
||||
m_id = std::move(other.m_id);
|
||||
m_name = std::move(other.m_name);
|
||||
m_help_email = std::move(other.m_help_email);
|
||||
m_help_web = std::move(other.m_help_web);
|
||||
m_help_phone = std::move(other.m_help_phone);
|
||||
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;
|
||||
@ -583,69 +583,69 @@ bool eap::config_provider::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR *
|
||||
return false;
|
||||
|
||||
// Add configuration to the list.
|
||||
m_methods.push_back(move(cfg));
|
||||
m_methods.push_back(std::move(cfg));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void eap::config_provider::pack(_Inout_ eapserial::cursor_out &cursor) const
|
||||
void eap::config_provider::operator<<(_Inout_ cursor_out &cursor) const
|
||||
{
|
||||
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 );
|
||||
config::operator<<(cursor);
|
||||
cursor << m_read_only ;
|
||||
cursor << m_id ;
|
||||
cursor << m_name ;
|
||||
cursor << m_help_email ;
|
||||
cursor << m_help_web ;
|
||||
cursor << m_help_phone ;
|
||||
cursor << m_lbl_alt_credential;
|
||||
cursor << m_lbl_alt_identity ;
|
||||
cursor << m_lbl_alt_password ;
|
||||
cursor << m_methods ;
|
||||
}
|
||||
|
||||
|
||||
size_t eap::config_provider::get_pk_size() const
|
||||
{
|
||||
return
|
||||
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 );
|
||||
config::get_pk_size() +
|
||||
pksizeof(m_read_only ) +
|
||||
pksizeof(m_id ) +
|
||||
pksizeof(m_name ) +
|
||||
pksizeof(m_help_email ) +
|
||||
pksizeof(m_help_web ) +
|
||||
pksizeof(m_help_phone ) +
|
||||
pksizeof(m_lbl_alt_credential) +
|
||||
pksizeof(m_lbl_alt_identity ) +
|
||||
pksizeof(m_lbl_alt_password ) +
|
||||
pksizeof(m_methods );
|
||||
}
|
||||
|
||||
|
||||
void eap::config_provider::unpack(_Inout_ eapserial::cursor_in &cursor)
|
||||
void eap::config_provider::operator>>(_Inout_ cursor_in &cursor)
|
||||
{
|
||||
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 );
|
||||
config::operator>>(cursor);
|
||||
cursor >> m_read_only ;
|
||||
cursor >> m_id ;
|
||||
cursor >> m_name ;
|
||||
cursor >> m_help_email ;
|
||||
cursor >> m_help_web ;
|
||||
cursor >> m_help_phone ;
|
||||
cursor >> m_lbl_alt_credential;
|
||||
cursor >> m_lbl_alt_identity ;
|
||||
cursor >> m_lbl_alt_password ;
|
||||
|
||||
list<config_method>::size_type count;
|
||||
bool is_nonnull;
|
||||
eapserial::unpack(cursor, count);
|
||||
cursor >> count;
|
||||
m_methods.clear();
|
||||
for (list<config_method>::size_type i = 0; i < count; i++) {
|
||||
eapserial::unpack(cursor, is_nonnull);
|
||||
cursor >> is_nonnull;
|
||||
if (is_nonnull) {
|
||||
unique_ptr<config_method> el(m_module.make_config_method());
|
||||
el->unpack(cursor);
|
||||
m_methods.push_back(move(el));
|
||||
cursor >> *el;
|
||||
m_methods.push_back(std::move(el));
|
||||
} else
|
||||
m_methods.push_back(nullptr);
|
||||
}
|
||||
@ -669,8 +669,8 @@ eap::config_providers::config_providers(_In_ const config_providers &other) :
|
||||
|
||||
|
||||
eap::config_providers::config_providers(_Inout_ config_providers &&other) :
|
||||
m_providers(move(other.m_providers)),
|
||||
config(move(other))
|
||||
m_providers(std::move(other.m_providers)),
|
||||
config(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
@ -689,8 +689,8 @@ eap::config_providers& eap::config_providers::operator=(_In_ const config_provid
|
||||
eap::config_providers& eap::config_providers::operator=(_Inout_ config_providers &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config&&)*this = move(other);
|
||||
m_providers = move(other.m_providers);
|
||||
(config&&)*this = std::move(other);
|
||||
m_providers = std::move(other.m_providers);
|
||||
}
|
||||
|
||||
return *this;
|
||||
@ -769,17 +769,17 @@ bool eap::config_providers::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
|
||||
return false;
|
||||
|
||||
// Add provider to the list.
|
||||
m_providers.push_back(move(prov));
|
||||
m_providers.push_back(std::move(prov));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void eap::config_providers::pack(_Inout_ eapserial::cursor_out &cursor) const
|
||||
void eap::config_providers::operator<<(_Inout_ cursor_out &cursor) const
|
||||
{
|
||||
config::pack(cursor);
|
||||
eapserial::pack(cursor, m_providers);
|
||||
config::operator<<(cursor);
|
||||
cursor << m_providers;
|
||||
}
|
||||
|
||||
|
||||
@ -787,20 +787,20 @@ size_t eap::config_providers::get_pk_size() const
|
||||
{
|
||||
return
|
||||
config::get_pk_size() +
|
||||
eapserial::get_pk_size(m_providers);
|
||||
pksizeof(m_providers);
|
||||
}
|
||||
|
||||
|
||||
void eap::config_providers::unpack(_Inout_ eapserial::cursor_in &cursor)
|
||||
void eap::config_providers::operator>>(_Inout_ cursor_in &cursor)
|
||||
{
|
||||
config::unpack(cursor);
|
||||
config::operator>>(cursor);
|
||||
|
||||
list<config_provider>::size_type count;
|
||||
eapserial::unpack(cursor, count);
|
||||
cursor >> count;
|
||||
m_providers.clear();
|
||||
for (list<config_provider>::size_type i = 0; i < count; i++) {
|
||||
config_provider el(m_module);
|
||||
el.unpack(cursor);
|
||||
m_providers.push_back(move(el));
|
||||
cursor >> el;
|
||||
m_providers.push_back(std::move(el));
|
||||
}
|
||||
}
|
||||
|
@ -233,28 +233,28 @@ bool eap::credentials_pass::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_pass::pack(_Inout_ eapserial::cursor_out &cursor) const
|
||||
void eap::credentials_pass::operator<<(_Inout_ cursor_out &cursor) const
|
||||
{
|
||||
eap::credentials::pack(cursor);
|
||||
eapserial::pack(cursor, m_identity);
|
||||
eapserial::pack(cursor, m_password);
|
||||
credentials::operator<<(cursor);
|
||||
cursor << m_identity;
|
||||
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);
|
||||
credentials::get_pk_size() +
|
||||
pksizeof(m_identity) +
|
||||
pksizeof(m_password);
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_pass::unpack(_Inout_ eapserial::cursor_in &cursor)
|
||||
void eap::credentials_pass::operator>>(_Inout_ cursor_in &cursor)
|
||||
{
|
||||
eap::credentials::unpack(cursor);
|
||||
eapserial::unpack(cursor, m_identity);
|
||||
eapserial::unpack(cursor, m_password);
|
||||
credentials::operator>>(cursor);
|
||||
cursor >> m_identity;
|
||||
cursor >> m_password;
|
||||
}
|
||||
|
||||
|
||||
|
@ -141,7 +141,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
|
||||
virtual void operator<<(_Inout_ cursor_out &cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
@ -155,7 +155,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
|
||||
virtual void operator>>(_Inout_ cursor_in &cursor);
|
||||
|
||||
/// @}
|
||||
|
||||
|
@ -137,7 +137,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
|
||||
virtual void operator<<(_Inout_ cursor_out &cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
@ -151,7 +151,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
|
||||
virtual void operator>>(_Inout_ cursor_in &cursor);
|
||||
|
||||
/// @}
|
||||
|
||||
|
@ -87,7 +87,7 @@ eap::config_method_tls::config_method_tls(_Inout_ config_method_tls &&other) :
|
||||
}
|
||||
|
||||
|
||||
eap::config_method_tls& eap::config_method_tls::operator=(_In_ const eap::config_method_tls &other)
|
||||
eap::config_method_tls& eap::config_method_tls::operator=(_In_ const config_method_tls &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config_method&)*this = other;
|
||||
@ -99,7 +99,7 @@ eap::config_method_tls& eap::config_method_tls::operator=(_In_ const eap::config
|
||||
}
|
||||
|
||||
|
||||
eap::config_method_tls& eap::config_method_tls::operator=(_Inout_ eap::config_method_tls &&other)
|
||||
eap::config_method_tls& eap::config_method_tls::operator=(_Inout_ config_method_tls &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config_method&&)*this = std::move(other);
|
||||
@ -226,7 +226,7 @@ bool eap::config_method_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
|
||||
// Log loaded CA certificates.
|
||||
list<tstring> cert_names;
|
||||
for (std::list<winstd::cert_context>::const_iterator cert = m_trusted_root_ca.cbegin(), cert_end = m_trusted_root_ca.cend(); cert != cert_end; ++cert)
|
||||
cert_names.push_back(std::move(eap::get_cert_title(*cert)));
|
||||
cert_names.push_back(std::move(get_cert_title(*cert)));
|
||||
m_module.log_config((xpathServerSideCredential + L"/CA").c_str(), cert_names);
|
||||
}
|
||||
|
||||
@ -256,28 +256,28 @@ bool eap::config_method_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
|
||||
}
|
||||
|
||||
|
||||
void eap::config_method_tls::pack(_Inout_ eapserial::cursor_out &cursor) const
|
||||
void eap::config_method_tls::operator<<(_Inout_ cursor_out &cursor) const
|
||||
{
|
||||
eap::config_method::pack(cursor);
|
||||
eapserial::pack(cursor, m_trusted_root_ca);
|
||||
eapserial::pack(cursor, m_server_names );
|
||||
config_method::operator<<(cursor);
|
||||
cursor << m_trusted_root_ca;
|
||||
cursor << m_server_names ;
|
||||
}
|
||||
|
||||
|
||||
size_t eap::config_method_tls::get_pk_size() const
|
||||
{
|
||||
return
|
||||
eap::config_method::get_pk_size() +
|
||||
eapserial::get_pk_size(m_trusted_root_ca) +
|
||||
eapserial::get_pk_size(m_server_names );
|
||||
config_method::get_pk_size() +
|
||||
pksizeof(m_trusted_root_ca) +
|
||||
pksizeof(m_server_names );
|
||||
}
|
||||
|
||||
|
||||
void eap::config_method_tls::unpack(_Inout_ eapserial::cursor_in &cursor)
|
||||
void eap::config_method_tls::operator>>(_Inout_ cursor_in &cursor)
|
||||
{
|
||||
eap::config_method::unpack(cursor);
|
||||
eapserial::unpack(cursor, m_trusted_root_ca);
|
||||
eapserial::unpack(cursor, m_server_names );
|
||||
config_method::operator>>(cursor);
|
||||
cursor >> m_trusted_root_ca;
|
||||
cursor >> m_server_names ;
|
||||
}
|
||||
|
||||
|
||||
@ -289,7 +289,7 @@ eap::credentials* eap::config_method_tls::make_credentials() const
|
||||
|
||||
eap::type_t eap::config_method_tls::get_method_id() const
|
||||
{
|
||||
return eap::type_tls;
|
||||
return type_tls;
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,25 +167,25 @@ bool eap::credentials_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR *
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_tls::pack(_Inout_ eapserial::cursor_out &cursor) const
|
||||
void eap::credentials_tls::operator<<(_Inout_ cursor_out &cursor) const
|
||||
{
|
||||
eap::credentials::pack(cursor);
|
||||
eapserial::pack(cursor, m_cert);
|
||||
credentials::operator<<(cursor);
|
||||
cursor << m_cert;
|
||||
}
|
||||
|
||||
|
||||
size_t eap::credentials_tls::get_pk_size() const
|
||||
{
|
||||
return
|
||||
eap::credentials::get_pk_size() +
|
||||
eapserial::get_pk_size(m_cert);
|
||||
credentials::get_pk_size() +
|
||||
pksizeof(m_cert);
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_tls::unpack(_Inout_ eapserial::cursor_in &cursor)
|
||||
void eap::credentials_tls::operator>>(_Inout_ cursor_in &cursor)
|
||||
{
|
||||
eap::credentials::unpack(cursor);
|
||||
eapserial::unpack(cursor, m_cert);
|
||||
credentials::operator>>(cursor);
|
||||
cursor >> m_cert;
|
||||
}
|
||||
|
||||
|
||||
@ -279,7 +279,7 @@ std::wstring eap::credentials_tls::get_identity() const
|
||||
|
||||
tstring eap::credentials_tls::get_name() const
|
||||
{
|
||||
return m_cert ? std::move(eap::get_cert_title(m_cert)) : L"<blank>";
|
||||
return m_cert ? std::move(get_cert_title(m_cert)) : L"<blank>";
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,7 +127,7 @@ namespace eap {
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
|
||||
virtual void operator<<(_Inout_ cursor_out &cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
@ -141,7 +141,7 @@ namespace eap {
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
|
||||
virtual void operator>>(_Inout_ cursor_in &cursor);
|
||||
|
||||
///
|
||||
/// Returns EAP method type of this configuration
|
||||
|
@ -133,7 +133,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
|
||||
virtual void operator<<(_Inout_ cursor_out &cursor) const;
|
||||
|
||||
///
|
||||
/// Returns packed size of a configuration
|
||||
@ -147,7 +147,7 @@ namespace eap
|
||||
///
|
||||
/// \param[inout] cursor Memory cursor
|
||||
///
|
||||
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
|
||||
virtual void operator>>(_Inout_ cursor_in &cursor);
|
||||
|
||||
/// \name Storage
|
||||
/// @{
|
||||
|
@ -146,7 +146,7 @@ bool eap::config_method_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERRO
|
||||
{
|
||||
// PAP
|
||||
m_module.log_config((xpath + L"/NonEAPAuthMethod").c_str(), L"PAP");
|
||||
m_inner.reset(new eap::config_method_pap(m_module));
|
||||
m_inner.reset(new config_method_pap(m_module));
|
||||
if (!m_inner->load(pXmlElInnerAuthenticationMethod, ppEapError))
|
||||
return false;
|
||||
} else {
|
||||
@ -158,19 +158,19 @@ bool eap::config_method_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERRO
|
||||
}
|
||||
|
||||
|
||||
void eap::config_method_ttls::pack(_Inout_ eapserial::cursor_out &cursor) const
|
||||
void eap::config_method_ttls::operator<<(_Inout_ cursor_out &cursor) const
|
||||
{
|
||||
eap::config_method_tls::pack(cursor);
|
||||
config_method_tls::operator<<(cursor);
|
||||
if (m_inner) {
|
||||
if (dynamic_cast<eap::config_method_pap*>(m_inner.get())) {
|
||||
eapserial::pack(cursor, eap::type_pap);
|
||||
m_inner->pack(cursor);
|
||||
if (dynamic_cast<config_method_pap*>(m_inner.get())) {
|
||||
cursor << type_pap;
|
||||
cursor << *m_inner;
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
eapserial::pack(cursor, eap::type_undefined);
|
||||
cursor << type_undefined;
|
||||
}
|
||||
} else
|
||||
eapserial::pack(cursor, eap::type_undefined);
|
||||
cursor << type_undefined;
|
||||
}
|
||||
|
||||
|
||||
@ -178,33 +178,33 @@ 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())) {
|
||||
if (dynamic_cast<config_method_pap*>(m_inner.get())) {
|
||||
size_inner =
|
||||
eapserial::get_pk_size(eap::type_pap) +
|
||||
m_inner->get_pk_size();
|
||||
pksizeof(type_pap) +
|
||||
pksizeof(*m_inner);
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
size_inner = eapserial::get_pk_size(eap::type_undefined);
|
||||
size_inner = pksizeof(type_undefined);
|
||||
}
|
||||
} else
|
||||
size_inner = eapserial::get_pk_size(eap::type_undefined);
|
||||
size_inner = pksizeof(type_undefined);
|
||||
|
||||
return
|
||||
eap::config_method_tls::get_pk_size() +
|
||||
config_method_tls::get_pk_size() +
|
||||
size_inner;
|
||||
}
|
||||
|
||||
|
||||
void eap::config_method_ttls::unpack(_Inout_ eapserial::cursor_in &cursor)
|
||||
void eap::config_method_ttls::operator>>(_Inout_ cursor_in &cursor)
|
||||
{
|
||||
eap::config_method_tls::unpack(cursor);
|
||||
config_method_tls::operator>>(cursor);
|
||||
|
||||
eap::type_t eap_type;
|
||||
eapserial::unpack(cursor, eap_type);
|
||||
type_t eap_type;
|
||||
cursor >> eap_type;
|
||||
switch (eap_type) {
|
||||
case eap::type_pap:
|
||||
m_inner.reset(new eap::config_method_pap(m_module));
|
||||
m_inner->unpack(cursor);
|
||||
case type_pap:
|
||||
m_inner.reset(new config_method_pap(m_module));
|
||||
cursor >> *m_inner;
|
||||
break;
|
||||
default:
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
@ -215,5 +215,5 @@ void eap::config_method_ttls::unpack(_Inout_ eapserial::cursor_in &cursor)
|
||||
|
||||
eap::type_t eap::config_method_ttls::get_method_id() const
|
||||
{
|
||||
return eap::type_ttls;
|
||||
return type_ttls;
|
||||
}
|
||||
|
@ -149,19 +149,19 @@ bool eap::credentials_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_ttls::pack(_Inout_ eapserial::cursor_out &cursor) const
|
||||
void eap::credentials_ttls::operator<<(_Inout_ cursor_out &cursor) const
|
||||
{
|
||||
eap::credentials_tls::pack(cursor);
|
||||
credentials_tls::operator<<(cursor);
|
||||
if (m_inner) {
|
||||
if (dynamic_cast<eap::credentials_pap*>(m_inner.get())) {
|
||||
eapserial::pack(cursor, eap::type_pap);
|
||||
m_inner->pack(cursor);
|
||||
if (dynamic_cast<credentials_pap*>(m_inner.get())) {
|
||||
cursor << type_pap;
|
||||
cursor << *m_inner;
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
eapserial::pack(cursor, eap::type_undefined);
|
||||
cursor << type_undefined;
|
||||
}
|
||||
} else
|
||||
eapserial::pack(cursor, eap::type_undefined);
|
||||
cursor << type_undefined;
|
||||
}
|
||||
|
||||
|
||||
@ -169,33 +169,33 @@ 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())) {
|
||||
if (dynamic_cast<credentials_pap*>(m_inner.get())) {
|
||||
size_inner =
|
||||
eapserial::get_pk_size(eap::type_pap) +
|
||||
m_inner->get_pk_size();
|
||||
pksizeof(type_pap) +
|
||||
pksizeof(*m_inner);
|
||||
} else {
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
size_inner = eapserial::get_pk_size(eap::type_undefined);
|
||||
size_inner = pksizeof(type_undefined);
|
||||
}
|
||||
} else
|
||||
size_inner = eapserial::get_pk_size(eap::type_undefined);
|
||||
size_inner = pksizeof(type_undefined);
|
||||
|
||||
return
|
||||
eap::credentials_tls::get_pk_size() +
|
||||
credentials_tls::get_pk_size() +
|
||||
size_inner;
|
||||
}
|
||||
|
||||
|
||||
void eap::credentials_ttls::unpack(_Inout_ eapserial::cursor_in &cursor)
|
||||
void eap::credentials_ttls::operator>>(_Inout_ cursor_in &cursor)
|
||||
{
|
||||
eap::credentials_tls::unpack(cursor);
|
||||
credentials_tls::operator>>(cursor);
|
||||
|
||||
eap::type_t eap_type;
|
||||
eapserial::unpack(cursor, eap_type);
|
||||
type_t eap_type;
|
||||
cursor >> eap_type;
|
||||
switch (eap_type) {
|
||||
case eap::type_pap:
|
||||
m_inner.reset(new eap::credentials_pap(m_module));
|
||||
m_inner->unpack(cursor);
|
||||
case type_pap:
|
||||
m_inner.reset(new credentials_pap(m_module));
|
||||
cursor >> *m_inner;
|
||||
break;
|
||||
default:
|
||||
assert(0); // Unsupported inner authentication method type.
|
||||
|
Loading…
x
Reference in New Issue
Block a user