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.

222 lines
7.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1996
  6. //
  7. // File: certtest.h
  8. //
  9. // Contents: Certificate Test Helper API Prototypes and Definitions
  10. //
  11. // History: 11-Apr-96 philh created
  12. //--------------------------------------------------------------------------
  13. #ifndef __CERTTEST_H__
  14. #define __CERTTEST_H__
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include "wincrypt.h"
  19. #include "mssip.h"
  20. #include "sipbase.h"
  21. #include "softpub.h"
  22. #include "signutil.h"
  23. #define MAX_HASH_LEN 20
  24. //+-------------------------------------------------------------------------
  25. // Error output routines
  26. //--------------------------------------------------------------------------
  27. void PrintError(LPCSTR pszMsg);
  28. void PrintLastError(LPCSTR pszMsg);
  29. //+-------------------------------------------------------------------------
  30. // Test allocation and free routines
  31. //--------------------------------------------------------------------------
  32. LPVOID
  33. WINAPI
  34. TestAlloc(
  35. IN size_t cbBytes
  36. );
  37. LPVOID
  38. WINAPI
  39. TestRealloc(
  40. IN LPVOID pvOrg,
  41. IN size_t cbBytes
  42. );
  43. VOID
  44. WINAPI
  45. TestFree(
  46. IN LPVOID pv
  47. );
  48. //+-------------------------------------------------------------------------
  49. // Allocate and convert a multi-byte string to a wide string
  50. //--------------------------------------------------------------------------
  51. LPWSTR AllocAndSzToWsz(LPCSTR psz);
  52. //+-------------------------------------------------------------------------
  53. // Useful display functions
  54. //--------------------------------------------------------------------------
  55. LPCSTR FileTimeText(FILETIME *pft);
  56. void PrintBytes(LPCSTR pszHdr, BYTE *pb, DWORD cbSize);
  57. //+-------------------------------------------------------------------------
  58. // Allocate and read an encoded DER blob from a file
  59. //--------------------------------------------------------------------------
  60. BOOL ReadDERFromFile(
  61. LPCSTR pszFileName,
  62. PBYTE *ppbDER,
  63. PDWORD pcbDER
  64. );
  65. //+-------------------------------------------------------------------------
  66. // Write an encoded DER blob to a file
  67. //--------------------------------------------------------------------------
  68. BOOL WriteDERToFile(
  69. LPCSTR pszFileName,
  70. PBYTE pbDER,
  71. DWORD cbDER
  72. );
  73. //+-------------------------------------------------------------------------
  74. // Get the default Crypt Provider. Create the private signature/exchange
  75. // if they don't already exist.
  76. //--------------------------------------------------------------------------
  77. HCRYPTPROV GetCryptProv();
  78. //+-------------------------------------------------------------------------
  79. // Open/Save the specified cert store
  80. //--------------------------------------------------------------------------
  81. HCERTSTORE OpenStore(BOOL fSystemStore, LPCSTR pszStoreFilename);
  82. HCERTSTORE OpenStoreEx(BOOL fSystemStore, LPCSTR pszStoreFilename,
  83. DWORD dwFlags);
  84. // returns NULL if unable to open. Doesn't open memory store as in the above
  85. // 2 versions of OpenStore
  86. HCERTSTORE OpenSystemStoreOrFile(BOOL fSystemStore, LPCSTR pszStoreFilename,
  87. DWORD dwFlags);
  88. void SaveStore(HCERTSTORE hStore, LPCSTR pszSaveFilename);
  89. void SaveStoreEx(HCERTSTORE hStore, BOOL fPKCS7Save, LPCSTR pszSaveFilename);
  90. //+-------------------------------------------------------------------------
  91. // Open the specified cert store or SPC file
  92. //
  93. // No longer supported. The above OpenStore tries opening as
  94. // SPC if unable to open as a store.
  95. //--------------------------------------------------------------------------
  96. HCERTSTORE OpenStoreOrSpc(BOOL fSystemStore, LPCSTR pszStoreFilename,
  97. BOOL *pfSpc);
  98. //+-------------------------------------------------------------------------
  99. // Certificate encoding type used by cert test routines.
  100. // The default is X509_ASN_ENCODING;
  101. //--------------------------------------------------------------------------
  102. extern DWORD dwCertEncodingType;
  103. //+-------------------------------------------------------------------------
  104. // Message encoding type used by cert test routines.
  105. // The default is PKCS_7_ASN_ENCODING;
  106. //--------------------------------------------------------------------------
  107. extern DWORD dwMsgEncodingType;
  108. //+-------------------------------------------------------------------------
  109. // Message and certificate encoding type used by cert test routines.
  110. // The default is PKCS_7_ASN_ENCODING | X509_ASN_ENCODING;
  111. //--------------------------------------------------------------------------
  112. extern DWORD dwMsgAndCertEncodingType;
  113. //+-------------------------------------------------------------------------
  114. // Certificate Display definitions and APIs
  115. //--------------------------------------------------------------------------
  116. // Display flags
  117. #define DISPLAY_VERBOSE_FLAG 0x00000001
  118. #define DISPLAY_CHECK_FLAG 0x00000002
  119. #define DISPLAY_BRIEF_FLAG 0x00000004
  120. #define DISPLAY_KEY_THUMB_FLAG 0x00000008
  121. #define DISPLAY_UI_FLAG 0x00000010
  122. #define DISPLAY_NO_ISSUER_FLAG 0x00000100
  123. #define DISPLAY_CHECK_SIGN_FLAG 0x00001000
  124. #define DISPLAY_CHECK_TIME_FLAG 0x00002000
  125. void DisplayVerifyFlags(LPSTR pszHdr, DWORD dwFlags);
  126. void DisplayCert(
  127. PCCERT_CONTEXT pCert,
  128. DWORD dwDisplayFlags = 0,
  129. DWORD dwIssuer = 0
  130. );
  131. void DisplayCert2(
  132. HCERTSTORE hStore, // needed when displaying cert from file
  133. PCCERT_CONTEXT pCert,
  134. DWORD dwDisplayFlags = 0,
  135. DWORD dwIssuer = 0
  136. );
  137. void DisplayCrl(
  138. PCCRL_CONTEXT pCrl,
  139. DWORD dwDisplayFlags = 0
  140. );
  141. void DisplayCtl(
  142. PCCTL_CONTEXT pCtl,
  143. DWORD dwDisplayFlags = 0,
  144. HCERTSTORE hStore = NULL
  145. );
  146. void DisplaySignerInfo(
  147. HCRYPTMSG hMsg,
  148. DWORD dwSignerIndex = 0,
  149. DWORD dwDisplayFlags = 0
  150. );
  151. void DisplayStore(
  152. IN HCERTSTORE hStore,
  153. IN DWORD dwDisplayFlags = 0
  154. );
  155. // Not displayed when DISPLAY_BRIEF_FLAG is set
  156. void DisplayCertKeyProvInfo(
  157. PCCERT_CONTEXT pCert,
  158. DWORD dwDisplayFlags = 0
  159. );
  160. void PrintCrlEntries(
  161. DWORD cEntry,
  162. PCRL_ENTRY pEntry,
  163. DWORD dwDisplayFlags = 0
  164. );
  165. //+-------------------------------------------------------------------------
  166. // Returns TRUE if the CTL is still time valid.
  167. //
  168. // A CTL without a NextUpdate is considered time valid.
  169. //--------------------------------------------------------------------------
  170. BOOL IsTimeValidCtl(
  171. IN PCCTL_CONTEXT pCtl
  172. );
  173. //+-------------------------------------------------------------------------
  174. // Display structures used in Software Publishing Certificate (SPC)
  175. //--------------------------------------------------------------------------
  176. void DisplaySpcLink(PSPC_LINK pSpcLink);
  177. //+-------------------------------------------------------------------------
  178. // Returns OID's name string. If not found returns L"???".
  179. //--------------------------------------------------------------------------
  180. LPCWSTR GetOIDName(LPCSTR pszOID, DWORD dwGroupId = 0);
  181. //+-------------------------------------------------------------------------
  182. // Returns OID's Algid. If not found returns 0.
  183. //--------------------------------------------------------------------------
  184. ALG_ID GetAlgid(LPCSTR pszOID, DWORD dwGroupId = 0);
  185. #ifdef __cplusplus
  186. } // Balance extern "C" above
  187. #endif
  188. #endif