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.

188 lines
4.4 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. cred.hxx
  5. Abstract:
  6. This file contains definitions for cred.cxx
  7. Shared memory data structures for digest sspi package.
  8. Author:
  9. Adriaan Canter (adriaanc) 01-Aug-1998
  10. --*/
  11. #ifndef CRED_HXX
  12. #define CRED_HXX
  13. #define SIG_CRED 'DERC'
  14. #define SIG_NONC 'CNON'
  15. #define SIG_SESS 'SSES'
  16. #define SERVER_NONCE 0
  17. #define CLIENT_NONCE 1
  18. #define OFFSET_TO_POINTER( _ep_, _offset_) \
  19. (LPVOID)((LPBYTE)(_ep_) + (_offset_))
  20. #define POINTER_TO_OFFSET( _ep1_, _ep2_) \
  21. (DWORD) ((DWORD_PTR)(_ep2_) - (_ep1_))
  22. class CCred;
  23. class CNonce;
  24. //--------------------------------------------------------------------
  25. // Class CEntry.
  26. // Base node in doubly linked list.
  27. //--------------------------------------------------------------------
  28. class CEntry : public MAP_ENTRY
  29. {
  30. public:
  31. DWORD dwPrev;
  32. DWORD dwNext;
  33. // Base destructor - all descendents need only
  34. // call this function to be freed in the map.
  35. static DWORD Free(CMMFile *pMMFile, CEntry* pEntry);
  36. static CEntry* GetNext(CEntry*);
  37. static CEntry* GetPrev(CEntry*);
  38. };
  39. //--------------------------------------------------------------------
  40. // CSess
  41. // BUGBUG - comment pcred and rename dws as offsets
  42. //--------------------------------------------------------------------
  43. class CSess : public CEntry
  44. {
  45. public:
  46. DWORD dwCred;
  47. BOOL fHTTP;
  48. DWORD cbSess;
  49. DWORD dwAppCtx;
  50. DWORD dwUserCtx;
  51. static CSess* Create(CMMFile *pMMFile, LPSTR szAppCtx,
  52. LPSTR szUserCtx, BOOL fHTTP);
  53. static LPSTR GetAppCtx(CSess*);
  54. static LPSTR GetUserCtx(CSess*);
  55. static LPSTR GetCtx(CSess*);
  56. static BOOL CtxMatch(CSess*, CSess*);
  57. static CCred *SetCred(CSess*, CCred*);
  58. static CCred *GetCred(CSess*);
  59. };
  60. //--------------------------------------------------------------------
  61. // Credential class.
  62. //--------------------------------------------------------------------
  63. class CCred : public CEntry
  64. {
  65. public:
  66. DWORD cbCred;
  67. DWORD tStamp;
  68. DWORD dwNonce;
  69. DWORD dwCNonce;
  70. DWORD dwRealm;
  71. DWORD dwUser;
  72. DWORD dwPass;
  73. // Credential specific constructor.
  74. static CCred* Create(CMMFile *pMMFile,
  75. LPSTR szHost, LPSTR szRealm, LPSTR szUser,
  76. LPSTR szPass, LPSTR szNonce, LPSTR szCNonce);
  77. static LPSTR GetRealm(CCred*);
  78. static LPSTR GetUser(CCred*);
  79. static LPSTR GetPass(CCred*);
  80. static VOID SetNonce(CMMFile *pMMFile, CCred* pCred,
  81. LPSTR szHost, LPSTR szNonce, DWORD dwFlags);
  82. static CNonce *GetNonce(CCred* pCred, LPSTR szHost, DWORD dwType);
  83. static VOID Free(CMMFile *pMMFile, CSess *pSess, CCred *pCred);
  84. };
  85. //--------------------------------------------------------------------
  86. // Nonce class
  87. //--------------------------------------------------------------------
  88. class CNonce : public CEntry
  89. {
  90. public:
  91. DWORD cbNonce;
  92. DWORD cCount;
  93. DWORD dwHost;
  94. DWORD dwNonce;
  95. // Nonce specific constructor.
  96. static CNonce* Create(CMMFile *pMMFile, LPSTR szHost, LPSTR szNonce);
  97. static LPSTR GetNonce(CNonce*);
  98. static DWORD GetCount(CNonce*);
  99. static BOOL IsHostMatch(CNonce *pNonce, LPSTR szHost);
  100. };
  101. //--------------------------------------------------------------------
  102. // Class CList.
  103. // Manages doubly linked list of base type CEntry.
  104. //--------------------------------------------------------------------
  105. class CList
  106. {
  107. public:
  108. DWORD *_pdwOffset;
  109. CEntry *_pHead;
  110. CEntry *_pCur;
  111. DWORD _dwStatus;
  112. CList();
  113. CEntry* Init(LPDWORD pdwOffset);
  114. CEntry* Insert(CEntry *pEntry);
  115. CEntry* GetNext();
  116. CEntry* GetPrev();
  117. CEntry* Seek();
  118. CEntry* DeLink(CEntry *pEntry);
  119. };
  120. //--------------------------------------------------------------------
  121. // Credential Info class
  122. //--------------------------------------------------------------------
  123. class CCredInfo
  124. {
  125. public:
  126. LPSTR szHost;
  127. LPSTR szRealm;
  128. LPSTR szUser;
  129. LPSTR szPass;
  130. LPSTR szNonce;
  131. LPSTR szCNonce;
  132. DWORD tStamp;
  133. DWORD cCount;
  134. DWORD dwStatus;
  135. CCredInfo *pPrev;
  136. CCredInfo *pNext;
  137. CCredInfo(CCred* pCred, LPSTR szHost);
  138. CCredInfo(LPSTR szHost, LPSTR szRealm, LPSTR szUser, LPSTR szPass,
  139. LPSTR szNonce, LPSTR szCNonce);
  140. ~CCredInfo();
  141. };
  142. #endif // CRED_HXX
  143.