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.

269 lines
8.1 KiB

  1. //
  2. // Copyright (C) Microsoft Corporation, 1995 - 1999
  3. //
  4. // File: frmtfunc.h
  5. //
  6. // Contents: The header for frmtfunc.cpp
  7. //
  8. // History: Sept. 1st, 1997
  9. //
  10. //--------------------------------------------------------------------------
  11. #ifndef __FRMTFUNC_H__
  12. #define __FRMTFUNC_H__
  13. #include <wchar.h>
  14. #include "wintrust.h"
  15. #include "mssip.h"
  16. #include "sipbase.h"
  17. #include "pfx.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. //----------------------------------------------------------------------------
  22. // constants
  23. //--------------------------------------------------------------------------
  24. #define UPPER_BITS 0xF0
  25. #define LOWER_BITS 0x0F
  26. #define CHAR_SIZE 2
  27. #define HEX_SIZE 3
  28. //for other name in the subject alt name
  29. #define PREFIX_SIZE 50
  30. #define POSTFIX_SIZE 10
  31. #define INT_SIZE 20
  32. //for szOID_BASIC_CONSTRAINTS2
  33. #define SUBJECT_SIZE 256
  34. #define NONE_SIZE 256
  35. //for szOID_CRL_REASON_CODE
  36. #define CRL_REASON_SIZE 256
  37. //for szOID_ENHANCED_KEY_USAGE
  38. #define NO_INFO_SIZE 256
  39. //for szOID_ALT_NAME
  40. #define UNKNOWN_VALUE_SIZE 256
  41. #define ALT_NAME_SIZE 256
  42. //for SPC_FINANCIAL_CRIERIA
  43. #define AVAIL_SIZE 256
  44. #define YES_NO_SIZE 256
  45. //for netscape cert type
  46. #define CERT_TYPE_SIZE 100
  47. //
  48. // Post Win2K
  49. //
  50. // for szOID_NAME_CONSTRAINTS
  51. #define NAME_CONSTRAINTS_SIZE 256
  52. //for Key Usage
  53. #define KEY_USAGE_SIZE 256
  54. #define UNKNOWN_ACCESS_METHOD_SIZE 256
  55. #define UNKNOWN_KEY_USAGE_SIZE 256
  56. #define DAY_SIZE 256
  57. #define MONTH_SIZE 256
  58. #define AMPM_SIZE 256
  59. #define CRL_DIST_NAME_SIZE 256
  60. #define UNKNOWN_CRL_REASON_SIZE 256
  61. #define PRE_FIX_SIZE 256
  62. #define UNKNOWN_OID_SIZE 256
  63. //----------------------------------------------------------------------------
  64. // WCHAR string contants
  65. //--------------------------------------------------------------------------
  66. //used for formatting
  67. #define wszPLUS L" + "
  68. #define wszCOMMA L", "
  69. #define wszSEMICOLON L"; "
  70. #define wszCRLF L"\r\n"
  71. #define wszEQUAL L"="
  72. #define strCOMMA ", "
  73. //
  74. // Post Win2K
  75. //
  76. #define wszSPACE L" "
  77. #define wszTAB L" "
  78. #define wszCOLON L": "
  79. #define wszEMPTY L""
  80. //certificate
  81. #define BEGINCERT_W L"-----BEGIN CERTIFICATE-----"
  82. #define CBBEGINCERT_W (sizeof(BEGINCERT_W)/sizeof(WCHAR) - 1)
  83. #define BEGINCERT_A "-----BEGIN CERTIFICATE-----"
  84. #define CBBEGINCERT_A (sizeof(BEGINCERT_A)/sizeof(CHAR) - 1)
  85. //CRL
  86. #define BEGINCRL_W L"-----BEGIN X509 CRL-----"
  87. #define CBBEGINCRL_W (sizeof(BEGINCRL_W)/sizeof(WCHAR) - 1)
  88. #define BEGINCRL_A "-----BEGIN X509 CRL-----"
  89. #define CBBEGINCRL_A (sizeof(BEGINCRL_A)/sizeof(CHAR) - 1)
  90. //certificate request
  91. #define BEGINREQUEST_W L"-----BEGIN NEW CERTIFICATE REQUEST-----"
  92. #define CBBEGINREQUEST_W (sizeof(BEGINREQUEST_W)/sizeof(WCHAR) - 1)
  93. #define BEGINREQUEST_A "-----BEGIN NEW CERTIFICATE REQUEST-----"
  94. #define CBBEGINREQUEST_A (sizeof(BEGINREQUEST_A)/sizeof(CHAR) - 1)
  95. //---------------------------------------------------------
  96. // The following is used by this dll
  97. //
  98. //-----------------------------------------------------------
  99. const DWORD g_AllocateSize=128*sizeof(WCHAR);
  100. //macro needed to format the CA
  101. #define _16BITMASK ((1 << 16) - 1)
  102. #define CANAMEIDTOIKEY(NameId) ((NameId) >> 16)
  103. #define CANAMEIDTOICERT(NameId) (_16BITMASK & (NameId))
  104. typedef struct _FORMAT_CERT_TYPE_INFO {
  105. BYTE bCertType;
  106. UINT idsCertType;
  107. } FORMAT_CERT_TYPE_INFO;
  108. //---------------------------------------------------------------------------
  109. //
  110. // Unitlity functions used by the dll
  111. //---------------------------------------------------------------------------
  112. BOOL DecodeGenericBLOB(DWORD dwEncodingType, LPCSTR lpszStructType,
  113. const BYTE *pbEncoded, DWORD cbEncoded,void **ppStructInfo);
  114. BOOL FormatMessageUnicode(LPWSTR *ppwszFormat,UINT ids,...);
  115. HRESULT SZtoWSZ(LPSTR szStr,LPWSTR *pwsz);
  116. DWORD FormatToStr(DWORD dwFormatType);
  117. //BOOL FormatMessageStr(LPSTR *ppszFormat,UINT ids,...);
  118. BOOL GetCertNameMulti(LPWSTR pwszNameStr,
  119. UINT idsPreFix,
  120. LPWSTR *ppwsz);
  121. BOOL FormatFileTime(FILETIME *pFileTime,LPWSTR *ppwszFormat);
  122. BOOL FormatCertPolicyID(PCERT_POLICY_ID pCertPolicyID, LPWSTR *ppwszFormat);
  123. BOOL FormatCRLReason(DWORD dwCertEncodingType,
  124. DWORD dwFormatType,
  125. DWORD dwFormatStrType,
  126. void *pFormatStruct,
  127. LPCSTR lpszStructType,
  128. PCRYPT_BIT_BLOB pInfo,
  129. LPWSTR *ppwszFormat);
  130. static BOOL
  131. WINAPI
  132. FormatBytesToHex(
  133. DWORD dwCertEncodingType,
  134. DWORD dwFormatType,
  135. DWORD dwFormatStrType,
  136. void *pFormatStruct,
  137. LPCSTR lpszStructType,
  138. const BYTE *pbEncoded,
  139. DWORD cbEncoded,
  140. void *pbFormat,
  141. DWORD *pcbFormat);
  142. BOOL FormatAltNameInfo(
  143. DWORD dwCertEncodingType,
  144. DWORD dwFormatType,
  145. DWORD dwFormatStrType,
  146. void *pFormatStruct,
  147. UINT idsPreFix,
  148. BOOL fNewLine,
  149. PCERT_ALT_NAME_INFO pInfo,
  150. void *pbFormat,
  151. DWORD *pcbFormat);
  152. static BOOL
  153. WINAPI
  154. FormatKeyUsageBLOB(
  155. DWORD dwCertEncodingType,
  156. DWORD dwFormatType,
  157. DWORD dwFormatStrType,
  158. void *pFormatStruct,
  159. LPCSTR lpszStructType,
  160. PCRYPT_BIT_BLOB pInfo,
  161. void *pbFormat,
  162. DWORD *pcbFormat);
  163. BOOL FormatDistPointName(
  164. DWORD dwCertEncodingType,
  165. DWORD dwFormatType,
  166. DWORD dwFormatStrType,
  167. void *pFormatStruct,
  168. PCRL_DIST_POINT_NAME pInfo,
  169. LPWSTR *ppwszFormat);
  170. BOOL FormatCertQualifier(
  171. DWORD dwCertEncodingType,
  172. DWORD dwFormatType,
  173. DWORD dwFormatStrType,
  174. void *pFormatStruct,
  175. PCERT_POLICY_QUALIFIER_INFO pInfo,
  176. LPWSTR *ppwszFormat);
  177. BOOL FormatSPCObject(
  178. DWORD dwFormatType,
  179. DWORD dwFormatStrType,
  180. void *pFormatStruct,
  181. UINT idsPrefix,
  182. PSPC_SERIALIZED_OBJECT pInfo,
  183. LPWSTR *ppwszFormat);
  184. BOOL FormatSPCLink(
  185. DWORD dwFormatType,
  186. DWORD dwFormatStrType,
  187. void *pFormatStruct,
  188. UINT idsPrefix,
  189. PSPC_LINK pInfo,
  190. LPWSTR *ppwszFormat);
  191. BOOL FormatSPCImage(
  192. DWORD dwFormatType,
  193. DWORD dwFormatStrType,
  194. void *pFormatStruct,
  195. UINT idsPrefix,
  196. PSPC_IMAGE pInfo,
  197. LPWSTR *ppwszImageFormat);
  198. BOOL CryptDllFormatNameAll(
  199. DWORD dwEncodingType,
  200. DWORD dwFormatType,
  201. DWORD dwFormatStrType,
  202. void *pStruct,
  203. UINT idsPreFix,
  204. BOOL fToAllocate,
  205. const BYTE *pbEncoded,
  206. DWORD cbEncoded,
  207. void **ppbBuffer,
  208. DWORD *pcbBuffer);
  209. #ifdef __cplusplus
  210. } // Balance extern "C" above
  211. #endif
  212. #endif // __FRMTFUNC_H__