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.

225 lines
5.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows NT Security
  4. // Copyright (C) Microsoft Corporation, 1997 - 1999
  5. //
  6. // File: scstore.h
  7. //
  8. // Contents: Smart Card Store Provider
  9. //
  10. // History: 11-25-1997 kirtd Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #if !defined(__SCSTORE_H__)
  14. #define __SCSTORE_H__
  15. //
  16. // Store provider open store function name
  17. //
  18. #define SMART_CARD_OPEN_STORE_PROV_FUNC "SmartCardProvOpenStore"
  19. //
  20. // CSmartCardStore. This class implements all callbacks for the Smart Card
  21. // Store provider. A pointer to an instance of this class is used as the
  22. // hStoreProv parameter for the callback functions implemented
  23. //
  24. class CSmartCardStore
  25. {
  26. public:
  27. //
  28. // Construction
  29. //
  30. CSmartCardStore ();
  31. ~CSmartCardStore ();
  32. //
  33. // Store functions
  34. //
  35. BOOL OpenStore (
  36. LPCSTR pszStoreProv,
  37. DWORD dwMsgAndCertEncodingType,
  38. HCRYPTPROV hCryptProv,
  39. DWORD dwFlags,
  40. const void* pvPara,
  41. HCERTSTORE hCertStore,
  42. PCERT_STORE_PROV_INFO pStoreProvInfo
  43. );
  44. VOID CloseStore (DWORD dwFlags);
  45. BOOL DeleteCert (PCCERT_CONTEXT pCertContext, DWORD dwFlags);
  46. BOOL SetCertProperty (
  47. PCCERT_CONTEXT pCertContext,
  48. DWORD dwPropId,
  49. DWORD dwFlags,
  50. const void* pvPara
  51. );
  52. BOOL WriteCert (PCCERT_CONTEXT pCertContext, DWORD dwFlags);
  53. BOOL StoreControl (DWORD dwFlags, DWORD dwCtrlType, LPVOID pvCtrlPara);
  54. BOOL Resync ();
  55. private:
  56. //
  57. // Object lock
  58. //
  59. CRITICAL_SECTION m_StoreLock;
  60. //
  61. // Open Store flags
  62. //
  63. DWORD m_dwOpenFlags;
  64. //
  65. // Open filter parameters
  66. //
  67. LPWSTR m_pwszCardName;
  68. LPWSTR m_pwszProvider;
  69. DWORD m_dwProviderType;
  70. LPWSTR m_pwszContainer;
  71. //
  72. // Cache Store
  73. //
  74. HCERTSTORE m_hCacheStore;
  75. //
  76. // Private methods
  77. //
  78. BOOL FillCacheStore (BOOL fClearCache);
  79. BOOL ModifyCertOnCard (PCCERT_CONTEXT pCertContext, BOOL fDelete);
  80. };
  81. //
  82. // Smart Card Store Provider functions
  83. //
  84. BOOL WINAPI SmartCardProvOpenStore (
  85. IN LPCSTR pszStoreProv,
  86. IN DWORD dwMsgAndCertEncodingType,
  87. IN HCRYPTPROV hCryptProv,
  88. IN DWORD dwFlags,
  89. IN const void* pvPara,
  90. IN HCERTSTORE hCertStore,
  91. IN OUT PCERT_STORE_PROV_INFO pStoreProvInfo
  92. );
  93. void WINAPI SmartCardProvCloseStore (
  94. IN HCERTSTOREPROV hStoreProv,
  95. IN DWORD dwFlags
  96. );
  97. BOOL WINAPI SmartCardProvDeleteCert (
  98. IN HCERTSTOREPROV hStoreProv,
  99. IN PCCERT_CONTEXT pCertContext,
  100. IN DWORD dwFlags
  101. );
  102. BOOL WINAPI SmartCardProvSetCertProperty (
  103. IN HCERTSTOREPROV hStoreProv,
  104. IN PCCERT_CONTEXT pCertContext,
  105. IN DWORD dwPropId,
  106. IN DWORD dwFlags,
  107. IN const void* pvData
  108. );
  109. BOOL WINAPI SmartCardProvWriteCert (
  110. IN HCERTSTOREPROV hStoreProv,
  111. IN PCCERT_CONTEXT pCertContext,
  112. IN DWORD dwFlags
  113. );
  114. BOOL WINAPI SmartCardProvStoreControl (
  115. IN HCERTSTOREPROV hStoreProv,
  116. IN DWORD dwFlags,
  117. IN DWORD dwCtrlType,
  118. IN LPVOID pvCtrlPara
  119. );
  120. //
  121. // Smart Card Store Provider Function table
  122. //
  123. static void* const rgpvSmartCardProvFunc[] = {
  124. // CERT_STORE_PROV_CLOSE_FUNC 0
  125. SmartCardProvCloseStore,
  126. // CERT_STORE_PROV_READ_CERT_FUNC 1
  127. NULL,
  128. // CERT_STORE_PROV_WRITE_CERT_FUNC 2
  129. SmartCardProvWriteCert,
  130. // CERT_STORE_PROV_DELETE_CERT_FUNC 3
  131. SmartCardProvDeleteCert,
  132. // CERT_STORE_PROV_SET_CERT_PROPERTY_FUNC 4
  133. SmartCardProvSetCertProperty,
  134. // CERT_STORE_PROV_READ_CRL_FUNC 5
  135. NULL,
  136. // CERT_STORE_PROV_WRITE_CRL_FUNC 6
  137. NULL,
  138. // CERT_STORE_PROV_DELETE_CRL_FUNC 7
  139. NULL,
  140. // CERT_STORE_PROV_SET_CRL_PROPERTY_FUNC 8
  141. NULL,
  142. // CERT_STORE_PROV_READ_CTL_FUNC 9
  143. NULL,
  144. // CERT_STORE_PROV_WRITE_CTL_FUNC 10
  145. NULL,
  146. // CERT_STORE_PROV_DELETE_CTL_FUNC 11
  147. NULL,
  148. // CERT_STORE_PROV_SET_CTL_PROPERTY_FUNC 12
  149. NULL,
  150. // CERT_STORE_PROV_CONTROL_FUNC 13
  151. SmartCardProvStoreControl
  152. };
  153. #define SMART_CARD_PROV_FUNC_COUNT (sizeof(rgpvSmartCardProvFunc) / \
  154. sizeof(rgpvSmartCardProvFunc[0]))
  155. //
  156. // Smart Card Store Helper Functions
  157. //
  158. BOOL WINAPI
  159. SCStoreParseOpenFilter (
  160. IN LPWSTR pwszOpenFilter,
  161. OUT LPWSTR* ppwszCardName,
  162. OUT LPWSTR* ppwszProvider,
  163. OUT DWORD* pdwProviderType,
  164. OUT LPWSTR* ppwszContainer
  165. );
  166. BOOL WINAPI
  167. SCStoreAcquireHandleForCertKeyPair (
  168. IN HCRYPTPROV hContainer,
  169. IN PCCERT_CONTEXT pCertContext,
  170. OUT HCRYPTKEY* phKeyPair
  171. );
  172. BOOL WINAPI
  173. SCStoreWriteCertToCard (
  174. IN OPTIONAL PCCERT_CONTEXT pCertContext,
  175. IN HCRYPTKEY hKeyPair
  176. );
  177. //
  178. // Open filter parsing definitions
  179. //
  180. #define PARSE_ELEM 4
  181. #endif