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.

216 lines
6.3 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 2000
  6. //
  7. // File: user.h
  8. //
  9. // Contents: declarations, constants for UserMode context manager
  10. //
  11. //
  12. // History: KDamour 13Apr00 Created
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef NTDIGEST_USER_H
  16. #define NTDIGEST_USER_H
  17. #include "nonce.h"
  18. #define DES_BLOCKSIZE 8
  19. #define RC4_BLOCKSIZE 1
  20. // For import of plain text keys
  21. typedef struct _PLAINTEXTBLOB
  22. {
  23. BLOBHEADER Blob;
  24. DWORD dwKeyLen;
  25. CHAR bKey[MD5_HASH_BYTESIZE];
  26. } PLAINTEXTBLOB;
  27. // Initializes the context manager package
  28. NTSTATUS UserCtxtHandlerInit(VOID);
  29. // Add a Context into the Cntext List
  30. NTSTATUS UserCtxtHandlerInsertCred(IN PDIGEST_USERCONTEXT pDigestCtxt);
  31. // Initialize all the struct elements in a Context
  32. NTSTATUS NTAPI UserCtxtInit(IN PDIGEST_USERCONTEXT pContext);
  33. // Release memory utilized by the Context
  34. NTSTATUS NTAPI UserCtxtFree(IN PDIGEST_USERCONTEXT pContext);
  35. // Find the security context by the security context handle
  36. NTSTATUS NTAPI
  37. UserCtxtHandlerHandleToContext(
  38. IN ULONG_PTR ContextHandle,
  39. IN BOOLEAN fDerefContextHandle,
  40. IN BOOLEAN fRefContextHandle,
  41. OUT PDIGEST_USERCONTEXT *ppContext
  42. );
  43. // Releases the Context by decreasing reference counter
  44. NTSTATUS UserCtxtHandlerRelease(PDIGEST_USERCONTEXT pContext);
  45. // Check to see if Context is within valid lifetime
  46. BOOL UserCtxtHandlerTimeHasElapsed(PDIGEST_USERCONTEXT pContext);
  47. // Creates a new DACL for the token granting the server and client
  48. NTSTATUS SspCreateTokenDacl(HANDLE Token);
  49. // From userapi.cxx
  50. // SECURITY_STATUS SEC_ENTRY FreeContextBuffer(void SEC_FAR * pvContextBuffer);
  51. NTSTATUS SspGetTokenUser(HANDLE Token, PTOKEN_USER * pTokenUser);
  52. // Create a local context for a real context
  53. NTSTATUS SspMapDigestContext(IN PDIGEST_CONTEXT pLsaContext,
  54. IN PDIGEST_PARAMETER pDigest,
  55. IN ULONG ulFlagOptions,
  56. OUT PSecBuffer ContextData);
  57. NTSTATUS NTAPI DigestUserProcessParameters(
  58. IN OUT PDIGEST_USERCONTEXT pContext,
  59. IN PDIGEST_PARAMETER pDigest,
  60. OUT PSecBuffer pFirstOutputToken);
  61. NTSTATUS NTAPI DigestUserHTTPHelper(
  62. IN PDIGEST_USERCONTEXT pContext,
  63. IN eSignSealOp Op,
  64. IN OUT PSecBufferDesc pMessage,
  65. IN ULONG MessageSeqNo
  66. );
  67. NTSTATUS NTAPI DigestUserSignHelperMulti(
  68. IN PDIGEST_USERCONTEXT pContext,
  69. IN OUT PSecBufferDesc pMessage,
  70. IN ULONG MessageSeqNo
  71. );
  72. NTSTATUS NTAPI DigestUserSealHelperMulti(
  73. IN PDIGEST_USERCONTEXT pContext,
  74. IN OUT PSecBufferDesc pMessage,
  75. IN ULONG MessageSeqNo
  76. );
  77. NTSTATUS NTAPI DigestUserUnsealHelper(
  78. IN PDIGEST_USERCONTEXT pContext,
  79. IN OUT PSecBufferDesc pMessage,
  80. IN ULONG MessageSeqNo
  81. );
  82. NTSTATUS NTAPI DigestUserVerifyHelper(
  83. IN PDIGEST_USERCONTEXT pContext,
  84. IN OUT PSecBufferDesc pMessage,
  85. IN ULONG MessageSeqNo
  86. );
  87. // Unpack the context from LSA mode into the User mode Context
  88. NTSTATUS DigestUnpackContext(
  89. IN PDIGEST_PACKED_USERCONTEXT pPackedUserContext,
  90. OUT PDIGEST_USERCONTEXT pContext);
  91. // Printout the fields present in usercontext pContext
  92. NTSTATUS UserContextPrint(PDIGEST_USERCONTEXT pContext);
  93. // Create a symmetric key with a given cleartext shared secret
  94. NTSTATUS SEC_ENTRY CreateSymmetricKey(
  95. IN ALG_ID Algid,
  96. IN DWORD cbKey,
  97. IN UCHAR *pbKey,
  98. IN UCHAR *pbIV,
  99. OUT HCRYPTKEY *phKey
  100. );
  101. NTSTATUS SEC_ENTRY EncryptData2Multi(
  102. IN HCRYPTKEY hKey,
  103. IN ULONG cbBlocklength,
  104. IN PSecBufferDesc pSecBuff,
  105. IN ULONG cbSignature,
  106. IN OUT UCHAR *pbSignature
  107. );
  108. NTSTATUS SEC_ENTRY LinkBuffersToEncrypt(
  109. IN HCRYPTKEY hKey,
  110. IN ULONG cbBlocklength,
  111. IN PSecBufferDesc pSecBuff,
  112. IN OUT PULONG pulIndex,
  113. IN OUT PULONG pcbDataBytesUsed,
  114. IN PUCHAR pbSignature,
  115. IN ULONG cbSignature
  116. );
  117. NTSTATUS SEC_ENTRY DecryptData(
  118. IN HCRYPTKEY hKey,
  119. IN ULONG cbData,
  120. IN OUT UCHAR *pbData
  121. );
  122. // Calculate the HMAC block for SASL messaging
  123. NTSTATUS
  124. SEC_ENTRY
  125. CalculateSASLHMAC(
  126. IN PDIGEST_USERCONTEXT pContext,
  127. IN BOOL fSign,
  128. IN PSTRING pstrSignKeyConst,
  129. IN DWORD dwSeqNum,
  130. IN PBYTE pdata, // location of data to HMAC
  131. IN ULONG cbdata, // How many bytes of data to process
  132. OUT PSASL_MAC_BLOCK pMacBlock
  133. );
  134. // Calculate the HMAC block for SASL messaging (multiData SecBuffer)
  135. NTSTATUS
  136. SEC_ENTRY
  137. CalculateSASLHMACMulti(
  138. IN PDIGEST_USERCONTEXT pContext,
  139. IN BOOL fSign,
  140. IN PSTRING pstrSignKeyConst,
  141. IN DWORD dwSeqNum,
  142. IN PSecBufferDesc pSecBuff, // location of data buffers to HMAC
  143. OUT PSASL_MAC_BLOCK pMacBlock
  144. );
  145. // For encrypt (seal)/ decrypt (unseal) calculate the value of Kc RFC 2831 sect 2.4
  146. NTSTATUS
  147. SEC_ENTRY
  148. CalculateKc(
  149. IN PBYTE pbSessionKey,
  150. IN USHORT cbHA1n,
  151. IN PSTRING pstrSealKeyConst,
  152. IN PBYTE pHashData
  153. );
  154. void
  155. SetDESParity(
  156. PBYTE pbKey,
  157. DWORD cbKey
  158. );
  159. NTSTATUS
  160. AddDESParity(
  161. IN PBYTE pbSrcKey,
  162. IN DWORD cbSrcKey,
  163. OUT PBYTE pbDstKey,
  164. OUT PDWORD pcbDstKey
  165. );
  166. NTSTATUS
  167. CalculateDataCount(
  168. IN PSecBufferDesc pSecBuff,
  169. OUT PULONG pulData
  170. );
  171. NTSTATUS
  172. SEC_ENTRY
  173. DigestUserCompareDirectives(
  174. IN PDIGEST_USERCONTEXT pContext,
  175. IN PDIGEST_PARAMETER pDigest
  176. );
  177. #endif // DIGEST_USER_H