Support for pre-shared credentials introduced
This commit is contained in:
@@ -58,6 +58,8 @@ namespace eapserial
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Credentials.h"
|
||||
|
||||
#include "../../EAPBase/include/Config.h"
|
||||
|
||||
#include <WinStd/Crypt.h>
|
||||
@@ -70,7 +72,7 @@ namespace eapserial
|
||||
|
||||
namespace eap
|
||||
{
|
||||
class config_tls : public config_method
|
||||
class config_tls : public config_method<credentials_tls>
|
||||
{
|
||||
public:
|
||||
///
|
||||
@@ -174,24 +176,24 @@ namespace eapserial
|
||||
{
|
||||
inline void pack(_Inout_ unsigned char *&cursor, _In_ const eap::config_tls &val)
|
||||
{
|
||||
pack(cursor, (const eap::config_method&)val);
|
||||
pack(cursor, val.m_trusted_root_ca );
|
||||
pack(cursor, val.m_server_names );
|
||||
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_tls &val)
|
||||
{
|
||||
return
|
||||
get_pk_size((const eap::config_method&)val) +
|
||||
get_pk_size(val.m_trusted_root_ca ) +
|
||||
get_pk_size(val.m_server_names );
|
||||
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_tls &val)
|
||||
{
|
||||
unpack(cursor, (eap::config_method&)val );
|
||||
unpack(cursor, (eap::config_method<eap::credentials_tls>&)val);
|
||||
unpack(cursor, val.m_trusted_root_ca);
|
||||
unpack(cursor, val.m_server_names );
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ using namespace winstd;
|
||||
// eap::config_tls
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
eap::config_tls::config_tls(_In_ module &mod) : config_method(mod)
|
||||
eap::config_tls::config_tls(_In_ module &mod) : config_method<credentials_tls>(mod)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ eap::config_tls::config_tls(_In_ module &mod) : config_method(mod)
|
||||
eap::config_tls::config_tls(_In_ const config_tls &other) :
|
||||
m_trusted_root_ca(other.m_trusted_root_ca),
|
||||
m_server_names(other.m_server_names),
|
||||
config_method(other)
|
||||
config_method<credentials_tls>(other)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ eap::config_tls::config_tls(_In_ const config_tls &other) :
|
||||
eap::config_tls::config_tls(_Inout_ config_tls &&other) :
|
||||
m_trusted_root_ca(std::move(other.m_trusted_root_ca)),
|
||||
m_server_names(std::move(other.m_server_names)),
|
||||
config_method(std::move(other))
|
||||
config_method<credentials_tls>(std::move(other))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ eap::config_tls::config_tls(_Inout_ config_tls &&other) :
|
||||
eap::config_tls& eap::config_tls::operator=(_In_ const eap::config_tls &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config_method&)*this = other;
|
||||
m_trusted_root_ca = other.m_trusted_root_ca;
|
||||
m_server_names = other.m_server_names;
|
||||
(config_method<credentials_tls>&)*this = other;
|
||||
m_trusted_root_ca = other.m_trusted_root_ca;
|
||||
m_server_names = other.m_server_names;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -64,9 +64,9 @@ eap::config_tls& eap::config_tls::operator=(_In_ const eap::config_tls &other)
|
||||
eap::config_tls& eap::config_tls::operator=(_Inout_ eap::config_tls &&other)
|
||||
{
|
||||
if (this != &other) {
|
||||
(config_method&&)*this = std::move(other);
|
||||
m_trusted_root_ca = std::move(other.m_trusted_root_ca);
|
||||
m_server_names = std::move(other.m_server_names);
|
||||
(config_method<credentials_tls>&&)*this = std::move(other);
|
||||
m_trusted_root_ca = std::move(other.m_trusted_root_ca);
|
||||
m_server_names = std::move(other.m_server_names);
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -129,7 +129,7 @@ DWORD eap::config_tls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pConfi
|
||||
}
|
||||
}
|
||||
|
||||
return config_method::save(pDoc, pConfigRoot, ppEapError);
|
||||
return config_method<credentials_tls>::save(pDoc, pConfigRoot, ppEapError);
|
||||
}
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ DWORD eap::config_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppE
|
||||
}
|
||||
}
|
||||
|
||||
return config_method::load(pConfigRoot, ppEapError);
|
||||
return config_method<credentials_tls>::load(pConfigRoot, ppEapError);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -41,7 +41,7 @@ eap::credentials_tls::credentials_tls(_In_ const credentials_tls &other) :
|
||||
|
||||
|
||||
eap::credentials_tls::credentials_tls(_Inout_ credentials_tls &&other) :
|
||||
m_cert_hash(std::move(m_cert_hash)),
|
||||
m_cert_hash(std::move(other.m_cert_hash)),
|
||||
credentials(std::move(other))
|
||||
{
|
||||
}
|
||||
@@ -93,12 +93,14 @@ DWORD eap::credentials_tls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *p
|
||||
const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata");
|
||||
DWORD dwResult;
|
||||
|
||||
if ((dwResult = credentials::save(pDoc, pConfigRoot, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
|
||||
// <CertHash>
|
||||
if (!m_cert_hash.empty())
|
||||
if ((dwResult = eapxml::put_element_hex(pDoc, pConfigRoot, bstr(L"CertHash"), bstrNamespace, m_cert_hash.data(), m_cert_hash.size())) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <CertHash> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
if ((dwResult = eapxml::put_element_hex(pDoc, pConfigRoot, bstr(L"CertHash"), bstrNamespace, m_cert_hash.data(), m_cert_hash.size())) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating <CertHash> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
@@ -107,9 +109,16 @@ DWORD eap::credentials_tls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *p
|
||||
DWORD eap::credentials_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapError)
|
||||
{
|
||||
assert(pConfigRoot);
|
||||
UNREFERENCED_PARAMETER(ppEapError);
|
||||
DWORD dwResult;
|
||||
|
||||
eapxml::get_element_hex(pConfigRoot, bstr(L"CertHash"), m_cert_hash);
|
||||
if ((dwResult = credentials::load(pConfigRoot, ppEapError)) != ERROR_SUCCESS)
|
||||
return dwResult;
|
||||
|
||||
// <CertHash>
|
||||
if ((dwResult = eapxml::get_element_hex(pConfigRoot, bstr(L"eap-metadata:CertHash"), m_cert_hash)) != ERROR_SUCCESS) {
|
||||
*ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error reading <CertHash> element."), NULL);
|
||||
return dwResult;
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
Reference in New Issue
Block a user