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.

148 lines
3.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 2001 - 2001
  6. //
  7. // File: testutil.h
  8. //
  9. // Contents: Test Utility API Prototypes and Definitions
  10. //
  11. // History: 29-Jan-01 philh created
  12. //--------------------------------------------------------------------------
  13. #ifndef __TEST_UTIL_H__
  14. #define __TEST_UTIL_H__
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include "wincrypt.h"
  19. #include "minasn1.h"
  20. #include "mincrypt.h"
  21. //+-------------------------------------------------------------------------
  22. // Error output routines
  23. //--------------------------------------------------------------------------
  24. VOID
  25. PrintErr(
  26. IN LPCSTR pszMsg,
  27. IN LONG lErr
  28. );
  29. //+-------------------------------------------------------------------------
  30. // Test allocation and free routines
  31. //--------------------------------------------------------------------------
  32. LPVOID
  33. TestAlloc(
  34. IN size_t cbBytes
  35. );
  36. VOID
  37. TestFree(
  38. IN LPVOID pv
  39. );
  40. //+-------------------------------------------------------------------------
  41. // Allocate and convert a multi-byte string to a wide string. TestFree()
  42. // must be called to free the returned wide string.
  43. //--------------------------------------------------------------------------
  44. LPWSTR
  45. AllocAndSzToWsz(
  46. IN LPCSTR psz
  47. );
  48. //+-------------------------------------------------------------------------
  49. // Conversions functions between encoded OID and the dot string
  50. // representation
  51. //--------------------------------------------------------------------------
  52. #define MAX_OID_STRING_LEN 0x80
  53. #define MAX_ENCODED_OID_LEN 0x80
  54. BOOL
  55. EncodedOIDToDot(
  56. IN PCRYPT_DER_BLOB pEncodedOIDBlob,
  57. OUT CHAR rgszOID[MAX_OID_STRING_LEN]
  58. );
  59. BOOL
  60. DotToEncodedOID(
  61. IN LPCSTR pszOID,
  62. OUT BYTE rgbEncodedOID[MAX_ENCODED_OID_LEN],
  63. OUT DWORD *pcbEncodedOID
  64. );
  65. //+-------------------------------------------------------------------------
  66. // Functions to print bytes
  67. //--------------------------------------------------------------------------
  68. VOID
  69. PrintBytes(
  70. IN PCRYPT_DER_BLOB pBlob
  71. );
  72. VOID
  73. PrintMultiLineBytes(
  74. IN LPCSTR pszHdr,
  75. IN PCRYPT_DER_BLOB pBlob
  76. );
  77. //+-------------------------------------------------------------------------
  78. // Allocate and read an encoded DER blob from a file
  79. //--------------------------------------------------------------------------
  80. BOOL
  81. ReadDERFromFile(
  82. IN LPCSTR pszFileName,
  83. OUT PBYTE *ppbDER,
  84. OUT PDWORD pcbDER
  85. );
  86. //+-------------------------------------------------------------------------
  87. // Write an encoded DER blob to a file
  88. //--------------------------------------------------------------------------
  89. BOOL
  90. WriteDERToFile(
  91. IN LPCSTR pszFileName,
  92. IN PBYTE pbDER,
  93. IN DWORD cbDER
  94. );
  95. //+-------------------------------------------------------------------------
  96. // Display functions
  97. //--------------------------------------------------------------------------
  98. VOID
  99. DisplayCert(
  100. IN CRYPT_DER_BLOB rgCertBlob[MINASN1_CERT_BLOB_CNT],
  101. IN BOOL fVerbose = FALSE
  102. );
  103. VOID
  104. DisplayName(
  105. IN PCRYPT_DER_BLOB pNameValueBlob
  106. );
  107. VOID
  108. DisplayExts(
  109. IN PCRYPT_DER_BLOB pExtsValueBlob
  110. );
  111. VOID
  112. DisplayCTL(
  113. IN PCRYPT_DER_BLOB pEncodedContentBlob,
  114. IN BOOL fVerbose = FALSE
  115. );
  116. VOID
  117. DisplayAttrs(
  118. IN LPCSTR pszHdr,
  119. IN PCRYPT_DER_BLOB pAttrsValueBlob
  120. );
  121. #ifdef __cplusplus
  122. } // Balance extern "C" above
  123. #endif
  124. #endif