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.

1138 lines
36 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 CURRENT_TERMINAL_SERVER_VERSION MICROSOFT_WINDOWS_TERMINAL_SERVER_5_1
  305. #define TERMSRV_OS_INDEX_WINNT_5_0 0x00000000
  306. #define TERMSRV_OS_INDEX_WINNT_5_1 0x00000001
  307. #define TERMSRV_OS_INDEX_WINNT_POST_5_1 0x00000002
  308. ///////////////////////////////////////////////////////////////////////////////
  309. //
  310. // Scope name
  311. //
  312. #ifndef OS_WINCE //SCOPE_NAME is being defined by iprtrmib.h which is included by iphlpapi.h
  313. #define SCOPE_NAME "microsoft.com"
  314. #endif
  315. ///////////////////////////////////////////////////////////////////////////////
  316. //
  317. // Maximum product info string length in bytes
  318. //
  319. #define MAX_PRODUCT_INFO_STRING_LENGTH 255
  320. ///////////////////////////////////////////////////////////////////////////////
  321. // Different crypt algid definitions
  322. // We are keeping an option open to generatize it in future
  323. //
  324. ///////////////////////////////////////////////////////////////////////////////
  325. //
  326. // Key exchange algorithms
  327. //
  328. #define KEY_EXCHANGE_ALG_RSA 1
  329. #define KEY_EXCHANGE_ALG_DH 2
  330. ///////////////////////////////////////////////////////////////////////////////
  331. //
  332. // Certificate Signature Algorithms
  333. //
  334. #define SIGNATURE_ALG_RSA 1
  335. #define SIGNATURE_ALG_DSS 2
  336. ///////////////////////////////////////////////////////////////////////////////
  337. //
  338. // Symmetric cryptographic algorithms
  339. //
  340. #define BASIC_RC4_128 1
  341. ///////////////////////////////////////////////////////////////////////////////
  342. //
  343. // MAC generation algorithms
  344. //
  345. #define MAC_MD5_SHA 1
  346. ///////////////////////////////////////////////////////////////////////////////
  347. //
  348. // hydra client to hydra server message types
  349. //
  350. #define HC_LICENSE_INFO 0x12
  351. #define HC_NEW_LICENSE_REQUEST 0x13
  352. #define HC_PLATFORM_INFO 0x14
  353. #define HC_PLATFORM_CHALENGE_RESPONSE 0x15
  354. ///////////////////////////////////////////////////////////////////////////////
  355. //
  356. // hydra server to hydra client message types
  357. //
  358. #define HS_LICENSE_REQUEST 0x01
  359. #define HS_PLATFORM_CHALLENGE 0x02
  360. #define HS_NEW_LICENSE 0x03
  361. #define HS_UPGRADE_LICENSE 0x04
  362. #define LICENSE_VERSION_1 0x01
  363. #define GM_ERROR_ALERT 0xFF
  364. ///////////////////////////////////////////////////////////////////////////////
  365. //
  366. // Error and alert codes
  367. //
  368. #define GM_HC_ERR_INVALID_SERVER_CERTIFICATE 0x00000001
  369. #define GM_HC_ERR_NO_LICENSE 0x00000002
  370. #define GM_HC_ERR_INVALID_MAC 0x00000003
  371. #define GM_HS_ERR_INVALID_SCOPE 0x00000004
  372. #define GM_HS_ERR_INVALID_MAC 0x00000005
  373. #define GM_HS_ERR_NO_LICENSE_SERVER 0x00000006
  374. #define GM_HS_ERR_VALID_CLIENT 0x00000007
  375. #define GM_HS_ERR_INVALID_CLIENT 0x00000008
  376. #define GM_HS_ERR_LICENSE_UPGRADE 0x00000009
  377. #define GM_HS_ERR_EXPIRED_LICENSE 0x0000000A
  378. #define GM_HS_ERR_INVALID_PRODUCTID 0x0000000B
  379. #define GM_HS_ERR_INVALID_MESSAGE_LEN 0x0000000C
  380. ///////////////////////////////////////////////////////////////////////////////
  381. //
  382. // License status and status codes
  383. //
  384. typedef DWORD LICENSE_STATUS;
  385. #define LICENSE_STATUS_OK 0x00000000
  386. #define LICENSE_STATUS_OUT_OF_MEMORY 0x00000001
  387. #define LICENSE_STATUS_INSUFFICIENT_BUFFER 0x00000002
  388. #define LICENSE_STATUS_INVALID_INPUT 0x00000003
  389. #define LICENSE_STATUS_INVALID_CLIENT_CONTEXT 0x00000004
  390. #define LICENSE_STATUS_INITIALIZATION_FAILED 0x00000005
  391. #define LICENSE_STATUS_INVALID_SIGNATURE 0x00000006
  392. #define LICENSE_STATUS_INVALID_CRYPT_STATE 0x00000007
  393. #define LICENSE_STATUS_CONTINUE 0x00000008
  394. #define LICENSE_STATUS_ISSUED_LICENSE 0x00000009
  395. #define LICENSE_STATUS_CLIENT_ABORT 0x0000000A
  396. #define LICENSE_STATUS_SERVER_ABORT 0x0000000B
  397. #define LICENSE_STATUS_NO_CERTIFICATE 0x0000000C
  398. #define LICENSE_STATUS_NO_PRIVATE_KEY 0x0000000D
  399. #define LICENSE_STATUS_SEND_ERROR 0x0000000E
  400. #define LICENSE_STATUS_INVALID_RESPONSE 0x0000000F
  401. #define LICENSE_STATUS_CONTEXT_INITIALIZATION_ERROR 0x00000010
  402. #define LICENSE_STATUS_NO_MESSAGE 0x00000011
  403. #define LICENSE_STATUS_INVALID_CLIENT_STATE 0x00000012
  404. #define LICENSE_STATUS_OPEN_STORE_ERROR 0x00000013
  405. #define LICENSE_STATUS_CLOSE_STORE_ERROR 0x00000014
  406. #define LICENSE_STATUS_WRITE_STORE_ERROR 0x00000015
  407. #define LICENSE_STATUS_INVALID_STORE_HANDLE 0x00000016
  408. #define LICENSE_STATUS_DUPLICATE_LICENSE_ERROR 0x00000017
  409. #define LICENSE_STATUS_INVALID_MAC_DATA 0x00000018
  410. #define LICENSE_STATUS_INCOMPLETE_MESSAGE 0x00000019
  411. #define LICENSE_STATUS_RESTART_NEGOTIATION 0x0000001A
  412. #define LICENSE_STATUS_NO_LICENSE_SERVER 0x0000001B
  413. #define LICENSE_STATUS_NO_PLATFORM_CHALLENGE 0x0000001C
  414. #define LICENSE_STATUS_NO_LICENSE_SERVER_SECRET_KEY 0x0000001D
  415. #define LICENSE_STATUS_INVALID_SERVER_CONTEXT 0x0000001E
  416. #define LICENSE_STATUS_CANNOT_DECODE_LICENSE 0x0000001F
  417. #define LICENSE_STATUS_INVALID_LICENSE 0x00000020
  418. #define LICENSE_STATUS_CANNOT_VERIFY_HWID 0x00000021
  419. #define LICENSE_STATUS_NO_LICENSE_ERROR 0x00000022
  420. #define LICENSE_STATUS_EXPIRED_LICENSE 0x00000023
  421. #define LICENSE_STATUS_MUST_UPGRADE_LICENSE 0x00000024
  422. #define LICENSE_STATUS_UNSPECIFIED_ERROR 0x00000025
  423. #define LICENSE_STATUS_INVALID_PLATFORM_CHALLENGE_RESPONSE 0x00000026
  424. #define LICENSE_STATUS_SHOULD_UPGRADE_LICENSE 0x00000027
  425. #define LICENSE_STATUS_CANNOT_UPGRADE_LICENSE 0x00000028
  426. #define LICENSE_STATUS_CANNOT_FIND_CLIENT_IMAGE 0x00000029
  427. #define LICENSE_STATUS_CANNOT_READ_CLIENT_IMAGE 0x0000002A
  428. #define LICENSE_STATUS_CANNOT_WRITE_CLIENT_IMAGE 0x0000002B
  429. #define LICENSE_STATUS_CANNOT_FIND_ISSUER_CERT 0x0000002C
  430. #define LICENSE_STATUS_NOT_HYDRA 0x0000002D
  431. #define LICENSE_STATUS_INVALID_X509_NAME 0x0000002E
  432. #define LICENSE_STATUS_NOT_SUPPORTED 0x0000002F
  433. #define LICENSE_STATUS_INVALID_CERTIFICATE 0x00000030
  434. #define LICENSE_STATUS_NO_ATTRIBUTES 0x00000031
  435. #define LICENSE_STATUS_NO_EXTENSION 0x00000032
  436. #define LICENSE_STATUS_ASN_ERROR 0x00000033
  437. #define LICENSE_STATUS_INVALID_HANDLE 0x00000034
  438. #define LICENSE_STATUS_CANNOT_MAKE_KEY_PAIR 0x00000035
  439. #define LICENSE_STATUS_AUTHENTICATION_ERROR 0x00000036
  440. #define LICENSE_STATUS_CERTIFICATE_REQUEST_ERROR 0x00000037
  441. #define LICENSE_STATUS_CANNOT_OPEN_SECRET_STORE 0x00000038
  442. #define LICENSE_STATUS_CANNOT_STORE_SECRET 0x00000039
  443. #define LICENSE_STATUS_CANNOT_RETRIEVE_SECRET 0x0000003A
  444. #define LICENSE_STATUS_UNSUPPORTED_VERSION 0x0000003B
  445. #define LICENSE_STATUS_NO_INTERNET_LICENSE_INSTALLED 0x0000003C
  446. ///////////////////////////////////////////////////////////////////////////////
  447. // State transitions
  448. //
  449. #define ST_TOTAL_ABORT 0x00000001
  450. #define ST_NO_TRANSITION 0x00000002
  451. #define ST_RESET_PHASE_TO_START 0x00000003
  452. #define ST_RESEND_LAST_MESSAGE 0x00000004
  453. #define PLATFORM_WINNT_40 0x00040000
  454. #define PLATFORM_WINCE_20 0x00020001
  455. ///////////////////////////////////////////////////////////////////////////////
  456. // message exchange supporting structures
  457. //
  458. typedef struct _Product_Info
  459. {
  460. DWORD dwVersion;
  461. DWORD cbCompanyName;
  462. PBYTE pbCompanyName;
  463. DWORD cbProductID;
  464. PBYTE pbProductID;
  465. } Product_Info;
  466. #ifdef OS_WIN16
  467. typedef Product_Info FAR *PProduct_Info;
  468. #else
  469. typedef Product_Info *PProduct_Info;
  470. #endif //OS_WIN16
  471. typedef struct _Duration
  472. {
  473. FILETIME NotBefore;
  474. FILETIME NotAfter;
  475. } Duration;
  476. #ifdef OS_WIN16
  477. typedef Duration FAR * PDuration;
  478. #else
  479. typedef Duration *PDuration;
  480. #endif //OS_WIN16
  481. typedef struct _New_License_Info
  482. {
  483. DWORD dwVersion; //Added -Shubho
  484. DWORD cbScope;
  485. PBYTE pbScope;
  486. DWORD cbCompanyName;
  487. PBYTE pbCompanyName;
  488. DWORD cbProductID;
  489. PBYTE pbProductID;
  490. DWORD cbLicenseInfo;
  491. PBYTE pbLicenseInfo;
  492. }New_License_Info;
  493. #ifdef OS_WIN16
  494. typedef New_License_Info FAR * PNew_License_Info;
  495. #else
  496. typedef New_License_Info *PNew_License_Info;
  497. #endif //OS_WIN16
  498. ///////////////////////////////////////////////////////////////////////////////
  499. // binary blob format to support expanded message format
  500. //
  501. typedef struct _Binary_Blob
  502. {
  503. WORD wBlobType;
  504. WORD wBlobLen;
  505. PBYTE pBlob;
  506. } Binary_Blob;
  507. #ifdef OS_WIN16
  508. typedef Binary_Blob FAR * PBinary_Blob;
  509. #else
  510. typedef Binary_Blob UNALIGNED* PBinary_Blob;
  511. #endif //OS_WIN16
  512. ///////////////////////////////////////////////////////////////////////////////
  513. // Binary Blob Data Types
  514. //
  515. #define BB_DATA_BLOB 0x0001
  516. #define BB_RANDOM_BLOB 0x0002
  517. #define BB_CERTIFICATE_BLOB 0x0003
  518. #define BB_ERROR_BLOB 0x0004
  519. #define BB_DH_KEY_BLOB 0x0005
  520. #define BB_RSA_KEY_BLOB 0x0006
  521. #define BB_DSS_SIGNATURE_BLOB 0x0007
  522. #define BB_RSA_SIGNATURE_BLOB 0x0008
  523. #define BB_ENCRYPTED_DATA_BLOB 0x0009
  524. #define BB_MAC_DATA_BLOB 0x000A
  525. #define BB_INTEGER_BLOB 0x000B
  526. #define BB_NAME_BLOB 0x000C
  527. #define BB_KEY_EXCHG_ALG_BLOB 0x000D
  528. #define BB_SCOPE_BLOB 0x000E
  529. #define BB_CLIENT_USER_NAME_BLOB 0x000F
  530. #define BB_CLIENT_MACHINE_NAME_BLOB 0x0010
  531. //////////////////////////////////////////////////////
  532. // Binary Blob Data Version Numbers
  533. //
  534. #define BB_ERROR_BLOB_VERSION 0x0001
  535. ///////////////////////////////////////////////////////////////////////////////
  536. // message exchange structures for licensing protocol
  537. //
  538. typedef struct _Preamble
  539. {
  540. BYTE bMsgType; // Contains the type of message
  541. BYTE bVersion; // Contains the version no. info.
  542. WORD wMsgSize; // Length of the whole message including PREAMBLE
  543. } Preamble;
  544. #ifdef OS_WIN16
  545. typedef Preamble FAR * PPreamble;
  546. #else
  547. typedef Preamble * PPreamble;
  548. #endif //OS_WIN16
  549. typedef struct _Scope_List
  550. {
  551. DWORD dwScopeCount;
  552. PBinary_Blob Scopes;
  553. } Scope_List;
  554. #ifdef OS_WIN16
  555. typedef Scope_List FAR * PScope_List;
  556. #else
  557. typedef Scope_List * PScope_List;
  558. #endif //OS_WIN16
  559. typedef struct _License_Error_Message
  560. {
  561. DWORD dwErrorCode;
  562. DWORD dwStateTransition;
  563. Binary_Blob bbErrorInfo;
  564. } License_Error_Message;
  565. #ifdef OS_WIN16
  566. typedef License_Error_Message FAR * PLicense_Error_Message;
  567. #else
  568. typedef License_Error_Message * PLicense_Error_Message;
  569. #endif //OS_WIN16
  570. typedef struct _Hydra_Client_License_Info
  571. {
  572. DWORD dwPrefKeyExchangeAlg;
  573. DWORD dwPlatformID;
  574. BYTE ClientRandom[LICENSE_RANDOM];
  575. Binary_Blob EncryptedPreMasterSecret;
  576. Binary_Blob LicenseInfo;
  577. Binary_Blob EncryptedHWID;
  578. BYTE MACData[LICENSE_MAC_DATA];
  579. } Hydra_Client_License_Info;
  580. #ifdef OS_WIN16
  581. typedef Hydra_Client_License_Info FAR * PHydra_Client_License_Info;
  582. #else
  583. typedef Hydra_Client_License_Info * PHydra_Client_License_Info;
  584. #endif //OS_WIN16
  585. typedef struct _Hydra_Client_New_License_Request
  586. {
  587. DWORD dwPrefKeyExchangeAlg;
  588. DWORD dwPlatformID;
  589. BYTE ClientRandom[LICENSE_RANDOM];
  590. Binary_Blob EncryptedPreMasterSecret;
  591. Binary_Blob ClientUserName;
  592. Binary_Blob ClientMachineName;
  593. } Hydra_Client_New_License_Request;
  594. #ifdef OS_WIN16
  595. typedef Hydra_Client_New_License_Request FAR * PHydra_Client_New_License_Request;
  596. #else
  597. typedef Hydra_Client_New_License_Request * PHydra_Client_New_License_Request;
  598. #endif //OS_WIN16
  599. //
  600. // High Byte - Major version, Low Byte - Minor version
  601. //
  602. #define PLATFORMCHALLENGE_VERSION 0x0100
  603. #define CURRENT_PLATFORMCHALLENGE_VERSION PLATFORMCHALLENGE_VERSION
  604. //
  605. // Client Platform Challenge Type
  606. //
  607. #define WIN32_PLATFORMCHALLENGE_TYPE 0x0100
  608. #define WIN16_PLATFORMCHALLENGE_TYPE 0x0200
  609. #define WINCE_PLATFORMCHALLENGE_TYPE 0x0300
  610. #define OTHER_PLATFORMCHALLENGE_TYPE 0xFF00
  611. //
  612. // Client License Detail level -
  613. //
  614. // This should be in LicenseRequest but
  615. // 1) Require changes to RPC interface.
  616. // 2) Nothing in structure for us to identify version.
  617. // 3) Current licensing protocol, no way to tell actual client type
  618. //
  619. //
  620. // client license + license server's self signed
  621. //
  622. #define LICENSE_DETAIL_SIMPLE 0x0001
  623. //
  624. // license chain up to issuer of license server's certificate
  625. //
  626. #define LICENSE_DETAIL_MODERATE 0x0002
  627. //
  628. // Detail client license chain up to root.
  629. //
  630. #define LICENSE_DETAIL_DETAIL 0x0003
  631. typedef struct __PlatformChallengeResponseData
  632. {
  633. WORD wVersion; // structure version
  634. WORD wClientType; // client type
  635. WORD wLicenseDetailLevel; // license detail, TS will re-modify this value
  636. WORD cbChallenge; // size of client challenge response data
  637. BYTE pbChallenge[1]; // start of variable length data
  638. } PlatformChallengeResponseData;
  639. #ifdef OS_WIN16
  640. typedef PlatformChallengeResponseData FAR * PPlatformChallengeResponseData;
  641. #else
  642. typedef PlatformChallengeResponseData * PPlatformChallengeResponseData;
  643. #endif //OS_WIN16
  644. #define PLATFORM_CHALLENGE_LENGTH 64
  645. typedef struct _Hydra_Client_Platform_Challenge_Response
  646. {
  647. Binary_Blob EncryptedChallengeResponse;
  648. Binary_Blob EncryptedHWID;
  649. BYTE MACData[LICENSE_MAC_DATA];
  650. } Hydra_Client_Platform_Challenge_Response;
  651. #ifdef OS_WIN16
  652. typedef Hydra_Client_Platform_Challenge_Response FAR * PHydra_Client_Platform_Challenge_Response;
  653. #else
  654. typedef Hydra_Client_Platform_Challenge_Response * PHydra_Client_Platform_Challenge_Response;
  655. #endif //OS_WIN16
  656. typedef struct _Hydra_Server_License_Request
  657. {
  658. BYTE ServerRandom[LICENSE_RANDOM];
  659. Product_Info ProductInfo;
  660. Binary_Blob KeyExchngList;
  661. Binary_Blob ServerCert;
  662. Scope_List ScopeList;
  663. } Hydra_Server_License_Request;
  664. #ifdef OS_WIN16
  665. typedef Hydra_Server_License_Request FAR * PHydra_Server_License_Request;
  666. #else
  667. typedef Hydra_Server_License_Request * PHydra_Server_License_Request;
  668. #endif //OS_WIN16
  669. typedef struct _Hydra_Server_Platform_Challenge
  670. {
  671. DWORD dwConnectFlags;
  672. Binary_Blob EncryptedPlatformChallenge;
  673. BYTE MACData[LICENSE_MAC_DATA];
  674. } Hydra_Server_Platform_Challenge;
  675. #ifdef OS_WIN16
  676. typedef Hydra_Server_Platform_Challenge FAR * PHydra_Server_Platform_Challenge;
  677. #else
  678. typedef Hydra_Server_Platform_Challenge * PHydra_Server_Platform_Challenge;
  679. #endif //OS_WIN16
  680. typedef struct _Hydra_Server_New_License
  681. {
  682. Binary_Blob EncryptedNewLicenseInfo;
  683. BYTE MACData[LICENSE_MAC_DATA];
  684. } Hydra_Server_New_License;
  685. #ifdef OS_WIN16
  686. typedef Hydra_Server_New_License FAR * PHydra_Server_New_License;
  687. #else
  688. typedef Hydra_Server_New_License * PHydra_Server_New_License;
  689. #endif //OS_WIN16
  690. typedef Hydra_Server_New_License Hydra_Server_Upgrade_License;
  691. typedef PHydra_Server_New_License PHydra_Server_Upgrade_License;
  692. ///////////////////////////////////////////////////////////////////////////////
  693. // Hydra Server Authentication Certificate structures;
  694. // Here we assume that before Licensing module comes into play
  695. // the client will somehow notify the Server about the supported
  696. // Provider and the Hydra Server will accordingly provide
  697. // appropriate certificate
  698. //
  699. typedef struct _Hydra_Server_Cert
  700. {
  701. DWORD dwVersion;
  702. DWORD dwSigAlgID;
  703. DWORD dwKeyAlgID;
  704. Binary_Blob PublicKeyData;
  705. Binary_Blob SignatureBlob;
  706. } Hydra_Server_Cert;
  707. #ifdef OS_WIN16
  708. typedef Hydra_Server_Cert FAR * PHydra_Server_Cert;
  709. #else
  710. typedef Hydra_Server_Cert * PHydra_Server_Cert;
  711. #endif //OS_WIN16
  712. ///////////////////////////////////////////////////////////////////////////////
  713. // Hydra Client HWID structure
  714. // Note : We have to finalize on this structure and generation algorithm.
  715. // Currently we have hardcoded these values in Cryptkey.c. - Shubho
  716. typedef struct _HWID
  717. {
  718. DWORD dwPlatformID;
  719. DWORD Data1;
  720. DWORD Data2;
  721. DWORD Data3;
  722. DWORD Data4;
  723. } HWID;
  724. #ifdef OS_WIN16
  725. typedef HWID FAR * PHWID;
  726. #else
  727. typedef HWID * PHWID;
  728. #endif //OS_WIN16
  729. typedef struct _LicenseRequest
  730. {
  731. PBYTE pbEncryptedHwid;
  732. DWORD cbEncryptedHwid;
  733. DWORD dwLanguageID;
  734. DWORD dwPlatformID;
  735. PProduct_Info pProductInfo;
  736. } LICENSEREQUEST;
  737. #ifdef OS_WIN16
  738. typedef LICENSEREQUEST FAR * PLICENSEREQUEST;
  739. #else
  740. typedef LICENSEREQUEST * PLICENSEREQUEST;
  741. #endif //OS_WIN16
  742. //
  743. // dwLicenseVersion Value
  744. //
  745. // HYDRA_CERT_VERSION_BETA Beta2 client license
  746. // HYDRA_CERT_VERSION_NO_CERT Post Beta2 license without certificate chain
  747. // HYDRA_CERT_VERSION_CURRENT Post Beta2 license with certificate chain
  748. //
  749. typedef struct _LicensedProduct
  750. {
  751. DWORD dwLicenseVersion;
  752. DWORD dwQuantity;
  753. PBYTE pbOrgProductID; // original license request product Id
  754. DWORD cbOrgProductID; // size of original license request product Id
  755. LICENSEREQUEST LicensedProduct; // licensed product
  756. LICENSED_VERSION_INFO* pLicensedVersion; // licensed product version
  757. DWORD dwNumLicensedVersion; // number of licensed product version
  758. LPTSTR szIssuer;
  759. LPTSTR szIssuerId; // license server setup ID
  760. LPTSTR szIssuerScope;
  761. LPTSTR szLicensedClient;
  762. LPTSTR szLicensedUser;
  763. LPTSTR szIssuerDnsName;
  764. HWID Hwid;
  765. FILETIME NotBefore; // license's validity
  766. FILETIME NotAfter;
  767. PBYTE pbPolicyData; // Policy specfic extension
  768. DWORD cbPolicyData; // size of policy specific extension
  769. ULARGE_INTEGER ulSerialNumber; // Client license's serial number
  770. } LICENSEDPRODUCT;
  771. #ifdef OS_WIN16
  772. typedef LICENSEDPRODUCT FAR * PLICENSEDPRODUCT;
  773. #else
  774. typedef LICENSEDPRODUCT *PLICENSEDPRODUCT;
  775. #endif //OS_WIN16
  776. //-----------------------------------------------------------------------------
  777. //
  778. // Types of certificate used by the server to authenticate itself to the clients
  779. //
  780. // CERT_TYPE_PROPRIETORY
  781. // Proprietory format certificate
  782. //
  783. // CERT_TYPE_X509
  784. // X509 format certificate
  785. //
  786. //-----------------------------------------------------------------------------
  787. typedef enum
  788. {
  789. CERT_TYPE_INVALID = 0,
  790. CERT_TYPE_PROPRIETORY = 1,
  791. CERT_TYPE_X509 = 2
  792. } CERT_TYPE;
  793. //+----------------------------------------------------------------------------
  794. //
  795. // Ceritificate Blob. Each blob contains an X509 certificate
  796. //
  797. //+----------------------------------------------------------------------------
  798. typedef struct _Cert_Blob
  799. {
  800. DWORD cbCert; // size of this certificate blob
  801. BYTE abCert[1]; // beginning byte of this certificate
  802. } Cert_Blob;
  803. #ifdef OS_WIN16
  804. typedef Cert_Blob FAR * PCert_Blob;
  805. #else
  806. typedef Cert_Blob * PCert_Blob;
  807. #endif //OS_WIN16
  808. //+----------------------------------------------------------------------------
  809. //
  810. // Certificate chain with a number of certificate blobs
  811. //
  812. // The most significant bit denotes whether the certificate that has been
  813. // issued is temporary. The license server will issue a temporary certificate
  814. // if it has not yet obtained a certificate from the clearing house.
  815. //
  816. // We also assume that the chain is in the order such that each subsequent
  817. // certificate belongs to the issuer of the previous certificate.
  818. //
  819. //+----------------------------------------------------------------------------
  820. typedef struct _Cert_Chain
  821. {
  822. DWORD dwVersion; // version of this structure
  823. DWORD dwNumCertBlobs; // Number of certificate blobs
  824. Cert_Blob CertBlob[1]; // First certificate blob
  825. } Cert_Chain;
  826. #ifdef OS_WIN16
  827. typedef Cert_Chain FAR * PCert_Chain;
  828. #else
  829. typedef Cert_Chain * PCert_Chain;
  830. #endif //OS_WIN16
  831. #define CERT_CHAIN_VERSION_1 0x00000001
  832. #define CERT_CHAIN_VERSION_2 0x00000002
  833. #define MAX_CERT_CHAIN_VERSION CERT_CHAIN_VERSION_2
  834. #define GET_CERTIFICATE_VERSION( x ) ( 0x0FFFFFFF & x )
  835. #define IS_TEMP_CERTIFICATE( x ) ( 0xF0000000 & x )
  836. //-----------------------------------------------------------------------------
  837. //
  838. // LICENSE_CAPABILITIES
  839. //
  840. // Data structure used to initialize a licensing context.
  841. //
  842. // KeyExchangeAlg - The key exchange algorithm: RSA or Diffie Helman
  843. // ProtocolVer - The supported licensing protocol
  844. // fAuthenticateServer - Whether the client is going to authenticate the server
  845. // CertType - Indicate the type of certificate that has already been transmitted
  846. // to the client.
  847. //
  848. //-----------------------------------------------------------------------------
  849. typedef struct _LICENSE_CAPABILITIES
  850. {
  851. DWORD KeyExchangeAlg;
  852. DWORD ProtocolVer;
  853. BOOL fAuthenticateServer;
  854. CERT_TYPE CertType;
  855. DWORD cbClientName;
  856. PBYTE pbClientName;
  857. } LICENSE_CAPABILITIES;
  858. #ifdef OS_WIN16
  859. typedef LICENSE_CAPABILITIES FAR * PLICENSE_CAPABILITIES;
  860. #else
  861. typedef LICENSE_CAPABILITIES * PLICENSE_CAPABILITIES;
  862. #endif //OS_WIN16
  863. typedef PLICENSE_CAPABILITIES LPLICENSE_CAPABILITIES;
  864. //-----------------------------------------------------------------------------
  865. //
  866. // Client licensing info retrievable by terminal server
  867. //
  868. //-----------------------------------------------------------------------------
  869. typedef struct _TS_LICENSE_INFO
  870. {
  871. ULARGE_INTEGER ulSerialNumber; // Client license's serial number
  872. DWORD dwProductVersion;
  873. PBYTE pbOrgProductID; // original license request product Id
  874. DWORD cbOrgProductID; // size of original license request product Id
  875. BOOL fTempLicense;
  876. LPTSTR szIssuer;
  877. LPTSTR szIssuerId; // license server setup ID
  878. FILETIME NotBefore; // license's validity
  879. FILETIME NotAfter;
  880. LPTSTR szLicensedClient; // client's machine name
  881. LPTSTR szLicensedUser; // client's user name
  882. PBYTE pbRawLicense; // storage for marking it later
  883. DWORD cbRawLicense;
  884. DWORD dwSupportFlags;
  885. } TS_LICENSE_INFO;
  886. #ifdef OS_WIN16
  887. typedef TS_LICENSE_INFO FAR * PTS_LICENSE_INFO;
  888. #else
  889. typedef TS_LICENSE_INFO * PTS_LICENSE_INFO;
  890. #endif //OS_WIN16
  891. typedef PTS_LICENSE_INFO LPTS_LICENSE_INFO;
  892. // Support Flags: which DCRs are supported
  893. #define SUPPORT_PER_SEAT_REISSUANCE 0x1
  894. #define SUPPORT_PER_SEAT_POST_LOGON 0x2
  895. #define SUPPORT_CONCURRENT 0x4
  896. #define SUPPORT_WHISTLER_CAL 0x8
  897. #define ALL_KNOWN_SUPPORT_FLAGS (SUPPORT_PER_SEAT_REISSUANCE|SUPPORT_PER_SEAT_POST_LOGON|SUPPORT_CONCURRENT|SUPPORT_WHISTLER_CAL)
  898. // Mark Flags: bits marking the license
  899. #define MARK_FLAG_USER_AUTHENTICATED 0x1
  900. #endif //_LICENSE_H_