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.

288 lines
7.6 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 2000
  6. //
  7. // File: krnldgst.h
  8. //
  9. // Contents: declarations, constants for Kernel Mode context manager
  10. //
  11. //
  12. // History: KDamour 13Apr00 Created
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef NTDIGEST_KRNLDGST_H
  16. #define NTDIGEST_KRNLDGST_H
  17. #ifndef UNICODE
  18. #define UNICODE
  19. #endif // UNICODE
  20. #define DES_BLOCKSIZE 8
  21. #define RC4_BLOCKSIZE 1
  22. // This structure contains the state info for the User mode
  23. // security context.
  24. // For longhorn - pull out the common context info between usermode
  25. // and kernel mode to share helper functions for verify/make signature...
  26. typedef struct _DIGEST_KERNELCONTEXT{
  27. //
  28. // Global list of all Contexts
  29. // (Serialized by UserContextCritSect)
  30. //
  31. KSEC_LIST_ENTRY List;
  32. //
  33. // Handle to the LsaContext
  34. // This will have the handle to the context in LSAMode Address space
  35. //
  36. ULONG_PTR LsaContext;
  37. //
  38. // Timeout the context after awhile.
  39. //
  40. TimeStamp ExpirationTime; // Time inwhich session key expires
  41. //
  42. // Used to prevent this Context from being deleted prematurely.
  43. // (Serialized by Interlocked*)
  44. //
  45. LONG lReferences;
  46. //
  47. // Flag to indicate that Context is not attached to List - skip when scanning list
  48. //
  49. BOOL bUnlinked;
  50. //
  51. // Digest Parameters for this context
  52. //
  53. DIGEST_TYPE typeDigest;
  54. //
  55. // QOP selected for this context
  56. //
  57. QOP_TYPE typeQOP;
  58. //
  59. // Digest Parameters for this context
  60. //
  61. ALGORITHM_TYPE typeAlgorithm;
  62. //
  63. // Cipher to use for encrypt/decrypt
  64. //
  65. CIPHER_TYPE typeCipher;
  66. //
  67. // Charset used for digest directive values
  68. //
  69. CHARSET_TYPE typeCharset;
  70. //
  71. // Token Handle of authenticated user
  72. // Only valid when in AuthenticatedState.
  73. // Filled in only by AcceptSecurityContext - so we are the server
  74. // Mapped to UserMode Client space from LSA TokenHandle
  75. // It will be NULL is struct is from InitializeSecurityContext - so we are client
  76. //
  77. HANDLE ClientTokenHandle;
  78. //
  79. // Maintain the context requirements
  80. //
  81. ULONG ContextReq;
  82. //
  83. // Maintain a copy of the credential UseFlags (we can tell if inbound or outbound)
  84. //
  85. ULONG CredentialUseFlags;
  86. // Flags FLAG_CONTEXT_AUTHZID_PROVIDED
  87. ULONG ulFlags;
  88. // Nonce Count
  89. ULONG ulNC;
  90. // Maxbuffer for auth-int and auth-conf processing
  91. ULONG ulSendMaxBuf;
  92. ULONG ulRecvMaxBuf;
  93. // SASL sequence numbering
  94. DWORD dwSendSeqNum; // Makesignature/verifysignature server to client sequence number
  95. DWORD dwRecvSeqNum; // Makesignature/verifysignature server to client sequence number
  96. //
  97. // Hex(H(A1)) sent from DC and stored in context for future
  98. // auth without going to the DC. Binary version is derived from HEX(H(A1))
  99. // and is used in SASL mode for integrity protection and encryption
  100. //
  101. STRING strSessionKey;
  102. BYTE bSessionKey[MD5_HASH_BYTESIZE];
  103. // Account name used in token creation for securityContext session
  104. UNICODE_STRING ustrAccountName;
  105. //
  106. // Values utilized in the Initial Digest Auth ChallResponse
  107. //
  108. STRING strParam[MD5_AUTH_LAST]; // points to owned memory - will need to free up!
  109. } DIGEST_KERNELCONTEXT, * PDIGEST_KERNELCONTEXT;
  110. extern "C"
  111. {
  112. KspInitPackageFn WDigestInitKernelPackage;
  113. KspDeleteContextFn WDigestDeleteKernelContext;
  114. KspInitContextFn WDigestInitKernelContext;
  115. KspMapHandleFn WDigestMapKernelHandle;
  116. KspMakeSignatureFn WDigestMakeSignature;
  117. KspVerifySignatureFn WDigestVerifySignature;
  118. KspSealMessageFn WDigestSealMessage;
  119. KspUnsealMessageFn WDigestUnsealMessage;
  120. KspGetTokenFn WDigestGetContextToken;
  121. KspQueryAttributesFn WDigestQueryContextAttributes;
  122. KspCompleteTokenFn WDigestCompleteToken;
  123. SpExportSecurityContextFn WDigestExportSecurityContext;
  124. SpImportSecurityContextFn WDigestImportSecurityContext;
  125. KspSetPagingModeFn WDigestSetPagingMode ;
  126. //
  127. // Useful macros
  128. //
  129. #define WDigestKAllocate( _x_ ) ExAllocatePoolWithTag( WDigestPoolType, (_x_) , 'CvsM')
  130. #define WDigestKFree( _x_ ) ExFreePool(_x_)
  131. #define MAYBE_PAGED_CODE() \
  132. if ( WDigestPoolType == PagedPool ) \
  133. { \
  134. PAGED_CODE(); \
  135. }
  136. #define WDigestReferenceContext( Context, Remove ) \
  137. KSecReferenceListEntry( (PKSEC_LIST_ENTRY) Context, \
  138. WDIGEST_CONTEXT_SIGNATURE, \
  139. Remove )
  140. NTSTATUS NTAPI WDigestInitKernelPackage(
  141. IN PSECPKG_KERNEL_FUNCTIONS pKernelFunctions);
  142. NTSTATUS NTAPI WDigestDeleteKernelContext(
  143. IN ULONG_PTR pKernelContextHandle,
  144. OUT PULONG_PTR pLsaContextHandle);
  145. VOID WDigestDerefContext(
  146. PDIGEST_KERNELCONTEXT pContext);
  147. NTSTATUS WDigestFreeKernelContext (
  148. PDIGEST_KERNELCONTEXT pKernelContext);
  149. NTSTATUS NTAPI WDigestInitKernelContext(
  150. IN ULONG_PTR LsaContextHandle,
  151. IN PSecBuffer PackedContext,
  152. OUT PULONG_PTR NewContextHandle);
  153. NTSTATUS DigestKernelUnpackContext(
  154. IN PDIGEST_PACKED_USERCONTEXT pPackedUserContext,
  155. OUT PDIGEST_KERNELCONTEXT pContext);
  156. NTSTATUS KernelContextPrint(
  157. PDIGEST_KERNELCONTEXT pContext);
  158. NTSTATUS NTAPI WDigestMapKernelHandle(
  159. IN ULONG_PTR KernelContextHandle,
  160. OUT PULONG_PTR LsaContextHandle);
  161. NTSTATUS NTAPI DigestKernelHTTPHelper(
  162. IN PDIGEST_KERNELCONTEXT pContext,
  163. IN eSignSealOp Op,
  164. IN OUT PSecBufferDesc pSecBuff,
  165. IN ULONG MessageSeqNo);
  166. NTSTATUS NTAPI WDigestMakeSignature(
  167. IN ULONG_PTR KernelContextHandle,
  168. IN ULONG fQOP,
  169. IN PSecBufferDesc pMessage,
  170. IN ULONG MessageSeqNo);
  171. NTSTATUS NTAPI WDigestVerifySignature(
  172. IN ULONG_PTR KernelContextHandle,
  173. IN PSecBufferDesc pMessage,
  174. IN ULONG MessageSeqNo,
  175. OUT PULONG pfQOP);
  176. NTSTATUS NTAPI DigestKernelProcessParameters(
  177. IN PDIGEST_KERNELCONTEXT pContext,
  178. IN PDIGEST_PARAMETER pDigest,
  179. OUT PSecBuffer pFirstOutputToken);
  180. NTSTATUS NTAPI WDigestSealMessage(
  181. IN ULONG_PTR KernelContextHandle,
  182. IN ULONG fQOP,
  183. IN PSecBufferDesc pMessage,
  184. IN ULONG MessageSeqNo);
  185. NTSTATUS NTAPI WDigestUnsealMessage(
  186. IN ULONG_PTR KernelContextHandle,
  187. IN PSecBufferDesc pMessage,
  188. IN ULONG MessageSeqNo,
  189. OUT PULONG pfQOP);
  190. NTSTATUS NTAPI WDigestGetContextToken(
  191. IN ULONG_PTR KernelContextHandle,
  192. OUT PHANDLE ImpersonationToken,
  193. OUT OPTIONAL PACCESS_TOKEN *RawToken);
  194. NTSTATUS NTAPI WDigestQueryContextAttributes(
  195. IN ULONG_PTR KernelContextHandle,
  196. IN ULONG Attribute,
  197. IN OUT PVOID Buffer);
  198. NTSTATUS NTAPI WDigestCompleteToken(
  199. IN ULONG_PTR ContextHandle,
  200. IN PSecBufferDesc InputBuffer);
  201. NTSTATUS WDigestImportSecurityContext(
  202. IN PSecBuffer PackedContext,
  203. IN OPTIONAL HANDLE TokenHandle,
  204. OUT PULONG_PTR ContextHandle);
  205. NTSTATUS WDigestImportSecurityContext(
  206. IN PSecBuffer PackedContext,
  207. IN OPTIONAL HANDLE TokenHandle,
  208. OUT PULONG_PTR ContextHandle);
  209. NTSTATUS WDigestSetPagingMode(
  210. BOOLEAN Pagable);
  211. } // extern "C"
  212. #endif // NTDIGEST_KRNLDGST_H