Leaked source code of windows server 2003
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.

245 lines
6.7 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 fAppRemoteProv; // Does application own hRemoteProv?
  36. DWORD dwCertFlags; // Is this a server SGC cert?
  37. DWORD dwKeySpec;
  38. ExchSpec dwExchSpec;
  39. PPUBLICKEY pPublicKey;
  40. PBYTE pbSsl3SerializedChain;
  41. DWORD cbSsl3SerializedChain;
  42. HCRYPTKEY hTek; // Ephemeral DH
  43. LIST_ENTRY ListEntry;
  44. } SPCredential, *PSPCredential;
  45. typedef struct _SPCredentialGroup {
  46. DWORD Magic;
  47. DWORD grbitProtocol;
  48. DWORD grbitEnabledProtocols;
  49. DWORD dwFlags;
  50. DWORD dwMinStrength;
  51. DWORD dwMaxStrength;
  52. DWORD cSupportedAlgs;
  53. ALG_ID * palgSupportedAlgs;
  54. DWORD dwSessionLifespan;
  55. ULONG ProcessId;
  56. // server-side only
  57. LONG cMappers;
  58. HMAPPER ** pahMappers;
  59. HCERTSTORE hApplicationRoots; // Specified by application.
  60. HCERTSTORE hUserRoots; // Current user ROOT - monitored for changes
  61. PBYTE pbTrustedIssuers;
  62. DWORD cbTrustedIssuers;
  63. CRED_THUMBPRINT CredThumbprint; // Used when purging server cache entries.
  64. LONG RefCount;
  65. DWORD CredCount;
  66. LIST_ENTRY CredList;
  67. RTL_RESOURCE csCredListLock;
  68. LIST_ENTRY GlobalCredList;
  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 LockCredentialExclusive(p) RtlAcquireResourceExclusive(&(p)->csCredListLock, TRUE)
  97. #define LockCredentialShared(p) RtlAcquireResourceShared(&(p)->csCredListLock, TRUE)
  98. #define UnlockCredential(p) RtlReleaseResource(&(p)->csCredListLock)
  99. BOOL
  100. SslInitCredentialManager(VOID);
  101. BOOL
  102. SslFreeCredentialManager(VOID);
  103. BOOL
  104. SslCheckForGPEvent(void);
  105. BOOL
  106. IsValidThumbprint(
  107. PCRED_THUMBPRINT Thumbprint);
  108. BOOL
  109. IsSameThumbprint(
  110. PCRED_THUMBPRINT Thumbprint1,
  111. PCRED_THUMBPRINT Thumbprint2);
  112. void
  113. GenerateCertThumbprint(
  114. PCCERT_CONTEXT pCertContext,
  115. PCRED_THUMBPRINT Thumbprint);
  116. NTSTATUS
  117. GenerateRandomThumbprint(
  118. PCRED_THUMBPRINT Thumbprint);
  119. BOOL
  120. DoesCredThumbprintMatch(
  121. PSPCredentialGroup pCredGroup,
  122. PCRED_THUMBPRINT pThumbprint);
  123. void
  124. ComputeCredExpiry(
  125. PSPCredentialGroup pCredGroup,
  126. PTimeStamp ptsExpiry);
  127. SP_STATUS
  128. SPCreateCred(
  129. DWORD dwProtocol,
  130. PLSA_SCHANNEL_SUB_CRED pSubCred,
  131. PSPCredential pCurrentCred,
  132. BOOL * pfEventLogged);
  133. SP_STATUS
  134. SPCreateCredential(
  135. PSPCredentialGroup *ppCred,
  136. DWORD grbitProtocol,
  137. PLSA_SCHANNEL_CRED pSchannelCred);
  138. SP_STATUS
  139. AddCredentialToGroup(
  140. PSPCredentialGroup pCredGroup,
  141. PSPCredential pCred);
  142. SP_STATUS
  143. IsCredentialInGroup(
  144. PSPCredentialGroup pCredGroup,
  145. PCCERT_CONTEXT pCertContext,
  146. PBOOL pfInGroup);
  147. SECURITY_STATUS
  148. UpdateCredentialFormat(
  149. PSCH_CRED pSchCred, // in
  150. PLSA_SCHANNEL_CRED pCred); // out
  151. void
  152. GlobalCheckForCertificateRenewal(void);
  153. void
  154. CheckForCredentialRenewal(
  155. PSPCredentialGroup pCredGroup);
  156. BOOL
  157. CheckForCertificateRenewal(
  158. DWORD dwProtocol,
  159. PCCERT_CONTEXT pCertContext,
  160. PCCERT_CONTEXT *ppNewCertificate);
  161. NTSTATUS
  162. FindDefaultMachineCred(
  163. PSPCredentialGroup *ppCred,
  164. DWORD dwProtocol);
  165. BOOL
  166. SPReferenceCredential(
  167. PSPCredentialGroup pCred);
  168. BOOL
  169. SPDereferenceCredential(
  170. PSPCredentialGroup pCred,
  171. BOOL fFreeRemoteHandle);
  172. void
  173. SPDeleteCred(
  174. PSPCredential pCred,
  175. BOOL fFreeRemoteHandle);
  176. BOOL
  177. SPDeleteCredential(
  178. PSPCredentialGroup pCred,
  179. BOOL fFreeRemoteHandle);
  180. // flag bit definitions
  181. #define CRED_FLAG_NO_SYSTEM_MAPPER 0x00000004 // client cert mapping
  182. #define CRED_FLAG_NO_SERVERNAME_CHECK 0x00000008 // server cert validation
  183. #define CRED_FLAG_MANUAL_CRED_VALIDATION 0x00000010 // server cert validation
  184. #define CRED_FLAG_NO_DEFAULT_CREDS 0x00000020 // client certificate selection
  185. #define CRED_FLAG_UPDATE_ISSUER_LIST 0x00000040 // new settings have been downloaded from GPO
  186. #define CRED_FLAG_DELETED 0x00000080 // credential has been deleted by application.
  187. #define CRED_FLAG_REVCHECK_END_CERT 0x00000100
  188. #define CRED_FLAG_REVCHECK_CHAIN 0x00000200
  189. #define CRED_FLAG_REVCHECK_CHAIN_EXCLUDE_ROOT 0x00000400
  190. #define CRED_FLAG_IGNORE_NO_REVOCATION_CHECK 0x00000800
  191. #define CRED_FLAG_IGNORE_REVOCATION_OFFLINE 0x00001000
  192. #define CRED_FLAG_CHECK_FOR_RENEWAL 0x00002000
  193. #define CRED_FLAG_DISABLE_RECONNECTS 0x00004000
  194. #endif