20 #include <winpr/config.h>
22 #include <winpr/crt.h>
23 #include <winpr/sspi.h>
28 #include "../../log.h"
30 #define TAG WINPR_TAG("sspi.CredSSP")
32 static const char* CREDSSP_PACKAGE_NAME =
"CredSSP";
34 static SECURITY_STATUS SEC_ENTRY credssp_InitializeSecurityContextW(
36 ULONG Reserved1, ULONG TargetDataRep,
PSecBufferDesc pInput, ULONG Reserved2,
39 WLog_ERR(TAG,
"TODO: Implement");
40 return SEC_E_UNSUPPORTED_FUNCTION;
43 static SECURITY_STATUS SEC_ENTRY credssp_InitializeSecurityContextA(
45 ULONG Reserved1, ULONG TargetDataRep,
PSecBufferDesc pInput, ULONG Reserved2,
52 if (phContext && !phContext->dwLower && !phContext->dwUpper)
53 return SEC_E_INVALID_HANDLE;
55 context = (
CREDSSP_CONTEXT*)sspi_SecureHandleGetLowerPointer(phContext);
64 context = credssp_ContextNew();
67 return SEC_E_INSUFFICIENT_MEMORY;
69 credentials = (
SSPI_CREDENTIALS*)sspi_SecureHandleGetLowerPointer(phCredential);
73 credssp_ContextFree(context);
74 return SEC_E_INVALID_HANDLE;
77 sspi_SecureHandleSetLowerPointer(phNewContext, context);
79 cnv.cpv = CREDSSP_PACKAGE_NAME;
80 sspi_SecureHandleSetUpperPointer(phNewContext, cnv.pv);
102 static SECURITY_STATUS SEC_ENTRY credssp_QueryContextAttributes(
PCtxtHandle phContext,
103 ULONG ulAttribute,
void* pBuffer)
106 return SEC_E_INVALID_HANDLE;
109 return SEC_E_INSUFFICIENT_MEMORY;
111 WLog_ERR(TAG,
"TODO: Implement");
112 return SEC_E_UNSUPPORTED_FUNCTION;
115 static SECURITY_STATUS SEC_ENTRY credssp_AcquireCredentialsHandleW(
116 SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage, ULONG fCredentialUse,
void* pvLogonID,
117 void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
void* pvGetKeyArgument,
PCredHandle phCredential,
120 WLog_ERR(TAG,
"TODO: Implement");
121 return SEC_E_UNSUPPORTED_FUNCTION;
124 static SECURITY_STATUS SEC_ENTRY credssp_AcquireCredentialsHandleA(
125 SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage, ULONG fCredentialUse,
void* pvLogonID,
126 void* pAuthData, SEC_GET_KEY_FN pGetKeyFn,
void* pvGetKeyArgument,
PCredHandle phCredential,
130 SEC_WINNT_AUTH_IDENTITY* identity = NULL;
132 if (fCredentialUse == SECPKG_CRED_OUTBOUND)
139 credentials = sspi_CredentialsNew();
142 return SEC_E_INSUFFICIENT_MEMORY;
144 identity = (SEC_WINNT_AUTH_IDENTITY*)pAuthData;
145 CopyMemory(&(credentials->identity), identity,
sizeof(SEC_WINNT_AUTH_IDENTITY));
146 sspi_SecureHandleSetLowerPointer(phCredential, (
void*)credentials);
148 cnv.cpv = CREDSSP_PACKAGE_NAME;
149 sspi_SecureHandleSetUpperPointer(phCredential, cnv.pv);
153 WLog_ERR(TAG,
"TODO: Implement");
154 return SEC_E_UNSUPPORTED_FUNCTION;
157 static SECURITY_STATUS SEC_ENTRY credssp_QueryCredentialsAttributesW(
PCredHandle phCredential,
161 WLog_ERR(TAG,
"TODO: Implement");
162 return SEC_E_UNSUPPORTED_FUNCTION;
165 static SECURITY_STATUS SEC_ENTRY credssp_QueryCredentialsAttributesA(
PCredHandle phCredential,
169 if (ulAttribute == SECPKG_CRED_ATTR_NAMES)
175 return SEC_E_INVALID_HANDLE;
180 WLog_ERR(TAG,
"TODO: Implement");
181 return SEC_E_UNSUPPORTED_FUNCTION;
184 static SECURITY_STATUS SEC_ENTRY credssp_FreeCredentialsHandle(
PCredHandle phCredential)
189 return SEC_E_INVALID_HANDLE;
191 credentials = (
SSPI_CREDENTIALS*)sspi_SecureHandleGetLowerPointer(phCredential);
194 return SEC_E_INVALID_HANDLE;
196 sspi_CredentialsFree(credentials);
200 static SECURITY_STATUS SEC_ENTRY credssp_EncryptMessage(
PCtxtHandle phContext, ULONG fQOP,
203 WLog_ERR(TAG,
"TODO: Implement");
204 return SEC_E_UNSUPPORTED_FUNCTION;
207 static SECURITY_STATUS SEC_ENTRY credssp_DecryptMessage(
PCtxtHandle phContext,
211 WLog_ERR(TAG,
"TODO: Implement");
212 return SEC_E_UNSUPPORTED_FUNCTION;
215 static SECURITY_STATUS SEC_ENTRY credssp_MakeSignature(
PCtxtHandle phContext, ULONG fQOP,
218 WLog_ERR(TAG,
"TODO: Implement");
219 return SEC_E_UNSUPPORTED_FUNCTION;
222 static SECURITY_STATUS SEC_ENTRY credssp_VerifySignature(
PCtxtHandle phContext,
224 ULONG MessageSeqNo, ULONG* pfQOP)
226 WLog_ERR(TAG,
"TODO: Implement");
227 return SEC_E_UNSUPPORTED_FUNCTION;
233 credssp_QueryCredentialsAttributesA,
234 credssp_AcquireCredentialsHandleA,
235 credssp_FreeCredentialsHandle,
237 credssp_InitializeSecurityContextA,
242 credssp_QueryContextAttributes,
245 credssp_MakeSignature,
246 credssp_VerifySignature,
256 credssp_EncryptMessage,
257 credssp_DecryptMessage,
265 credssp_QueryCredentialsAttributesW,
266 credssp_AcquireCredentialsHandleW,
267 credssp_FreeCredentialsHandle,
269 credssp_InitializeSecurityContextW,
274 credssp_QueryContextAttributes,
277 credssp_MakeSignature,
278 credssp_VerifySignature,
288 credssp_EncryptMessage,
289 credssp_DecryptMessage,
300 "Microsoft CredSSP Security Provider"
303 static WCHAR CREDSSP_SecPkgInfoW_NameBuffer[128] = { 0 };
304 static WCHAR CREDSSP_SecPkgInfoW_CommentBuffer[128] = { 0 };
311 CREDSSP_SecPkgInfoW_NameBuffer,
312 CREDSSP_SecPkgInfoW_CommentBuffer
315 BOOL CREDSSP_init(
void)
317 InitializeConstWCharFromUtf8(CREDSSP_SecPkgInfoA.Name, CREDSSP_SecPkgInfoW_NameBuffer,
318 ARRAYSIZE(CREDSSP_SecPkgInfoW_NameBuffer));
319 InitializeConstWCharFromUtf8(CREDSSP_SecPkgInfoA.Comment, CREDSSP_SecPkgInfoW_CommentBuffer,
320 ARRAYSIZE(CREDSSP_SecPkgInfoW_CommentBuffer));