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.

176 lines
5.1 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. // Finf the security context by the security context handle
  36. NTSTATUS NTAPI UserCtxtHandlerHandleToContext(IN ULONG_PTR ContextHandle, IN BOOLEAN RemoveContext,
  37. OUT PDIGEST_USERCONTEXT *ppContext);
  38. // Releases the Context by decreasing reference counter
  39. NTSTATUS UserCtxtHandlerRelease(PDIGEST_USERCONTEXT pContext);
  40. // Check to see if Context is within valid lifetime
  41. BOOL UserCtxtHandlerTimeHasElapsed(PDIGEST_USERCONTEXT pContext);
  42. // Creates a new DACL for the token granting the server and client
  43. NTSTATUS SspCreateTokenDacl(HANDLE Token);
  44. // From userapi.cxx
  45. // SECURITY_STATUS SEC_ENTRY FreeContextBuffer(void SEC_FAR * pvContextBuffer);
  46. NTSTATUS SspGetTokenUser(HANDLE Token, PTOKEN_USER * pTokenUser);
  47. // Create a local context for a real context
  48. NTSTATUS SspMapDigestContext(IN PDIGEST_CONTEXT pLsaContext,
  49. IN PDIGEST_PARAMETER pDigest,
  50. OUT PSecBuffer ContextData);
  51. NTSTATUS NTAPI DigestUserProcessParameters(
  52. IN OUT PDIGEST_USERCONTEXT pContext,
  53. IN PDIGEST_PARAMETER pDigest,
  54. OUT PSecBuffer pFirstOutputToken);
  55. NTSTATUS NTAPI DigestUserHTTPHelper(
  56. IN PDIGEST_USERCONTEXT pContext,
  57. IN eSignSealOp Op,
  58. IN OUT PSecBufferDesc pMessage,
  59. IN ULONG MessageSeqNo
  60. );
  61. NTSTATUS NTAPI DigestUserSignHelper(
  62. IN PDIGEST_USERCONTEXT pContext,
  63. IN OUT PSecBufferDesc pMessage,
  64. IN ULONG MessageSeqNo
  65. );
  66. NTSTATUS NTAPI DigestUserSealHelper(
  67. IN PDIGEST_USERCONTEXT pContext,
  68. IN OUT PSecBufferDesc pMessage,
  69. IN ULONG MessageSeqNo
  70. );
  71. NTSTATUS NTAPI DigestUserUnsealHelper(
  72. IN PDIGEST_USERCONTEXT pContext,
  73. IN OUT PSecBufferDesc pMessage,
  74. IN ULONG MessageSeqNo
  75. );
  76. NTSTATUS NTAPI DigestUserVerifyHelper(
  77. IN PDIGEST_USERCONTEXT pContext,
  78. IN OUT PSecBufferDesc pMessage,
  79. IN ULONG MessageSeqNo
  80. );
  81. // Unpack the context from LSA mode into the User mode Context
  82. NTSTATUS DigestUnpackContext(
  83. IN PDIGEST_PACKED_USERCONTEXT pPackedUserContext,
  84. OUT PDIGEST_USERCONTEXT pContext);
  85. // Printout the fields present in usercontext pContext
  86. NTSTATUS UserContextPrint(PDIGEST_USERCONTEXT pContext);
  87. // Create a symmetric key with a given cleartext shared secret
  88. NTSTATUS SEC_ENTRY CreateSymmetricKey(
  89. IN ALG_ID Algid,
  90. IN DWORD cbKey,
  91. IN UCHAR *pbKey,
  92. IN UCHAR *pbIV,
  93. OUT HCRYPTKEY *phKey
  94. );
  95. // Encrypt data with the symmetric key - non-consecutive buffers
  96. NTSTATUS SEC_ENTRY EncryptData2(
  97. IN HCRYPTKEY hKey,
  98. IN ULONG cbBlocklength,
  99. IN ULONG cbData,
  100. IN OUT UCHAR *pbData,
  101. IN ULONG cbSignature,
  102. IN OUT UCHAR *pbSignature
  103. );
  104. NTSTATUS SEC_ENTRY DecryptData(
  105. IN HCRYPTKEY hKey,
  106. IN ULONG cbData,
  107. IN OUT UCHAR *pbData
  108. );
  109. // Calculate the HMAC block for SASL messaging
  110. NTSTATUS
  111. SEC_ENTRY
  112. CalculateSASLHMAC(
  113. IN PDIGEST_USERCONTEXT pContext,
  114. IN BOOL fSign,
  115. IN PSTRING pstrSignKeyConst,
  116. IN DWORD dwSeqNum,
  117. IN PBYTE pdata, // location of data to HMAC
  118. IN ULONG cbdata, // How many bytes of data to process
  119. OUT PSASL_MAC_BLOCK pMacBlock
  120. );
  121. // For encrypt (seal)/ decrypt (unseal) calculate the value of Kc RFC 2831 sect 2.4
  122. NTSTATUS
  123. SEC_ENTRY
  124. CalculateKc(
  125. IN PBYTE pbSessionKey,
  126. IN USHORT cbHA1n,
  127. IN PSTRING pstrSealKeyConst,
  128. IN PBYTE pHashData
  129. );
  130. void
  131. SetDESParity(
  132. PBYTE pbKey,
  133. DWORD cbKey
  134. );
  135. NTSTATUS
  136. AddDESParity(
  137. IN PBYTE pbSrcKey,
  138. IN DWORD cbSrcKey,
  139. OUT PBYTE pbDstKey,
  140. OUT PDWORD pcbDstKey
  141. );
  142. #endif // DIGEST_USER_H