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.

231 lines
4.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows NT Security
  4. // Copyright (C) Microsoft Corporation, 1997 - 1999
  5. //
  6. // File: callctx.h
  7. //
  8. // Contents: Certificate Chaining Infrastructure Call Context
  9. //
  10. // History: 02-Mar-98 kirtd Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #if !defined(__CALLCTX_H__)
  14. #define __CALLCTX_H__
  15. #include <chain.h>
  16. #define DEFAULT_CREATION_CACHE_BUCKETS 13
  17. // The first revocation URL retrieval uses half of this timeout
  18. #define DEFAULT_REV_ACCUMULATIVE_URL_RETRIEVAL_TIMEOUT 20000
  19. //
  20. // The call context object provides a mechanism for packaging and passing
  21. // around per-call data in the certificate chaining infrastructure.
  22. //
  23. class CChainCallContext
  24. {
  25. public:
  26. //
  27. // Construction
  28. //
  29. CChainCallContext (
  30. IN PCCERTCHAINENGINE pChainEngine,
  31. IN OPTIONAL LPFILETIME pRequestedTime,
  32. IN OPTIONAL PCERT_CHAIN_PARA pChainPara,
  33. IN DWORD dwFlags,
  34. OUT BOOL& rfResult
  35. );
  36. ~CChainCallContext ();
  37. inline PCCERTCHAINENGINE ChainEngine();
  38. inline VOID CurrentTime (
  39. OUT LPFILETIME pCurrentTime
  40. );
  41. inline VOID RequestedTime (
  42. OUT LPFILETIME pCurrentTime
  43. );
  44. inline PCERT_CHAIN_PARA ChainPara();
  45. inline BOOL HasDefaultUrlRetrievalTimeout ();
  46. DWORD RevocationUrlRetrievalTimeout();
  47. inline DWORD CallFlags();
  48. inline DWORD EngineFlags();
  49. inline DWORD CallOrEngineFlags();
  50. //
  51. // Cert Object Creation Cache
  52. //
  53. // This caches all certificate objects created in the context of this
  54. // call.
  55. //
  56. BOOL AddPathObjectToCreationCache (
  57. IN PCCHAINPATHOBJECT pPathObject
  58. );
  59. PCCHAINPATHOBJECT FindPathObjectInCreationCache (
  60. IN BYTE rgbCertHash[ CHAINHASHLEN ]
  61. );
  62. inline VOID FlushObjectsInCreationCache( );
  63. BOOL IsOnline ();
  64. //
  65. // Engine Touching
  66. //
  67. inline VOID TouchEngine ();
  68. BOOL IsTouchedEngine ();
  69. inline VOID ResetTouchEngine ();
  70. private:
  71. //
  72. // Cert Object Creation cache
  73. //
  74. // NOTE: LRU is turned off
  75. //
  76. HLRUCACHE m_hObjectCreationCache;
  77. PCCERTCHAINENGINE m_pChainEngine;
  78. FILETIME m_CurrentTime;
  79. FILETIME m_RequestedTime;
  80. CERT_CHAIN_PARA m_ChainPara;
  81. BOOL m_fDefaultUrlRetrievalTimeout;
  82. DWORD m_dwCallFlags;
  83. DWORD m_dwStatus;
  84. DWORD m_dwTouchEngineCount;
  85. FILETIME m_RevEndTime;
  86. };
  87. #define CHAINCALLCONTEXT_CHECKED_ONLINE_FLAG 0x00000001
  88. #define CHAINCALLCONTEXT_ONLINE_FLAG 0x00010000
  89. #define CHAINCALLCONTEXT_REV_END_TIME_FLAG 0x00000010
  90. //
  91. // Call Context Utility Functions
  92. //
  93. BOOL WINAPI
  94. CallContextCreateCallObject (
  95. IN PCCERTCHAINENGINE pChainEngine,
  96. IN OPTIONAL LPFILETIME pRequestedTime,
  97. IN OPTIONAL PCERT_CHAIN_PARA pChainPara,
  98. IN DWORD dwFlags,
  99. OUT PCCHAINCALLCONTEXT* ppCallContext
  100. );
  101. VOID WINAPI
  102. CallContextFreeCallObject (
  103. IN PCCHAINCALLCONTEXT pCallContext
  104. );
  105. VOID WINAPI
  106. CallContextOnCreationCacheObjectRemoval (
  107. IN LPVOID pv,
  108. IN LPVOID pvRemovalContext
  109. );
  110. //
  111. // Inline methods
  112. //
  113. //+---------------------------------------------------------------------------
  114. //
  115. // Member: CChainCallContext::FlushObjectsInCreationCache, public
  116. //
  117. // Synopsis: flush the cache of objects
  118. //
  119. //----------------------------------------------------------------------------
  120. inline VOID
  121. CChainCallContext::FlushObjectsInCreationCache( )
  122. {
  123. I_CryptFlushLruCache( m_hObjectCreationCache, 0, this );
  124. }
  125. inline PCCERTCHAINENGINE
  126. CChainCallContext::ChainEngine ()
  127. {
  128. return( m_pChainEngine);
  129. }
  130. inline VOID
  131. CChainCallContext::RequestedTime (
  132. OUT LPFILETIME pRequestedTime
  133. )
  134. {
  135. *pRequestedTime = m_RequestedTime;
  136. }
  137. inline VOID
  138. CChainCallContext::CurrentTime (
  139. OUT LPFILETIME pCurrentTime
  140. )
  141. {
  142. *pCurrentTime = m_CurrentTime;
  143. }
  144. inline PCERT_CHAIN_PARA
  145. CChainCallContext::ChainPara()
  146. {
  147. return( &m_ChainPara );
  148. }
  149. inline BOOL
  150. CChainCallContext::HasDefaultUrlRetrievalTimeout()
  151. {
  152. return( m_fDefaultUrlRetrievalTimeout );
  153. }
  154. inline DWORD
  155. CChainCallContext::CallFlags ()
  156. {
  157. return( m_dwCallFlags );
  158. }
  159. inline DWORD
  160. CChainCallContext::EngineFlags ()
  161. {
  162. return( m_pChainEngine->Flags() );
  163. }
  164. inline DWORD
  165. CChainCallContext::CallOrEngineFlags ()
  166. {
  167. return( m_dwCallFlags | m_pChainEngine->Flags() );
  168. }
  169. inline VOID
  170. CChainCallContext::TouchEngine ()
  171. {
  172. m_dwTouchEngineCount = m_pChainEngine->IncrementTouchEngineCount();
  173. }
  174. inline VOID
  175. CChainCallContext::ResetTouchEngine ()
  176. {
  177. m_dwTouchEngineCount = m_pChainEngine->TouchEngineCount();
  178. }
  179. #endif