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.

1691 lines
35 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. #ifndef _GLOBALS_H_
  3. #define _GLOBALS_H_
  4. #include "winsock2.h"
  5. #include "httpext.h"
  6. #include "assert.h"
  7. #pragma warning(disable:4200)
  8. //
  9. // Version Number for the CH Structs. (Build Number)
  10. //
  11. #define CH_STRUCTS_VERSION_RC1 11
  12. #define CH_STRUCTS_CURRENT_VERSION 35
  13. #define MAX_RETAILSPKCOUNT 20
  14. #define LSSPK_LEN 96
  15. #define PIN_LEN 96
  16. #define REQUEST_ID_LEN 64
  17. #define CA_CUSTMER_NAME_LEN 60
  18. #define CA_ORG_UNIT_LEN 60
  19. #define CA_ADDRESS_LEN 200
  20. #define CA_CITY_LEN 30
  21. #define CA_STATE_LEN 30
  22. #define CA_COUNTRY_LEN 2
  23. #define CA_ZIP_LEN 16
  24. #define CA_NAME_LEN 30
  25. #define CA_PHONE_LEN 64
  26. #define CA_FAX_LEN 64
  27. #define CA_EMAIL_LEN 64
  28. #define CA_REVOKE_REASONCODE_LEN 4
  29. #define CA_LSERVERID_LEN 32
  30. #define PROGRAM_NAME_LEN 64
  31. #define MAX_CERTTYPE_LEN 32
  32. //Retail SPK Return Values
  33. #define RETAIL_SPK_NULL ((TCHAR)'0')
  34. #define RETAIL_SPK_OK ((TCHAR)'1')
  35. #define RETAIL_SPK_INVALID_SIGNATURE ((TCHAR)'2')
  36. #define RETAIL_SPK_INVALID_PRODUCT_TYPE ((TCHAR)'3')
  37. #define RETAIL_SPK_INVALID_SERIAL_NUMBER ((TCHAR)'4')
  38. #define RETAIL_SPK_ALREADY_REGISTERED ((TCHAR)'5')
  39. #define RETAIL_MAX_LENGTH 25 //25 TCHARS
  40. //Select/Open override
  41. #define OVERRIDE_MAX_SIZE 10
  42. typedef struct _CERTCUSTINFO_TAG_
  43. {
  44. TCHAR OrgName[CA_CUSTMER_NAME_LEN+1];
  45. TCHAR OrgUnit[CA_ORG_UNIT_LEN+1];
  46. TCHAR Address[CA_ADDRESS_LEN+1];
  47. TCHAR City[CA_CITY_LEN+1];
  48. TCHAR State[CA_STATE_LEN+1];
  49. TCHAR Country[CA_COUNTRY_LEN+1];
  50. TCHAR Zip[CA_ZIP_LEN+1];
  51. TCHAR LName[CA_NAME_LEN+1];
  52. TCHAR FName[CA_NAME_LEN+1];
  53. TCHAR Phone[CA_PHONE_LEN+1];
  54. TCHAR Fax[CA_FAX_LEN+1];
  55. TCHAR Email[CA_EMAIL_LEN+1];
  56. TCHAR LSID[CA_LSERVERID_LEN+1];
  57. TCHAR ProgramName[PROGRAM_NAME_LEN];
  58. } CERTCUSTINFO, * PCERTCUSTINFO;
  59. #define HydraContent "application/octet-stream"
  60. /*********************************************************************************************************
  61. * Hydra request header definitions *
  62. *********************************************************************************************************/
  63. enum RequestTypes
  64. {
  65. PingRequest = 1, //ping upto isapi extension
  66. CertificateRequest, //New Certificate request
  67. CertificateDownload, //certificate download request
  68. CertificateSignOnly, //convert from SPK to certificate
  69. CertificateRevoke, //Revoke current certificate
  70. CertificateReissue, //Reissue the certificate
  71. CertificateDownloadAck, //Certificate download ack request
  72. ValidateCert, //Validate Certificate Request
  73. NewLicenseRequest, //new license request
  74. ReturnLicenseRequest, //return license request
  75. ReissueLicenseRequest, //reissue last license key pack
  76. LKPDownloadAckRequest, //acknowledgement
  77. NoOperation //unknown operation
  78. };
  79. enum ResponseTypes
  80. {
  81. Response_Invalid_Response = 0,
  82. Response_Success,
  83. Response_Failure,
  84. Response_InvalidData,
  85. Response_ServerError,
  86. Response_NotYetImplemented,
  87. Response_VersionMismatch,
  88. Response_Reg_Bad_SPK,
  89. Response_Reg_Bad_Cert,
  90. Response_Reg_Expired,
  91. Response_Reg_Revoked,
  92. Response_TDO_TDN_Failed,
  93. Response_License_Info_Failed,
  94. Response_Invalid_Conf_Num,
  95. Response_Conf_Num_Already_Used,
  96. Response_SelectMloLicense_NotValid,
  97. Response_NotASupervisor_NotValid,
  98. Response_Invalid_Transfer,
  99. Response_Denied_Other_Program_Id,
  100. Response_Invalid_Other_Program_Qty
  101. };
  102. enum TransactionStates
  103. {
  104. Void = 0,
  105. NotValidated,
  106. Validated,
  107. LicenceRequestPending,
  108. LicenceRequestGranted,
  109. UpgradeRequestPending
  110. // ...
  111. };
  112. enum RegistrationMethods
  113. {
  114. Reg_Internet = 0,
  115. Reg_Telephone,
  116. Reg_Fax
  117. };
  118. enum TransportTypes
  119. {
  120. Transport_Internet =1, //will be supported
  121. Transport_Disk,
  122. Transport_Modem,
  123. Transport_FaxModem,
  124. Transport_Other //unknown transport yet!
  125. };
  126. typedef struct TCB_DISK_PARAM_TAG
  127. {
  128. char * pszFileName;
  129. char * pPostData;
  130. DWORD dwPostDataLen;
  131. }TCB_DISK_PARAM, * PTCB_DISK_PARAM;
  132. typedef struct TCB_INTERNET_PARAM_TAG
  133. {
  134. char * pURL;
  135. char * pPostData;
  136. DWORD dwPostDataLen;
  137. }TCB_INTERNET_PARAM, *PTCB_INTERNET_PARAM;
  138. /*
  139. * This is the transport control block which is filled in prior to calling the
  140. * Send Request routine.
  141. *
  142. */
  143. typedef struct TCB_TAG_
  144. {
  145. RequestTypes RequestType; //request identifier
  146. TransportTypes TransportType; //transport identifier
  147. void * pvParam; //parameters based on the Transport Type
  148. void * pvReserved; //should be set to null at request time and then left alone.
  149. void * pvResponse; //void pointer to response
  150. DWORD dwResponseLen; //response length
  151. DWORD dwRetCode; //Return code from wait operation
  152. }TCB, * PTCB;
  153. /*
  154. * This is the generic structure of the request header that goes on the wire
  155. */
  156. class RequestHeader
  157. {
  158. public:
  159. RequestHeader()
  160. { SetRequestType(NoOperation);
  161. SetResponseType(Response_Invalid_Response);
  162. m_dwLanguageID = 0;
  163. SetVersion(CH_STRUCTS_CURRENT_VERSION);
  164. SetRegistrationMethod(Reg_Internet);
  165. };
  166. void SetRequestType (enum RequestTypes Req)
  167. {
  168. m_Request = (enum RequestTypes)htonl(Req);
  169. };
  170. enum RequestTypes GetRequestType()
  171. {
  172. return (enum RequestTypes) ntohl(m_Request);
  173. };
  174. void SetResponseType (enum ResponseTypes eResp)
  175. {
  176. m_Response = (enum ResponseTypes)htonl(eResp);
  177. };
  178. enum ResponseTypes GetResponseType()
  179. {
  180. return (enum ResponseTypes) ntohl(m_Response);
  181. };
  182. void SetRegistrationMethod (enum RegistrationMethods eRegM)
  183. {
  184. m_RegistrationMethod = (enum RegistrationMethods)htonl(eRegM);
  185. };
  186. enum RegistrationMethods GetRegistrationMethod()
  187. {
  188. return (enum RegistrationMethods) ntohl(m_RegistrationMethod);
  189. };
  190. void SetLanguageId(DWORD dwLanguagwId)
  191. {
  192. m_dwLanguageID = htonl(dwLanguagwId);
  193. };
  194. DWORD GetLanguageId()
  195. {
  196. return ntohl(m_dwLanguageID);
  197. };
  198. void SetVersion(DWORD dwVersion)
  199. {
  200. m_dwVersion = htonl(dwVersion);
  201. };
  202. DWORD GetVersion()
  203. {
  204. return ntohl(m_dwVersion);
  205. }
  206. private:
  207. enum RequestTypes m_Request; //Request Interaction Code
  208. enum ResponseTypes m_Response; //Response Type
  209. enum RegistrationMethods m_RegistrationMethod; //Registration Method
  210. DWORD m_dwLanguageID; //languageId
  211. DWORD m_dwVersion; // Version for the Request Header
  212. };
  213. /*
  214. * Validation request header
  215. */
  216. class Validate_Request
  217. {
  218. public:
  219. Validate_Request()
  220. {
  221. RequestHeader.SetRequestType(ValidateCert);
  222. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  223. };
  224. ~Validate_Request() {};
  225. void SetSPK (PBYTE pbSPK, DWORD dwSPKLen )
  226. {
  227. if (pbSPK != NULL)
  228. {
  229. memcpy ( m_szSPK, pbSPK, dwSPKLen );
  230. }
  231. };
  232. LPTSTR GetSPK ()
  233. {
  234. return ( (LPTSTR) m_szSPK );
  235. };
  236. void SetCertBlobLen (DWORD dwCertBlobLen)
  237. {
  238. m_dwCertBlobLen = htonl(dwCertBlobLen);
  239. };
  240. DWORD GetCertBlobLen ()
  241. {
  242. return (ntohl(m_dwCertBlobLen));
  243. };
  244. DWORD GetDataLen()
  245. {
  246. return ntohl(m_dwDataLen);
  247. };
  248. void SetDataLen(DWORD dwDataLen)
  249. {
  250. m_dwDataLen = htonl(dwDataLen);
  251. };
  252. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  253. RequestHeader RequestHeader;
  254. TCHAR m_szSPK[LSSPK_LEN]; //SPK
  255. DWORD m_dwCertBlobLen;
  256. DWORD m_dwDataLen; //Length of the Body
  257. //variable data part
  258. //CErt Blob follows here
  259. };
  260. /*
  261. * Validation response header
  262. */
  263. class Validate_Response
  264. {
  265. public:
  266. Validate_Response()
  267. {
  268. RequestHeader.SetRequestType(ValidateCert);
  269. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  270. memset(m_szCertType,0,sizeof(m_szCertType));
  271. };
  272. inline void SetCHExchCertLen (DWORD dwCertLen)
  273. {
  274. m_dwCHExchCertLen = htonl(dwCertLen);
  275. };
  276. inline DWORD GetCHExchCertLen ()
  277. {
  278. return ntohl(m_dwCHExchCertLen);
  279. };
  280. inline void SetCHSignCertLen (DWORD dwCertLen)
  281. {
  282. m_dwCHSignCertLen = htonl(dwCertLen);
  283. };
  284. inline DWORD GetCHSignCertLen ()
  285. {
  286. return ntohl(m_dwCHSignCertLen);
  287. };
  288. inline void SetCHRootCertLen(DWORD dwRootCertLen)
  289. {
  290. m_dwCHRootCertLen = htonl(dwRootCertLen);
  291. };
  292. inline DWORD GetCHRootCertLen ()
  293. {
  294. return ntohl(m_dwCHRootCertLen);
  295. };
  296. DWORD GetDataLen()
  297. {
  298. return ntohl(m_dwDataLen);
  299. };
  300. void SetDataLen(DWORD dwDataLen)
  301. {
  302. m_dwDataLen = htonl(dwDataLen);
  303. };
  304. void SetRetCode (DWORD dwRetCode )
  305. {
  306. m_dwRetCode = htonl(dwRetCode);
  307. }
  308. DWORD GetRetCode ()
  309. {
  310. return ntohl(m_dwRetCode);
  311. }
  312. void SetCertType(PBYTE pbCertType, DWORD dwCertTypeLen )
  313. {
  314. memcpy (m_szCertType, pbCertType, dwCertTypeLen );
  315. }
  316. LPTSTR GetCertType()
  317. {
  318. return ((LPTSTR)m_szCertType);
  319. }
  320. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  321. RequestHeader RequestHeader;
  322. DWORD m_dwRetCode;
  323. DWORD m_dwCHRootCertLen;
  324. DWORD m_dwCHExchCertLen;
  325. DWORD m_dwCHSignCertLen;
  326. TCHAR m_szCertType[MAX_CERTTYPE_LEN];
  327. DWORD m_dwDataLen; //Length of the Body
  328. //Variable length response
  329. //1.CH Root Cert
  330. //2.CH Exch cert
  331. //3.CH Sign Cert
  332. };
  333. //Send the old certificate and SPK with this request and
  334. //then get the response back
  335. class CertRevoke_Request
  336. {
  337. public:
  338. CertRevoke_Request()
  339. {
  340. RequestHeader.SetRequestType(CertificateRevoke);
  341. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  342. memset (m_szSPK,0,sizeof(m_szSPK));
  343. memset (m_LName, 0, sizeof(m_LName));
  344. memset (m_FName,0,sizeof(m_FName));
  345. memset (m_Phone, 0, sizeof(m_Phone));
  346. memset (m_FAX, 0, sizeof(m_FAX));
  347. memset (m_EMail,0,sizeof(m_EMail));
  348. memset (m_ReasonCode,0,sizeof(m_ReasonCode));
  349. m_dwExchgCertLen = 0;
  350. m_dwSignCertLen = 0;
  351. };
  352. DWORD GetDataLen()
  353. {
  354. return ntohl(m_dwDataLen);
  355. };
  356. void SetDataLen(DWORD dwDataLen)
  357. {
  358. m_dwDataLen = htonl(dwDataLen);
  359. };
  360. void SetSPK (PBYTE pbSPK, DWORD dwSPKLen )
  361. {
  362. if (pbSPK != NULL)
  363. {
  364. memcpy ( m_szSPK, pbSPK, dwSPKLen );
  365. }
  366. };
  367. LPTSTR GetSPK ()
  368. {
  369. return ( (LPTSTR) m_szSPK );
  370. };
  371. void SetExchgCertLen (DWORD dwExchgCertLen)
  372. {
  373. m_dwExchgCertLen = htonl(dwExchgCertLen);
  374. };
  375. DWORD GetExchgCertLen ()
  376. {
  377. return (ntohl(m_dwExchgCertLen));
  378. };
  379. void SetSignCertLen (DWORD dwSignCertLen)
  380. {
  381. m_dwSignCertLen = htonl(dwSignCertLen);
  382. };
  383. DWORD GetSignCertLen ()
  384. {
  385. return (ntohl(m_dwSignCertLen));
  386. };
  387. void SetLName ( PBYTE pbLName, DWORD dwLNameLen )
  388. {
  389. memcpy ( m_LName, pbLName, dwLNameLen );
  390. };
  391. LPTSTR GetLName ()
  392. {
  393. return ((LPTSTR)m_LName);
  394. };
  395. void SetFName ( PBYTE pbFName, DWORD dwFNameLen )
  396. {
  397. memcpy ( m_FName, pbFName, dwFNameLen );
  398. };
  399. LPTSTR GetFName ()
  400. {
  401. return ((LPTSTR)m_FName);
  402. };
  403. void SetPhone ( PBYTE pbPhone, DWORD dwPhoneLen )
  404. {
  405. memcpy ( m_Phone, pbPhone, dwPhoneLen );
  406. };
  407. LPTSTR GetPhone ()
  408. {
  409. return ((LPTSTR)m_Phone);
  410. };
  411. void SetFax ( PBYTE pbFAX, DWORD dwFAXLen )
  412. {
  413. memcpy ( m_FAX, pbFAX, dwFAXLen );
  414. };
  415. LPTSTR GetFax ()
  416. {
  417. return ((LPTSTR)m_FAX);
  418. };
  419. void SetEMail ( PBYTE pbEMail, DWORD dwEMailLen )
  420. {
  421. memcpy ( m_EMail, pbEMail, dwEMailLen);
  422. };
  423. LPTSTR GetEMail ()
  424. {
  425. return ((LPTSTR)m_EMail);
  426. };
  427. void SetReasonCode( PBYTE pbReasonCode, DWORD dwReasonCodeLen )
  428. {
  429. memcpy ( m_ReasonCode, pbReasonCode, dwReasonCodeLen );
  430. };
  431. LPTSTR GetReasonCode ()
  432. {
  433. return ((LPTSTR)m_ReasonCode);
  434. };
  435. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  436. RequestHeader RequestHeader;
  437. DWORD m_dwExchgCertLen;
  438. DWORD m_dwSignCertLen;
  439. TCHAR m_szSPK[LSSPK_LEN]; //SPK
  440. TCHAR m_LName[CA_NAME_LEN+1]; //LName of the revoker
  441. TCHAR m_FName[CA_NAME_LEN+1]; //FName of the revoker
  442. TCHAR m_Phone[CA_PHONE_LEN+1]; //phone
  443. TCHAR m_FAX[CA_FAX_LEN+1]; //FAX
  444. TCHAR m_EMail[CA_EMAIL_LEN+1]; //email - optional of the revoker
  445. TCHAR m_ReasonCode[CA_REVOKE_REASONCODE_LEN+1]; //reason for revokation
  446. DWORD m_dwDataLen; //Length of the Body
  447. //Variable length data
  448. //1.Exchange Cert Blob
  449. //2.Signature cert blob
  450. };
  451. //nothing to send back. Either the operation succeeds or fails.
  452. class CertRevoke_Response
  453. {
  454. public:
  455. CertRevoke_Response()
  456. {
  457. RequestHeader.SetRequestType(CertificateRevoke);
  458. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  459. m_dwDataLen = 0;
  460. }
  461. DWORD GetDataLen()
  462. {
  463. return ntohl(m_dwDataLen);
  464. };
  465. void SetDataLen(DWORD dwDataLen)
  466. {
  467. m_dwDataLen = htonl(dwDataLen);
  468. };
  469. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  470. RequestHeader RequestHeader;
  471. DWORD m_dwDataLen; //Length of the Body
  472. };
  473. //reissue the certificate
  474. //This is an online request. We dont go thru' the e-mail loop etc.
  475. //This request accepts the old SPK and send the new SPK back.
  476. //Then when the authenticate comes across, we do a signonly
  477. //of this cert and deposit the new cert into the system
  478. class CertReissue_Request
  479. {
  480. public:
  481. CertReissue_Request()
  482. {
  483. RequestHeader.SetRequestType(CertificateReissue);
  484. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  485. memset (m_szSPK,0,sizeof(m_szSPK));
  486. memset (m_LName,0,sizeof(m_LName));
  487. memset (m_FName,0,sizeof(m_FName));
  488. memset (m_Phone,0,sizeof(m_Phone));
  489. memset (m_FAX,0,sizeof(m_FAX));
  490. memset (m_EMail,0,sizeof(m_EMail));
  491. memset (m_ReasonCode,0,sizeof(m_ReasonCode));
  492. m_dwDataLen = 0;
  493. };
  494. DWORD GetDataLen()
  495. {
  496. return ntohl(m_dwDataLen);
  497. };
  498. void SetDataLen(DWORD dwDataLen)
  499. {
  500. m_dwDataLen = htonl(dwDataLen);
  501. };
  502. void SetSPK (PBYTE pbSPK, DWORD dwSPKLen )
  503. {
  504. memcpy ( m_szSPK, pbSPK, dwSPKLen );
  505. };
  506. LPTSTR GetSPK ()
  507. {
  508. return ( (LPTSTR) m_szSPK );
  509. };
  510. void SetLName ( PBYTE pbLName, DWORD dwLNameLen )
  511. {
  512. memcpy ( m_LName, pbLName, dwLNameLen );
  513. };
  514. LPTSTR GetLName ()
  515. {
  516. return ((LPTSTR)m_LName);
  517. };
  518. void SetFName ( PBYTE pbFName, DWORD dwFNameLen )
  519. {
  520. memcpy ( m_FName, pbFName, dwFNameLen );
  521. };
  522. LPTSTR GetFName ()
  523. {
  524. return ((LPTSTR)m_FName);
  525. };
  526. void SetPhone ( PBYTE pbPhone, DWORD dwPhoneLen )
  527. {
  528. memcpy ( m_Phone, pbPhone, dwPhoneLen );
  529. };
  530. LPTSTR GetPhone ()
  531. {
  532. return ((LPTSTR)m_Phone);
  533. };
  534. void SetFax ( PBYTE pbFAX, DWORD dwFAXLen )
  535. {
  536. memcpy ( m_FAX, pbFAX, dwFAXLen );
  537. };
  538. LPTSTR GetFax ()
  539. {
  540. return ((LPTSTR)m_FAX);
  541. };
  542. void SetEMail ( PBYTE pbEMail, DWORD dwEMailLen )
  543. {
  544. memcpy ( m_EMail, pbEMail, dwEMailLen);
  545. };
  546. LPTSTR GetEMail ()
  547. {
  548. return ((LPTSTR)m_EMail);
  549. };
  550. void SetReasonCode( PBYTE pbReasonCode, DWORD dwReasonCodeLen )
  551. {
  552. memcpy ( m_ReasonCode, pbReasonCode, dwReasonCodeLen );
  553. };
  554. LPTSTR GetReasonCode ()
  555. {
  556. return ((LPTSTR)m_ReasonCode);
  557. };
  558. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  559. RequestHeader RequestHeader; //Request Header
  560. TCHAR m_szSPK[LSSPK_LEN]; //SPK
  561. TCHAR m_LName[CA_NAME_LEN+1]; //LName of the reissuer
  562. TCHAR m_FName[CA_NAME_LEN+1]; //FName of the reissuer
  563. TCHAR m_Phone[CA_PHONE_LEN+1]; //phone
  564. TCHAR m_FAX[CA_FAX_LEN+1]; //FAX
  565. TCHAR m_EMail[CA_EMAIL_LEN+1]; //email - optional of the reissuer
  566. TCHAR m_ReasonCode[CA_REVOKE_REASONCODE_LEN+1]; //reason for reissue
  567. DWORD m_dwDataLen; //Length of the Body
  568. //Variable portion of this request
  569. //no variable portion here
  570. };
  571. class CertReissue_Response
  572. {
  573. public:
  574. CertReissue_Response()
  575. {
  576. RequestHeader.SetRequestType(CertificateReissue);
  577. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  578. memset ( m_szSPK,0,sizeof(m_szSPK));
  579. m_dwDataLen = 0;
  580. };
  581. DWORD GetDataLen()
  582. {
  583. return ntohl(m_dwDataLen);
  584. };
  585. void SetDataLen(DWORD dwDataLen)
  586. {
  587. m_dwDataLen = htonl(dwDataLen);
  588. };
  589. void SetRegRequestId ( PBYTE pbRegRequestId, DWORD dwRegRequestIdLen )
  590. {
  591. if( pbRegRequestId != NULL )
  592. {
  593. memcpy ( m_szRegRequestId, pbRegRequestId, dwRegRequestIdLen );
  594. }
  595. };
  596. LPTSTR GetRegRequestId ( )
  597. {
  598. return ((LPTSTR)m_szRegRequestId);
  599. };
  600. void SetSPK (PBYTE pbSPK, DWORD dwSPKLen )
  601. {
  602. memcpy ( m_szSPK, pbSPK, dwSPKLen );
  603. };
  604. LPTSTR GetSPK ()
  605. {
  606. return ( (LPTSTR) m_szSPK );
  607. };
  608. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  609. RequestHeader RequestHeader;
  610. TCHAR m_szRegRequestId[REQUEST_ID_LEN]; //Registration Request Id
  611. TCHAR m_szSPK[LSSPK_LEN]; //new SPK
  612. DWORD m_dwDataLen; //Length of the Body
  613. //Variable Portion of the response
  614. //no variable portion here
  615. };
  616. /*
  617. * NewLicense KeyPack Requests
  618. */
  619. class ReissueLKP_Request
  620. {
  621. public:
  622. ReissueLKP_Request()
  623. {
  624. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  625. RequestHeader.SetRequestType(ReissueLicenseRequest);
  626. memset (m_szSPK,0,sizeof(m_szSPK));
  627. };
  628. DWORD GetDataLen()
  629. {
  630. return ntohl(m_dwDataLen);
  631. };
  632. void SetDataLen(DWORD dwDataLen)
  633. {
  634. m_dwDataLen = htonl(dwDataLen);
  635. };
  636. void SetSPK (PBYTE pbSPK, DWORD dwSPKLen )
  637. {
  638. memcpy ( m_szSPK, pbSPK, dwSPKLen );
  639. };
  640. LPTSTR GetSPK ()
  641. {
  642. return ( (LPTSTR) m_szSPK );
  643. };
  644. void SetCertBlobLen (DWORD dwCertBlobLen)
  645. {
  646. m_dwCertBlobLen = htonl(dwCertBlobLen);
  647. };
  648. DWORD GetCertBlobLen ()
  649. {
  650. return (ntohl(m_dwCertBlobLen));
  651. };
  652. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  653. RequestHeader RequestHeader;
  654. TCHAR m_szSPK[LSSPK_LEN]; //SPK
  655. DWORD m_dwCertBlobLen; //certificate length
  656. DWORD m_dwDataLen; //Length of the Body
  657. //Variable portion of the request
  658. //1.Cert Blob
  659. };
  660. class ReissueLKP_Response
  661. {
  662. public:
  663. ReissueLKP_Response()
  664. {
  665. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  666. RequestHeader.SetRequestType(ReissueLicenseRequest);
  667. }
  668. DWORD GetDataLen()
  669. {
  670. return ntohl(m_dwDataLen);
  671. };
  672. void SetDataLen(DWORD dwDataLen)
  673. {
  674. m_dwDataLen = htonl(dwDataLen);
  675. };
  676. void SetLKPLength(DWORD dwLKPLen)
  677. {
  678. m_dwLKPLen = htonl(dwLKPLen);
  679. };
  680. DWORD GetLKPLength()
  681. {
  682. return ( ntohl(m_dwLKPLen));
  683. };
  684. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  685. RequestHeader RequestHeader;
  686. DWORD m_dwLKPLen;
  687. DWORD m_dwDataLen; //Length of the Body
  688. //Variable part of the request
  689. //1. Last LKP issued
  690. };
  691. class NewLKP_Request
  692. {
  693. public:
  694. NewLKP_Request ()
  695. {
  696. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  697. RequestHeader.SetRequestType(NewLicenseRequest);
  698. memset (m_szSPK,0,sizeof(m_szSPK));
  699. m_dwRetailSPKCount = 0;
  700. m_dwCertBlobLen = 0;
  701. m_dwNewLKPRequestLen = 0;
  702. };
  703. ~NewLKP_Request () {};
  704. void SetCertBlobLen ( DWORD dwCertBlobLen )
  705. {
  706. m_dwCertBlobLen = htonl(dwCertBlobLen);
  707. };
  708. DWORD GetCertBlobLen ( )
  709. {
  710. return( ntohl(m_dwCertBlobLen));
  711. };
  712. void SetNewLKPRequestLen ( DWORD dwNewLKPRequestLen )
  713. {
  714. m_dwNewLKPRequestLen = htonl(dwNewLKPRequestLen);
  715. };
  716. DWORD GetNewLKPRequestLen ( )
  717. {
  718. return( ntohl(m_dwNewLKPRequestLen ));
  719. };
  720. DWORD GetDataLen()
  721. {
  722. return ntohl(m_dwDataLen);
  723. };
  724. void SetDataLen(DWORD dwDataLen)
  725. {
  726. m_dwDataLen = htonl(dwDataLen);
  727. };
  728. void SetSPK (PBYTE pbSPK, DWORD dwSPKLen )
  729. {
  730. memcpy ( m_szSPK, pbSPK, dwSPKLen );
  731. };
  732. LPTSTR GetSPK ()
  733. {
  734. return ( (LPTSTR) m_szSPK );
  735. };
  736. void SetRetailSPKCount (DWORD dwRetailSPKCount)
  737. {
  738. assert(dwRetailSPKCount <= MAX_RETAILSPKCOUNT );
  739. m_dwRetailSPKCount = htonl(dwRetailSPKCount);
  740. };
  741. DWORD GetRetailSPKCount()
  742. {
  743. return ntohl(m_dwRetailSPKCount);
  744. };
  745. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  746. RequestHeader RequestHeader;
  747. DWORD m_dwCertBlobLen;
  748. DWORD m_dwNewLKPRequestLen;
  749. DWORD m_dwRetailSPKCount;
  750. TCHAR m_szSPK[LSSPK_LEN]; //SPK
  751. DWORD m_dwDataLen; //Length of the Body
  752. //Variable length data here
  753. //1.Cert Blob
  754. //2. New LKP Request Blob
  755. //3. As many 25 character Retail SPK items as specified in count above
  756. };
  757. class NewLKP_Response
  758. {
  759. public:
  760. NewLKP_Response()
  761. {
  762. RequestHeader.SetRequestType(NewLicenseRequest);
  763. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  764. memset ( m_szRegRequestId,0,sizeof(m_szRegRequestId));
  765. memset ( m_szLicenseReqId,0,sizeof(m_szLicenseReqId));
  766. memset ( m_dwRetailSPKStatus, 0, sizeof(m_dwRetailSPKStatus));
  767. };
  768. void SetLKPLength(DWORD dwLKPLen)
  769. {
  770. m_dwLKPLen = htonl(dwLKPLen);
  771. };
  772. DWORD GetLKPLength()
  773. {
  774. return ( ntohl(m_dwLKPLen));
  775. };
  776. void SetRegRequestId (PBYTE pbRegReqId, DWORD dwRegReqIdLen)
  777. {
  778. if( pbRegReqId != NULL )
  779. {
  780. memcpy (m_szRegRequestId, pbRegReqId, dwRegReqIdLen );
  781. }
  782. };
  783. LPTSTR GetRegRequestId ()
  784. {
  785. return ((LPTSTR)m_szRegRequestId);
  786. };
  787. void SetLicenseReqId (PBYTE pbLicenseReqId, DWORD dwLicenseReqIdLen)
  788. {
  789. memcpy (m_szLicenseReqId, pbLicenseReqId, dwLicenseReqIdLen);
  790. };
  791. LPTSTR GetLicenseReqId ()
  792. {
  793. return ((LPTSTR)m_szLicenseReqId);
  794. };
  795. DWORD GetDataLen()
  796. {
  797. return ntohl(m_dwDataLen);
  798. };
  799. void SetDataLen(DWORD dwDataLen)
  800. {
  801. m_dwDataLen = htonl(dwDataLen);
  802. };
  803. void SetRetailSPKStatus ( DWORD dwIndex, TCHAR dwStatus )
  804. {
  805. assert ( dwIndex < MAX_RETAILSPKCOUNT );
  806. m_dwRetailSPKStatus[dwIndex] = dwStatus;
  807. };
  808. TCHAR GetRetailSPKStatus(DWORD dwIndex )
  809. {
  810. assert ( dwIndex < MAX_RETAILSPKCOUNT );
  811. return m_dwRetailSPKStatus[dwIndex];
  812. };
  813. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  814. RequestHeader RequestHeader;
  815. DWORD m_dwLKPLen;
  816. TCHAR m_szRegRequestId[REQUEST_ID_LEN];
  817. TCHAR m_szLicenseReqId[REQUEST_ID_LEN];
  818. TCHAR m_dwRetailSPKStatus[MAX_RETAILSPKCOUNT];
  819. DWORD m_dwDataLen; //Length of the Body
  820. //LKP here
  821. };
  822. class NewLKP_AckRequest
  823. {
  824. public:
  825. NewLKP_AckRequest()
  826. {
  827. RequestHeader.SetRequestType(LKPDownloadAckRequest);
  828. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  829. memset ( m_szRegRequestId,0,sizeof(m_szRegRequestId));
  830. memset ( m_szLicenseReqId,0,sizeof(m_szLicenseReqId));
  831. m_bAckType = 0;
  832. m_dwDataLen = 0;
  833. };
  834. void SetRegRequestId (PBYTE pbReqId, DWORD dwReqIdLen)
  835. {
  836. if(pbReqId != NULL)
  837. {
  838. memcpy ( m_szRegRequestId, pbReqId, dwReqIdLen );
  839. }
  840. };
  841. LPTSTR GetRegRequestId ()
  842. {
  843. return ( (LPTSTR)m_szRegRequestId);
  844. };
  845. void SetAckType ( BYTE bAckType )
  846. {
  847. m_bAckType = bAckType;
  848. };
  849. BYTE GetAckType ()
  850. {
  851. return m_bAckType;
  852. };
  853. void SetLicenseReqId (PBYTE pbLicenseReqId, DWORD dwLicenseReqIdLen)
  854. {
  855. memcpy (m_szLicenseReqId, pbLicenseReqId, dwLicenseReqIdLen);
  856. };
  857. LPTSTR GetLicenseReqId ()
  858. {
  859. return ((LPTSTR)m_szLicenseReqId);
  860. };
  861. DWORD GetDataLen()
  862. {
  863. return ntohl(m_dwDataLen);
  864. };
  865. void SetDataLen(DWORD dwDataLen)
  866. {
  867. m_dwDataLen = htonl(dwDataLen);
  868. };
  869. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  870. RequestHeader RequestHeader;
  871. TCHAR m_szRegRequestId[REQUEST_ID_LEN];
  872. TCHAR m_szLicenseReqId[REQUEST_ID_LEN];
  873. BYTE m_bAckType; //1 = success 2 = fail
  874. DWORD m_dwDataLen; //Length of the Body
  875. };
  876. class NewLKP_AckResponse
  877. {
  878. public:
  879. NewLKP_AckResponse()
  880. {
  881. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  882. RequestHeader.SetRequestType(LKPDownloadAckRequest);
  883. m_dwDataLen = 0;
  884. }
  885. DWORD GetDataLen()
  886. {
  887. return ntohl(m_dwDataLen);
  888. };
  889. void SetDataLen(DWORD dwDataLen)
  890. {
  891. m_dwDataLen = htonl(dwDataLen);
  892. };
  893. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  894. RequestHeader RequestHeader;
  895. DWORD m_dwDataLen; //Length of the Body
  896. //nothing here
  897. };
  898. /*
  899. * Certificate Acknowledgement Request / Interactions
  900. */
  901. class Certificate_AckRequest
  902. {
  903. public:
  904. Certificate_AckRequest ()
  905. {
  906. RequestHeader.SetRequestType(CertificateDownloadAck);
  907. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  908. memset (m_szRegRequestId,0,sizeof(m_szRegRequestId));
  909. m_bAckType = 0;
  910. m_dwDataLen = 0;
  911. };
  912. ~Certificate_AckRequest () {};
  913. void SetRegRequestId (PBYTE pbReqId, DWORD dwReqIdLen)
  914. {
  915. if(pbReqId != NULL)
  916. {
  917. memcpy ( m_szRegRequestId, pbReqId, dwReqIdLen );
  918. }
  919. };
  920. LPTSTR GetRegRequestId ()
  921. {
  922. return ( (LPTSTR)m_szRegRequestId);
  923. };
  924. void SetAckType ( BYTE bAckType )
  925. {
  926. m_bAckType = bAckType;
  927. };
  928. BYTE GetAckType ()
  929. {
  930. return m_bAckType;
  931. };
  932. DWORD GetDataLen()
  933. {
  934. return ntohl(m_dwDataLen);
  935. };
  936. void SetDataLen(DWORD dwDataLen)
  937. {
  938. m_dwDataLen = htonl(dwDataLen);
  939. };
  940. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  941. RequestHeader RequestHeader;
  942. TCHAR m_szRegRequestId[REQUEST_ID_LEN];
  943. BYTE m_bAckType; //1 = success 2 = fail
  944. DWORD m_dwDataLen; //Length of the Body
  945. //no variable data
  946. };
  947. class Certificate_AckResponse
  948. {
  949. public:
  950. Certificate_AckResponse ()
  951. {
  952. RequestHeader.SetRequestType(CertificateDownloadAck);
  953. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  954. m_dwDataLen = 0;
  955. };
  956. ~Certificate_AckResponse () {};
  957. DWORD GetDataLen()
  958. {
  959. return ntohl(m_dwDataLen);
  960. };
  961. void SetDataLen(DWORD dwDataLen)
  962. {
  963. m_dwDataLen = htonl(dwDataLen);
  964. };
  965. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  966. RequestHeader RequestHeader;
  967. DWORD m_dwDataLen; //Length of the Body
  968. //no variable data
  969. };
  970. //Request for sendind the New CErt
  971. class NewCert_Request
  972. {
  973. public:
  974. NewCert_Request ()
  975. {
  976. RequestHeader.SetRequestType(CertificateRequest);
  977. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  978. };
  979. ~NewCert_Request () {};
  980. DWORD GetExchgPKCS10Length()
  981. {
  982. return ( ntohl(m_dwExchPKCS10Length) );
  983. };
  984. void SetExchgPKCS10Length(DWORD dwExchPKCS10Length)
  985. {
  986. m_dwExchPKCS10Length = htonl(dwExchPKCS10Length);
  987. };
  988. DWORD GetSignPKCS10Length()
  989. {
  990. return ( ntohl(m_dwSignPKCS10Length) );
  991. };
  992. void SetSignPKCS10Length(DWORD dwSignPKCS10Length)
  993. {
  994. m_dwSignPKCS10Length = htonl(dwSignPKCS10Length);
  995. };
  996. DWORD GetDataLen()
  997. {
  998. return ntohl(m_dwDataLen);
  999. };
  1000. void SetDataLen(DWORD dwDataLen)
  1001. {
  1002. m_dwDataLen = htonl(dwDataLen);
  1003. };
  1004. void SetServerName(TCHAR * tc)
  1005. {
  1006. _stprintf(m_szLServerName, _T("%.*s"), MAX_COMPUTERNAME_LENGTH + 4, tc);
  1007. }
  1008. TCHAR * GetServerName(void)
  1009. {
  1010. return m_szLServerName;
  1011. }
  1012. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  1013. RequestHeader RequestHeader;
  1014. DWORD m_dwExchPKCS10Length;
  1015. DWORD m_dwSignPKCS10Length;
  1016. CERTCUSTINFO stCertInfo;
  1017. TCHAR m_szLServerName[MAX_COMPUTERNAME_LENGTH + 5];
  1018. DWORD m_dwDataLen; //Length of the Body
  1019. //Variable data goes here
  1020. //First Exchg PKCS10
  1021. //Second Sign PKCS10
  1022. };
  1023. //New Certificate request response structure
  1024. class NewCert_Response
  1025. {
  1026. public:
  1027. NewCert_Response ()
  1028. {
  1029. RequestHeader.SetRequestType(CertificateRequest);
  1030. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  1031. memset ( m_szSPK, 0, sizeof(m_szSPK ));
  1032. memset ( m_szRegRequestId, 0, sizeof(m_szRegRequestId) );
  1033. };
  1034. ~NewCert_Response () {};
  1035. DWORD GetExchgPKCS7Length()
  1036. {
  1037. return ( ntohl(m_dwExchPKCS7Length) );
  1038. };
  1039. void SetExchgPKCS7Length(DWORD dwExchPKCS7Length)
  1040. {
  1041. m_dwExchPKCS7Length = htonl(dwExchPKCS7Length);
  1042. };
  1043. DWORD GetSignPKCS7Length()
  1044. {
  1045. return ( ntohl(m_dwSignPKCS7Length) );
  1046. };
  1047. void SetSignPKCS10Length(DWORD dwSignPKCS7Length)
  1048. {
  1049. m_dwSignPKCS7Length = htonl(dwSignPKCS7Length);
  1050. };
  1051. DWORD GetRootCertLength()
  1052. {
  1053. return ( ntohl(m_dwRootCertLength) );
  1054. };
  1055. void SetRootCertLength(DWORD dwRootCertLength)
  1056. {
  1057. m_dwRootCertLength = htonl(dwRootCertLength);
  1058. };
  1059. void SetRegRequestId ( PBYTE pbRegRequestId, DWORD dwRegRequestIdLen )
  1060. {
  1061. if( pbRegRequestId != NULL )
  1062. {
  1063. memcpy ( m_szRegRequestId, pbRegRequestId, dwRegRequestIdLen );
  1064. }
  1065. };
  1066. LPTSTR GetRegRequestId ( )
  1067. {
  1068. return ((LPTSTR)m_szRegRequestId);
  1069. };
  1070. void SetSPK ( PBYTE pbSPK, DWORD dwSPKLen)
  1071. {
  1072. memcpy ( m_szSPK, pbSPK, dwSPKLen );
  1073. };
  1074. LPTSTR GetSPK ( )
  1075. {
  1076. return ((LPTSTR)m_szSPK);
  1077. };
  1078. DWORD GetDataLen()
  1079. {
  1080. return ntohl(m_dwDataLen);
  1081. };
  1082. void SetDataLen(DWORD dwDataLen)
  1083. {
  1084. m_dwDataLen = htonl(dwDataLen);
  1085. };
  1086. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  1087. RequestHeader RequestHeader;
  1088. DWORD m_dwExchPKCS7Length;
  1089. DWORD m_dwSignPKCS7Length;
  1090. DWORD m_dwRootCertLength;
  1091. TCHAR m_szRegRequestId[REQUEST_ID_LEN];
  1092. TCHAR m_szSPK[LSSPK_LEN];
  1093. DWORD m_dwDataLen; //Length of the Body
  1094. //variable data part
  1095. //1.Exchange PKCS7
  1096. //2.Signature PKCS7
  1097. //3.Root Cert
  1098. };
  1099. //Certificate sign only request structure
  1100. class CertificateSignOnly_Request
  1101. {
  1102. public:
  1103. CertificateSignOnly_Request()
  1104. {
  1105. RequestHeader.SetRequestType(CertificateSignOnly);
  1106. memset (m_szSPK,0,sizeof(m_szSPK));
  1107. };
  1108. ~CertificateSignOnly_Request(){};
  1109. DWORD GetExchgPKCS10Length()
  1110. {
  1111. return ( ntohl(m_dwExchPKCS10Length) );
  1112. };
  1113. void SetExchgPKCS10Length(DWORD dwExchPKCS10Length)
  1114. {
  1115. m_dwExchPKCS10Length = htonl(dwExchPKCS10Length);
  1116. };
  1117. DWORD GetSignPKCS10Length()
  1118. {
  1119. return ( ntohl(m_dwSignPKCS10Length) );
  1120. };
  1121. void SetSignPKCS10Length(DWORD dwSignPKCS10Length)
  1122. {
  1123. m_dwSignPKCS10Length = htonl(dwSignPKCS10Length);
  1124. };
  1125. DWORD GetDataLen()
  1126. {
  1127. return ntohl(m_dwDataLen);
  1128. };
  1129. void SetDataLen(DWORD dwDataLen)
  1130. {
  1131. m_dwDataLen = htonl(dwDataLen);
  1132. };
  1133. void SetSPK (PBYTE pbSPK, DWORD dwSPKLen )
  1134. {
  1135. memcpy ( m_szSPK, pbSPK, dwSPKLen );
  1136. };
  1137. LPTSTR GetSPK ()
  1138. {
  1139. return ( (LPTSTR) m_szSPK );
  1140. };
  1141. void SetServerName(TCHAR * tc)
  1142. {
  1143. _stprintf(m_szLServerName, _T("%.*s"), MAX_COMPUTERNAME_LENGTH + 4, tc);
  1144. }
  1145. TCHAR * GetServerName(void)
  1146. {
  1147. return m_szLServerName;
  1148. }
  1149. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  1150. RequestHeader RequestHeader;
  1151. DWORD m_dwExchPKCS10Length;
  1152. DWORD m_dwSignPKCS10Length;
  1153. TCHAR m_szSPK[LSSPK_LEN]; //SPK
  1154. TCHAR m_szLServerName[MAX_COMPUTERNAME_LENGTH + 5];
  1155. DWORD m_dwDataLen; //Length of the Body
  1156. //variable data goes here
  1157. //First Exchg PKCS10
  1158. //Second Sign PKCS10
  1159. };
  1160. //Certificate sign only response structure
  1161. class CertificateSignOnly_Response
  1162. {
  1163. public:
  1164. CertificateSignOnly_Response()
  1165. {
  1166. memset(m_szRegRequestId,0,sizeof(m_szRegRequestId));
  1167. RequestHeader.SetRequestType(CertificateSignOnly);
  1168. };
  1169. ~CertificateSignOnly_Response(){};
  1170. DWORD GetExchgPKCS7Length()
  1171. {
  1172. return ( ntohl(m_dwExchPKCS7Length) );
  1173. };
  1174. void SetExchgPKCS7Length(DWORD dwExchPKCS7Length)
  1175. {
  1176. m_dwExchPKCS7Length = htonl(dwExchPKCS7Length);
  1177. };
  1178. DWORD GetSignPKCS7Length()
  1179. {
  1180. return ( ntohl(m_dwSignPKCS7Length) );
  1181. };
  1182. void SetSignPKCS7Length(DWORD dwSignPKCS7Length)
  1183. {
  1184. m_dwSignPKCS7Length = htonl(dwSignPKCS7Length);
  1185. };
  1186. DWORD GetRootCertLength()
  1187. {
  1188. return ( ntohl(m_dwRootCertLength) );
  1189. };
  1190. void SetRootCertLength(DWORD dwRootCertLength)
  1191. {
  1192. m_dwRootCertLength = htonl(dwRootCertLength);
  1193. };
  1194. void SetRegRequestId ( PBYTE pbRegRequestId, DWORD dwRegRequestIdLen )
  1195. {
  1196. if( pbRegRequestId != NULL )
  1197. {
  1198. memcpy ( m_szRegRequestId, pbRegRequestId, dwRegRequestIdLen );
  1199. }
  1200. };
  1201. LPTSTR GetRegRequestId ( )
  1202. {
  1203. return ((LPTSTR)m_szRegRequestId);
  1204. };
  1205. DWORD GetDataLen()
  1206. {
  1207. return ntohl(m_dwDataLen);
  1208. };
  1209. void SetDataLen(DWORD dwDataLen)
  1210. {
  1211. m_dwDataLen = htonl(dwDataLen);
  1212. };
  1213. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  1214. RequestHeader RequestHeader;
  1215. DWORD m_dwExchPKCS7Length;
  1216. DWORD m_dwSignPKCS7Length;
  1217. DWORD m_dwRootCertLength;
  1218. TCHAR m_szRegRequestId[REQUEST_ID_LEN];
  1219. DWORD m_dwDataLen; //Length of the Body
  1220. //Variable data
  1221. //first ExchgPKCS7
  1222. //Second SignPKCS7
  1223. //third Root CErt
  1224. };
  1225. class CertificateDownload_Request
  1226. {
  1227. public:
  1228. CertificateDownload_Request ()
  1229. {
  1230. RequestHeader.SetRequestType(CertificateDownload);
  1231. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  1232. m_dwDataLen = 0;
  1233. memset ( m_szPIN,0,sizeof(m_szPIN));
  1234. };
  1235. ~CertificateDownload_Request () {};
  1236. void SetPIN ( PBYTE pbPIN, DWORD dwPINLen )
  1237. {
  1238. if( pbPIN != NULL )
  1239. {
  1240. memcpy ( m_szPIN, pbPIN, dwPINLen );
  1241. }
  1242. };
  1243. LPTSTR GetPIN ( )
  1244. {
  1245. return ((LPTSTR)m_szPIN);
  1246. };
  1247. DWORD GetDataLen()
  1248. {
  1249. return ntohl(m_dwDataLen);
  1250. };
  1251. void SetDataLen(DWORD dwDataLen)
  1252. {
  1253. m_dwDataLen = htonl(dwDataLen);
  1254. };
  1255. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  1256. RequestHeader RequestHeader;
  1257. TCHAR m_szPIN[PIN_LEN];
  1258. DWORD m_dwDataLen; //Length of the Body
  1259. //no variable data part!!
  1260. };
  1261. class CertificateDownload_Response
  1262. {
  1263. public:
  1264. CertificateDownload_Response ()
  1265. {
  1266. RequestHeader.SetRequestType(CertificateDownload);
  1267. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  1268. memset(m_szRegRequestId,0,sizeof(m_szRegRequestId));
  1269. memset(m_szSPK,0,sizeof(m_szSPK));
  1270. };
  1271. ~CertificateDownload_Response () {};
  1272. DWORD GetExchgPKCS7Length()
  1273. {
  1274. return ( ntohl(m_dwExchPKCS7Length) );
  1275. };
  1276. void SetExchgPKCS7Length(DWORD dwExchPKCS7Length)
  1277. {
  1278. m_dwExchPKCS7Length = htonl(dwExchPKCS7Length);
  1279. };
  1280. DWORD GetSignPKCS7Length()
  1281. {
  1282. return ( ntohl(m_dwSignPKCS7Length) );
  1283. };
  1284. void SetSignPKCS10Length(DWORD dwSignPKCS7Length)
  1285. {
  1286. m_dwSignPKCS7Length = htonl(dwSignPKCS7Length);
  1287. };
  1288. DWORD GetRootCertLength()
  1289. {
  1290. return ( ntohl(m_dwRootCertLength) );
  1291. };
  1292. void SetRootCertLength(DWORD dwRootCertLength)
  1293. {
  1294. m_dwRootCertLength = htonl(dwRootCertLength);
  1295. };
  1296. void SetRegRequestId ( PBYTE pbRegRequestId, DWORD dwRegRequestIdLen )
  1297. {
  1298. if( pbRegRequestId != NULL )
  1299. {
  1300. memcpy ( m_szRegRequestId, pbRegRequestId, dwRegRequestIdLen );
  1301. }
  1302. };
  1303. LPTSTR GetRegRequestId ( )
  1304. {
  1305. return ((LPTSTR)m_szRegRequestId);
  1306. };
  1307. void SetSPK ( PBYTE pbSPK, DWORD dwSPKLen)
  1308. {
  1309. if(pbSPK != NULL)
  1310. {
  1311. memcpy ( m_szSPK, pbSPK, dwSPKLen );
  1312. }
  1313. };
  1314. LPTSTR GetSPK ( )
  1315. {
  1316. return ((LPTSTR)m_szSPK);
  1317. };
  1318. DWORD GetDataLen()
  1319. {
  1320. return ntohl(m_dwDataLen);
  1321. };
  1322. void SetDataLen(DWORD dwDataLen)
  1323. {
  1324. m_dwDataLen = htonl(dwDataLen);
  1325. };
  1326. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  1327. RequestHeader RequestHeader;
  1328. DWORD m_dwExchPKCS7Length;
  1329. DWORD m_dwSignPKCS7Length;
  1330. DWORD m_dwRootCertLength;
  1331. TCHAR m_szRegRequestId[REQUEST_ID_LEN];
  1332. TCHAR m_szSPK[LSSPK_LEN];
  1333. DWORD m_dwDataLen; //Length of the Body
  1334. //variable data part
  1335. //1.Exchange PKCS7
  1336. //2.Signature PKCS7
  1337. //3.Root Cert
  1338. };
  1339. //ping request and response class
  1340. class Ping_Request
  1341. {
  1342. public:
  1343. Ping_Request ()
  1344. {
  1345. RequestHeader.SetRequestType(PingRequest);
  1346. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  1347. m_dwDataLen = 0;
  1348. _tcscpy ( tszPingReqData, _TEXT("Houston we have a problem"));
  1349. };
  1350. ~Ping_Request () {};
  1351. DWORD GetDataLen()
  1352. {
  1353. return ntohl(m_dwDataLen);
  1354. };
  1355. void SetDataLen(DWORD dwDataLen)
  1356. {
  1357. m_dwDataLen = htonl(dwDataLen);
  1358. };
  1359. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  1360. RequestHeader RequestHeader;
  1361. TCHAR tszPingReqData[32]; //32 characters
  1362. DWORD m_dwDataLen; //Length of the Body
  1363. };
  1364. class Ping_Response
  1365. {
  1366. public:
  1367. Ping_Response()
  1368. {
  1369. RequestHeader.SetRequestType(PingRequest);
  1370. RequestHeader.SetLanguageId(GetSystemDefaultLangID());
  1371. _tcscpy ( tszPingResponse, _TEXT("Beam'er up Scottie!"));
  1372. }
  1373. ~Ping_Response() {};
  1374. DWORD GetDataLen()
  1375. {
  1376. return ntohl(m_dwDataLen);
  1377. };
  1378. void SetDataLen(DWORD dwDataLen)
  1379. {
  1380. m_dwDataLen = htonl(dwDataLen);
  1381. };
  1382. BYTE *data() { return (BYTE *)(&m_dwDataLen+1); };
  1383. RequestHeader RequestHeader;
  1384. TCHAR tszPingResponse[32];
  1385. DWORD m_dwDataLen; //Length of the Body
  1386. };
  1387. //stream header declarations
  1388. #define BLOCK_TYPE_NAME 1
  1389. #define BLOCK_TYPE_VALUE 2
  1390. #define BLOCK_TYPE_PROP_PAIR 3
  1391. typedef struct
  1392. {
  1393. long m_wType;
  1394. long m_lNameSize;
  1395. long m_lValueSize;
  1396. void SetType (long lType) {m_wType = htonl(lType);};
  1397. long GetType (){return ntohl(m_wType);};
  1398. void SetNameSize(long lNameSize) {m_lNameSize = htonl(lNameSize);};
  1399. long GetNameSize(){return (ntohl(m_lNameSize));};
  1400. void SetValueSize(long lValueSize){m_lValueSize = htonl(lValueSize);};
  1401. long GetValueSize(){return (ntohl(m_lValueSize));};
  1402. } BLOCK_HDR;
  1403. #define STREAM_HDR_TITLE _TEXT("ICB") //header title
  1404. #define STREAM_HDR_TYPE 1 //header type
  1405. typedef struct
  1406. {
  1407. TCHAR m_szTitle[4]; //will be ICB for now
  1408. DWORD m_wHeader; //reserved for now will be implemented later
  1409. //set it to 0x0000
  1410. DWORD m_itemCount; //number of items in the stream!
  1411. void SetHeader ( DWORD wHeader ) {m_wHeader = htonl(wHeader);};
  1412. DWORD GetHeader (){return ntohl(m_wHeader);};
  1413. void SetItemCount ( DWORD ItemCount ) { m_itemCount = htonl(ItemCount);};
  1414. DWORD GetItemCount (){return ntohl(m_itemCount);};
  1415. } STREAM_HDR;
  1416. #endif