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.

325 lines
7.8 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996-1998
  5. //
  6. // File: licprotp.h
  7. //
  8. // Contents: Hydra Server License Protocol API private header file
  9. //
  10. // History: 02-08-00 RobLeit Created
  11. //
  12. //-----------------------------------------------------------------------------
  13. #ifndef _LICPROTP_H_
  14. #define _LICPROTP_H_
  15. //-----------------------------------------------------------------------------
  16. //
  17. // Hydra server licensing-related registry keys and values
  18. //
  19. //-----------------------------------------------------------------------------
  20. #define HYDRA_SERVER_PARAM L"SYSTEM\\CurrentControlSet\\Services\\TermService\\Parameters"
  21. #define PERSEAT_LEEWAY_VALUE L"PerSeatExpirationLeeway"
  22. //-----------------------------------------------------------------------------
  23. //
  24. // Info of the license requester
  25. //
  26. // pwszMachineName - The name of the machine that the license is installed on.
  27. // pwszUserName - The user name for which the license is issued to.
  28. //
  29. //-----------------------------------------------------------------------------
  30. typedef struct _License_Requester_Info
  31. {
  32. LPTSTR ptszMachineName;
  33. LPTSTR ptszUserName;
  34. } License_Requester_Info, * PLicense_Requester_Info;
  35. //-----------------------------------------------------------------------------
  36. //
  37. // The license request structure
  38. //
  39. //-----------------------------------------------------------------------------
  40. typedef LICENSEREQUEST License_Request;
  41. typedef PLICENSEREQUEST PLicense_Request;
  42. //-----------------------------------------------------------------------------
  43. //
  44. // The files containing the hydra server certificates and keys
  45. //
  46. //-----------------------------------------------------------------------------
  47. #define HYDRA_SERVER_RSA_CERTIFICATE_FILE L"hsrsa.cer"
  48. #define HYDRA_SERVER_PRIVATE_KEY_FILE L"hskey.prv"
  49. //-----------------------------------------------------------------------------
  50. //
  51. // Registry value to configure number of days prior to grace period expiration
  52. // for event logging.
  53. //
  54. //-----------------------------------------------------------------------------
  55. #define HS_PARAM_GRACE_PERIOD_EXPIRATION_WARNING_DAYS L"LicensingGracePeriodExpirationWarningDays"
  56. //-----------------------------------------------------------------------------
  57. //
  58. // The license protocol states
  59. //
  60. //-----------------------------------------------------------------------------
  61. typedef enum
  62. {
  63. INIT = 1,
  64. SENT_SERVER_HELLO,
  65. CLIENT_LICENSE_PENDING,
  66. ISSUED_PLATFORM_CHALLENGE,
  67. ABORTED,
  68. ISSUED_LICENSE_COMPLETE,
  69. VALIDATION_ERROR,
  70. VALIDATED_LICENSE_COMPLETE
  71. } HS_LICENSE_STATE;
  72. ///////////////////////////////////////////////////////////////////////////
  73. // The validation information that needs to be given to validate a license.
  74. //
  75. typedef struct _Validation_Info
  76. {
  77. Product_Info * pProductInfo;
  78. DWORD cbLicense;
  79. PBYTE pLicense;
  80. DWORD cbValidationData;
  81. PBYTE pValidationData;
  82. } Validation_Info, * PValidation_Info;
  83. //////////////////////////////////////////////////////////////////////////////
  84. // The data used for verifying licenses
  85. //
  86. typedef struct _License_Verification_Data
  87. {
  88. //
  89. // encrypted HWID
  90. //
  91. PBYTE pEncryptedHwid;
  92. DWORD cbEncryptedHwid;
  93. //
  94. // Valid dates
  95. //
  96. FILETIME NotBefore;
  97. FILETIME NotAfter;
  98. //
  99. // License Info
  100. //
  101. LPCERT_LICENSE_INFO pLicenseInfo;
  102. //
  103. // Manufacturer
  104. //
  105. PBYTE pManufacturer;
  106. //
  107. // Manufacturer Data
  108. //
  109. LPMSMANUFACTURER_DATA pManufacturerData;
  110. //
  111. // Add any other fields necessary for verifying a license:
  112. //
  113. } License_Verification_Data, * PLicense_Verification_Data;
  114. //-----------------------------------------------------------------------------
  115. //
  116. // license protocol context
  117. //
  118. //-----------------------------------------------------------------------------
  119. typedef struct _HS_Protocol_Context
  120. {
  121. CRITICAL_SECTION CritSec;
  122. DWORD dwProtocolVersion;
  123. BOOL fAuthenticateServer;
  124. Product_Info ProductInfo;
  125. HS_LICENSE_STATE State;
  126. TLS_HANDLE hLSHandle;
  127. DWORD dwClientPlatformID;
  128. DWORD dwClientError;
  129. PCHALLENGE_CONTEXT pChallengeContext;
  130. PTCHAR ptszClientUserName;
  131. PTCHAR ptszClientMachineName;
  132. CERT_TYPE CertTypeUsed;
  133. DWORD dwKeyExchangeAlg;
  134. DWORD cbOldLicense;
  135. PBYTE pbOldLicense;
  136. PTS_LICENSE_INFO pTsLicenseInfo;
  137. CryptSystem CryptoContext;
  138. BOOL fLoggedProtocolError;
  139. BYTE Scope[MAX_PRODUCT_INFO_STRING_LENGTH];
  140. } HS_Protocol_Context, * PHS_Protocol_Context;
  141. #define PLATFORM_CHALLENGE_LENGTH 64
  142. //-----------------------------------------------------------------------------
  143. //
  144. // Internal Functions
  145. //
  146. //-----------------------------------------------------------------------------
  147. #ifdef __cplusplus
  148. extern "C" {
  149. #endif
  150. LICENSE_STATUS
  151. CreateHydraServerHello(
  152. PHS_Protocol_Context pLicenseContext,
  153. DWORD cbInBuf,
  154. PBYTE pInBuf,
  155. DWORD * pcbOutBuf,
  156. PBYTE * ppOutBuf );
  157. void
  158. HandleErrorCondition(
  159. PHS_Protocol_Context pLicenseContext,
  160. PDWORD pcbOutBuf,
  161. PBYTE * ppOutBuf,
  162. LICENSE_STATUS * pStatus );
  163. LICENSE_STATUS
  164. ConstructServerResponse(
  165. DWORD dwProtocolVersion,
  166. DWORD dwResponse,
  167. PDWORD pcbOutBuf,
  168. PBYTE * ppOutBuf );
  169. LICENSE_STATUS
  170. HandleHelloResponse(
  171. PHS_Protocol_Context pLicenseContext,
  172. DWORD cbInBuf,
  173. PBYTE pInBuf,
  174. DWORD * pcbOutBuf,
  175. PBYTE * ppOutBuf );
  176. LICENSE_STATUS
  177. HandleClientLicense(
  178. PHS_Protocol_Context pLicenseContext,
  179. DWORD cbInBuf,
  180. PBYTE pInBuf,
  181. DWORD * pcbOutBuf,
  182. PBYTE * ppOutBuf );
  183. LICENSE_STATUS
  184. HandleNewLicenseRequest(
  185. PHS_Protocol_Context pLicenseContext,
  186. DWORD cbInBuf,
  187. PBYTE pInBuf,
  188. DWORD * pcbOutBuf,
  189. PBYTE * ppOutBuf );
  190. LICENSE_STATUS
  191. HandleClientError(
  192. PHS_Protocol_Context pLicenseContext,
  193. DWORD cbInBuf,
  194. PBYTE pInBuf,
  195. DWORD * pcbOutBuf,
  196. PBYTE * ppOutBuf );
  197. LICENSE_STATUS
  198. HandlePlatformChallengeResponse(
  199. PHS_Protocol_Context pLicenseContext,
  200. DWORD cbInBuf,
  201. PBYTE pInBuf,
  202. DWORD * pcbOutBuf,
  203. PBYTE * ppOutBuf );
  204. LICENSE_STATUS
  205. GetEnvelopedData(
  206. CERT_TYPE CertType,
  207. PBYTE pEnvelopedData,
  208. DWORD dwEnvelopedDataLen,
  209. PBYTE * ppData,
  210. PDWORD pdwDataLen );
  211. LICENSE_STATUS
  212. InitProductInfo(
  213. PProduct_Info pProductInfo,
  214. LPTSTR lptszProductSku );
  215. LICENSE_STATUS
  216. IssuePlatformChallenge(
  217. PHS_Protocol_Context pLicenseContext,
  218. PDWORD pcbOutBuf,
  219. PBYTE * ppOutBuf );
  220. LICENSE_STATUS
  221. PackageLicense(
  222. PHS_Protocol_Context pLicenseContext,
  223. DWORD cbLicense,
  224. PBYTE pLicense,
  225. PDWORD pcbOutBuf,
  226. PBYTE * ppOutBuf,
  227. BOOL fNewLicense );
  228. void
  229. LicenseLogEvent(
  230. WORD wEventType,
  231. DWORD dwEventId,
  232. WORD cStrings,
  233. PWCHAR *apwszStrings );
  234. LICENSE_STATUS
  235. CacheRawLicenseData(
  236. PHS_Protocol_Context pLicenseContext,
  237. PBYTE pbRawLicense,
  238. DWORD cbRawLicense );
  239. LICENSE_STATUS
  240. SetExtendedData(
  241. PHS_Protocol_Context pLicenseContext,
  242. DWORD dwSupportFlags );
  243. #ifdef UNICODE
  244. LICENSE_STATUS
  245. Ascii2Wchar(
  246. LPSTR lpszAsciiStr,
  247. LPWSTR * ppwszWideStr );
  248. #endif
  249. #ifdef __cplusplus
  250. }
  251. #endif
  252. #endif