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.

238 lines
5.7 KiB

  1. /**********************************************************************/
  2. /** Microsoft Passport **/
  3. /** Copyright(c) Microsoft Corporation, 1999 - 2001 **/
  4. /**********************************************************************/
  5. /*
  6. HelperFuncs.h
  7. defines helper functions for passport manager object
  8. FILE HISTORY:
  9. */
  10. // HelperFuncs.h : Useful functions
  11. #ifndef __HELPERFUNCS_H_
  12. #define __HELPERFUNCS_H_
  13. #include <httpfilt.h>
  14. #include <httpext.h>
  15. #include "nsconst.h"
  16. #include "passport.h"
  17. #include "smartcls.h"
  18. typedef enum { PM_LOGOTYPE_SIGNIN, PM_LOGOTYPE_SIGNOUT } PM_LOGOTYPE;
  19. #define SECURELEVEL_USE_HTTPS(n) (n >= k_iSeclevelSecureChannel)
  20. BSTR
  21. FormatNormalLogoTag(
  22. LPCWSTR pszLoginServerURL,
  23. ULONG ulSiteId,
  24. LPCWSTR pszReturnURL,
  25. ULONG ulTimeWindow,
  26. BOOL bForceLogin,
  27. ULONG ulCurrentCryptVersion,
  28. time_t tCurrentTime,
  29. LPCWSTR pszCoBrand,
  30. LPCWSTR pszImageURL,
  31. LPCWSTR pszNameSpace,
  32. int nKPP,
  33. PM_LOGOTYPE nLogoType,
  34. USHORT lang,
  35. ULONG ulSecureLevel,
  36. CRegistryConfig* pCRC,
  37. BOOL fRedirToSelf,
  38. BOOL bCreateTPF
  39. );
  40. BSTR
  41. FormatUpdateLogoTag(
  42. LPCWSTR pszLoginServerURL,
  43. ULONG ulSiteId,
  44. LPCWSTR pszReturnURL,
  45. ULONG ulTimeWindows,
  46. BOOL bForceLogin,
  47. ULONG ulCurrentKeyVersion,
  48. time_t tCurrentTime,
  49. LPCWSTR pszCoBrand,
  50. int nKPP,
  51. LPCWSTR pszUpdateServerURL,
  52. BOOL bSecure,
  53. LPCWSTR pszProfileUpdate,
  54. PM_LOGOTYPE nLogoType,
  55. ULONG ulSecureLevel,
  56. CRegistryConfig* pCRC,
  57. BOOL bCreateTPF
  58. );
  59. BSTR
  60. FormatAuthURL(
  61. LPCWSTR pszLoginServerURL,
  62. ULONG ulSiteId,
  63. LPCWSTR pszReturnURL,
  64. ULONG ulTimeWindow,
  65. BOOL bForceLogin,
  66. ULONG ulCurrentKeyVersion,
  67. time_t tCurrentTime,
  68. LPCWSTR pszCoBrand,
  69. LPCWSTR pszNameSpace,
  70. int nKPP,
  71. USHORT lang,
  72. ULONG ulSecureLevel,
  73. CRegistryConfig* pCRC,
  74. BOOL fRedirToSelf,
  75. BOOL bCreateTPF
  76. );
  77. BOOL
  78. GetQueryData(
  79. LPCSTR pszQueryString,
  80. BSTR* pbstrTicket,
  81. BSTR* pbstrProfile,
  82. BSTR* pbstrFlags
  83. );
  84. BOOL
  85. GetCookie(
  86. LPCSTR pszCookieHeader,
  87. LPCSTR pszCookieName,
  88. BSTR* pbstrCookieVal
  89. );
  90. BOOL
  91. BuildCookieHeaders(
  92. LPCSTR pszTicket,
  93. LPCSTR pszProfile,
  94. LPCSTR pszConsent,
  95. LPCSTR pszSecure,
  96. LPCSTR pszTicketDomain,
  97. LPCSTR pszTicketPath,
  98. LPCSTR pszConsentDomain,
  99. LPCSTR pszConsentPath,
  100. LPCSTR pszSecuredomain,
  101. LPCSTR pszSecurePath,
  102. BOOL bSave,
  103. LPSTR pszBuf,
  104. LPDWORD pdwBufLen,
  105. bool bHTTPOnly
  106. );
  107. HRESULT
  108. DecryptTicketAndProfile(
  109. BSTR bstrTicket,
  110. BSTR bstrProfile,
  111. BOOL bCheckConsent,
  112. BSTR bstrConsent,
  113. CRegistryConfig* pRegistryConfig,
  114. IPassportTicket* piTicket,
  115. IPassportProfile* piProfile
  116. );
  117. HRESULT
  118. DoSecureCheck(
  119. BSTR bstrSecure,
  120. CRegistryConfig* pRegistryConfig,
  121. IPassportTicket* piTicket
  122. );
  123. HRESULT
  124. GetSiteNamePFC(
  125. PHTTP_FILTER_CONTEXT pfc,
  126. LPSTR szBuf,
  127. LPDWORD lpdwBufLen
  128. );
  129. HRESULT
  130. GetSiteNameECB(
  131. EXTENSION_CONTROL_BLOCK* pECB,
  132. LPSTR szBuf,
  133. LPDWORD lpdwBufLen
  134. );
  135. LPSTR
  136. GetServerVariableECB(
  137. EXTENSION_CONTROL_BLOCK* pECB,
  138. LPSTR pszHeader
  139. );
  140. LPSTR
  141. GetServerVariablePFC(
  142. PHTTP_FILTER_CONTEXT pPFC,
  143. LPSTR pszHeader
  144. );
  145. int GetRawHeaders(LPCSTR headers, LPCSTR* names, LPCSTR* values, DWORD* dwSizes, DWORD namescount);
  146. LPCSTR GetRawQueryString(LPCSTR headers, DWORD* dwSize);
  147. LONG
  148. FromHex(
  149. LPCWSTR pszHexString
  150. );
  151. // max sizes for URLs (without qs) and with
  152. // these could be a bit opportunistic
  153. #define MAX_URL_LENGTH 2048
  154. #define MAX_QS_LENGTH 2048
  155. #define PP_MAX_ATTRIBUTE_LENGTH MAX_URL_LENGTH
  156. #define PPSITE_CHALLENGE L"msppchlg=1"
  157. #define PPSITE_CHALLENGE_A "msppchlg=1"
  158. #define PPLOGIN_PARAM L"mspplogin="
  159. #define PPLOGIN_PARAM_A "mspplogin="
  160. // identification string for the auth method
  161. #define PASSPORT_PROT14_A "Passport1.4"
  162. #define PASSPORT_PROT14 L"Passport1.4"
  163. #define C_PPAUTH_INFO_HEADER "Authentication-Info"
  164. #define W_PPAUTH_INFO_HEADER L"Authentication-Info"
  165. // cookie names for Tweener
  166. #define C_PPCOOKIE_NAMES "tname=MSPAuth,tname=MSPProf,tname=MSPConsent,tname=MSPSecAuth"
  167. #define W_PPCOOKIE_NAMES L"tname=MSPAuth,tname=MSPProf,tname=MSPConsent,tname=MSPSecAuth"
  168. #define C_AUTH_INFO_HEADER_PASSPORT C_PPAUTH_INFO_HEADER ": " PASSPORT_PROT14_A " " C_PPCOOKIE_NAMES "\r\n"
  169. PWSTR
  170. FormatAuthURLParameters(
  171. LPCWSTR pszLoginServerURL,
  172. ULONG ulSiteId,
  173. LPCWSTR pszReturnURL,
  174. ULONG ulTimeWindow,
  175. BOOL bForceLogin,
  176. ULONG ulCurrentKeyVersion,
  177. time_t tCurrentTime,
  178. LPCWSTR pszCoBrand,
  179. LPCWSTR pszNameSpace,
  180. int nKPP,
  181. PWSTR pszBufStart,
  182. ULONG cBufLen,
  183. USHORT lang,
  184. ULONG ulSecureLevel,
  185. CRegistryConfig* pCRC,
  186. BOOL fRedirectToSelf,
  187. BOOL bCreateTPF
  188. );
  189. HRESULT SignQueryString(
  190. CRegistryConfig* pCRC,
  191. ULONG ulCurrentKeyVersion,
  192. LPWSTR pszBufStart,
  193. LPWSTR& pszCurrent,
  194. LPCWSTR pszBufEnd,
  195. BOOL bCreateTPF
  196. );
  197. HRESULT PartnerHash(
  198. CRegistryConfig* pCRC,
  199. ULONG ulCurrentKeyVersion,
  200. LPCWSTR tobeSigned,
  201. ULONG nChars,
  202. BSTR* pbstrHash);
  203. #endif