Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ANSI functions explicitly #85

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/wintls/detail/encrypt_buffers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class encrypt_buffers : public sspi_buffer_sequence<4> {

template <typename ConstBufferSequence> std::size_t operator()(const ConstBufferSequence& buffers, SECURITY_STATUS& sc) {
if (data_.empty()) {
sc = sspi_functions::QueryContextAttributes(ctxt_handle_.get(), SECPKG_ATTR_STREAM_SIZES, &stream_sizes_);
sc = sspi_functions::QueryContextAttributesA(ctxt_handle_.get(), SECPKG_ATTR_STREAM_SIZES, &stream_sizes_);
if (sc != SEC_E_OK) {
return 0;
}
Expand Down
16 changes: 8 additions & 8 deletions include/wintls/detail/sspi_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ namespace wintls {
namespace detail {
namespace sspi_functions {

inline SecurityFunctionTable* sspi_function_table() {
static SecurityFunctionTable* impl = InitSecurityInterface();
inline SecurityFunctionTableA* sspi_function_table() {
static SecurityFunctionTableA* impl = InitSecurityInterfaceA();
// TODO: Figure out some way to signal this to the user instead of aborting
WINTLS_ASSERT_MSG(impl != nullptr, "Unable to initialize SecurityFunctionTable");
return impl;
}

inline SECURITY_STATUS AcquireCredentialsHandle(SEC_CHAR* pPrincipal,
inline SECURITY_STATUS AcquireCredentialsHandleA(SEC_CHAR* pPrincipal,
SEC_CHAR* pPackage,
unsigned long fCredentialUse,
void* pvLogonId,
Expand All @@ -31,7 +31,7 @@ inline SECURITY_STATUS AcquireCredentialsHandle(SEC_CHAR* pPrincipal,
void* pvGetKeyArgument,
PCredHandle phCredential,
PTimeStamp ptsExpiry) {
return sspi_function_table()->AcquireCredentialsHandle(pPrincipal,
return sspi_function_table()->AcquireCredentialsHandleA(pPrincipal,
pPackage,
fCredentialUse,
pvLogonId,
Expand All @@ -46,7 +46,7 @@ inline SECURITY_STATUS DeleteSecurityContext(PCtxtHandle phContext) {
return sspi_function_table()->DeleteSecurityContext(phContext);
}

inline SECURITY_STATUS InitializeSecurityContext(PCredHandle phCredential,
inline SECURITY_STATUS InitializeSecurityContextA(PCredHandle phCredential,
PCtxtHandle phContext,
SEC_CHAR* pTargetName,
unsigned long fContextReq,
Expand All @@ -58,7 +58,7 @@ inline SECURITY_STATUS InitializeSecurityContext(PCredHandle phCredential,
PSecBufferDesc pOutput,
unsigned long* pfContextAttr,
PTimeStamp ptsExpiry) {
return sspi_function_table()->InitializeSecurityContext(phCredential,
return sspi_function_table()->InitializeSecurityContextA(phCredential,
phContext,
pTargetName,
fContextReq,
Expand All @@ -80,8 +80,8 @@ inline SECURITY_STATUS DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMes
return sspi_function_table()->DecryptMessage(phContext, pMessage, MessageSeqNo, pfQOP);
}

inline SECURITY_STATUS QueryContextAttributes(PCtxtHandle phContext, unsigned long ulAttribute, void* pBuffer) {
return sspi_function_table()->QueryContextAttributes(phContext, ulAttribute, pBuffer);
inline SECURITY_STATUS QueryContextAttributesA(PCtxtHandle phContext, unsigned long ulAttribute, void* pBuffer) {
return sspi_function_table()->QueryContextAttributesA(phContext, ulAttribute, pBuffer);
}

inline SECURITY_STATUS EncryptMessage(PCtxtHandle phContext, unsigned long fQOP, PSecBufferDesc pMessage, unsigned long MessageSeqNo) {
Expand Down
8 changes: 4 additions & 4 deletions include/wintls/detail/sspi_handshake.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class sspi_handshake {
}

TimeStamp expiry;
last_error_ = detail::sspi_functions::AcquireCredentialsHandle(nullptr,
last_error_ = detail::sspi_functions::AcquireCredentialsHandleA(nullptr,
const_cast<SEC_CHAR*>(UNISP_NAME),
static_cast<unsigned>(usage),
nullptr,
Expand All @@ -106,7 +106,7 @@ class sspi_handshake {
DWORD out_flags = 0;

handshake_output_buffers buffers;
last_error_ = detail::sspi_functions::InitializeSecurityContext(cred_handle_.get(),
last_error_ = detail::sspi_functions::InitializeSecurityContextA(cred_handle_.get(),
nullptr,
const_cast<SEC_CHAR*>(server_hostname_.c_str()),
client_context_flags,
Expand Down Expand Up @@ -148,7 +148,7 @@ class sspi_handshake {

switch(handshake_type_) {
case handshake_type::client:
last_error_ = detail::sspi_functions::InitializeSecurityContext(cred_handle_.get(),
last_error_ = detail::sspi_functions::InitializeSecurityContextA(cred_handle_.get(),
ctxt_handle_.get(),
const_cast<SEC_CHAR*>(server_hostname_.c_str()),
client_context_flags,
Expand Down Expand Up @@ -281,7 +281,7 @@ class sspi_handshake {
return SEC_E_OK;
}
const CERT_CONTEXT* ctx_ptr = nullptr;
last_error_ = detail::sspi_functions::QueryContextAttributes(ctxt_handle_.get(), SECPKG_ATTR_REMOTE_CERT_CONTEXT, &ctx_ptr);
last_error_ = detail::sspi_functions::QueryContextAttributesA(ctxt_handle_.get(), SECPKG_ATTR_REMOTE_CERT_CONTEXT, &ctx_ptr);
if (last_error_ != SEC_E_OK) {
return last_error_;
}
Expand Down
2 changes: 1 addition & 1 deletion include/wintls/detail/sspi_shutdown.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class sspi_shutdown {
}

DWORD out_flags = 0;
sc = detail::sspi_functions::InitializeSecurityContext(cred_handle_.get(),
sc = detail::sspi_functions::InitializeSecurityContextA(cred_handle_.get(),
ctxt_handle_.get(),
nullptr,
client_context_flags,
Expand Down
Loading