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.

386 lines
8.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1995 - 1999
  6. //
  7. // File: certhlp.h
  8. //
  9. // Contents: the header for certhlp.cpp, the helper functions for
  10. // CertMgr tool
  11. //
  12. //
  13. // History: 21-July-97 xiaohs created
  14. //
  15. //--------------------------------------------------------------------------
  16. #ifndef CERTHLP_H
  17. #define CERTHLP_H
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. BOOL CheckParameter();
  22. BOOL ParseSwitch (int *pArgc, WCHAR **pArgv[]);
  23. void Usage(void);
  24. void UndocumentedUsage();
  25. BOOL InitModule();
  26. wchar_t *IDSwcscat(HMODULE hModule, WCHAR *pwsz, int idsString);
  27. BOOL SetParam(WCHAR **ppwszParam, WCHAR *pwszValue);
  28. BOOL OpenGenericStore(LPWSTR wszStoreName,
  29. BOOL fSystemStore,
  30. DWORD dwStoreFlag,
  31. LPSTR szStoreProvider,
  32. DWORD dwStoreOpenFlag,
  33. BOOL fCheckExist,
  34. HCERTSTORE *phCertStore);
  35. BOOL AddCertStore(HCERTSTORE hCertStore);
  36. BOOL DeleteCertStore(HCERTSTORE hCertStore);
  37. BOOL PutCertStore(HCERTSTORE hCertStore);
  38. BOOL SaveStore(HCERTSTORE hSrcStore);
  39. BOOL SetEKUProperty( HCERTSTORE hSrcStore);
  40. BOOL SetNameProperty( HCERTSTORE hSrcStore);
  41. PCCRL_CONTEXT FindCRLInStore(HCERTSTORE hCertStore,
  42. CRYPT_HASH_BLOB *pBlob);
  43. BOOL MoveItem(HCERTSTORE hSrcStore,
  44. HCERTSTORE hDesStore,
  45. DWORD dwItem);
  46. BOOL DeleteItem(HCERTSTORE hSrcStore,
  47. DWORD dwItem);
  48. BOOL DisplayCertAndPrompt(PCCERT_CONTEXT *rgpCertContext,
  49. DWORD dwCertCount,
  50. DWORD *pdwIndex);
  51. BOOL DisplayCRLAndPrompt(PCCRL_CONTEXT *rgpCRLContext,
  52. DWORD dwCRLCount,
  53. DWORD *pdwIndex);
  54. BOOL DisplayCTLAndPrompt(PCCTL_CONTEXT *rgpCTLContext,
  55. DWORD dwCTLCount,
  56. DWORD *pdwIndex);
  57. BOOL BuildCertList(HCERTSTORE hCertStore,
  58. LPWSTR wszCertCN,
  59. PCCERT_CONTEXT **prgpCertContext,
  60. DWORD *pdwCertCount);
  61. BOOL BuildCRLList( HCERTSTORE hCertStore,
  62. PCCRL_CONTEXT **prgpCRLContext,
  63. DWORD *pdwCRLCount);
  64. BOOL BuildCTLList( HCERTSTORE hCertStore,
  65. PCCTL_CONTEXT **prgpCTLContext,
  66. DWORD *pdwCTLCount);
  67. BOOL DisplayCertStore(HCERTSTORE hCertStore);
  68. BOOL DisplayCert(PCCERT_CONTEXT pCertContext, DWORD dwItem);
  69. BOOL DisplayCTL(PCCTL_CONTEXT pCTLContext, DWORD dwItem);
  70. BOOL DisplayCRL(PCCRL_CONTEXT pCRLContext, DWORD dwItem);
  71. BOOL DisplaySignerInfo(HCRYPTMSG hMsg, DWORD dwItem);
  72. HCERTSTORE OpenSipStore(LPWSTR pwszStoreFilename);
  73. HRESULT Base64ToBytes(CHAR *pEncode, DWORD cbEncode, BYTE **ppb, DWORD *pcb);
  74. HRESULT Base64ToBytesW(WCHAR *pEncode, DWORD cbEncode, BYTE **ppb, DWORD *pcb);
  75. BOOL GetBase64Decoded(LPWSTR wszStoreName,
  76. BYTE **ppbByte,
  77. DWORD *pcbByte);
  78. HCERTSTORE OpenEncodedCRL(LPWSTR pwszStoreFilename);
  79. HCERTSTORE OpenEncodedCTL (LPWSTR pwszStoreFilename);
  80. HCERTSTORE OpenEncodedCert (LPWSTR pwszStoreFilename);
  81. BOOL SetParam(WCHAR **ppwszParam, WCHAR *pwszValue);
  82. HRESULT WSZtoBLOB(LPWSTR pwsz, BYTE **ppbByte, DWORD *pcbByte);
  83. DWORD SkipOverIdentifierAndLengthOctets(
  84. IN const BYTE *pbDER,
  85. IN DWORD cbDER
  86. );
  87. BOOL SignNoContentWrap(IN const BYTE *pbDER, IN DWORD cbDER);
  88. BOOL
  89. WINAPI
  90. FormatBasicConstraints2(
  91. DWORD dwCertEncodingType,
  92. DWORD dwFormatType,
  93. DWORD dwFormatStrType,
  94. void *pFormatStruct,
  95. LPCSTR lpszStructType,
  96. const BYTE *pbEncoded,
  97. DWORD cbEncoded,
  98. void *pbFormat,
  99. DWORD *pcbFormat);
  100. void PrintCtlEntries(PCCTL_CONTEXT pCtl, DWORD dwDisplayFlag);
  101. void PrintCrlEntries(DWORD cEntry, PCRL_ENTRY pEntry,
  102. DWORD dwDisplayFlags);
  103. BOOL DisplaySignerInfo(HCRYPTMSG hMsg, DWORD dwItem);
  104. void PrintBytes(LPWSTR pwszHdr, BYTE *pb, DWORD cbSize);
  105. void PrintAttributes(DWORD cAttr, PCRYPT_ATTRIBUTE pAttr,
  106. DWORD dwItem);
  107. void DecodeAndDisplayAltName(
  108. BYTE *pbEncoded,
  109. DWORD cbEncoded,
  110. DWORD dwDisplayFlags);
  111. void DisplayAltName(
  112. PCERT_ALT_NAME_INFO pInfo,
  113. DWORD dwDisplayFlags);
  114. void DisplayAltNameEntry(
  115. PCERT_ALT_NAME_ENTRY pEntry,
  116. DWORD dwDisplayFlags);
  117. void DisplayThumbprint(
  118. LPWSTR pwszHash,
  119. BYTE *pbHash,
  120. DWORD cbHash
  121. );
  122. LPWSTR FileTimeText(FILETIME *pft);
  123. void PrintAuxCertProperties(PCCERT_CONTEXT pCert,DWORD dwDisplayFlags);
  124. void DecodeAndDisplayCtlUsage(
  125. BYTE *pbEncoded,
  126. DWORD cbEncoded,
  127. DWORD dwDisplayFlags);
  128. void DisplaySignature(
  129. BYTE *pbEncoded,
  130. DWORD cbEncoded,
  131. DWORD dwDisplayFlags
  132. );
  133. BOOL DecodeName(BYTE *pbEncoded, DWORD cbEncoded, DWORD dwDisplayFlags);
  134. void PrintExtensions(DWORD cExt, PCERT_EXTENSION pExt, DWORD dwDisplayFlags);
  135. void DisplaySMIMECapabilitiesExtension(
  136. BYTE *pbEncoded,
  137. DWORD cbEncoded,
  138. DWORD dwDisplayFlags);
  139. void DisplayEnhancedKeyUsageExtension(
  140. BYTE *pbEncoded,
  141. DWORD cbEncoded,
  142. DWORD dwDisplayFlags);
  143. void DisplayCommonNameExtension(
  144. BYTE *pbEncoded,
  145. DWORD cbEncoded,
  146. DWORD dwDisplayFlags);
  147. void DisplaySpcFinancialCriteriaExtension(
  148. BYTE *pbEncoded,
  149. DWORD cbEncoded,
  150. DWORD dwDisplayFlags);
  151. void DisplaySpcMinimalCriteriaExtension(
  152. BYTE *pbEncoded,
  153. DWORD cbEncoded,
  154. DWORD dwDisplayFlags);
  155. void DisplaySpcLink(PSPC_LINK pSpcLink);
  156. void DisplaySpcSpAgencyExtension(
  157. BYTE *pbEncoded,
  158. DWORD cbEncoded,
  159. DWORD dwDisplayFlags);
  160. void DisplayPoliciesExtension(
  161. int idsIDS,
  162. BYTE *pbEncoded,
  163. DWORD cbEncoded,
  164. DWORD dwDisplayFlags);
  165. void DisplayKeyUsageExtension(
  166. BYTE *pbEncoded,
  167. DWORD cbEncoded,
  168. DWORD dwDisplayFlags);
  169. void DisplayBasicConstraints2Extension(
  170. BYTE *pbEncoded,
  171. DWORD cbEncoded,
  172. DWORD dwDisplayFlags);
  173. void DisplayBasicConstraintsExtension(
  174. BYTE *pbEncoded,
  175. DWORD cbEncoded,
  176. DWORD dwDisplayFlags);
  177. void DisplayKeyUsage(BYTE bFlag);
  178. void DisplayKeyUsageRestrictionExtension(
  179. BYTE *pbEncoded,
  180. DWORD cbEncoded,
  181. DWORD dwDisplayFlags);
  182. void DisplayCRLReason(
  183. BYTE *pbEncoded,
  184. DWORD cbEncoded,
  185. DWORD dwDisplayFlags);
  186. void DisplayAltNameExtension(
  187. int idsIDS,
  188. BYTE *pbEncoded,
  189. DWORD cbEncoded,
  190. DWORD dwDisplayFlags);
  191. void DisplayKeyAttrExtension(
  192. BYTE *pbEncoded,
  193. DWORD cbEncoded,
  194. DWORD dwDisplayFlags);
  195. void DisplayCrlDistPointsExtension(
  196. BYTE *pbEncoded,
  197. DWORD cbEncoded,
  198. DWORD dwDisplayFlags);
  199. void DisplayAuthorityKeyIdExtension(
  200. BYTE *pbEncoded,
  201. DWORD cbEncoded,
  202. DWORD dwDisplayFlags);
  203. void DisplayAuthorityKeyId2Extension(
  204. BYTE *pbEncoded,
  205. DWORD cbEncoded,
  206. DWORD dwDisplayFlags);
  207. void DisplayAnyString(
  208. int idsIDS,
  209. BYTE *pbEncoded,
  210. DWORD cbEncoded,
  211. DWORD dwDisplayFlags);
  212. void DisplayBits(
  213. int idsIDS,
  214. BYTE *pbEncoded,
  215. DWORD cbEncoded,
  216. DWORD dwDisplayFlags);
  217. void DisplayOctetString(
  218. int idsIDS,
  219. BYTE *pbEncoded,
  220. DWORD cbEncoded,
  221. DWORD dwDisplayFlags);
  222. LPCWSTR GetOIDName(LPCSTR pszOID, DWORD dwGroupId = 0);
  223. BOOL InstalledFormat(LPSTR szStructType, BYTE *pbEncoded, DWORD cbEncoded);
  224. WCHAR *GuidText(GUID *pguid);
  225. void *AllocAndGetMsgParam(
  226. IN HCRYPTMSG hMsg,
  227. IN DWORD dwParamType,
  228. IN DWORD dwIndex,
  229. OUT DWORD *pcbData
  230. );
  231. HRESULT SZtoWSZ(LPSTR szStr,LPWSTR *pwsz);
  232. void *TestNoCopyDecodeObject(
  233. IN LPCSTR lpszStructType,
  234. IN const BYTE *pbEncoded,
  235. IN DWORD cbEncoded,
  236. OUT DWORD *pcbInfo = NULL
  237. );
  238. BOOL IsTimeValidCtl(IN PCCTL_CONTEXT pCtl);
  239. void DisplaySerialNumber(PCRYPT_INTEGER_BLOB pSerialNumber);
  240. void ReverseBytes(IN OUT PBYTE pbIn, IN DWORD cbIn);
  241. ALG_ID GetAlgid(LPCSTR pszOID, DWORD dwGroupId);
  242. void GetSignAlgids(
  243. IN LPCSTR pszOID,
  244. OUT ALG_ID *paiHash,
  245. OUT ALG_ID *paiPubKey
  246. );
  247. void GetSignAlgids(
  248. IN LPCSTR pszOID,
  249. OUT ALG_ID *paiHash,
  250. OUT ALG_ID *paiPubKey
  251. );
  252. void DisplayTimeStamp(BYTE *pbEncoded,DWORD cbEncoded,DWORD dwDisplayFlags);
  253. #ifdef __cplusplus
  254. }
  255. #endif
  256. #endif // CERTHLP_H