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.

199 lines
5.0 KiB

  1. //
  2. // Utils.h
  3. //
  4. // 7/6/00 dangriff created
  5. //
  6. #ifndef __UTILS__H__
  7. #define __UTILS__H__
  8. #include <windows.h>
  9. #include "cspstruc.h"
  10. //
  11. // Function: TestAlloc
  12. // Purpose: Malloc and zero-ize the requested memory. Log an error
  13. // if malloc fails.
  14. //
  15. BOOL TestAlloc(
  16. OUT PBYTE *ppb,
  17. IN DWORD cb,
  18. PTESTCASE ptc);
  19. //
  20. // Function: PrintBytes
  21. // Purpose: Display bytes to the console for debugging
  22. //
  23. void PrintBytes(LPWSTR pwszHdr, BYTE *pb, DWORD cbSize);
  24. //
  25. // Function: MkWStr
  26. // Purpose: Convert the psz parameter into a Unicode string.
  27. // Return the Unicode string.
  28. //
  29. LPWSTR MkWStr(LPSTR psz);
  30. //
  31. // -----------------------------
  32. // System/Test Version Utilities
  33. // -----------------------------
  34. //
  35. //
  36. // Function: IsVersionCorrect
  37. // Purpose: Check that the specified version information
  38. // is at least as high a Rev as the system running this process.
  39. //
  40. // If the system is newer than the specified information, return FALSE.
  41. // Otherwise, return TRUE.
  42. //
  43. /*
  44. BOOL IsVersionCorrect(
  45. IN DWORD dwMajorVersion,
  46. IN DWORD dwMinorVersion,
  47. IN DWORD dwServicePackMajor,
  48. IN DWORD dwServicePackMinor);
  49. */
  50. //
  51. // -------------------------------------------------------
  52. // ALGLIST
  53. // A linked list structure for storing PP_ENUMALGS_EX data
  54. // -------------------------------------------------------
  55. //
  56. //
  57. // Function: BuildAlgList
  58. // Purpose: Using the user-supplied hProv, call CryptGetProvParam repeatedly with
  59. // the PP_ENUMALGS_EX flag until ERROR_NO_MORE_ITEMS is returned. For each
  60. // algorithm returned, add a new ALGNODE to the pCSPInfo->pAlgNode list.
  61. //
  62. // Note that the string pointers in the ProvEnumalgsEx struct in each ALGNODE
  63. // will be valid only until the CSP dll unloads.
  64. //
  65. BOOL BuildAlgList(
  66. IN HCRYPTPROV hProv,
  67. IN OUT PCSPINFO pCSPInfo);
  68. //
  69. // Function: PrintAlgList
  70. // Purpose: Display the list of ALGNODE structs in pretty form.
  71. //
  72. void PrintAlgList(PALGNODE pAlgList);
  73. //
  74. // Function: AlgListIterate
  75. // Purpose: Iterate through each item in pAlgList. Each list item is passed to the
  76. // pfnFilter function. If the function returns true for that item, the item is passed
  77. // to the pfnProc function.
  78. //
  79. // AlgListIterate returns TRUE if pfnProc returns TRUE for every item passed to it.
  80. //
  81. typedef BOOL (*PFN_ALGNODE_FILTER)(PALGNODE pAlgNode);
  82. typedef BOOL (*PFN_ALGNODE_PROC)(PALGNODE pAlgNode, PTESTCASE ptc, PVOID pvProcData);
  83. BOOL AlgListIterate(
  84. IN PALGNODE pAlgList,
  85. IN PFN_ALGNODE_FILTER pfnFilter,
  86. IN PFN_ALGNODE_PROC pfnProc,
  87. IN PVOID pvProcData,
  88. IN PTESTCASE ptc);
  89. //
  90. // Function: HashAlgFilter
  91. // Purpose: If pAlgNode represents a known hash algorithm, return
  92. // TRUE, otherwise return FALSE. Mac algorithms are excluded
  93. // from this set (return FALSE).
  94. //
  95. BOOL HashAlgFilter(PALGNODE pAlgNode);
  96. //
  97. // Function: MacAlgFilter
  98. // Purpose: If pAlgNode represents a known Mac algorithm, return
  99. // TRUE, otherwise return FALSE
  100. //
  101. BOOL MacAlgFilter(PALGNODE pAlgNode);
  102. //
  103. // Function: BlockCipherFilter
  104. // Purpose: If pAlgNode represents a known block cipher algorithm,
  105. // return TRUE, otherwise return FALSE.
  106. //
  107. BOOL BlockCipherFilter(PALGNODE pAlgNode);
  108. //
  109. // Function: DataEncryptFilter
  110. // Purpose: If pAlgNode represents a known data encryption
  111. // symmetric key algorithm, return TRUE, otherwise return FALSE.
  112. //
  113. BOOL DataEncryptFilter(PALGNODE pAlgNode);
  114. //
  115. // Function: AllEncryptionAlgsFilter
  116. // Purpose: Same algorithm set as DataEncryptFilter above,
  117. // with the addition of the RSA key-exchange alg.
  118. //
  119. BOOL AllEncryptionAlgsFilter(PALGNODE pAlgNode);
  120. //
  121. // Function: RSAAlgFilter
  122. // Purpose: If pAlgNode represents an RSA algorithm, return
  123. // TRUE, otherwise return FALSE
  124. //
  125. BOOL RSAAlgFilter(PALGNODE pAlgNode);
  126. //
  127. // ------------------------------------------------
  128. // Test wrappers for creating crypto object handles
  129. // ------------------------------------------------
  130. //
  131. //
  132. // Function: CreateNewInteropContext
  133. // Purpose: Create a new cryptographic context with the provided
  134. // parameters. The context will be for the CSP specified by the
  135. // user at the command line to be the interoperability-test
  136. // provider.
  137. //
  138. BOOL CreateNewInteropContext(
  139. OUT HCRYPTPROV *phProv,
  140. IN LPWSTR pwszContainer,
  141. IN DWORD dwFlags,
  142. IN PTESTCASE ptc);
  143. //
  144. // Function: CreateNewContext
  145. // Purpose: Call CryptAcquireContext with the provided parameters. If
  146. // CRYPT_VERIFYCONTEXT is not specified in dwFlags, any existing
  147. // key container named pwszContainer will be deleted first, and the CRYPT_NEWKEYSET
  148. // flag will be used to re-create the container.
  149. //
  150. BOOL CreateNewContext(
  151. OUT HCRYPTPROV *phProv,
  152. IN LPWSTR pwszContainer,
  153. IN DWORD dwFlags,
  154. IN PTESTCASE ptc);
  155. //
  156. // Function: CreateNewKey
  157. // Purpose: Call CryptGenKey with the provided parameters.
  158. //
  159. BOOL CreateNewKey(
  160. IN HCRYPTPROV hProv,
  161. IN ALG_ID Algid,
  162. IN DWORD dwFlags,
  163. OUT HCRYPTKEY *phKey,
  164. IN PTESTCASE ptc);
  165. //
  166. // Function: CreateNewHash
  167. // Purpose: Call CryptCreateHash with the provided parameters.
  168. //
  169. BOOL CreateNewHash(
  170. IN HCRYPTPROV hProv,
  171. IN ALG_ID Algid,
  172. OUT HCRYPTHASH *phHash,
  173. IN PTESTCASE ptc);
  174. #endif