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.

231 lines
9.3 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows, Copyright (C) Microsoft Corporation, 2000 - 2001.
  3. File: CertHlpr.h
  4. Content: Declaration of the certificate helper functions.
  5. History: 09-07-2001 dsie created
  6. ------------------------------------------------------------------------------*/
  7. #ifndef __CERTHLPR_H_
  8. #define __CERTHLPR_H_
  9. #include "Debug.h"
  10. #include "SignHlpr.h"
  11. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  12. Function : GetEnhancedKeyUsage
  13. Synopsis : Retrieve the EKU from the cert.
  14. Parameter: PCCERT_CONTEXT pCertContext - Pointer to CERT_CONTEXT.
  15. DWORD dwFlags - 0, or
  16. CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG, or
  17. CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG.
  18. PCERT_ENHKEY_USAGE * ppUsage - Pointer to PCERT_ENHKEY_USAGE
  19. to receive the usages.
  20. Remark : If EKU extension is found with no EKU, then return HRESULT
  21. is CERT_E_WRONG_USAGE.
  22. ------------------------------------------------------------------------------*/
  23. HRESULT GetEnhancedKeyUsage (PCCERT_CONTEXT pCertContext,
  24. DWORD dwFlags,
  25. PCERT_ENHKEY_USAGE * ppUsage);
  26. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  27. Function : BuildChain
  28. Synopsis : Build a chain using the specified policy.
  29. Parameter: PCCERT_CONTEXT pCertContext - CERT_CONTEXT of cert to verify.
  30. HCERTSTORE hCertStore - Additional store (can be NULL).
  31. LPCSTR pszPolicy - Policy used to verify the cert (i.e.
  32. CERT_CHAIN_POLICY_BASE).
  33. PCCERT_CHAIN_CONTEXT * ppChainContext - Pointer to
  34. PCCERT_CHAIN_CONTEXT.
  35. Remark :
  36. ------------------------------------------------------------------------------*/
  37. HRESULT BuildChain (PCCERT_CONTEXT pCertContext,
  38. HCERTSTORE hCertStore,
  39. LPCSTR pszPolicy,
  40. PCCERT_CHAIN_CONTEXT * ppChainContext);
  41. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  42. Function : VerifyCertificate
  43. Synopsis : Verify if the certificate is valid.
  44. Parameter: PCCERT_CONTEXT pCertContext - CERT_CONTEXT of cert to verify.
  45. HCERTSTORE hCertStore - Additional store (can be NULL).
  46. LPCSTR pszPolicy - Policy used to verify the cert (i.e.
  47. CERT_CHAIN_POLICY_BASE).
  48. Remark :
  49. ------------------------------------------------------------------------------*/
  50. HRESULT VerifyCertificate (PCCERT_CONTEXT pCertContext,
  51. HCERTSTORE hCertStore,
  52. LPCSTR pszPolicy);
  53. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  54. Function : SelectCertificateContext
  55. Synopsis : Pop UI to prompt user to select a certificate from an opened store.
  56. Parameter: HCERTSTORE hCertStore - Source cert store.
  57. HWND hWndParent - Parent window handle.
  58. LPWCSTR pwszTitle - Dialog title string.
  59. LPWCSTR - pwszDisplayString - Dialog display string.
  60. BOOL bMultiSelect - TRUE to enable multi-select.
  61. PFNCFILTERPROC pfnFilterCallback - Pointer to filter callback
  62. function.
  63. HCERTSTORE hSelectedCertStore - HCERTSTORE to receive the
  64. selected certs for multi-select
  65. mode.
  66. PCCERT_CONTEXT * ppCertContext - Pointer to PCCERT_CONTEXT
  67. receive the certificate context
  68. for single selection mode.
  69. Remark : typedef struct tagCRYPTUI_SELECTCERTIFICATE_STRUCTW {
  70. DWORD dwSize;
  71. HWND hwndParent; // OPTIONAL
  72. DWORD dwFlags; // OPTIONAL
  73. LPCWSTR szTitle; // OPTIONAL
  74. DWORD dwDontUseColumn; // OPTIONAL
  75. LPCWSTR szDisplayString; // OPTIONAL
  76. PFNCFILTERPROC pFilterCallback; // OPTIONAL
  77. PFNCCERTDISPLAYPROC pDisplayCallback; // OPTIONAL
  78. void * pvCallbackData; // OPTIONAL
  79. DWORD cDisplayStores;
  80. HCERTSTORE * rghDisplayStores;
  81. DWORD cStores; // OPTIONAL
  82. HCERTSTORE * rghStores; // OPTIONAL
  83. DWORD cPropSheetPages; // OPTIONAL
  84. LPCPROPSHEETPAGEW rgPropSheetPages; // OPTIONAL
  85. HCERTSTORE hSelectedCertStore; // OPTIONAL
  86. } CRYPTUI_SELECTCERTIFICATE_STRUCTW
  87. ------------------------------------------------------------------------------*/
  88. HRESULT SelectCertificateContext (HCERTSTORE hCertStore,
  89. LPCWSTR pwszTitle,
  90. LPCWSTR pwszDisplayString,
  91. BOOL bMultiSelect,
  92. PFNCFILTERPROC pfnFilterCallback,
  93. HCERTSTORE hSelectedCertStore,
  94. PCCERT_CONTEXT * ppCertContext);
  95. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  96. Function : SelectCertificate
  97. Synopsis : Select a certificate from the sepcified store. If only 1 cert is
  98. found after the filter, then that cert is returned. If more than
  99. 1 cert is found, then UI is popped to prompt user to select a
  100. certificate from the specified store.
  101. Parameter: CAPICOM_STORE_INFO StoreInfo - Store to select from.
  102. PFNCFILTERPROC pfnFilterCallback - Pointer to filter callback
  103. function.
  104. ICertificate2 ** ppICertificate - Pointer to pointer to
  105. ICertificate to receive interface
  106. pointer.
  107. Remark :
  108. ------------------------------------------------------------------------------*/
  109. HRESULT SelectCertificate (CAPICOM_STORE_INFO StoreInfo,
  110. PFNCFILTERPROC pfnFilterCallback,
  111. ICertificate2 ** ppICertificate);
  112. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  113. Function : ExportCertificatesToStore
  114. Synopsis : Copy all certs from the collections to the specified store.
  115. Parameter: ICertificates2 * pICertificate - Pointer to collection.
  116. HCERTSTORE hCertStore - Store to copy to.
  117. Remark :
  118. ------------------------------------------------------------------------------*/
  119. HRESULT ExportCertificatesToStore(ICertificates2 * pICertificate,
  120. HCERTSTORE hCertStore);
  121. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  122. Function : CreateMemoryStoreFromCertificates
  123. Synopsis : Create a memory cert store and copy all certs from the collections
  124. to the store.
  125. Parameter: ICertificates2 * pICertificates - Pointer to collection.
  126. HCERTSTORE * phCertStore - Pointer to receive store handle.
  127. Remark : If pICertificate is NULL, then the returned store is still valid
  128. nut empty. Also, caller must close the returned store.
  129. ------------------------------------------------------------------------------*/
  130. HRESULT CreateMemoryStoreFromCertificates(ICertificates2 * pICertificates,
  131. HCERTSTORE * phCertStore);
  132. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  133. Function : CompareCertAndContainerPublicKey
  134. Synopsis : Compare public key in cert matches the container's key.
  135. Parameter: PCCERT_CONTEXT pCertContext - Pointer to CERT_CONTEXT to be used
  136. to initialize the IPrivateKey object.
  137. BSTR ContainerName - Container name.
  138. BSTR ProviderName - Provider name.
  139. DWORD dwProvType - Provider type.
  140. DWORD dwKeySpec - Key spec.
  141. DWORD dwFlags - Provider flags.
  142. Remark :
  143. ------------------------------------------------------------------------------*/
  144. HRESULT CompareCertAndContainerPublicKey (PCCERT_CONTEXT pCertContext,
  145. LPWSTR pwszContainerName,
  146. LPWSTR pwszProvName,
  147. DWORD dwProvType,
  148. DWORD dwKeySpec,
  149. DWORD dwFlags);
  150. #endif // __CERTHLPR_H_