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.

161 lines
5.2 KiB

  1. //+-------------------------------------------------------------------------
  2. // Microsoft Windows
  3. //
  4. // Copyright (C) Microsoft Corporation, 1996 - 1996
  5. //
  6. // File: crypttls.h
  7. //
  8. // Contents: Crypt Thread Local Storage (TLS) and Asn1 Module
  9. // installation and allocation functions
  10. //
  11. // APIs:
  12. // I_CryptAllocTls
  13. // I_CryptFreeTls
  14. // I_CryptGetTls
  15. // I_CryptSetTls
  16. // I_CryptDetachTls
  17. //
  18. // I_CryptInstallAsn1Module
  19. // I_CryptUninstallAsn1Module
  20. // I_CryptGetAsn1Encoder
  21. // I_CryptGetAsn1Decoder
  22. //
  23. //
  24. // History: 17-Nov-96 philh created
  25. //--------------------------------------------------------------------------
  26. #ifndef __CRYPTTLS_H__
  27. #define __CRYPTTLS_H__
  28. #include "msasn1.h"
  29. #include <wincrypt.h>
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. // Handle to an allocated Crypt TLS entry
  34. typedef DWORD HCRYPTTLS;
  35. // Handle to an installed Asn1 module
  36. typedef DWORD HCRYPTASN1MODULE;
  37. //+-------------------------------------------------------------------------
  38. // Install a thread local storage entry and return a handle for future access.
  39. //--------------------------------------------------------------------------
  40. HCRYPTTLS
  41. WINAPI
  42. I_CryptAllocTls();
  43. //+-------------------------------------------------------------------------
  44. // Called at DLL_PROCESS_DETACH to free a thread local storage entry.
  45. // Optionally, calls the callback for each thread having a non-NULL pvTls.
  46. //--------------------------------------------------------------------------
  47. BOOL
  48. WINAPI
  49. I_CryptFreeTls(
  50. IN HCRYPTTLS hCryptTls,
  51. IN OPTIONAL PFN_CRYPT_FREE pfnFree
  52. );
  53. //+-------------------------------------------------------------------------
  54. // Get the thread specific pointer specified by the
  55. // hCryptTls returned by I_CryptAllocTls().
  56. //
  57. // Returns NULL for an error or uninitialized pointer.
  58. //--------------------------------------------------------------------------
  59. void *
  60. WINAPI
  61. I_CryptGetTls(
  62. IN HCRYPTTLS hCryptTls
  63. );
  64. //+-------------------------------------------------------------------------
  65. // Set the thread specific pointer specified by the
  66. // hCryptTls returned by I_CryptAllocTls().
  67. //
  68. // Returns FALSE for an invalid handle or unable to allocate memory.
  69. //--------------------------------------------------------------------------
  70. BOOL
  71. WINAPI
  72. I_CryptSetTls(
  73. IN HCRYPTTLS hCryptTls,
  74. IN void *pvTls
  75. );
  76. //+-------------------------------------------------------------------------
  77. // Called at DLL_THREAD_DETACH to free the thread's
  78. // TLS entry specified by the hCryptTls. Returns the thread specific pointer
  79. // to be freed by the caller.
  80. //
  81. // Note, at DLL_PROCESS_DETACH, I_CryptFreeTls should be called instead.
  82. //--------------------------------------------------------------------------
  83. void *
  84. WINAPI
  85. I_CryptDetachTls(
  86. IN HCRYPTTLS hCryptTls
  87. );
  88. //+-------------------------------------------------------------------------
  89. // Install an Asn1 module entry and return a handle for future access.
  90. //
  91. // Each thread has its own copy of the decoder and encoder associated
  92. // with the Asn1 module. Creation is deferred until first referenced by
  93. // the thread.
  94. //
  95. // I_CryptGetAsn1Encoder or I_CryptGetAsn1Decoder must be called with the
  96. // handle returned by I_CryptInstallAsn1Module to get the thread specific
  97. // Asn1 encoder or decoder.
  98. //
  99. // Currently, dwFlags and pvReserved aren't used and must be set to 0.
  100. //--------------------------------------------------------------------------
  101. HCRYPTASN1MODULE
  102. WINAPI
  103. I_CryptInstallAsn1Module(
  104. IN ASN1module_t pMod,
  105. IN DWORD dwFlags,
  106. IN void *pvReserved
  107. );
  108. //+-------------------------------------------------------------------------
  109. // Called at DLL_PROCESS_DETACH to uninstall an hAsn1Module entry. Iterates
  110. // through the threads and frees their created Asn1 encoders and decoders.
  111. //--------------------------------------------------------------------------
  112. BOOL
  113. WINAPI
  114. I_CryptUninstallAsn1Module(
  115. IN HCRYPTASN1MODULE hAsn1Module
  116. );
  117. //+-------------------------------------------------------------------------
  118. // Get the thread specific pointer to the Asn1 encoder specified by the
  119. // hAsn1Module returned by CryptInstallAsn1Module. If the
  120. // encoder doesn't exist, then, its created using the Asn1 module
  121. // associated with hAsn1Module.
  122. //--------------------------------------------------------------------------
  123. ASN1encoding_t
  124. WINAPI
  125. I_CryptGetAsn1Encoder(
  126. IN HCRYPTASN1MODULE hAsn1Module
  127. );
  128. //+-------------------------------------------------------------------------
  129. // Get the thread specific pointer to the Asn1 decoder specified by the
  130. // hAsn1Module returned by CryptInstallAsn1Module. If the
  131. // decoder doesn't exist, then, its created using the Asn1 module
  132. // associated with hAsn1Module.
  133. //--------------------------------------------------------------------------
  134. ASN1decoding_t
  135. WINAPI
  136. I_CryptGetAsn1Decoder(
  137. IN HCRYPTASN1MODULE hAsn1Module
  138. );
  139. #ifdef __cplusplus
  140. } // Balance extern "C" above
  141. #endif
  142. #endif