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.

256 lines
5.6 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. DWORD AIAUrlRetrievalTimeout();
  48. inline DWORD AIAUrlRetrievalCount();
  49. inline VOID IncrementAIAUrlRetrievalCount();
  50. inline DWORD CallFlags();
  51. inline DWORD EngineFlags();
  52. inline DWORD CallOrEngineFlags();
  53. //
  54. // Cert Object Creation Cache
  55. //
  56. // This caches all certificate objects created in the context of this
  57. // call.
  58. //
  59. BOOL AddPathObjectToCreationCache (
  60. IN PCCHAINPATHOBJECT pPathObject
  61. );
  62. VOID RemovePathObjectFromCreationCache (
  63. IN PCCHAINPATHOBJECT pPathObject
  64. );
  65. PCCHAINPATHOBJECT FindPathObjectInCreationCache (
  66. IN BYTE rgbCertHash[ CHAINHASHLEN ]
  67. );
  68. inline VOID FlushObjectsInCreationCache( );
  69. BOOL IsOnline ();
  70. //
  71. // Engine Touching
  72. //
  73. inline VOID TouchEngine ();
  74. BOOL IsTouchedEngine ();
  75. inline VOID ResetTouchEngine ();
  76. private:
  77. //
  78. // Cert Object Creation cache
  79. //
  80. // NOTE: LRU is turned off
  81. //
  82. HLRUCACHE m_hObjectCreationCache;
  83. PCCERTCHAINENGINE m_pChainEngine;
  84. FILETIME m_CurrentTime;
  85. FILETIME m_RequestedTime;
  86. CERT_CHAIN_PARA m_ChainPara;
  87. BOOL m_fDefaultUrlRetrievalTimeout;
  88. DWORD m_dwCallFlags;
  89. DWORD m_dwStatus;
  90. DWORD m_dwTouchEngineCount;
  91. FILETIME m_RevEndTime;
  92. DWORD m_dwAIAUrlRetrievalCount;
  93. FILETIME m_AIAEndTime;
  94. };
  95. #define CHAINCALLCONTEXT_CHECKED_ONLINE_FLAG 0x00000001
  96. #define CHAINCALLCONTEXT_ONLINE_FLAG 0x00010000
  97. #define CHAINCALLCONTEXT_REV_END_TIME_FLAG 0x00000010
  98. #define CHAINCALLCONTEXT_AIA_END_TIME_FLAG 0x00000020
  99. //
  100. // Call Context Utility Functions
  101. //
  102. BOOL WINAPI
  103. CallContextCreateCallObject (
  104. IN PCCERTCHAINENGINE pChainEngine,
  105. IN OPTIONAL LPFILETIME pRequestedTime,
  106. IN OPTIONAL PCERT_CHAIN_PARA pChainPara,
  107. IN DWORD dwFlags,
  108. OUT PCCHAINCALLCONTEXT* ppCallContext
  109. );
  110. VOID WINAPI
  111. CallContextFreeCallObject (
  112. IN PCCHAINCALLCONTEXT pCallContext
  113. );
  114. VOID WINAPI
  115. CallContextOnCreationCacheObjectRemoval (
  116. IN LPVOID pv,
  117. IN LPVOID pvRemovalContext
  118. );
  119. //
  120. // Inline methods
  121. //
  122. //+---------------------------------------------------------------------------
  123. //
  124. // Member: CChainCallContext::FlushObjectsInCreationCache, public
  125. //
  126. // Synopsis: flush the cache of objects
  127. //
  128. //----------------------------------------------------------------------------
  129. inline VOID
  130. CChainCallContext::FlushObjectsInCreationCache( )
  131. {
  132. I_CryptFlushLruCache( m_hObjectCreationCache, 0, this );
  133. m_dwAIAUrlRetrievalCount = 0;
  134. }
  135. inline PCCERTCHAINENGINE
  136. CChainCallContext::ChainEngine ()
  137. {
  138. return( m_pChainEngine);
  139. }
  140. inline VOID
  141. CChainCallContext::RequestedTime (
  142. OUT LPFILETIME pRequestedTime
  143. )
  144. {
  145. *pRequestedTime = m_RequestedTime;
  146. }
  147. inline VOID
  148. CChainCallContext::CurrentTime (
  149. OUT LPFILETIME pCurrentTime
  150. )
  151. {
  152. *pCurrentTime = m_CurrentTime;
  153. }
  154. inline PCERT_CHAIN_PARA
  155. CChainCallContext::ChainPara()
  156. {
  157. return( &m_ChainPara );
  158. }
  159. inline BOOL
  160. CChainCallContext::HasDefaultUrlRetrievalTimeout()
  161. {
  162. return( m_fDefaultUrlRetrievalTimeout );
  163. }
  164. inline DWORD
  165. CChainCallContext::CallFlags ()
  166. {
  167. return( m_dwCallFlags );
  168. }
  169. inline DWORD
  170. CChainCallContext::EngineFlags ()
  171. {
  172. return( m_pChainEngine->Flags() );
  173. }
  174. inline DWORD
  175. CChainCallContext::CallOrEngineFlags ()
  176. {
  177. return( m_dwCallFlags | m_pChainEngine->Flags() );
  178. }
  179. inline VOID
  180. CChainCallContext::TouchEngine ()
  181. {
  182. m_dwTouchEngineCount = m_pChainEngine->IncrementTouchEngineCount();
  183. }
  184. inline VOID
  185. CChainCallContext::ResetTouchEngine ()
  186. {
  187. m_dwTouchEngineCount = m_pChainEngine->TouchEngineCount();
  188. }
  189. inline DWORD
  190. CChainCallContext::AIAUrlRetrievalCount ()
  191. {
  192. return( m_dwAIAUrlRetrievalCount );
  193. }
  194. inline VOID
  195. CChainCallContext::IncrementAIAUrlRetrievalCount ()
  196. {
  197. m_dwAIAUrlRetrievalCount++;
  198. }
  199. #endif