--- /dev/null
+/**
+ * WinPR: Windows Portable Runtime
+ * Credentials Management
+ *
+ * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WINPR_CREDENTIALS_H
+#define WINPR_CREDENTIALS_H
+
+#include <winpr/winpr.h>
+#include <winpr/wtypes.h>
+
+#ifndef _WIN32
+
+#define CRED_SESSION_WILDCARD_NAME_W L"*Session"
+#define CRED_SESSION_WILDCARD_NAME_A "*Session"
+#define CRED_SESSION_WILDCARD_NAME_LENGTH (sizeof(CRED_SESSION_WILDCARD_NAME_A) - 1)
+
+#define CRED_MAX_STRING_LENGTH 256
+#define CRED_MAX_USERNAME_LENGTH (256 + 1 + 256)
+#define CRED_MAX_GENERIC_TARGET_NAME_LENGTH 32767
+#define CRED_MAX_DOMAIN_TARGET_NAME_LENGTH (256 + 1 + 80)
+#define CRED_MAX_VALUE_SIZE 256
+#define CRED_MAX_ATTRIBUTES 64
+
+#define CRED_FLAGS_PASSWORD_FOR_CERT 0x0001
+#define CRED_FLAGS_PROMPT_NOW 0x0002
+#define CRED_FLAGS_USERNAME_TARGET 0x0004
+#define CRED_FLAGS_OWF_CRED_BLOB 0x0008
+#define CRED_FLAGS_VALID_FLAGS 0x000F
+
+#define CRED_TYPE_GENERIC 1
+#define CRED_TYPE_DOMAIN_PASSWORD 2
+#define CRED_TYPE_DOMAIN_CERTIFICATE 3
+#define CRED_TYPE_DOMAIN_VISIBLE_PASSWORD 4
+#define CRED_TYPE_MAXIMUM 5
+#define CRED_TYPE_MAXIMUM_EX (CRED_TYPE_MAXIMUM + 1000)
+
+#define CRED_MAX_CREDENTIAL_BLOB_SIZE 512
+
+#define CRED_PERSIST_NONE 0
+#define CRED_PERSIST_SESSION 1
+#define CRED_PERSIST_LOCAL_MACHINE 2
+#define CRED_PERSIST_ENTERPRISE 3
+
+#define CRED_PRESERVE_CREDENTIAL_BLOB 0x1
+#define CRED_CACHE_TARGET_INFORMATION 0x1
+#define CRED_ALLOW_NAME_RESOLUTION 0x1
+
+typedef struct _CREDENTIAL_ATTRIBUTEA
+{
+ LPSTR Keyword;
+ DWORD Flags;
+ DWORD ValueSize;
+ LPBYTE Value;
+} CREDENTIAL_ATTRIBUTEA, *PCREDENTIAL_ATTRIBUTEA;
+
+typedef struct _CREDENTIAL_ATTRIBUTEW
+{
+ LPWSTR Keyword;
+ DWORD Flags;
+ DWORD ValueSize;
+ LPBYTE Value;
+} CREDENTIAL_ATTRIBUTEW, *PCREDENTIAL_ATTRIBUTEW;
+
+typedef struct _CREDENTIALA
+{
+ DWORD Flags;
+ DWORD Type;
+ LPSTR TargetName;
+ LPSTR Comment;
+ FILETIME LastWritten;
+ DWORD CredentialBlobSize;
+ LPBYTE CredentialBlob;
+ DWORD Persist;
+ DWORD AttributeCount;
+ PCREDENTIAL_ATTRIBUTEA Attributes;
+ LPSTR TargetAlias;
+ LPSTR UserName;
+} CREDENTIALA, *PCREDENTIALA;
+
+typedef struct _CREDENTIALW
+{
+ DWORD Flags;
+ DWORD Type;
+ LPWSTR TargetName;
+ LPWSTR Comment;
+ FILETIME LastWritten;
+ DWORD CredentialBlobSize;
+ LPBYTE CredentialBlob;
+ DWORD Persist;
+ DWORD AttributeCount;
+ PCREDENTIAL_ATTRIBUTEW Attributes;
+ LPWSTR TargetAlias;
+ LPWSTR UserName;
+} CREDENTIALW, *PCREDENTIALW;
+
+typedef struct _CREDENTIAL_TARGET_INFORMATIONA
+{
+ LPSTR TargetName;
+ LPSTR NetbiosServerName;
+ LPSTR DnsServerName;
+ LPSTR NetbiosDomainName;
+ LPSTR DnsDomainName;
+ LPSTR DnsTreeName;
+ LPSTR PackageName;
+ ULONG Flags;
+ DWORD CredTypeCount;
+ LPDWORD CredTypes;
+} CREDENTIAL_TARGET_INFORMATIONA, *PCREDENTIAL_TARGET_INFORMATIONA;
+
+typedef struct _CREDENTIAL_TARGET_INFORMATIONW
+{
+ LPWSTR TargetName;
+ LPWSTR NetbiosServerName;
+ LPWSTR DnsServerName;
+ LPWSTR NetbiosDomainName;
+ LPWSTR DnsDomainName;
+ LPWSTR DnsTreeName;
+ LPWSTR PackageName;
+ ULONG Flags;
+ DWORD CredTypeCount;
+ LPDWORD CredTypes;
+} CREDENTIAL_TARGET_INFORMATIONW, *PCREDENTIAL_TARGET_INFORMATIONW;
+
+typedef enum _CRED_MARSHAL_TYPE
+{
+ CertCredential = 1,
+ UsernameTargetCredential
+} CRED_MARSHAL_TYPE, *PCRED_MARSHAL_TYPE;
+
+typedef enum _CRED_PROTECTION_TYPE
+{
+ CredUnprotected = 0,
+ CredUserProtection = 1,
+ CredTrustedProtection = 2
+} CRED_PROTECTION_TYPE, *PCRED_PROTECTION_TYPE;
+
+WINPR_API BOOL CredWriteW(PCREDENTIALW Credential, DWORD Flags);
+WINPR_API BOOL CredWriteA(PCREDENTIALA Credential, DWORD Flags);
+
+WINPR_API BOOL CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW* Credential);
+WINPR_API BOOL CredReadA(LPCSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALA* Credential);
+
+WINPR_API BOOL CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD* Count, PCREDENTIALW** Credential);
+WINPR_API BOOL CredEnumerateA(LPCSTR Filter, DWORD Flags, DWORD* Count, PCREDENTIALA** Credential);
+
+WINPR_API BOOL CredWriteDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW TargetInfo, PCREDENTIALW Credential, DWORD Flags);
+WINPR_API BOOL CredWriteDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInfo, PCREDENTIALA Credential, DWORD Flags);
+
+WINPR_API BOOL CredReadDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW TargetInfo, DWORD Flags, DWORD* Count, PCREDENTIALW** Credential);
+WINPR_API BOOL CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInfo, DWORD Flags, DWORD* Count, PCREDENTIALA** Credential);
+
+WINPR_API BOOL CredDeleteW(LPCWSTR TargetName, DWORD Type, DWORD Flags);
+WINPR_API BOOL CredDeleteA(LPCSTR TargetName, DWORD Type, DWORD Flags);
+
+WINPR_API BOOL CredRenameW(LPCWSTR OldTargetName, LPCWSTR NewTargetName, DWORD Type, DWORD Flags);
+WINPR_API BOOL CredRenameA(LPCSTR OldTargetName, LPCSTR NewTargetName, DWORD Type, DWORD Flags);
+
+WINPR_API BOOL CredGetTargetInfoW(LPCWSTR TargetName, DWORD Flags, PCREDENTIAL_TARGET_INFORMATIONW* TargetInfo);
+WINPR_API BOOL CredGetTargetInfoA(LPCSTR TargetName, DWORD Flags, PCREDENTIAL_TARGET_INFORMATIONA* TargetInfo);
+
+WINPR_API BOOL CredMarshalCredentialW(CRED_MARSHAL_TYPE CredType, PVOID Credential, LPWSTR* MarshaledCredential);
+WINPR_API BOOL CredMarshalCredentialA(CRED_MARSHAL_TYPE CredType, PVOID Credential, LPSTR* MarshaledCredential);
+
+WINPR_API BOOL CredUnmarshalCredentialW(LPCWSTR MarshaledCredential, PCRED_MARSHAL_TYPE CredType, PVOID* Credential);
+WINPR_API BOOL CredUnmarshalCredentialA(LPCSTR MarshaledCredential, PCRED_MARSHAL_TYPE CredType, PVOID* Credential);
+
+WINPR_API BOOL CredIsMarshaledCredentialW(LPCWSTR MarshaledCredential);
+WINPR_API BOOL CredIsMarshaledCredentialA(LPCSTR MarshaledCredential);
+
+WINPR_API BOOL CredProtectW(BOOL fAsSelf, LPWSTR pszCredentials, DWORD cchCredentials,
+ LPWSTR pszProtectedCredentials, DWORD* pcchMaxChars, CRED_PROTECTION_TYPE* ProtectionType);
+WINPR_API BOOL CredProtectA(BOOL fAsSelf, LPSTR pszCredentials, DWORD cchCredentials,
+ LPSTR pszProtectedCredentials, DWORD* pcchMaxChars, CRED_PROTECTION_TYPE* ProtectionType);
+
+WINPR_API BOOL CredUnprotectW(BOOL fAsSelf, LPWSTR pszProtectedCredentials,
+ DWORD cchCredentials, LPWSTR pszCredentials, DWORD* pcchMaxChars);
+WINPR_API BOOL CredUnprotectA(BOOL fAsSelf, LPSTR pszProtectedCredentials,
+ DWORD cchCredentials, LPSTR pszCredentials, DWORD* pcchMaxChars);
+
+WINPR_API BOOL CredIsProtectedW(LPWSTR pszProtectedCredentials, CRED_PROTECTION_TYPE* pProtectionType);
+WINPR_API BOOL CredIsProtectedA(LPSTR pszProtectedCredentials, CRED_PROTECTION_TYPE* pProtectionType);
+
+WINPR_API BOOL CredFindBestCredentialW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW* Credential);
+WINPR_API BOOL CredFindBestCredentialA(LPCSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALA* Credential);
+
+WINPR_API BOOL CredGetSessionTypes(DWORD MaximumPersistCount, LPDWORD MaximumPersist);
+
+WINPR_API VOID CredFree(PVOID Buffer);
+
+#endif
+
+#endif /* WINPR_CREDENTIALS_H */
+
--- /dev/null
+/**
+ * WinPR: Windows Portable Runtime
+ * Credentials Management
+ *
+ * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <winpr/crt.h>
+
+#include <winpr/credentials.h>
+
+/*
+ * Low-Level Credentials Management Functions:
+ * http://msdn.microsoft.com/en-us/library/windows/desktop/aa374731(v=vs.85).aspx#low_level_credentials_management_functions
+ */
+
+#ifndef _WIN32
+
+BOOL CredWriteW(PCREDENTIALW Credential, DWORD Flags)
+{
+ return TRUE;
+}
+
+BOOL CredWriteA(PCREDENTIALA Credential, DWORD Flags)
+{
+ return TRUE;
+}
+
+BOOL CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW* Credential)
+{
+ return TRUE;
+}
+
+BOOL CredReadA(LPCSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALA* Credential)
+{
+ return TRUE;
+}
+
+BOOL CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD* Count, PCREDENTIALW** Credential)
+{
+ return TRUE;
+}
+
+BOOL CredEnumerateA(LPCSTR Filter, DWORD Flags, DWORD* Count, PCREDENTIALA** Credential)
+{
+ return TRUE;
+}
+
+BOOL CredWriteDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW TargetInfo, PCREDENTIALW Credential, DWORD Flags)
+{
+ return TRUE;
+}
+
+BOOL CredWriteDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInfo, PCREDENTIALA Credential, DWORD Flags)
+{
+ return TRUE;
+}
+
+BOOL CredReadDomainCredentialsW(PCREDENTIAL_TARGET_INFORMATIONW TargetInfo, DWORD Flags, DWORD* Count, PCREDENTIALW** Credential)
+{
+ return TRUE;
+}
+
+BOOL CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInfo, DWORD Flags, DWORD* Count, PCREDENTIALA** Credential)
+{
+ return TRUE;
+}
+
+BOOL CredDeleteW(LPCWSTR TargetName, DWORD Type, DWORD Flags)
+{
+ return TRUE;
+}
+
+BOOL CredDeleteA(LPCSTR TargetName, DWORD Type, DWORD Flags)
+{
+ return TRUE;
+}
+
+BOOL CredRenameW(LPCWSTR OldTargetName, LPCWSTR NewTargetName, DWORD Type, DWORD Flags)
+{
+ return TRUE;
+}
+
+BOOL CredRenameA(LPCSTR OldTargetName, LPCSTR NewTargetName, DWORD Type, DWORD Flags)
+{
+ return TRUE;
+}
+
+BOOL CredGetTargetInfoW(LPCWSTR TargetName, DWORD Flags, PCREDENTIAL_TARGET_INFORMATIONW* TargetInfo)
+{
+ return TRUE;
+}
+
+BOOL CredGetTargetInfoA(LPCSTR TargetName, DWORD Flags, PCREDENTIAL_TARGET_INFORMATIONA* TargetInfo)
+{
+ return TRUE;
+}
+
+BOOL CredMarshalCredentialW(CRED_MARSHAL_TYPE CredType, PVOID Credential, LPWSTR* MarshaledCredential)
+{
+ return TRUE;
+}
+
+BOOL CredMarshalCredentialA(CRED_MARSHAL_TYPE CredType, PVOID Credential, LPSTR* MarshaledCredential)
+{
+ return TRUE;
+}
+
+BOOL CredUnmarshalCredentialW(LPCWSTR MarshaledCredential, PCRED_MARSHAL_TYPE CredType, PVOID* Credential)
+{
+ return TRUE;
+}
+
+BOOL CredUnmarshalCredentialA(LPCSTR MarshaledCredential, PCRED_MARSHAL_TYPE CredType, PVOID* Credential)
+{
+ return TRUE;
+}
+
+BOOL CredIsMarshaledCredentialW(LPCWSTR MarshaledCredential)
+{
+ return TRUE;
+}
+
+BOOL CredIsMarshaledCredentialA(LPCSTR MarshaledCredential)
+{
+ return TRUE;
+}
+
+BOOL CredProtectW(BOOL fAsSelf, LPWSTR pszCredentials, DWORD cchCredentials,
+ LPWSTR pszProtectedCredentials, DWORD* pcchMaxChars, CRED_PROTECTION_TYPE* ProtectionType)
+{
+ return TRUE;
+}
+
+BOOL CredProtectA(BOOL fAsSelf, LPSTR pszCredentials, DWORD cchCredentials,
+ LPSTR pszProtectedCredentials, DWORD* pcchMaxChars, CRED_PROTECTION_TYPE* ProtectionType)
+{
+ return TRUE;
+}
+
+BOOL CredUnprotectW(BOOL fAsSelf, LPWSTR pszProtectedCredentials,
+ DWORD cchCredentials, LPWSTR pszCredentials, DWORD* pcchMaxChars)
+{
+ return TRUE;
+}
+
+BOOL CredUnprotectA(BOOL fAsSelf, LPSTR pszProtectedCredentials,
+ DWORD cchCredentials, LPSTR pszCredentials, DWORD* pcchMaxChars)
+{
+ return TRUE;
+}
+
+BOOL CredIsProtectedW(LPWSTR pszProtectedCredentials, CRED_PROTECTION_TYPE* pProtectionType)
+{
+ return TRUE;
+}
+
+BOOL CredIsProtectedA(LPSTR pszProtectedCredentials, CRED_PROTECTION_TYPE* pProtectionType)
+{
+ return TRUE;
+}
+
+BOOL CredFindBestCredentialW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW* Credential)
+{
+ return TRUE;
+}
+
+BOOL CredFindBestCredentialA(LPCSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALA* Credential)
+{
+ return TRUE;
+}
+
+BOOL CredGetSessionTypes(DWORD MaximumPersistCount, LPDWORD MaximumPersist)
+{
+ return TRUE;
+}
+
+VOID CredFree(PVOID Buffer)
+{
+
+}
+
+#endif