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.

218 lines
7.4 KiB

  1. //+-------------------------------------------------------------------------
  2. // Microsoft Windows
  3. //
  4. // Copyright (C) Microsoft Corporation, 1997 - 1999
  5. //
  6. // File: certprot.h
  7. //
  8. // Contents: Certificate Protection APIs
  9. //
  10. // APIs: I_CertProtectFunction
  11. // I_CertCltProtectFunction
  12. // I_CertSrvProtectFunction
  13. //
  14. // History: 27-Nov-97 philh created
  15. //--------------------------------------------------------------------------
  16. #ifndef __CERTPROT_H__
  17. #define __CERTPROT_H__
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. //+-------------------------------------------------------------------------
  22. // Calls the services process to do a protected certificate function,
  23. // such as, add or delete a protected root certificate.
  24. //
  25. // CryptMemFree must be called to free the returned *ppbOut.
  26. //--------------------------------------------------------------------------
  27. BOOL
  28. WINAPI
  29. I_CertProtectFunction(
  30. IN DWORD dwFuncId,
  31. IN DWORD dwFlags,
  32. IN OPTIONAL LPCWSTR pwszIn,
  33. IN OPTIONAL BYTE *pbIn,
  34. IN DWORD cbIn,
  35. OUT OPTIONAL BYTE **ppbOut,
  36. OUT OPTIONAL DWORD *pcbOut
  37. );
  38. #define CERT_PROT_INIT_ROOTS_FUNC_ID 1
  39. #define CERT_PROT_PURGE_LM_ROOTS_FUNC_ID 2
  40. #define CERT_PROT_ADD_ROOT_FUNC_ID 3
  41. #define CERT_PROT_DELETE_ROOT_FUNC_ID 4
  42. #define CERT_PROT_DELETE_UNKNOWN_ROOTS_FUNC_ID 5
  43. #define CERT_PROT_ROOT_LIST_FUNC_ID 6
  44. #define CERT_PROT_ADD_ROOT_IN_CTL_FUNC_ID 7
  45. #define CERT_PROT_LOG_EVENT_FUNC_ID 8
  46. //+-------------------------------------------------------------------------
  47. // CERT_PROT_INIT_ROOTS_FUNC_ID
  48. //
  49. // Initialize the protected list of CurrentUser roots. Note, no UI.
  50. //
  51. // No IN/OUT parameters.
  52. //--------------------------------------------------------------------------
  53. //+-------------------------------------------------------------------------
  54. // CERT_PROT_PURGE_LM_ROOTS_FUNC_ID
  55. //
  56. // Purge all CurrentUser roots from the protected list that also exist
  57. // in the LocalMachine SystemRegistry "Root" store. Also removes duplicated
  58. // certificates from the CurrentUser SystemRegistry "Root" store.
  59. //
  60. // Note, no UI. Purging can be disabled by setting the
  61. // CERT_PROT_ROOT_INHIBIT_PURGE_LM_FLAG in the registry's ProtectedRootFlags
  62. // value.
  63. //
  64. // No IN/OUT parameters.
  65. //
  66. // Even if purging is disabled, the protected list of roots is still
  67. // initialized.
  68. //--------------------------------------------------------------------------
  69. //+-------------------------------------------------------------------------
  70. // CERT_PROT_ADD_ROOT_FUNC_ID
  71. //
  72. // Add the specified certificate to the CurrentUser SystemRegistry "Root"
  73. // store and the protected list of roots. The user is prompted before doing
  74. // the add.
  75. //
  76. // pbIn and cbIn must be updated with the pointer to and length of the
  77. // serialized certificate context to be added. No other IN/OUT parameters.
  78. //--------------------------------------------------------------------------
  79. //+-------------------------------------------------------------------------
  80. // CERT_PROT_DELETE_ROOT_FUNC_ID
  81. //
  82. // Delete the specified certificate from the CurrentUser SystemRegistry "Root"
  83. // store and the protected list of roots. The user is prompted before doing
  84. // the delete.
  85. //
  86. // pbIn and cbIn must be updated with the pointer to and length of the
  87. // certificate's SHA1 hash property. No other IN/OUT parameters.
  88. //--------------------------------------------------------------------------
  89. //+-------------------------------------------------------------------------
  90. // CERT_PROT_DELETE_UNKNOWN_ROOTS_FUNC_ID
  91. //
  92. // Delete all CurrentUser roots from the protected list that don't also
  93. // exist in the CurrentUser SystemRegistry "Root" store. The user is
  94. // prompted before doing the delete.
  95. //
  96. // No IN/OUT parameters.
  97. //--------------------------------------------------------------------------
  98. //+-------------------------------------------------------------------------
  99. // CERT_PROT_ROOT_LIST_FUNC_ID
  100. //
  101. // Add or remove the signed list of certificates to/from the CurrentUser
  102. // SystemRegistry "Root" store and the protected list of roots. The user
  103. // isn't prompted before doing the add or remove.
  104. //
  105. // pbIn and cbIn must be updated with the pointer to and length of the
  106. // serialized CTL containing the signed list of roots to be added or
  107. // removed. No other IN/OUT parameters.
  108. //
  109. // CURRENTLY NOT SUPPORTED!!!
  110. //--------------------------------------------------------------------------
  111. //+-------------------------------------------------------------------------
  112. // CERT_PROT_ADD_ROOT_IN_CTL_FUNC_ID
  113. //
  114. // Add the certificate in the Auto Update CTL to the HKLM AuthRoot store.
  115. //
  116. // pbIn and cbIn must be updated with the pointer to and length of the
  117. // serialized X.509 certificate immediately followed by the
  118. // serialized CTL. No other IN/OUT parameters.
  119. //--------------------------------------------------------------------------
  120. //+-------------------------------------------------------------------------
  121. // CERT_PROT_LOG_EVENT_FUNC_ID
  122. //
  123. // Logs a crypt32 event.
  124. //
  125. // pbIn and cbIn must be updated to point to the following
  126. // CERT_PROT_EVENT_LOG_PARA data structure. It contains the parameters
  127. // passed to advapi32!ReportEventW.
  128. //
  129. // wNumString NULL terminated unicode strings immediately follow. Followed by
  130. // dwDataSize binary data bytes.
  131. //
  132. // wCategory, wNumStrings and dwDataSize are optional.
  133. //--------------------------------------------------------------------------
  134. typedef struct _CERT_PROT_EVENT_LOG_PARA {
  135. WORD wType;
  136. WORD wCategory; // OPTIONAL, may be 0
  137. DWORD dwEventID;
  138. WORD wNumStrings; // OPTIONAL, may be 0
  139. WORD wPad1;
  140. DWORD dwDataSize; // OPTIONAL, may be 0
  141. } CERT_PROT_EVENT_LOG_PARA, *PCERT_PROT_EVENT_LOG_PARA;
  142. //+-------------------------------------------------------------------------
  143. // Called from the client process to do the RPC to the server process.
  144. //--------------------------------------------------------------------------
  145. BOOL
  146. WINAPI
  147. I_CertCltProtectFunction(
  148. IN DWORD dwFuncId,
  149. IN DWORD dwFlags,
  150. IN OPTIONAL LPCWSTR pwszIn,
  151. IN OPTIONAL BYTE *pbIn,
  152. IN DWORD cbIn,
  153. OUT OPTIONAL BYTE **ppbOut,
  154. OUT OPTIONAL DWORD *pcbOut
  155. );
  156. typedef void __RPC_FAR * (__RPC_USER *PFN_CERT_PROT_MIDL_USER_ALLOC)(
  157. IN size_t cb
  158. );
  159. typedef void (__RPC_USER *PFN_CERT_PROT_MIDL_USER_FREE)(
  160. IN void __RPC_FAR *pv
  161. );
  162. //+-------------------------------------------------------------------------
  163. // Called from the services process to process a protected certificate
  164. // function.
  165. //
  166. // Returns the error status, ie, not returned in LastError.
  167. //--------------------------------------------------------------------------
  168. DWORD
  169. WINAPI
  170. I_CertSrvProtectFunction(
  171. IN handle_t hRpc,
  172. IN DWORD dwFuncId,
  173. IN DWORD dwFlags,
  174. IN LPCWSTR pwszIn,
  175. IN BYTE *pbIn,
  176. IN DWORD cbIn,
  177. OUT BYTE **ppbOut,
  178. OUT DWORD *pcbOut,
  179. IN PFN_CERT_PROT_MIDL_USER_ALLOC pfnAlloc,
  180. IN PFN_CERT_PROT_MIDL_USER_FREE pfnFree
  181. );
  182. typedef DWORD (WINAPI *PFN_CERT_SRV_PROTECT_FUNCTION)(
  183. IN handle_t hRpc,
  184. IN DWORD dwFuncId,
  185. IN DWORD dwFlags,
  186. IN LPCWSTR pwszIn,
  187. IN BYTE *pbIn,
  188. IN DWORD cbIn,
  189. OUT BYTE **ppbOut,
  190. OUT DWORD *pcbOut,
  191. IN PFN_CERT_PROT_MIDL_USER_ALLOC pfnAlloc,
  192. IN PFN_CERT_PROT_MIDL_USER_FREE pfnFree
  193. );
  194. #ifdef __cplusplus
  195. } // Balance extern "C" above
  196. #endif
  197. #endif