20#include <winpr/config.h>
23#include <winpr/sspi.h>
30#define TAG WINPR_TAG("sspi.CredSSP")
32static const char* CREDSSP_PACKAGE_NAME =
"CredSSP";
34static SECURITY_STATUS SEC_ENTRY credssp_InitializeSecurityContextW(
36 WINPR_ATTR_UNUSED SEC_WCHAR* pszTargetName, WINPR_ATTR_UNUSED ULONG fContextReq,
37 WINPR_ATTR_UNUSED ULONG Reserved1, WINPR_ATTR_UNUSED ULONG TargetDataRep,
38 WINPR_ATTR_UNUSED
PSecBufferDesc pInput, WINPR_ATTR_UNUSED ULONG Reserved2,
40 WINPR_ATTR_UNUSED PULONG pfContextAttr, WINPR_ATTR_UNUSED
PTimeStamp ptsExpiry)
42 WLog_ERR(TAG,
"TODO: Implement");
43 return SEC_E_UNSUPPORTED_FUNCTION;
46static SECURITY_STATUS SEC_ENTRY credssp_InitializeSecurityContextA(
48 WINPR_ATTR_UNUSED ULONG fContextReq, WINPR_ATTR_UNUSED ULONG Reserved1,
49 WINPR_ATTR_UNUSED ULONG TargetDataRep, WINPR_ATTR_UNUSED
PSecBufferDesc pInput,
50 WINPR_ATTR_UNUSED ULONG Reserved2,
PCtxtHandle phNewContext,
51 WINPR_ATTR_UNUSED
PSecBufferDesc pOutput, WINPR_ATTR_UNUSED PULONG pfContextAttr,
58 if (phContext && !phContext->dwLower && !phContext->dwUpper)
59 return SEC_E_INVALID_HANDLE;
61 context = (
CREDSSP_CONTEXT*)sspi_SecureHandleGetLowerPointer(phContext);
70 context = credssp_ContextNew();
73 return SEC_E_INSUFFICIENT_MEMORY;
75 credentials = (
SSPI_CREDENTIALS*)sspi_SecureHandleGetLowerPointer(phCredential);
79 credssp_ContextFree(context);
80 return SEC_E_INVALID_HANDLE;
83 sspi_SecureHandleSetLowerPointer(phNewContext, context);
85 cnv.cpv = CREDSSP_PACKAGE_NAME;
86 sspi_SecureHandleSetUpperPointer(phNewContext, cnv.pv);
108static SECURITY_STATUS SEC_ENTRY credssp_QueryContextAttributes(
PCtxtHandle phContext,
109 WINPR_ATTR_UNUSED ULONG ulAttribute,
113 return SEC_E_INVALID_HANDLE;
116 return SEC_E_INSUFFICIENT_MEMORY;
118 WLog_ERR(TAG,
"TODO: Implement");
119 return SEC_E_UNSUPPORTED_FUNCTION;
122static SECURITY_STATUS SEC_ENTRY credssp_AcquireCredentialsHandleW(
123 WINPR_ATTR_UNUSED SEC_WCHAR* pszPrincipal, WINPR_ATTR_UNUSED SEC_WCHAR* pszPackage,
124 WINPR_ATTR_UNUSED ULONG fCredentialUse, WINPR_ATTR_UNUSED
void* pvLogonID,
125 WINPR_ATTR_UNUSED
void* pAuthData, WINPR_ATTR_UNUSED SEC_GET_KEY_FN pGetKeyFn,
126 WINPR_ATTR_UNUSED
void* pvGetKeyArgument, WINPR_ATTR_UNUSED
PCredHandle phCredential,
129 WLog_ERR(TAG,
"TODO: Implement");
130 return SEC_E_UNSUPPORTED_FUNCTION;
133static SECURITY_STATUS SEC_ENTRY credssp_AcquireCredentialsHandleA(
134 WINPR_ATTR_UNUSED SEC_CHAR* pszPrincipal, WINPR_ATTR_UNUSED SEC_CHAR* pszPackage,
135 WINPR_ATTR_UNUSED ULONG fCredentialUse, WINPR_ATTR_UNUSED
void* pvLogonID,
136 WINPR_ATTR_UNUSED
void* pAuthData, WINPR_ATTR_UNUSED SEC_GET_KEY_FN pGetKeyFn,
137 WINPR_ATTR_UNUSED
void* pvGetKeyArgument, WINPR_ATTR_UNUSED
PCredHandle phCredential,
141 SEC_WINNT_AUTH_IDENTITY* identity = NULL;
143 if (fCredentialUse == SECPKG_CRED_OUTBOUND)
150 credentials = sspi_CredentialsNew();
153 return SEC_E_INSUFFICIENT_MEMORY;
155 identity = (SEC_WINNT_AUTH_IDENTITY*)pAuthData;
156 CopyMemory(&(credentials->identity), identity,
sizeof(SEC_WINNT_AUTH_IDENTITY));
157 sspi_SecureHandleSetLowerPointer(phCredential, (
void*)credentials);
159 cnv.cpv = CREDSSP_PACKAGE_NAME;
160 sspi_SecureHandleSetUpperPointer(phCredential, cnv.pv);
164 WLog_ERR(TAG,
"TODO: Implement");
165 return SEC_E_UNSUPPORTED_FUNCTION;
168static SECURITY_STATUS SEC_ENTRY credssp_QueryCredentialsAttributesW(
169 WINPR_ATTR_UNUSED
PCredHandle phCredential, WINPR_ATTR_UNUSED ULONG ulAttribute,
170 WINPR_ATTR_UNUSED
void* pBuffer)
172 WLog_ERR(TAG,
"TODO: Implement");
173 return SEC_E_UNSUPPORTED_FUNCTION;
176static SECURITY_STATUS SEC_ENTRY credssp_QueryCredentialsAttributesA(
177 WINPR_ATTR_UNUSED
PCredHandle phCredential, WINPR_ATTR_UNUSED ULONG ulAttribute,
178 WINPR_ATTR_UNUSED
void* pBuffer)
180 if (ulAttribute == SECPKG_CRED_ATTR_NAMES)
186 return SEC_E_INVALID_HANDLE;
191 WLog_ERR(TAG,
"TODO: Implement");
192 return SEC_E_UNSUPPORTED_FUNCTION;
195static SECURITY_STATUS SEC_ENTRY credssp_FreeCredentialsHandle(
PCredHandle phCredential)
200 return SEC_E_INVALID_HANDLE;
202 credentials = (
SSPI_CREDENTIALS*)sspi_SecureHandleGetLowerPointer(phCredential);
205 return SEC_E_INVALID_HANDLE;
207 sspi_CredentialsFree(credentials);
211static SECURITY_STATUS SEC_ENTRY credssp_EncryptMessage(WINPR_ATTR_UNUSED
PCtxtHandle phContext,
212 WINPR_ATTR_UNUSED ULONG fQOP,
214 WINPR_ATTR_UNUSED ULONG MessageSeqNo)
216 WLog_ERR(TAG,
"TODO: Implement");
217 return SEC_E_UNSUPPORTED_FUNCTION;
220static SECURITY_STATUS SEC_ENTRY credssp_DecryptMessage(WINPR_ATTR_UNUSED
PCtxtHandle phContext,
222 WINPR_ATTR_UNUSED ULONG MessageSeqNo,
223 WINPR_ATTR_UNUSED ULONG* pfQOP)
225 WLog_ERR(TAG,
"TODO: Implement");
226 return SEC_E_UNSUPPORTED_FUNCTION;
229static SECURITY_STATUS SEC_ENTRY credssp_MakeSignature(WINPR_ATTR_UNUSED
PCtxtHandle phContext,
230 WINPR_ATTR_UNUSED ULONG fQOP,
232 WINPR_ATTR_UNUSED ULONG MessageSeqNo)
234 WLog_ERR(TAG,
"TODO: Implement");
235 return SEC_E_UNSUPPORTED_FUNCTION;
238static SECURITY_STATUS SEC_ENTRY credssp_VerifySignature(WINPR_ATTR_UNUSED
PCtxtHandle phContext,
240 WINPR_ATTR_UNUSED ULONG MessageSeqNo,
241 WINPR_ATTR_UNUSED ULONG* pfQOP)
243 WLog_ERR(TAG,
"TODO: Implement");
244 return SEC_E_UNSUPPORTED_FUNCTION;
250 credssp_QueryCredentialsAttributesA,
251 credssp_AcquireCredentialsHandleA,
252 credssp_FreeCredentialsHandle,
254 credssp_InitializeSecurityContextA,
259 credssp_QueryContextAttributes,
262 credssp_MakeSignature,
263 credssp_VerifySignature,
273 credssp_EncryptMessage,
274 credssp_DecryptMessage,
282 credssp_QueryCredentialsAttributesW,
283 credssp_AcquireCredentialsHandleW,
284 credssp_FreeCredentialsHandle,
286 credssp_InitializeSecurityContextW,
291 credssp_QueryContextAttributes,
294 credssp_MakeSignature,
295 credssp_VerifySignature,
305 credssp_EncryptMessage,
306 credssp_DecryptMessage,
317 "Microsoft CredSSP Security Provider"
320static WCHAR CREDSSP_SecPkgInfoW_NameBuffer[128] = { 0 };
321static WCHAR CREDSSP_SecPkgInfoW_CommentBuffer[128] = { 0 };
328 CREDSSP_SecPkgInfoW_NameBuffer,
329 CREDSSP_SecPkgInfoW_CommentBuffer
332BOOL CREDSSP_init(
void)
334 InitializeConstWCharFromUtf8(CREDSSP_SecPkgInfoA.Name, CREDSSP_SecPkgInfoW_NameBuffer,
335 ARRAYSIZE(CREDSSP_SecPkgInfoW_NameBuffer));
336 InitializeConstWCharFromUtf8(CREDSSP_SecPkgInfoA.Comment, CREDSSP_SecPkgInfoW_CommentBuffer,
337 ARRAYSIZE(CREDSSP_SecPkgInfoW_CommentBuffer));