Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
5.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: cred.h
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 09-23-97 jbanes LSA integration stuff.
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __CRED_H__
  18. #define __CRED_H__
  19. #define PCT_CRED_MAGIC *(DWORD *)"CtcP"
  20. typedef struct _CRED_THUMBPRINT
  21. {
  22. DWORD LowPart;
  23. DWORD HighPart;
  24. } CRED_THUMBPRINT, *PCRED_THUMBPRINT;
  25. typedef struct _SPCredential
  26. {
  27. PCCERT_CONTEXT pCert;
  28. CRED_THUMBPRINT CertThumbprint;
  29. HCRYPTPROV hProv;
  30. HCRYPTPROV hEphem512Prov;
  31. HCRYPTPROV hEphem1024Prov;
  32. HCRYPTPROV hRemoteProv;
  33. PROV_ENUMALGS_EX * pCapiAlgs; // Algs supported by hProv (server only)
  34. DWORD cCapiAlgs;
  35. DWORD dwCapiFlags; // Whether hProv is static or csp
  36. DWORD fAppRemoteProv; // Does application own hRemoteProv?
  37. DWORD dwCF; // Is this a server SGC cert?
  38. DWORD dwKeySpec;
  39. ExchSpec dwExchSpec;
  40. PPUBLICKEY pPublicKey;
  41. PBYTE pbSsl3SerializedChain;
  42. DWORD cbSsl3SerializedChain;
  43. HCRYPTKEY hTek; // Ephemeral DH
  44. } SPCredential, *PSPCredential;
  45. typedef struct _SPCredentialGroup {
  46. DWORD Magic;
  47. DWORD grbitProtocol;
  48. DWORD grbitEnabledProtocols;
  49. DWORD dwFlags;
  50. RTL_CRITICAL_SECTION csLock;
  51. DWORD dwMinStrength;
  52. DWORD dwMaxStrength;
  53. DWORD cSupportedAlgs;
  54. ALG_ID * palgSupportedAlgs;
  55. DWORD dwSessionLifespan;
  56. ULONG ProcessId;
  57. // server-side only
  58. LONG cMappers;
  59. HMAPPER ** pahMappers;
  60. HCERTSTORE hApplicationRoots; // Specified by application.
  61. HCERTSTORE hUserRoots; // Current user ROOT - monitored for changes
  62. PBYTE pbTrustedIssuers;
  63. DWORD cbTrustedIssuers;
  64. CRED_THUMBPRINT CredThumbprint; // Used when purging server cache entries.
  65. LONG RefCount;
  66. LIST_ENTRY ListEntry;
  67. PSPCredential pCredList;
  68. DWORD cCredList;
  69. } SPCredentialGroup, * PSPCredentialGroup;
  70. typedef struct _LSA_SCHANNEL_SUB_CRED
  71. {
  72. PCCERT_CONTEXT pCert;
  73. LPWSTR pszPin;
  74. HCRYPTPROV hRemoteProv;
  75. PVOID pPrivateKey;
  76. DWORD cbPrivateKey;
  77. LPSTR pszPassword;
  78. } LSA_SCHANNEL_SUB_CRED, *PLSA_SCHANNEL_SUB_CRED;
  79. typedef struct _LSA_SCHANNEL_CRED
  80. {
  81. DWORD dwVersion;
  82. DWORD cSubCreds;
  83. PLSA_SCHANNEL_SUB_CRED paSubCred;
  84. HCERTSTORE hRootStore;
  85. DWORD cMappers;
  86. struct _HMAPPER **aphMappers;
  87. DWORD cSupportedAlgs;
  88. ALG_ID * palgSupportedAlgs;
  89. DWORD grbitEnabledProtocols;
  90. DWORD dwMinimumCipherStrength;
  91. DWORD dwMaximumCipherStrength;
  92. DWORD dwSessionLifespan;
  93. DWORD dwFlags;
  94. DWORD reserved;
  95. } LSA_SCHANNEL_CRED, *PLSA_SCHANNEL_CRED;
  96. #define LockCredential(p) RtlEnterCriticalSection(&(p)->csLock)
  97. #define UnlockCredential(p) RtlLeaveCriticalSection(&(p)->csLock)
  98. BOOL
  99. SslInitCredentialManager(VOID);
  100. BOOL
  101. SslFreeCredentialManager(VOID);
  102. BOOL
  103. SslCheckForGPEvent(void);
  104. BOOL
  105. IsValidThumbprint(
  106. PCRED_THUMBPRINT Thumbprint);
  107. BOOL
  108. IsSameThumbprint(
  109. PCRED_THUMBPRINT Thumbprint1,
  110. PCRED_THUMBPRINT Thumbprint2);
  111. void
  112. GenerateCertThumbprint(
  113. PCCERT_CONTEXT pCertContext,
  114. PCRED_THUMBPRINT Thumbprint);
  115. void
  116. GenerateRandomThumbprint(
  117. PCRED_THUMBPRINT Thumbprint);
  118. BOOL
  119. DoesCredThumbprintMatch(
  120. PSPCredentialGroup pCredGroup,
  121. PCRED_THUMBPRINT pThumbprint);
  122. SP_STATUS
  123. SPCreateCred(
  124. DWORD dwProtocol,
  125. PLSA_SCHANNEL_SUB_CRED pSubCred,
  126. PSPCredential pCurrentCred,
  127. BOOL * pfEventLogged);
  128. SP_STATUS
  129. SPCreateCredential(
  130. PSPCredentialGroup *ppCred,
  131. DWORD grbitProtocol,
  132. PLSA_SCHANNEL_CRED pSchannelCred);
  133. SP_STATUS
  134. AddCredentialToGroup(
  135. PSPCredentialGroup pCredGroup,
  136. PSPCredential pCred);
  137. SP_STATUS
  138. IsCredentialInGroup(
  139. PSPCredentialGroup pCredGroup,
  140. PCCERT_CONTEXT pCertContext,
  141. PBOOL pfInGroup);
  142. SECURITY_STATUS
  143. UpdateCredentialFormat(
  144. PSCH_CRED pSchCred, // in
  145. PLSA_SCHANNEL_CRED pCred); // out
  146. DWORD
  147. GetCredentialKeySize(
  148. PSPCredential pCred);
  149. NTSTATUS
  150. FindDefaultMachineCred(
  151. PSPCredentialGroup *ppCred,
  152. DWORD dwProtocol);
  153. BOOL
  154. SPReferenceCredential(
  155. PSPCredentialGroup pCred);
  156. BOOL
  157. SPDereferenceCredential(
  158. PSPCredentialGroup pCred);
  159. void
  160. SPDeleteCred(
  161. PSPCredential pCred);
  162. BOOL
  163. SPDeleteCredential(PSPCredentialGroup pCred);
  164. // Downlevel credential versions
  165. #define SSL_CREDENTIAL_VERSION 0
  166. // flag bit definitions
  167. #define CRED_FLAG_NO_SYSTEM_MAPPER 0x00000004 // client cert mapping
  168. #define CRED_FLAG_NO_SERVERNAME_CHECK 0x00000008 // server cert validation
  169. #define CRED_FLAG_MANUAL_CRED_VALIDATION 0x00000010 // server cert validation
  170. #define CRED_FLAG_NO_DEFAULT_CREDS 0x00000020 // client certificate selection
  171. #define CRED_FLAG_UPDATE_ISSUER_LIST 0x00000040 // new setting have been downloaded from GPO
  172. #define CRED_FLAG_DELETED 0x00000080 // credential has been deleted by application.
  173. #define CRED_FLAG_REVCHECK_END_CERT 0x00000100
  174. #define CRED_FLAG_REVCHECK_CHAIN 0x00000200
  175. #define CRED_FLAG_REVCHECK_CHAIN_EXCLUDE_ROOT 0x00000400
  176. #define CRED_FLAG_IGNORE_NO_REVOCATION_CHECK 0x00000800
  177. #define CRED_FLAG_IGNORE_REVOCATION_OFFLINE 0x00001000
  178. #define CRED_FLAG_DISABLE_RECONNECTS 0x00004000
  179. #endif