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.

191 lines
4.6 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. DWORD cbPass;
  74. // Credential specific constructor.
  75. static CCred* Create(CMMFile *pMMFile,
  76. LPSTR szHost, LPSTR szRealm, LPSTR szUser,
  77. LPSTR szPass, LPSTR szNonce, LPSTR szCNonce);
  78. static LPSTR GetRealm(CCred*);
  79. static LPSTR GetUser(CCred*);
  80. static LPSTR GetPass(CCred*);
  81. static VOID SetNonce(CMMFile *pMMFile, CCred* pCred,
  82. LPSTR szHost, LPSTR szNonce, DWORD dwFlags);
  83. static CNonce *GetNonce(CCred* pCred, LPSTR szHost, DWORD dwType);
  84. static VOID Free(CMMFile *pMMFile, CSess *pSess, CCred *pCred);
  85. };
  86. //--------------------------------------------------------------------
  87. // Nonce class
  88. //--------------------------------------------------------------------
  89. class CNonce : public CEntry
  90. {
  91. public:
  92. DWORD cbNonce;
  93. DWORD cCount;
  94. DWORD dwHost;
  95. DWORD dwNonce;
  96. // Nonce specific constructor.
  97. static CNonce* Create(CMMFile *pMMFile, LPSTR szHost, LPSTR szNonce);
  98. static LPSTR GetNonce(CNonce*);
  99. static DWORD GetCount(CNonce*);
  100. static BOOL IsHostMatch(CNonce *pNonce, LPSTR szHost);
  101. };
  102. //--------------------------------------------------------------------
  103. // Class CList.
  104. // Manages doubly linked list of base type CEntry.
  105. //--------------------------------------------------------------------
  106. class CList
  107. {
  108. public:
  109. DWORD *_pdwOffset;
  110. CEntry *_pHead;
  111. CEntry *_pCur;
  112. DWORD _dwStatus;
  113. CList();
  114. CEntry* Init(LPDWORD pdwOffset);
  115. CEntry* Insert(CEntry *pEntry);
  116. CEntry* GetNext();
  117. CEntry* GetPrev();
  118. CEntry* Seek();
  119. CEntry* DeLink(CEntry *pEntry);
  120. };
  121. //--------------------------------------------------------------------
  122. // Credential Info class
  123. //--------------------------------------------------------------------
  124. class CCredInfo
  125. {
  126. public:
  127. LPSTR szHost;
  128. LPSTR szRealm;
  129. LPSTR szUser;
  130. CSecureStr Password;
  131. LPSTR szNonce;
  132. LPSTR szCNonce;
  133. DWORD tStamp;
  134. DWORD cCount;
  135. DWORD dwStatus;
  136. CCredInfo *pPrev;
  137. CCredInfo *pNext;
  138. CCredInfo(CCred* pCred, LPSTR szHost);
  139. CCredInfo(LPSTR szHost, LPSTR szRealm, LPSTR szUser, LPSTR szPass,
  140. LPSTR szNonce, LPSTR szCNonce);
  141. ~CCredInfo();
  142. LPSTR GetPass() { return Password.GetUnencryptedString(); }
  143. };
  144. #endif // CRED_HXX