config_method::m_preshared moved to heap, which in turn required shift to virtual methods for packing/unpacking BLOBs

This commit is contained in:
2016-07-20 14:59:12 +02:00
parent 3e82e988d4
commit ce0bbc5b45
17 changed files with 620 additions and 748 deletions

View File

@@ -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 );
}
}

View File

@@ -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 );
}
}

View File

@@ -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;

View File

@@ -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);