16 #include "handshake.h"
36 : m_atts(0L), m_error(0), m_complete(FALSE),
37 m_have_credentials(false), m_have_sec_context(false)
46 ret= AcquireCredentialsHandle(NULL, (SEC_CHAR*)ssp,
47 side == SERVER ? SECPKG_CRED_INBOUND : SECPKG_CRED_OUTBOUND,
52 DBUG_PRINT(
"error", (
"AcqireCredentialsHandle() failed"
53 " with error %X", ret));
54 ERROR_LOG(ERROR, (
"Could not obtain local credentials"
55 " required for authentication"));
63 Handshake::~Handshake()
66 FreeCredentialsHandle(&
m_cred);
68 DeleteSecurityContext(&
m_sctx);
73 FreeContextBuffer(m_ssp_info);
101 DBUG_PRINT(
"info", (
"Waiting for packet"));
105 ERROR_LOG(ERROR, (
"Error reading packet in round %d",
m_round));
108 DBUG_PRINT(
"info", (
"Got packet of length %d", packet.len()));
118 ERROR_LOG(ERROR, (
"Error processing packet in round %d",
m_round));
127 if (!new_data.is_null())
129 DBUG_PRINT(
"info", (
"Round %d started",
m_round));
131 DBUG_PRINT(
"info", (
"Sending packet of length %d", new_data.len()));
135 ERROR_LOG(ERROR, (
"Error writing packet in round %d",
m_round));
138 DBUG_PRINT(
"info", (
"Data sent"));
140 else if (!is_complete())
142 ERROR_LOG(ERROR, (
"No data to send in round %d"
143 " but handshake is not complete",
m_round));
152 if (
m_round > MAX_HANDSHAKE_ROUNDS)
154 ERROR_LOG(ERROR, (
"Authentication handshake could not be completed"
159 }
while(!is_complete());
161 ERROR_LOG(INFO, (
"Handshake completed after %d rounds",
m_round));
181 SecPkgContext_PackageInfo pinfo;
183 int ret= QueryContextAttributes(&
m_sctx, SECPKG_ATTR_PACKAGE_INFO, &pinfo);
187 m_ssp_info= pinfo.PackageInfo;
191 (
"Could not obtain SSP info from authentication context"
192 ", QueryContextAttributes() failed with error %X", ret));
195 return m_ssp_info ? m_ssp_info->Name : NULL;
226 case SEC_I_COMPLETE_NEEDED:
231 case SEC_I_CONTINUE_NEEDED:
232 case SEC_I_COMPLETE_AND_CONTINUE:
249 case SEC_I_COMPLETE_NEEDED:
250 case SEC_I_COMPLETE_AND_CONTINUE:
254 DBUG_PRINT(
"error", (
"CompleteAuthToken() failed with error %X", ret));
269 Security_buffer::Security_buffer(
const Blob &blob): m_allocated(false)
271 init(blob.ptr(), blob.len());
275 Security_buffer::Security_buffer(): m_allocated(true)
281 void Security_buffer::free(
void)
283 if (m_allocated && NULL != ptr())
285 FreeContextBuffer(ptr());