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.

128 lines
4.7 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 2000
  6. //
  7. // File: ctxt.h
  8. //
  9. // Contents: declarations, constants for context manager
  10. //
  11. //
  12. // History: KDamour 15Mar00 Created
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef NTDIGEST_CTXT_H
  16. #define NTDIGEST_CTXT_H
  17. // Utilized for Str to int conversion
  18. #define HEXBASE 16
  19. #define TENBASE 10
  20. // number of bytes to hold ChallengeResponse directives and symbols (actual count is 107) round up for padding
  21. // 14 for charset
  22. #define CB_CHALRESP 364
  23. #define CB_CHAL 400
  24. #define RSPAUTH_STR "rspauth=%Z"
  25. // Hash locations for pre-calculated DS hashes
  26. #define PRECALC_NONE 0
  27. #define PRECALC_ACCOUNTNAME 1
  28. #define PRECALC_UPN 2
  29. #define PRECALC_NETBIOS 3
  30. // Number of secbuffers for each type HTTP and SASL
  31. #define ASC_HTTP_NUM_INPUT_BUFFERS 5
  32. #define ASC_SASL_NUM_INPUT_BUFFERS 1
  33. #define ASC_HTTP_NUM_OUTPUT_BUFFERS 1
  34. #define ASC_SASL_NUM_OUTPUT_BUFFERS 1
  35. // Initializes the context manager package
  36. NTSTATUS CtxtHandlerInit(VOID);
  37. // Add a Context into the Cntext List
  38. NTSTATUS CtxtHandlerInsertCred(IN PDIGEST_CONTEXT pDigestCtxt);
  39. // Initialize all the struct elements in a Context from the Credential
  40. NTSTATUS NTAPI ContextInit(IN OUT PDIGEST_CONTEXT pContext, IN PDIGEST_CREDENTIAL pCredential);
  41. // Release memory utilized by the Context
  42. NTSTATUS NTAPI ContextFree(IN PDIGEST_CONTEXT pContext);
  43. // Find the security context handle by the opaque reference
  44. NTSTATUS NTAPI CtxtHandlerOpaqueToPtr(
  45. IN PSTRING pstrOpaque,
  46. OUT PDIGEST_CONTEXT *ppContext);
  47. // Find the security context by the security context handle
  48. NTSTATUS NTAPI CtxtHandlerHandleToContext(IN ULONG_PTR ContextHandle, IN BOOLEAN RemoveContext,
  49. OUT PDIGEST_CONTEXT *ppContext);
  50. // Releases the Context by decreasing reference counter
  51. NTSTATUS CtxtHandlerRelease(PDIGEST_CONTEXT pContext);
  52. // Check to see if COntext is within valid lifetime
  53. BOOL CtxtHandlerTimeHasElapsed(PDIGEST_CONTEXT pContext);
  54. // From ctxtapi.cxx
  55. // Creates the Output SecBuffer for the Challenge
  56. NTSTATUS NTAPI ContextCreateChal(IN PDIGEST_CONTEXT pContext, IN PSTRING pstrRealm, OUT PSecBuffer OutBuffer);
  57. // Creates the Output SecBuffer for the Challenge Response
  58. NTSTATUS NTAPI DigestCreateChalResp(IN PDIGEST_PARAMETER pDigest,
  59. IN PUSER_CREDENTIALS pUserCreds,
  60. OUT PSecBuffer OutBuffer);
  61. // Check SecurityToken for corredct structure format
  62. BOOL ContextIsTokenOK(IN PSecBuffer pTempToken, IN ULONG ulMaxSize);
  63. // Called for server incoming messages - verify Digest and generate sessionkey if necessary
  64. NTSTATUS NTAPI DigestProcessParameters(IN OUT PDIGEST_CONTEXT pContext,
  65. IN PDIGEST_PARAMETER pDigest,
  66. OUT PSecBuffer pFirstOutputToken,
  67. OUT PNTSTATUS pAuditLogStatus);
  68. // Called for client outbound messages - generate the response hash
  69. NTSTATUS NTAPI DigestGenerateParameters(IN OUT PDIGEST_CONTEXT pContext,
  70. IN PDIGEST_PARAMETER pDigest, OUT PSecBuffer pFirstOutputToken);
  71. // LSA calls this function in the Generic Passthrough call
  72. NTSTATUS NTAPI DigestPackagePassthrough(IN USHORT cbMessageRequest, IN BYTE *pMessageRequest,
  73. IN OUT ULONG *pulMessageResponse, OUT PBYTE *ppMessageResponse);
  74. // Lookup passwords and perform digest cal auth (runs on the DC)
  75. NTSTATUS NTAPI DigestResponseBru(IN BYTE *pDigestParamEncoded,
  76. IN OUT ULONG *pculResponse, OUT PBYTE *ppResponse);
  77. // Formatted printout of Digest Parameters
  78. NTSTATUS DigestPrint(PDIGEST_PARAMETER pDigest);
  79. // Formatted printout of Context
  80. NTSTATUS ContextPrint(IN PDIGEST_CONTEXT pDigest);
  81. // Create a logonSession for the Authenticated LogonToken in the SecurityContext
  82. NTSTATUS CtxtCreateLogSess(IN PDIGEST_CONTEXT pDigest);
  83. // Extract the username & domain from the Digest structure directives
  84. NTSTATUS UserCredentialsExtract(PDIGEST_PARAMETER pDigest,
  85. PUSER_CREDENTIALS pUserCreds);
  86. // Release memory allocated into UserCredentials
  87. NTSTATUS UserCredentialsFree(PUSER_CREDENTIALS pUserCreds);
  88. NTSTATUS DigestSASLResponseAuth(
  89. IN PDIGEST_PARAMETER pDigest,
  90. OUT PSecBuffer pOutputToken);
  91. NTSTATUS DigestCalculateResponseAuth(
  92. IN PDIGEST_PARAMETER pDigest,
  93. OUT PSTRING pstrHash);
  94. NTSTATUS DigestDecodeUserAccount(
  95. IN PDIGEST_PARAMETER pDigest,
  96. OUT PUNICODE_STRING pustrDC);
  97. #endif // DNTDIGEST_CTXT_H