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.

1140 lines
37 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: license.h
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 12-03-97 FredCh Created
  15. // 12-16-97 v-sbhatt Modified
  16. // 12-22-97 HueiWang Add Extension OID
  17. // 12-23-97 HueiWang Use structure instead of multiple OID
  18. //
  19. //----------------------------------------------------------------------------
  20. #ifndef _LICENSE_H_
  21. #define _LICENSE_H_
  22. #include "platform.h"
  23. #if defined(_WIN64)
  24. #define UNALIGNED __unaligned
  25. #define UNALIGNED64 __unaligned
  26. #elif !defined (OS_WINCE)
  27. #define UNALIGNED
  28. #define UNALIGNED64
  29. #endif
  30. ///////////////////////////////////////////////////////////////////////////////
  31. //
  32. // Random number length
  33. //
  34. #define LICENSE_RANDOM 32
  35. #define LICENSE_PRE_MASTER_SECRET 48
  36. #define LICENSE_MAC_WRITE_KEY 16
  37. #define LICENSE_SESSION_KEY 16
  38. #define LICENSE_MAC_DATA 16
  39. #define LICENSE_HWID_LENGTH 20
  40. //////////////////////////////////////////////////////////////////////////////
  41. // Licensing protocol versions
  42. //
  43. #ifndef OS_WIN16
  44. #ifndef OS_WINCE
  45. #define CALL_TYPE _stdcall
  46. #else
  47. #define CALL_TYPE
  48. #endif
  49. #else
  50. #define CALL_TYPE
  51. #endif //CALL_TYPE
  52. //-----------------------------------------------------------------------------
  53. //
  54. // Licensing protocol version
  55. //
  56. // The lowest byte of the version DWORD will be the preamble version.
  57. //
  58. //-----------------------------------------------------------------------------
  59. #define LICENSE_PROTOCOL_VERSION_1_0 0x00010000
  60. #define LICENSE_PROTOCOL_VERSION_2_0 0x00020000
  61. //
  62. // INT CompareTLSVersions(VERSION a, VERSION b);
  63. //
  64. #define CompareTLSVersions(a, b) \
  65. (HIWORD(a) == HIWORD(b) ? LOWORD(a) - LOWORD(b) : \
  66. HIWORD(a) - HIWORD(b))
  67. #define PREAMBLE_VERSION_1_0 0x01
  68. #define PREAMBLE_VERSION_2_0 0x02
  69. #define PREAMBLE_VERSION_3_0 0x03
  70. #define LICENSE_CURRENT_PREAMBLE_VERSION PREAMBLE_VERSION_3_0
  71. #define LICENSE_TS_40_PROTOCOL_VERSION LICENSE_PROTOCOL_VERSION_1_0 | PREAMBLE_VERSION_2_0
  72. #define LICENSE_TS_50_PROTOCOL_VERSION LICENSE_PROTOCOL_VERSION_1_0 | PREAMBLE_VERSION_3_0
  73. #define LICENSE_TS_51_PROTOCOL_VERSION LICENSE_PROTOCOL_VERSION_2_0 | PREAMBLE_VERSION_3_0
  74. #define LICENSE_HYDRA_40_PROTOCOL_VERSION LICENSE_TS_40_PROTOCOL_VERSION
  75. #if 1
  76. #define LICENSE_HIGHEST_PROTOCOL_VERSION LICENSE_PROTOCOL_VERSION_1_0 | LICENSE_CURRENT_PREAMBLE_VERSION
  77. #else
  78. #define LICENSE_HIGHEST_PROTOCOL_VERSION LICENSE_PROTOCOL_VERSION_2_0 | LICENSE_CURRENT_PREAMBLE_VERSION
  79. #endif
  80. #define GET_PREAMBLE_VERSION( _Version ) ( BYTE )( _Version & 0x000000FF )
  81. //-----------------------------------------------------------------------------
  82. //
  83. // Context flags used by the client and server licensing protocol APIs:
  84. //
  85. // LICENSE_CONTEXT_NO_SERVER_AUTHENTICATION
  86. //
  87. // Do not authenticate the server. Server authentication is done through
  88. // validating the server's certificate.
  89. //
  90. // LICENSE_CONTEXT_USE_PROPRIETORY_CERT
  91. //
  92. // Use in conjunction with the LICENSE_CONTEXT_NO_SERVER_AUTHENTICATION
  93. // flag to let that server know that a proprietory certificate has
  94. // been transmitted to the client.
  95. //
  96. // LICENSE_CONTEXT_USE_X509_CERT
  97. //
  98. // Use in conjunction with the LICENSE_CONTEXT_NO_SERVER_AUTHENTICATION
  99. // flag to let that server know that an X509 certificate has
  100. // been transmitted to the client.
  101. //
  102. //-----------------------------------------------------------------------------
  103. #define LICENSE_CONTEXT_NO_SERVER_AUTHENTICATION 0x00000001
  104. #define LICENSE_CONTEXT_USE_PROPRIETORY_CERT 0x00000002
  105. #define LICENSE_CONTEXT_USE_X509_CERT 0x00000004
  106. //////////////////////////////////////////////////////////////////////////////
  107. //
  108. // Hydra subtree Specific OID
  109. //
  110. #define szOID_PKIX_HYDRA_CERT_ROOT "1.3.6.1.4.1.311.18"
  111. /////////////////////////////////////////////////////////////////////////////
  112. //
  113. // License Info root at 1.3.6.1.4.1.311.18.1
  114. //
  115. // Reserved
  116. //
  117. #define szOID_PKIX_LICENSE_INFO "1.3.6.1.4.1.311.18.1"
  118. //
  119. // structure for License Info
  120. //
  121. typedef struct __LicenseInfo {
  122. DWORD dwVersion;
  123. DWORD dwQuantity;
  124. WORD wSerialNumberOffset;
  125. WORD wSerialNumberSize;
  126. WORD wScopeOffset;
  127. WORD wScopeSize;
  128. WORD wIssuerOffset;
  129. WORD wIssuerSize;
  130. BYTE bVariableDataStart[1];
  131. } CERT_LICENSE_INFO;
  132. #ifdef OS_WIN16
  133. typedef CERT_LICENSE_INFO FAR * LPCERT_LICENSE_INFO;
  134. #else
  135. typedef CERT_LICENSE_INFO *LPCERT_LICENSE_INFO;
  136. #endif //OS_WIN16
  137. /////////////////////////////////////////////////////////////////////////////
  138. // Manufacturer value 1.3.6.1.4.1.311.18.2
  139. // DWORD for manufacturer data
  140. //
  141. #define szOID_PKIX_MANUFACTURER "1.3.6.1.4.1.311.18.2"
  142. /////////////////////////////////////////////////////////////////////////////
  143. //
  144. // Manufacturer Specfic Data
  145. //
  146. // Reserved
  147. //
  148. #define szOID_PKIX_MANUFACTURER_MS_SPECIFIC "1.3.6.1.4.1.311.18.3"
  149. // structure for MS manufacturer specific data
  150. typedef struct __MSManufacturerData {
  151. DWORD dwVersion; // bit 31 - 1 Temp. License.
  152. DWORD dwPlatformID;
  153. DWORD dwLanguageID;
  154. WORD dwMajorVersion;
  155. WORD dwMinorVersion;
  156. WORD wProductIDOffset;
  157. WORD wProductIDSize;
  158. BYTE bVariableDataStart[1];
  159. } MSMANUFACTURER_DATA;
  160. ////////////////////////////////////////////////////////////////////////////
  161. ////////////////////////////////////////////////////////////////////////////
  162. //
  163. // OID for Certificate Version Stamp
  164. //
  165. // Reserved.
  166. //
  167. #define szOID_PKIX_HYDRA_CERT_VERSION szOID_PKIX_HYDRA_CERT_ROOT ".4"
  168. #define TERMSERV_CERT_VERSION_UNKNOWN 0xFFFFFFFF
  169. #define TERMSERV_CERT_VERSION_BETA 0x00000000 // Beta2 license
  170. #define TERMSERV_CERT_VERSION_NO_CERT 0x00010000 // New License without
  171. // license server's
  172. // certificate
  173. #define TERMSERV_CERT_VERSION_RC1 0x00010001 // New license with
  174. // license server's
  175. // certificate
  176. //
  177. // We don't support this certificate format.
  178. //
  179. //#define HYDRA_CERT_VERSION_CURRENT 0x00020001 // License issued by
  180. // // enforce version of
  181. // // license server
  182. #define TERMSERV_CERT_VERSION_MAJOR(x) HIWORD(x)
  183. #define TERMSERV_CERT_VERSION_MINOR(x) LOWORD(x)
  184. #define TERMSERV_CERT_VERSION_CURRENT 0x00050001
  185. //-------------------------------------------------------------------------
  186. //
  187. // OID for License Server to identify licensed product.
  188. //
  189. #define szOID_PKIX_LICENSED_PRODUCT_INFO szOID_PKIX_HYDRA_CERT_ROOT ".5"
  190. //
  191. // dwFlags in LICENSED_VERSION_INFO
  192. //
  193. // Bit 31 - 1 if temporary license, 0 if perm. license
  194. // Bit 24 to 30 - Any flag specific to temporary license, currently, there is none.
  195. // Bit 23 - 1 if RTM License, 0 if beta license.
  196. // Bit 16 to 22 - License server version.
  197. // Bit 20 to 22 - Major version.
  198. // Bit 16 to 19 - Minor version.
  199. // Bit 15 - Enforce license server.
  200. // Bit 0 to 3 is reserved by license server for internal use.
  201. // Other bits are not use.
  202. //
  203. #define LICENSED_VERSION_TEMPORARY 0x80000000
  204. #define LICENSED_VERSION_RTM 0x00800000
  205. #define LICENSE_ISSUER_ENFORCE_TYPE 0x00008000
  206. #define GET_LICENSE_ISSUER_VERSION(dwVersion) \
  207. (((dwVersion) & 0x007F0000) >> 16)
  208. #define GET_LICENSE_ISSUER_MAJORVERSION(dwVersion) \
  209. (((dwVersion) & 0x00700000) >> 20)
  210. #define GET_LICENSE_ISSUER_MINORVERSION(dwVersion) \
  211. (((dwVersion) & 0x000F0000) >> 16)
  212. #define IS_LICENSE_ISSUER_ENFORCE(dwVersion) \
  213. (((dwVersion) & LICENSE_ISSUER_ENFORCE_TYPE) > 0)
  214. #define IS_LICENSE_ISSUER_RTM(dwVersion) \
  215. (((dwVersion) & LICENSED_VERSION_RTM) > 0)
  216. typedef struct _LicensedVersionInfo {
  217. WORD wMajorVersion; // Product Major Version
  218. WORD wMinorVersion; // Product Minor Version
  219. DWORD dwFlags; // Product version specific flags
  220. } LICENSED_VERSION_INFO;
  221. #define LICENSED_PRODUCT_INFO_VERSION 0x0003000
  222. typedef struct _LicensedProductInfo {
  223. DWORD dwVersion; // structure version identifier
  224. DWORD dwQuantity; // number of licenses
  225. DWORD dwPlatformID; // Client platform ID
  226. DWORD dwLanguageID; // Licensed Language ID
  227. WORD wOrgProductIDOffset; // Offset to original licensed Product ID
  228. WORD wOrgProductIDSize; // Size of original licensed product ID
  229. WORD wAdjustedProductIdOffset; // Policy modified licensed product Id
  230. WORD wAdjustedProductIdSize; // size of Policy modified licensed Id.
  231. WORD wVersionInfoOffset; // Offset to array of LicensedVersionInfo
  232. WORD wNumberOfVersionInfo; // Number of VersionInfo entries
  233. BYTE bVariableDataStart[1]; // Variable data start.
  234. } LICENSED_PRODUCT_INFO;
  235. //
  236. // OID for License Server specific info.
  237. //
  238. #define szOID_PKIX_MS_LICENSE_SERVER_INFO szOID_PKIX_HYDRA_CERT_ROOT ".6"
  239. #define MS_LICENSE_SERVER_INFO_VERSION1 0x0001000
  240. #define MS_LICENSE_SERVER_INFO_VERSION2 0x0003000
  241. //
  242. // Version 1 structure
  243. //
  244. typedef struct _MsLicenseServerInfo10 {
  245. DWORD dwVersion;
  246. WORD wIssuerOffset; // Offset to issuer
  247. WORD wScopeOffset; // Offset to scope
  248. BYTE bVariableDataStart[1];
  249. } MS_LICENSE_SERVER_INFO10;
  250. typedef struct _MsLicenseServerInfo {
  251. DWORD dwVersion;
  252. WORD wIssuerOffset; // Offset to issuer
  253. WORD wIssuerIdOffset; // offset to issuer's setup ID
  254. WORD wScopeOffset; // Offset to scope
  255. BYTE bVariableDataStart[1];
  256. } MS_LICENSE_SERVER_INFO;
  257. //---------------------------------------------------------------------------
  258. //
  259. // Extension OID reserved for product policy module - only one is allowed.
  260. //
  261. #define szOID_PKIS_PRODUCT_SPECIFIC_OID szOID_PKIX_HYDRA_CERT_ROOT ".7"
  262. //
  263. //
  264. //
  265. #define szOID_PKIS_TLSERVER_SPK_OID szOID_PKIX_HYDRA_CERT_ROOT ".8"
  266. //
  267. // Save certificate chain into memory
  268. // This flag is passed into CertSaveStore() dwSaveAs parameter
  269. // Open should use same to open the store.
  270. #define szLICENSE_BLOB_SAVEAS_TYPE sz_CERT_STORE_PROV_PKCS7
  271. #define LICENSE_BLOB_SAVEAS_TYPE CERT_STORE_SAVE_AS_PKCS7
  272. #define OID_ISSUER_LICENSE_SERVER_NAME szOID_COMMON_NAME
  273. #define OID_ISSUER_LICENSE_SERVER_SCOPE szOID_LOCALITY_NAME
  274. #define OID_SUBJECT_CLIENT_COMPUTERNAME szOID_COMMON_NAME
  275. #define OID_SUBJECT_CLIENT_USERNAME szOID_LOCALITY_NAME
  276. #define OID_SUBJECT_CLIENT_HWID szOID_DEVICE_SERIAL_NUMBER
  277. #ifdef OS_WIN16
  278. typedef MSMANUFACTURER_DATA FAR *LPMSMANUFACTURER_DATA;
  279. #else
  280. typedef MSMANUFACTURER_DATA *LPMSMANUFACTURER_DATA;
  281. #endif //OS_WIN16
  282. ///////////////////////////////////////////////////////////////////////////////
  283. //
  284. #define LICENSE_GRACE_PERIOD 60
  285. ///////////////////////////////////////////////////////////////////////////////
  286. // Product Info for Hydra
  287. //
  288. #define PRODUCT_INFO_COMPANY_NAME L"Microsoft Corporation"
  289. ///////////////////////////////////////////////////////////////////////////////
  290. // The Product SKU is made up of the following fields:
  291. // x-y-z where x is the product identifer, y is the version
  292. // and z and the type.
  293. //
  294. #define PRODUCT_INFO_SKU_PRODUCT_ID L"A02"
  295. #define PRODUCT_INFO_INTERNET_SKU_PRODUCT_ID L"B96"
  296. #define PRODUCT_INFO_CONCURRENT_SKU_PRODUCT_ID L"C50" // not the same as what marketing uses, but that's okay
  297. ///////////////////////////////////////////////////////////////////////////////
  298. //
  299. // Microsoft Windows Terminal Server version definition.
  300. //
  301. #define MICROSOFT_WINDOWS_TERMINAL_SERVER_4_0 0x00040000
  302. #define MICROSOFT_WINDOWS_TERMINAL_SERVER_5_0 0x00050000
  303. #define MICROSOFT_WINDOWS_TERMINAL_SERVER_5_1 0x00050001
  304. #define MICROSOFT_WINDOWS_TERMINAL_SERVER_5_2 0x00050002
  305. #define CURRENT_TERMINAL_SERVER_VERSION MICROSOFT_WINDOWS_TERMINAL_SERVER_5_0
  306. #define TERMSRV_OS_INDEX_WINNT_5_0 0x00000000
  307. #define TERMSRV_OS_INDEX_WINNT_5_1 0x00000001
  308. #define TERMSRV_OS_INDEX_WINNT_5_2 0x00000002
  309. #define TERMSRV_OS_INDEX_WINNT_POST_5_2 0x00000003
  310. ///////////////////////////////////////////////////////////////////////////////
  311. //
  312. // Scope name
  313. //
  314. #ifndef OS_WINCE //SCOPE_NAME is being defined by iprtrmib.h which is included by iphlpapi.h
  315. #define SCOPE_NAME "microsoft.com"
  316. #endif
  317. ///////////////////////////////////////////////////////////////////////////////
  318. //
  319. // Maximum product info string length in bytes
  320. //
  321. #define MAX_PRODUCT_INFO_STRING_LENGTH 255
  322. ///////////////////////////////////////////////////////////////////////////////
  323. // Different crypt algid definitions
  324. // We are keeping an option open to generatize it in future
  325. //
  326. ///////////////////////////////////////////////////////////////////////////////
  327. //
  328. // Key exchange algorithms
  329. //
  330. #define KEY_EXCHANGE_ALG_RSA 1
  331. #define KEY_EXCHANGE_ALG_DH 2
  332. ///////////////////////////////////////////////////////////////////////////////
  333. //
  334. // Certificate Signature Algorithms
  335. //
  336. #define SIGNATURE_ALG_RSA 1
  337. #define SIGNATURE_ALG_DSS 2
  338. ///////////////////////////////////////////////////////////////////////////////
  339. //
  340. // Symmetric cryptographic algorithms
  341. //
  342. #define BASIC_RC4_128 1
  343. ///////////////////////////////////////////////////////////////////////////////
  344. //
  345. // MAC generation algorithms
  346. //
  347. #define MAC_MD5_SHA 1
  348. ///////////////////////////////////////////////////////////////////////////////
  349. //
  350. // hydra client to hydra server message types
  351. //
  352. #define HC_LICENSE_INFO 0x12
  353. #define HC_NEW_LICENSE_REQUEST 0x13
  354. #define HC_PLATFORM_INFO 0x14
  355. #define HC_PLATFORM_CHALENGE_RESPONSE 0x15
  356. ///////////////////////////////////////////////////////////////////////////////
  357. //
  358. // hydra server to hydra client message types
  359. //
  360. #define HS_LICENSE_REQUEST 0x01
  361. #define HS_PLATFORM_CHALLENGE 0x02
  362. #define HS_NEW_LICENSE 0x03
  363. #define HS_UPGRADE_LICENSE 0x04
  364. #define LICENSE_VERSION_1 0x01
  365. #define GM_ERROR_ALERT 0xFF
  366. ///////////////////////////////////////////////////////////////////////////////
  367. //
  368. // Error and alert codes
  369. //
  370. #define GM_HC_ERR_INVALID_SERVER_CERTIFICATE 0x00000001
  371. #define GM_HC_ERR_NO_LICENSE 0x00000002
  372. #define GM_HC_ERR_INVALID_MAC 0x00000003
  373. #define GM_HS_ERR_INVALID_SCOPE 0x00000004
  374. #define GM_HS_ERR_INVALID_MAC 0x00000005
  375. #define GM_HS_ERR_NO_LICENSE_SERVER 0x00000006
  376. #define GM_HS_ERR_VALID_CLIENT 0x00000007
  377. #define GM_HS_ERR_INVALID_CLIENT 0x00000008
  378. #define GM_HS_ERR_LICENSE_UPGRADE 0x00000009
  379. #define GM_HS_ERR_EXPIRED_LICENSE 0x0000000A
  380. #define GM_HS_ERR_INVALID_PRODUCTID 0x0000000B
  381. #define GM_HS_ERR_INVALID_MESSAGE_LEN 0x0000000C
  382. ///////////////////////////////////////////////////////////////////////////////
  383. //
  384. // License status and status codes
  385. //
  386. typedef DWORD LICENSE_STATUS;
  387. #define LICENSE_STATUS_OK 0x00000000
  388. #define LICENSE_STATUS_OUT_OF_MEMORY 0x00000001
  389. #define LICENSE_STATUS_INSUFFICIENT_BUFFER 0x00000002
  390. #define LICENSE_STATUS_INVALID_INPUT 0x00000003
  391. #define LICENSE_STATUS_INVALID_CLIENT_CONTEXT 0x00000004
  392. #define LICENSE_STATUS_INITIALIZATION_FAILED 0x00000005
  393. #define LICENSE_STATUS_INVALID_SIGNATURE 0x00000006
  394. #define LICENSE_STATUS_INVALID_CRYPT_STATE 0x00000007
  395. #define LICENSE_STATUS_CONTINUE 0x00000008
  396. #define LICENSE_STATUS_ISSUED_LICENSE 0x00000009
  397. #define LICENSE_STATUS_CLIENT_ABORT 0x0000000A
  398. #define LICENSE_STATUS_SERVER_ABORT 0x0000000B
  399. #define LICENSE_STATUS_NO_CERTIFICATE 0x0000000C
  400. #define LICENSE_STATUS_NO_PRIVATE_KEY 0x0000000D
  401. #define LICENSE_STATUS_SEND_ERROR 0x0000000E
  402. #define LICENSE_STATUS_INVALID_RESPONSE 0x0000000F
  403. #define LICENSE_STATUS_CONTEXT_INITIALIZATION_ERROR 0x00000010
  404. #define LICENSE_STATUS_NO_MESSAGE 0x00000011
  405. #define LICENSE_STATUS_INVALID_CLIENT_STATE 0x00000012
  406. #define LICENSE_STATUS_OPEN_STORE_ERROR 0x00000013
  407. #define LICENSE_STATUS_CLOSE_STORE_ERROR 0x00000014
  408. #define LICENSE_STATUS_WRITE_STORE_ERROR 0x00000015
  409. #define LICENSE_STATUS_INVALID_STORE_HANDLE 0x00000016
  410. #define LICENSE_STATUS_DUPLICATE_LICENSE_ERROR 0x00000017
  411. #define LICENSE_STATUS_INVALID_MAC_DATA 0x00000018
  412. #define LICENSE_STATUS_INCOMPLETE_MESSAGE 0x00000019
  413. #define LICENSE_STATUS_RESTART_NEGOTIATION 0x0000001A
  414. #define LICENSE_STATUS_NO_LICENSE_SERVER 0x0000001B
  415. #define LICENSE_STATUS_NO_PLATFORM_CHALLENGE 0x0000001C
  416. #define LICENSE_STATUS_NO_LICENSE_SERVER_SECRET_KEY 0x0000001D
  417. #define LICENSE_STATUS_INVALID_SERVER_CONTEXT 0x0000001E
  418. #define LICENSE_STATUS_CANNOT_DECODE_LICENSE 0x0000001F
  419. #define LICENSE_STATUS_INVALID_LICENSE 0x00000020
  420. #define LICENSE_STATUS_CANNOT_VERIFY_HWID 0x00000021
  421. #define LICENSE_STATUS_NO_LICENSE_ERROR 0x00000022
  422. #define LICENSE_STATUS_EXPIRED_LICENSE 0x00000023
  423. #define LICENSE_STATUS_MUST_UPGRADE_LICENSE 0x00000024
  424. #define LICENSE_STATUS_UNSPECIFIED_ERROR 0x00000025
  425. #define LICENSE_STATUS_INVALID_PLATFORM_CHALLENGE_RESPONSE 0x00000026
  426. #define LICENSE_STATUS_SHOULD_UPGRADE_LICENSE 0x00000027
  427. #define LICENSE_STATUS_CANNOT_UPGRADE_LICENSE 0x00000028
  428. #define LICENSE_STATUS_CANNOT_FIND_CLIENT_IMAGE 0x00000029
  429. #define LICENSE_STATUS_CANNOT_READ_CLIENT_IMAGE 0x0000002A
  430. #define LICENSE_STATUS_CANNOT_WRITE_CLIENT_IMAGE 0x0000002B
  431. #define LICENSE_STATUS_CANNOT_FIND_ISSUER_CERT 0x0000002C
  432. #define LICENSE_STATUS_NOT_HYDRA 0x0000002D
  433. #define LICENSE_STATUS_INVALID_X509_NAME 0x0000002E
  434. #define LICENSE_STATUS_NOT_SUPPORTED 0x0000002F
  435. #define LICENSE_STATUS_INVALID_CERTIFICATE 0x00000030
  436. #define LICENSE_STATUS_NO_ATTRIBUTES 0x00000031
  437. #define LICENSE_STATUS_NO_EXTENSION 0x00000032
  438. #define LICENSE_STATUS_ASN_ERROR 0x00000033
  439. #define LICENSE_STATUS_INVALID_HANDLE 0x00000034
  440. #define LICENSE_STATUS_CANNOT_MAKE_KEY_PAIR 0x00000035
  441. #define LICENSE_STATUS_AUTHENTICATION_ERROR 0x00000036
  442. #define LICENSE_STATUS_CERTIFICATE_REQUEST_ERROR 0x00000037
  443. #define LICENSE_STATUS_CANNOT_OPEN_SECRET_STORE 0x00000038
  444. #define LICENSE_STATUS_CANNOT_STORE_SECRET 0x00000039
  445. #define LICENSE_STATUS_CANNOT_RETRIEVE_SECRET 0x0000003A
  446. #define LICENSE_STATUS_UNSUPPORTED_VERSION 0x0000003B
  447. #define LICENSE_STATUS_NO_INTERNET_LICENSE_INSTALLED 0x0000003C
  448. ///////////////////////////////////////////////////////////////////////////////
  449. // State transitions
  450. //
  451. #define ST_TOTAL_ABORT 0x00000001
  452. #define ST_NO_TRANSITION 0x00000002
  453. #define ST_RESET_PHASE_TO_START 0x00000003
  454. #define ST_RESEND_LAST_MESSAGE 0x00000004
  455. #define PLATFORM_WINNT_40 0x00040000
  456. #define PLATFORM_WINCE_20 0x00020001
  457. ///////////////////////////////////////////////////////////////////////////////
  458. // message exchange supporting structures
  459. //
  460. typedef struct _Product_Info
  461. {
  462. DWORD dwVersion;
  463. DWORD cbCompanyName;
  464. PBYTE pbCompanyName;
  465. DWORD cbProductID;
  466. PBYTE pbProductID;
  467. } Product_Info;
  468. #ifdef OS_WIN16
  469. typedef Product_Info FAR *PProduct_Info;
  470. #else
  471. typedef Product_Info *PProduct_Info;
  472. #endif //OS_WIN16
  473. typedef struct _Duration
  474. {
  475. FILETIME NotBefore;
  476. FILETIME NotAfter;
  477. } Duration;
  478. #ifdef OS_WIN16
  479. typedef Duration FAR * PDuration;
  480. #else
  481. typedef Duration *PDuration;
  482. #endif //OS_WIN16
  483. typedef struct _New_License_Info
  484. {
  485. DWORD dwVersion; //Added -Shubho
  486. DWORD cbScope;
  487. PBYTE pbScope;
  488. DWORD cbCompanyName;
  489. PBYTE pbCompanyName;
  490. DWORD cbProductID;
  491. PBYTE pbProductID;
  492. DWORD cbLicenseInfo;
  493. PBYTE pbLicenseInfo;
  494. }New_License_Info;
  495. #ifdef OS_WIN16
  496. typedef New_License_Info FAR * PNew_License_Info;
  497. #else
  498. typedef New_License_Info *PNew_License_Info;
  499. #endif //OS_WIN16
  500. ///////////////////////////////////////////////////////////////////////////////
  501. // binary blob format to support expanded message format
  502. //
  503. typedef struct _Binary_Blob
  504. {
  505. WORD wBlobType;
  506. WORD wBlobLen;
  507. PBYTE pBlob;
  508. } Binary_Blob;
  509. #ifdef OS_WIN16
  510. typedef Binary_Blob FAR * PBinary_Blob;
  511. #else
  512. typedef Binary_Blob UNALIGNED* PBinary_Blob;
  513. #endif //OS_WIN16
  514. ///////////////////////////////////////////////////////////////////////////////
  515. // Binary Blob Data Types
  516. //
  517. #define BB_DATA_BLOB 0x0001
  518. #define BB_RANDOM_BLOB 0x0002
  519. #define BB_CERTIFICATE_BLOB 0x0003
  520. #define BB_ERROR_BLOB 0x0004
  521. #define BB_DH_KEY_BLOB 0x0005
  522. #define BB_RSA_KEY_BLOB 0x0006
  523. #define BB_DSS_SIGNATURE_BLOB 0x0007
  524. #define BB_RSA_SIGNATURE_BLOB 0x0008
  525. #define BB_ENCRYPTED_DATA_BLOB 0x0009
  526. #define BB_MAC_DATA_BLOB 0x000A
  527. #define BB_INTEGER_BLOB 0x000B
  528. #define BB_NAME_BLOB 0x000C
  529. #define BB_KEY_EXCHG_ALG_BLOB 0x000D
  530. #define BB_SCOPE_BLOB 0x000E
  531. #define BB_CLIENT_USER_NAME_BLOB 0x000F
  532. #define BB_CLIENT_MACHINE_NAME_BLOB 0x0010
  533. ///////////////////////////////////////////////////////////////////////////////
  534. // Binary Blob Data Version Numbers
  535. //
  536. #define BB_ERROR_BLOB_VERSION 0x0001
  537. ///////////////////////////////////////////////////////////////////////////////
  538. // message exchange structures for licensing protocol
  539. //
  540. typedef struct _Preamble
  541. {
  542. BYTE bMsgType; // Contains the type of message
  543. BYTE bVersion; // Contains the version no. info.
  544. WORD wMsgSize; // Length of the whole message including PREAMBLE
  545. } Preamble;
  546. #ifdef OS_WIN16
  547. typedef Preamble FAR * PPreamble;
  548. #else
  549. typedef Preamble * PPreamble;
  550. #endif //OS_WIN16
  551. typedef struct _Scope_List
  552. {
  553. DWORD dwScopeCount;
  554. PBinary_Blob Scopes;
  555. } Scope_List;
  556. #ifdef OS_WIN16
  557. typedef Scope_List FAR * PScope_List;
  558. #else
  559. typedef Scope_List * PScope_List;
  560. #endif //OS_WIN16
  561. typedef struct _License_Error_Message
  562. {
  563. DWORD dwErrorCode;
  564. DWORD dwStateTransition;
  565. Binary_Blob bbErrorInfo;
  566. } License_Error_Message;
  567. #ifdef OS_WIN16
  568. typedef License_Error_Message FAR * PLicense_Error_Message;
  569. #else
  570. typedef License_Error_Message * PLicense_Error_Message;
  571. #endif //OS_WIN16
  572. typedef struct _Hydra_Client_License_Info
  573. {
  574. DWORD dwPrefKeyExchangeAlg;
  575. DWORD dwPlatformID;
  576. BYTE ClientRandom[LICENSE_RANDOM];
  577. Binary_Blob EncryptedPreMasterSecret;
  578. Binary_Blob LicenseInfo;
  579. Binary_Blob EncryptedHWID;
  580. BYTE MACData[LICENSE_MAC_DATA];
  581. } Hydra_Client_License_Info;
  582. #ifdef OS_WIN16
  583. typedef Hydra_Client_License_Info FAR * PHydra_Client_License_Info;
  584. #else
  585. typedef Hydra_Client_License_Info * PHydra_Client_License_Info;
  586. #endif //OS_WIN16
  587. typedef struct _Hydra_Client_New_License_Request
  588. {
  589. DWORD dwPrefKeyExchangeAlg;
  590. DWORD dwPlatformID;
  591. BYTE ClientRandom[LICENSE_RANDOM];
  592. Binary_Blob EncryptedPreMasterSecret;
  593. Binary_Blob ClientUserName;
  594. Binary_Blob ClientMachineName;
  595. } Hydra_Client_New_License_Request;
  596. #ifdef OS_WIN16
  597. typedef Hydra_Client_New_License_Request FAR * PHydra_Client_New_License_Request;
  598. #else
  599. typedef Hydra_Client_New_License_Request * PHydra_Client_New_License_Request;
  600. #endif //OS_WIN16
  601. //
  602. // High Byte - Major version, Low Byte - Minor version
  603. //
  604. #define PLATFORMCHALLENGE_VERSION 0x0100
  605. #define CURRENT_PLATFORMCHALLENGE_VERSION PLATFORMCHALLENGE_VERSION
  606. //
  607. // Client Platform Challenge Type
  608. //
  609. #define WIN32_PLATFORMCHALLENGE_TYPE 0x0100
  610. #define WIN16_PLATFORMCHALLENGE_TYPE 0x0200
  611. #define WINCE_PLATFORMCHALLENGE_TYPE 0x0300
  612. #define OTHER_PLATFORMCHALLENGE_TYPE 0xFF00
  613. //
  614. // Client License Detail level -
  615. //
  616. // This should be in LicenseRequest but
  617. // 1) Require changes to RPC interface.
  618. // 2) Nothing in structure for us to identify version.
  619. // 3) Current licensing protocol, no way to tell actual client type
  620. //
  621. //
  622. // client license + license server's self signed
  623. //
  624. #define LICENSE_DETAIL_SIMPLE 0x0001
  625. //
  626. // license chain up to issuer of license server's certificate
  627. //
  628. #define LICENSE_DETAIL_MODERATE 0x0002
  629. //
  630. // Detail client license chain up to root.
  631. //
  632. #define LICENSE_DETAIL_DETAIL 0x0003
  633. typedef struct __PlatformChallengeResponseData
  634. {
  635. WORD wVersion; // structure version
  636. WORD wClientType; // client type
  637. WORD wLicenseDetailLevel; // license detail, TS will re-modify this value
  638. WORD cbChallenge; // size of client challenge response data
  639. BYTE pbChallenge[1]; // start of variable length data
  640. } PlatformChallengeResponseData;
  641. #ifdef OS_WIN16
  642. typedef PlatformChallengeResponseData FAR * PPlatformChallengeResponseData;
  643. #else
  644. typedef PlatformChallengeResponseData * PPlatformChallengeResponseData;
  645. #endif //OS_WIN16
  646. #define PLATFORM_CHALLENGE_LENGTH 64
  647. typedef struct _Hydra_Client_Platform_Challenge_Response
  648. {
  649. Binary_Blob EncryptedChallengeResponse;
  650. Binary_Blob EncryptedHWID;
  651. BYTE MACData[LICENSE_MAC_DATA];
  652. } Hydra_Client_Platform_Challenge_Response;
  653. #ifdef OS_WIN16
  654. typedef Hydra_Client_Platform_Challenge_Response FAR * PHydra_Client_Platform_Challenge_Response;
  655. #else
  656. typedef Hydra_Client_Platform_Challenge_Response * PHydra_Client_Platform_Challenge_Response;
  657. #endif //OS_WIN16
  658. typedef struct _Hydra_Server_License_Request
  659. {
  660. BYTE ServerRandom[LICENSE_RANDOM];
  661. Product_Info ProductInfo;
  662. Binary_Blob KeyExchngList;
  663. Binary_Blob ServerCert;
  664. Scope_List ScopeList;
  665. } Hydra_Server_License_Request;
  666. #ifdef OS_WIN16
  667. typedef Hydra_Server_License_Request FAR * PHydra_Server_License_Request;
  668. #else
  669. typedef Hydra_Server_License_Request * PHydra_Server_License_Request;
  670. #endif //OS_WIN16
  671. typedef struct _Hydra_Server_Platform_Challenge
  672. {
  673. DWORD dwConnectFlags;
  674. Binary_Blob EncryptedPlatformChallenge;
  675. BYTE MACData[LICENSE_MAC_DATA];
  676. } Hydra_Server_Platform_Challenge;
  677. #ifdef OS_WIN16
  678. typedef Hydra_Server_Platform_Challenge FAR * PHydra_Server_Platform_Challenge;
  679. #else
  680. typedef Hydra_Server_Platform_Challenge * PHydra_Server_Platform_Challenge;
  681. #endif //OS_WIN16
  682. typedef struct _Hydra_Server_New_License
  683. {
  684. Binary_Blob EncryptedNewLicenseInfo;
  685. BYTE MACData[LICENSE_MAC_DATA];
  686. } Hydra_Server_New_License;
  687. #ifdef OS_WIN16
  688. typedef Hydra_Server_New_License FAR * PHydra_Server_New_License;
  689. #else
  690. typedef Hydra_Server_New_License * PHydra_Server_New_License;
  691. #endif //OS_WIN16
  692. typedef Hydra_Server_New_License Hydra_Server_Upgrade_License;
  693. typedef PHydra_Server_New_License PHydra_Server_Upgrade_License;
  694. ///////////////////////////////////////////////////////////////////////////////
  695. // Hydra Server Authentication Certificate structures;
  696. // Here we assume that before Licensing module comes into play
  697. // the client will somehow notify the Server about the supported
  698. // Provider and the Hydra Server will accordingly provide
  699. // appropriate certificate
  700. //
  701. typedef struct _Hydra_Server_Cert
  702. {
  703. DWORD dwVersion;
  704. DWORD dwSigAlgID;
  705. DWORD dwKeyAlgID;
  706. Binary_Blob PublicKeyData;
  707. Binary_Blob SignatureBlob;
  708. } Hydra_Server_Cert;
  709. #ifdef OS_WIN16
  710. typedef Hydra_Server_Cert FAR * PHydra_Server_Cert;
  711. #else
  712. typedef Hydra_Server_Cert * PHydra_Server_Cert;
  713. #endif //OS_WIN16
  714. ///////////////////////////////////////////////////////////////////////////////
  715. // Hydra Client HWID structure
  716. // Note : We have to finalize on this structure and generation algorithm.
  717. // Currently we have hardcoded these values in Cryptkey.c. - Shubho
  718. typedef struct _HWID
  719. {
  720. DWORD dwPlatformID;
  721. DWORD Data1;
  722. DWORD Data2;
  723. DWORD Data3;
  724. DWORD Data4;
  725. } HWID;
  726. #ifdef OS_WIN16
  727. typedef HWID FAR * PHWID;
  728. #else
  729. typedef HWID * PHWID;
  730. #endif //OS_WIN16
  731. typedef struct _LicenseRequest
  732. {
  733. PBYTE pbEncryptedHwid;
  734. DWORD cbEncryptedHwid;
  735. DWORD dwLanguageID;
  736. DWORD dwPlatformID;
  737. PProduct_Info pProductInfo;
  738. } LICENSEREQUEST;
  739. #ifdef OS_WIN16
  740. typedef LICENSEREQUEST FAR * PLICENSEREQUEST;
  741. #else
  742. typedef LICENSEREQUEST * PLICENSEREQUEST;
  743. #endif //OS_WIN16
  744. //
  745. // dwLicenseVersion Value
  746. //
  747. // HYDRA_CERT_VERSION_BETA Beta2 client license
  748. // HYDRA_CERT_VERSION_NO_CERT Post Beta2 license without certificate chain
  749. // HYDRA_CERT_VERSION_CURRENT Post Beta2 license with certificate chain
  750. //
  751. typedef struct _LicensedProduct
  752. {
  753. DWORD dwLicenseVersion;
  754. DWORD dwQuantity;
  755. PBYTE pbOrgProductID; // original license request product Id
  756. DWORD cbOrgProductID; // size of original license request product Id
  757. LICENSEREQUEST LicensedProduct; // licensed product
  758. LICENSED_VERSION_INFO* pLicensedVersion; // licensed product version
  759. DWORD dwNumLicensedVersion; // number of licensed product version
  760. LPTSTR szIssuer;
  761. LPTSTR szIssuerId; // license server setup ID
  762. LPTSTR szIssuerScope;
  763. LPTSTR szLicensedClient;
  764. LPTSTR szLicensedUser;
  765. LPTSTR szIssuerDnsName;
  766. HWID Hwid;
  767. FILETIME NotBefore; // license's validity
  768. FILETIME NotAfter;
  769. PBYTE pbPolicyData; // Policy specfic extension
  770. DWORD cbPolicyData; // size of policy specific extension
  771. ULARGE_INTEGER ulSerialNumber; // Client license's serial number
  772. } LICENSEDPRODUCT;
  773. #ifdef OS_WIN16
  774. typedef LICENSEDPRODUCT FAR * PLICENSEDPRODUCT;
  775. #else
  776. typedef LICENSEDPRODUCT *PLICENSEDPRODUCT;
  777. #endif //OS_WIN16
  778. //-----------------------------------------------------------------------------
  779. //
  780. // Types of certificate used by the server to authenticate itself to the clients
  781. //
  782. // CERT_TYPE_PROPRIETORY
  783. // Proprietory format certificate
  784. //
  785. // CERT_TYPE_X509
  786. // X509 format certificate
  787. //
  788. //-----------------------------------------------------------------------------
  789. typedef enum
  790. {
  791. CERT_TYPE_INVALID = 0,
  792. CERT_TYPE_PROPRIETORY = 1,
  793. CERT_TYPE_X509 = 2
  794. } CERT_TYPE;
  795. //+----------------------------------------------------------------------------
  796. //
  797. // Ceritificate Blob. Each blob contains an X509 certificate
  798. //
  799. //+----------------------------------------------------------------------------
  800. typedef struct _Cert_Blob
  801. {
  802. DWORD cbCert; // size of this certificate blob
  803. BYTE abCert[1]; // beginning byte of this certificate
  804. } Cert_Blob;
  805. #ifdef OS_WIN16
  806. typedef Cert_Blob FAR * PCert_Blob;
  807. #else
  808. typedef Cert_Blob * PCert_Blob;
  809. #endif //OS_WIN16
  810. //+----------------------------------------------------------------------------
  811. //
  812. // Certificate chain with a number of certificate blobs
  813. //
  814. // The most significant bit denotes whether the certificate that has been
  815. // issued is temporary. The license server will issue a temporary certificate
  816. // if it has not yet obtained a certificate from the clearing house.
  817. //
  818. // We also assume that the chain is in the order such that each subsequent
  819. // certificate belongs to the issuer of the previous certificate.
  820. //
  821. //+----------------------------------------------------------------------------
  822. typedef struct _Cert_Chain
  823. {
  824. DWORD dwVersion; // version of this structure
  825. DWORD dwNumCertBlobs; // Number of certificate blobs
  826. Cert_Blob CertBlob[1]; // First certificate blob
  827. } Cert_Chain;
  828. #ifdef OS_WIN16
  829. typedef Cert_Chain FAR * PCert_Chain;
  830. #else
  831. typedef Cert_Chain * PCert_Chain;
  832. #endif //OS_WIN16
  833. #define CERT_CHAIN_VERSION_1 0x00000001
  834. #define CERT_CHAIN_VERSION_2 0x00000002
  835. #define MAX_CERT_CHAIN_VERSION CERT_CHAIN_VERSION_2
  836. #define GET_CERTIFICATE_VERSION( x ) ( 0x0FFFFFFF & x )
  837. #define IS_TEMP_CERTIFICATE( x ) ( 0xF0000000 & x )
  838. //-----------------------------------------------------------------------------
  839. //
  840. // LICENSE_CAPABILITIES
  841. //
  842. // Data structure used to initialize a licensing context.
  843. //
  844. // KeyExchangeAlg - The key exchange algorithm: RSA or Diffie Helman
  845. // ProtocolVer - The supported licensing protocol
  846. // fAuthenticateServer - Whether the client is going to authenticate the server
  847. // CertType - Indicate the type of certificate that has already been transmitted
  848. // to the client.
  849. //
  850. //-----------------------------------------------------------------------------
  851. typedef struct _LICENSE_CAPABILITIES
  852. {
  853. DWORD KeyExchangeAlg;
  854. DWORD ProtocolVer;
  855. BOOL fAuthenticateServer;
  856. CERT_TYPE CertType;
  857. DWORD cbClientName;
  858. PBYTE pbClientName;
  859. } LICENSE_CAPABILITIES;
  860. #ifdef OS_WIN16
  861. typedef LICENSE_CAPABILITIES FAR * PLICENSE_CAPABILITIES;
  862. #else
  863. typedef LICENSE_CAPABILITIES * PLICENSE_CAPABILITIES;
  864. #endif //OS_WIN16
  865. typedef PLICENSE_CAPABILITIES LPLICENSE_CAPABILITIES;
  866. //-----------------------------------------------------------------------------
  867. //
  868. // Client licensing info retrievable by terminal server
  869. //
  870. //-----------------------------------------------------------------------------
  871. typedef struct _TS_LICENSE_INFO
  872. {
  873. ULARGE_INTEGER ulSerialNumber; // Client license's serial number
  874. DWORD dwProductVersion;
  875. PBYTE pbOrgProductID; // original license request product Id
  876. DWORD cbOrgProductID; // size of original license request product Id
  877. BOOL fTempLicense;
  878. LPTSTR szIssuer;
  879. LPTSTR szIssuerId; // license server setup ID
  880. FILETIME NotBefore; // license's validity
  881. FILETIME NotAfter;
  882. LPTSTR szLicensedClient; // client's machine name
  883. LPTSTR szLicensedUser; // client's user name
  884. PBYTE pbRawLicense; // storage for marking it later
  885. DWORD cbRawLicense;
  886. DWORD dwSupportFlags;
  887. } TS_LICENSE_INFO;
  888. #ifdef OS_WIN16
  889. typedef TS_LICENSE_INFO FAR * PTS_LICENSE_INFO;
  890. #else
  891. typedef TS_LICENSE_INFO * PTS_LICENSE_INFO;
  892. #endif //OS_WIN16
  893. typedef PTS_LICENSE_INFO LPTS_LICENSE_INFO;
  894. // Support Flags: which DCRs are supported
  895. #define SUPPORT_PER_SEAT_REISSUANCE 0x1
  896. #define SUPPORT_PER_SEAT_POST_LOGON 0x2
  897. #define SUPPORT_CONCURRENT 0x4
  898. #define SUPPORT_WHISTLER_CAL 0x8
  899. #define SUPPORT_WHISTLER_52_CAL 0x16
  900. #define ALL_KNOWN_SUPPORT_FLAGS (SUPPORT_PER_SEAT_REISSUANCE|SUPPORT_PER_SEAT_POST_LOGON|SUPPORT_CONCURRENT|SUPPORT_WHISTLER_CAL| SUPPORT_WHISTLER_52_CAL)
  901. // Mark Flags: bits marking the license
  902. #define MARK_FLAG_USER_AUTHENTICATED 0x1
  903. #endif //_LICENSE_H_