|
4 | 4 | #pragma comment(lib,"Ws2_32") |
5 | 5 | #pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib") |
6 | 6 | #pragma comment(lib,"XEngine_Core/XEngine_OPenSsl") |
7 | | -#pragma comment(lib,"XEngine_Client/XClient_APIHelp") |
| 7 | +#pragma comment(lib,"XEngine_SystemSdk/XEngine_SystemApi") |
8 | 8 | #ifdef _WIN64 |
9 | 9 | #pragma comment(lib,"../../XEngine_Source/x64/Debug/jsoncpp") |
10 | 10 | #pragma comment(lib,"../../XEngine_Source/x64/Debug/AuthorizeModule_CDKey") |
|
19 | 19 | #include <inttypes.h> |
20 | 20 | #include <json/json.h> |
21 | 21 | #include <XEngine_Include/XEngine_CommHdr.h> |
| 22 | +#include <XEngine_Include/XEngine_Types.h> |
22 | 23 | #include <XEngine_Include/XEngine_ProtocolHdr.h> |
23 | 24 | #include <XEngine_Include/XEngine_BaseLib/BaseLib_Define.h> |
24 | 25 | #include <XEngine_Include/XEngine_BaseLib/BaseLib_Error.h> |
25 | 26 | #include <XEngine_Include/XEngine_Core/OPenSsl_Define.h> |
26 | 27 | #include <XEngine_Include/XEngine_Core/OPenSsl_Error.h> |
27 | | -#include <XEngine_Include/XEngine_Client/APIClient_Define.h> |
28 | | -#include <XEngine_Include/XEngine_Client/APIClient_Error.h> |
| 28 | +#include <XEngine_Include/XEngine_SystemSdk/SystemApi_Define.h> |
| 29 | +#include <XEngine_Include/XEngine_SystemSdk/SystemApi_Error.h> |
29 | 30 | #include "../../XEngine_Source/XAuth_Protocol.h" |
30 | 31 | #include "../../XEngine_Source/AuthorizeModule_CDKey/CDKey_Define.h" |
31 | 32 | #include "../../XEngine_Source/AuthorizeModule_CDKey/CDKey_Error.h" |
32 | 33 |
|
33 | 34 | //需要优先配置XEngine |
34 | | -//WINDOWS支持VS2022 x64 debug 编译调试 |
35 | | -//g++ -std=c++17 -Wall -g Authorize_APPLocal.cpp -o Authorize_APPLocal.exe -I ../../XEngine_Source/XEngine_Depend/XEngine_Module/jsoncpp -lXEngine_BaseLib -L ../../XEngine_Release -lXEngine_OPenSsl -lXClient_APIHelp -lAuthorizeModule_CDKey -ljsoncpp -Wl,-rpath=../../XEngine_Release |
| 35 | +//WINDOWS支持VS2022 x86 debug 编译调试 |
| 36 | +//g++ -std=c++17 -Wall -g Authorize_APPLocal.cpp -o Authorize_APPLocal.exe -I ../../XEngine_Source/XEngine_Depend/XEngine_Module/jsoncpp -L ../../XEngine_Release -lXEngine_BaseLib -lXEngine_OPenSsl -lXEngine_SystemApi -lAuthorizeModule_CDKey -ljsoncpp -Wl,-rpath=../../XEngine_Release |
36 | 37 |
|
37 | | -//#define XENGINE_AUTHORIZE_CDKEY_CRYPTO |
| 38 | +XCHAR tszSerialStr[MAX_PATH] = {}; |
| 39 | +//1.创建CDKEY.或者由管理员创建. |
| 40 | +bool Authorize_APPLocal_Create(LPCXSTR lpszKeyFile, LPCXSTR lpszPasswd) |
| 41 | +{ |
| 42 | + int nRet = 0; |
| 43 | + XCHAR tszENCodecBuffer[4096] = {}; |
| 44 | + XCHAR tszDECodecBuffer[4096] = {}; |
| 45 | + XENGINE_AUTHORIZE_LOCAL st_AuthLocal = {}; |
| 46 | + SYSTEMAPI_SERIAL_INFOMATION st_SDKSerial = {}; |
| 47 | + |
| 48 | + SystemApi_HardWare_GetSerial(&st_SDKSerial); |
| 49 | + //网络信息 |
| 50 | + st_AuthLocal.nPort = 5302; |
| 51 | + _tcsxcpy(st_AuthLocal.tszAddr, _X("http://app.xyry.org")); |
| 52 | + //软件信息 |
| 53 | + st_AuthLocal.st_AuthAppInfo.bInit = false; |
| 54 | + st_AuthLocal.st_AuthAppInfo.nExecTime = 0; |
| 55 | + _xstprintf(st_AuthLocal.st_AuthAppInfo.tszAppName, _X("XEngine_Authorize")); |
| 56 | + _xstprintf(st_AuthLocal.st_AuthAppInfo.tszAppVer, _X("V1.0.0.1")); |
| 57 | + //注册信息 |
| 58 | + st_AuthLocal.st_AuthRegInfo.enHWType = ENUM_AUTHORIZE_MODULE_HW_TYPE_BIOS; |
| 59 | + st_AuthLocal.st_AuthRegInfo.enRegType = ENUM_AUTHORIZE_MODULE_CDKEY_TYPE_TRY; |
| 60 | + st_AuthLocal.st_AuthRegInfo.enSerialType = ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_TIME; |
| 61 | + st_AuthLocal.st_AuthRegInfo.enVModeType = ENUM_AUTHORIZE_MODULE_VERMODE_TYPE_LOCAL; |
| 62 | + st_AuthLocal.st_AuthRegInfo.nHasTime = 0; |
| 63 | + BaseLib_OperatorTime_TimeToStr(st_AuthLocal.st_AuthRegInfo.tszCreateTime); |
| 64 | + _tcsxcpy(st_AuthLocal.st_AuthRegInfo.tszHardware, st_SDKSerial.tszBoardSerial); |
| 65 | + _xstprintf(st_AuthLocal.st_AuthRegInfo.tszLeftTime, _X("0")); //0次试用 |
| 66 | + //序列号信息.可以不写,如果不想启用用户自己注册.或者交给管理员填充 |
| 67 | + int nSerialCount = 3; |
| 68 | + XCHAR** pptszSerialList; |
| 69 | + Authorize_Serial_Create(&pptszSerialList, _X("XAUTH"), nSerialCount, 9); |
| 70 | + _tcsxcpy(tszSerialStr, pptszSerialList[0]); |
| 71 | + |
| 72 | + st_AuthLocal.st_AuthSerial.st_TimeLimit.nTimeCount = 5; |
| 73 | + _tcsxcpy(st_AuthLocal.st_AuthSerial.st_TimeLimit.tszTimeSerial, pptszSerialList[0]); |
| 74 | + |
| 75 | + st_AuthLocal.st_AuthSerial.st_DataLimit.bTimeAdd = false; |
| 76 | + _tcsxcpy(st_AuthLocal.st_AuthSerial.st_DataLimit.tszDataSerial, pptszSerialList[1]); |
| 77 | + XCHAR tszTimeStr[128] = {}; |
| 78 | + XENGINE_LIBTIMER st_LibTime = {}; |
| 79 | + BaseLib_OperatorTime_GetSysTime(&st_LibTime); |
| 80 | + st_LibTime.wYear += 1; //一年后过期 |
| 81 | + BaseLib_OperatorTime_TimeToStr(tszTimeStr, NULL, true, &st_LibTime); |
| 82 | + |
| 83 | + _tcsxcpy(st_AuthLocal.st_AuthSerial.st_DataLimit.tszDataTime, tszTimeStr); |
| 84 | + |
| 85 | + _tcsxcpy(st_AuthLocal.st_AuthSerial.st_UNLimit.tszUNLimitSerial, pptszSerialList[2]); |
| 86 | + //用户信息 |
| 87 | + _xstprintf(st_AuthLocal.st_AuthUserInfo.tszUserName, _X("qyt")); |
| 88 | + _xstprintf(st_AuthLocal. st_AuthUserInfo. tszUserContact, _X( "[email protected]")); |
| 89 | + |
| 90 | + Authorize_CDKey_WriteMemory(tszDECodecBuffer, &nRet, &st_AuthLocal); |
| 91 | + OPenSsl_XCrypto_Encoder(tszDECodecBuffer, &nRet, (XBYTE*)tszENCodecBuffer, lpszPasswd); |
| 92 | + FILE* pSt_File = _xtfopen(lpszKeyFile, _X("wb")); |
| 93 | + if (NULL == pSt_File) |
| 94 | + { |
| 95 | + printf("create key file is failed\n"); |
| 96 | + return false; |
| 97 | + } |
| 98 | + fwrite(tszENCodecBuffer, 1, nRet, pSt_File); |
| 99 | + fclose(pSt_File); |
| 100 | + |
| 101 | + return true; |
| 102 | +} |
| 103 | +//2.打开CDKEY并且授权(授权只能通过自我授权或者由管理员授权,用户不应该可以自己随意授权) |
| 104 | +bool Authorize_APPLocal_Auth(LPCXSTR lpszKeyFile, LPCXSTR lpszPasswd, LPCXSTR lpszSerialStr) |
| 105 | +{ |
| 106 | + XCHAR tszENCodecBuffer[4096] = {}; |
| 107 | + XCHAR tszDECodecBuffer[4096] = {}; |
| 108 | + XENGINE_AUTHORIZE_LOCAL st_AuthLocal = {}; |
| 109 | + |
| 110 | + FILE* pSt_File = _xtfopen(lpszKeyFile, _X("rb")); |
| 111 | + if (NULL == pSt_File) |
| 112 | + { |
| 113 | + printf("open key file is failed\n"); |
| 114 | + return false; |
| 115 | + } |
| 116 | + int nRet = fread(tszENCodecBuffer, 1, sizeof(tszENCodecBuffer), pSt_File); |
| 117 | + fclose(pSt_File); |
| 118 | + |
| 119 | + OPenSsl_XCrypto_Decoder(tszENCodecBuffer, &nRet, tszDECodecBuffer, lpszPasswd); |
| 120 | + //printf("大小:%d,内容:\n%s\n", nRet, tszDECodecBuffer); |
| 121 | + |
| 122 | + Authorize_CDKey_ReadMemory(tszDECodecBuffer, nRet, &st_AuthLocal); |
| 123 | + if (!Authorize_CDKey_UserRegister(&st_AuthLocal, lpszSerialStr)) |
| 124 | + { |
| 125 | + printf("serila verifacation is failed,error code:%lX\n", Authorize_GetLastError()); |
| 126 | + return false; |
| 127 | + } |
| 128 | + |
| 129 | + memset(tszENCodecBuffer, '\0', sizeof(tszENCodecBuffer)); |
| 130 | + memset(tszDECodecBuffer, '\0', sizeof(tszDECodecBuffer)); |
| 131 | + Authorize_CDKey_WriteMemory(tszDECodecBuffer, &nRet, &st_AuthLocal); |
| 132 | + OPenSsl_XCrypto_Encoder(tszDECodecBuffer, &nRet, (XBYTE*)tszENCodecBuffer, lpszPasswd); |
| 133 | + pSt_File = _xtfopen(lpszKeyFile, _X("wb")); |
| 134 | + fwrite(tszENCodecBuffer, 1, nRet, pSt_File); |
| 135 | + fclose(pSt_File); |
| 136 | + return true; |
| 137 | +} |
| 138 | +//3.验证CDkey |
| 139 | +bool Authorize_APPLocal_Auth(LPCXSTR lpszKeyFile, LPCXSTR lpszPasswd) |
| 140 | +{ |
| 141 | + XCHAR tszENCodecBuffer[4096] = {}; |
| 142 | + XCHAR tszDECodecBuffer[4096] = {}; |
| 143 | + XENGINE_AUTHORIZE_LOCAL st_AuthLocal = {}; |
38 | 144 |
|
39 | | -LPCXSTR lpszPasswd = _X("123123"); |
| 145 | + FILE* pSt_File = _xtfopen(lpszKeyFile, _X("rb")); |
| 146 | + if (NULL == pSt_File) |
| 147 | + { |
| 148 | + printf("open key file is failed\n"); |
| 149 | + return false; |
| 150 | + } |
| 151 | + int nRet = fread(tszENCodecBuffer, 1, sizeof(tszENCodecBuffer), pSt_File); |
| 152 | + fclose(pSt_File); |
40 | 153 |
|
| 154 | + OPenSsl_XCrypto_Decoder(tszENCodecBuffer, &nRet, tszDECodecBuffer, lpszPasswd); |
| 155 | + //printf("大小:%d,内容:\n%s\n", nRet, tszDECodecBuffer); |
| 156 | + Authorize_CDKey_ReadMemory(tszDECodecBuffer, nRet, &st_AuthLocal); |
| 157 | + if (!Authorize_CDKey_GetLeftTimer(&st_AuthLocal)) |
| 158 | + { |
| 159 | + //失败也需要重写CDKEY |
| 160 | + memset(tszENCodecBuffer, '\0', sizeof(tszENCodecBuffer)); |
| 161 | + memset(tszDECodecBuffer, '\0', sizeof(tszDECodecBuffer)); |
| 162 | + Authorize_CDKey_WriteMemory(tszDECodecBuffer, &nRet, &st_AuthLocal); |
| 163 | + OPenSsl_XCrypto_Encoder(tszDECodecBuffer, &nRet, (XBYTE*)tszENCodecBuffer, lpszPasswd); |
| 164 | + pSt_File = _xtfopen(lpszKeyFile, _X("wb")); |
| 165 | + fwrite(tszENCodecBuffer, 1, nRet, pSt_File); |
| 166 | + fclose(pSt_File); |
| 167 | + |
| 168 | + printf("verifaction is failed\n"); |
| 169 | + return false; |
| 170 | + } |
| 171 | + SYSTEMAPI_SERIAL_INFOMATION st_SDKSerial = {}; |
| 172 | + SystemApi_HardWare_GetSerial(&st_SDKSerial); |
| 173 | + |
| 174 | + if (ENUM_AUTHORIZE_MODULE_VERMODE_TYPE_LOCAL != st_AuthLocal.st_AuthRegInfo.enVModeType) |
| 175 | + { |
| 176 | + printf("cdkey does not support local verification\n"); |
| 177 | + return false; |
| 178 | + } |
| 179 | + if (ENUM_AUTHORIZE_MODULE_HW_TYPE_BIOS != st_AuthLocal.st_AuthRegInfo.enHWType) |
| 180 | + { |
| 181 | + printf("cdkey serial type is incorrect\n"); |
| 182 | + return false; |
| 183 | + } |
| 184 | + if (0 != _tcsxnicmp(st_SDKSerial.tszBoardSerial, st_AuthLocal.st_AuthRegInfo.tszHardware, _tcsxlen(st_SDKSerial.tszBoardSerial))) |
| 185 | + { |
| 186 | + printf("cdkey serial verification is failed\n"); |
| 187 | + return false; |
| 188 | + } |
| 189 | + |
| 190 | + memset(tszENCodecBuffer, '\0', sizeof(tszENCodecBuffer)); |
| 191 | + memset(tszDECodecBuffer, '\0', sizeof(tszDECodecBuffer)); |
| 192 | + Authorize_CDKey_WriteMemory(tszDECodecBuffer, &nRet, &st_AuthLocal); |
| 193 | + OPenSsl_XCrypto_Encoder(tszDECodecBuffer, &nRet, (XBYTE*)tszENCodecBuffer, lpszPasswd); |
| 194 | + pSt_File = _xtfopen(lpszKeyFile, _X("wb")); |
| 195 | + fwrite(tszENCodecBuffer, 1, nRet, pSt_File); |
| 196 | + fclose(pSt_File); |
| 197 | + return true; |
| 198 | +} |
41 | 199 | int main() |
42 | 200 | { |
43 | 201 | #ifdef _MSC_BUILD |
44 | 202 | WSADATA st_WSAData; |
45 | 203 | WSAStartup(MAKEWORD(2, 2), &st_WSAData); |
46 | | -#endif |
47 | | - int nLen = 0; |
48 | | - int nCode = 0; |
49 | | - Json::Value st_JsonRoot; |
50 | | - Json::Value st_JsonAPPInfo; |
51 | | - Json::Value st_JsonREGInfo; |
52 | | - Json::Value st_JsonUserInfo; |
53 | | - st_JsonRoot["tszAddr"] = "http://app.xyry.org"; |
54 | | - st_JsonRoot["nPort"] = 5501; |
55 | | - |
56 | | - st_JsonAPPInfo["tszAppName"] = "XEngine"; |
57 | | - st_JsonAPPInfo["tszAppVer"] = "1.0.0.1001"; |
58 | | - |
59 | | - st_JsonREGInfo["tszHardware"] = "5501012NE21N"; |
60 | | - st_JsonREGInfo["enSerialType"] = ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_TIME; |
61 | | - st_JsonREGInfo["enRegType"] = ENUM_AUTHORIZE_MODULE_CDKEY_TYPE_TRY; |
62 | | - st_JsonREGInfo["enHWType"] = ENUM_AUTHORIZE_MODULE_HW_TYPE_CPU; |
63 | | - |
64 | | - st_JsonUserInfo["tszUserName"] = "qyt"; |
65 | | - st_JsonUserInfo[ "tszUserContact"] = "[email protected]"; |
66 | | - |
67 | | - st_JsonRoot["st_AuthAppInfo"] = st_JsonAPPInfo; |
68 | | - st_JsonRoot["st_AuthRegInfo"] = st_JsonREGInfo; |
69 | | - st_JsonRoot["st_AuthUserInfo"] = st_JsonUserInfo; |
70 | | - |
71 | | - XCHAR* ptszCreateBuffer = NULL; |
72 | | - LPCXSTR lpszCreateUrl = _X("http://192.168.1.10:5302/auth/cdkey/create"); |
73 | | - //1. 创建CDKEY |
74 | | -#ifdef XENGINE_AUTHORIZE_CDKEY_CRYPTO |
75 | | - //加密 |
76 | | - CHAR tszCodecBuffer[4096]; |
77 | | - memset(tszCodecBuffer, '\0', sizeof(tszCodecBuffer)); |
78 | | - |
79 | | - nLen = st_JsonRoot.toStyledString().length(); |
80 | | - OPenSsl_XCrypto_Encoder(st_JsonRoot.toStyledString().c_str(), &nLen, (XBYTE *)tszCodecBuffer, lpszPasswd); |
81 | | - if (!APIClient_Http_Request(_X("POST"), lpszCreateUrl, tszCodecBuffer, &nCode, &ptszCreateBuffer, &nLen)) |
| 204 | + LPCXSTR lpszFileStr = _X("D:\\XEngine_Authorize\\XEngine_Apps\\Debug\\cd.key"); |
82 | 205 | #else |
83 | | - if (!APIClient_Http_Request(_X("POST"), lpszCreateUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszCreateBuffer, &nLen)) |
| 206 | + LPCXSTR lpszFileStr = _X("cd.key"); |
84 | 207 | #endif |
85 | | - { |
86 | | - printf("发送投递失败!\n"); |
87 | | - return 0; |
88 | | - } |
| 208 | + LPCXSTR lpszPasswd = _X("123123"); |
89 | 209 |
|
90 | | - XCHAR tszMsgBuffer[4096]; |
91 | | - memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer)); |
92 | | -#ifdef XENGINE_AUTHORIZE_CDKEY_CRYPTO |
93 | | - //解密 |
94 | | - memset(tszCodecBuffer, '\0', sizeof(tszCodecBuffer)); |
95 | | - |
96 | | - OPenSsl_XCrypto_Decoder(ptszCreateBuffer, &nLen, tszCodecBuffer, lpszPasswd); |
97 | | - printf("接受到数据,大小:%d,内容:\n%s\n", nLen, tszCodecBuffer); |
98 | | - //你也可以通过授权模块的API函数来读内存,都一回事,这里为了方便直接写了,请求分钟卡,拥有10分钟,也可以写自定义时间格式 |
99 | | - BaseLib_OperatorFile_WriteProfileFromMemory(tszCodecBuffer, nLen, "AuthReg", "tszLeftTime", "10", tszMsgBuffer, &nLen); |
100 | | -#else |
101 | | - BaseLib_OperatorFile_WriteProfileFromMemory(ptszCreateBuffer, nLen, "AuthReg", "tszLeftTime", "10", tszMsgBuffer, &nLen); |
102 | | - printf("接受到数据,大小:%d,内容:\n%s\n", nLen, ptszCreateBuffer); |
103 | | -#endif |
104 | | - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszCreateBuffer); |
105 | | - //2. 授权CDKEY |
106 | | - XCHAR* ptszAuthBuffer = NULL; |
107 | | - LPCXSTR lpszAuthUrl = _X("http://192.168.1.10:5302/auth/cdkey/auth"); |
108 | | -#ifdef XENGINE_AUTHORIZE_CDKEY_CRYPTO |
109 | | - //加密 |
110 | | - memset(tszCodecBuffer, '\0', sizeof(tszCodecBuffer)); |
111 | | - nLen = nLen; |
112 | | - OPenSsl_XCrypto_Encoder(tszMsgBuffer, &nLen, (XBYTE*)tszCodecBuffer, lpszPasswd); |
113 | | - if (!APIClient_Http_Request(_X("POST"), lpszAuthUrl, tszCodecBuffer, &nCode, &ptszAuthBuffer, &nLen)) |
114 | | -#else |
115 | | - if (!APIClient_Http_Request(_X("POST"), lpszAuthUrl, tszMsgBuffer, &nCode, &ptszAuthBuffer, &nLen)) |
116 | | -#endif |
| 210 | + if (!Authorize_APPLocal_Create(lpszFileStr, lpszPasswd)) |
117 | 211 | { |
118 | | - printf("发送投递失败!\n"); |
119 | | - return 0; |
| 212 | + return -1; |
120 | 213 | } |
121 | | -#ifdef XENGINE_AUTHORIZE_CDKEY_CRYPTO |
122 | | - //解密 |
123 | | - memset(tszCodecBuffer, '\0', sizeof(tszCodecBuffer)); |
124 | | - |
125 | | - OPenSsl_XCrypto_Decoder(ptszAuthBuffer, &nLen, tszCodecBuffer, lpszPasswd); |
126 | | - printf("接受到数据,大小:%d,内容:\n%s\n", nLen, tszCodecBuffer); |
127 | | - //你也可以通过授权模块的API函数来读内存,都一回事,这里为了方便直接写了,请求分钟卡,拥有10分钟,也可以写自定义时间格式 |
128 | | - BaseLib_OperatorFile_WriteProfileFromMemory(tszCodecBuffer, nLen, "AuthReg", "tszLeftTime", "10", tszMsgBuffer, &nLen); |
129 | | -#else |
130 | | - printf("接受到数据,大小:%d,内容:\n%s\n", nLen, ptszAuthBuffer); |
131 | | - BaseLib_OperatorFile_WriteProfileFromMemory(ptszAuthBuffer, nLen, "AuthReg", "tszLeftTime", "10", tszMsgBuffer, &nLen); |
132 | | -#endif |
133 | | - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszAuthBuffer); |
134 | | - //3. 验证CDKEY |
135 | | - XCHAR* ptszVerBuffer = NULL; |
136 | | - LPCXSTR lpszVerUrl = _X("http://192.168.1.10:5302/auth/cdkey/ver"); |
137 | | - |
138 | | - XENGINE_AUTHORIZE_LOCAL st_Authorize; |
139 | | - memset(&st_Authorize, '\0', sizeof(XENGINE_AUTHORIZE_LOCAL)); |
140 | | - |
141 | | -#ifdef XENGINE_AUTHORIZE_CDKEY_CRYPTO |
142 | | -//加密 |
143 | | - memset(tszCodecBuffer, '\0', sizeof(tszCodecBuffer)); |
144 | | - OPenSsl_XCrypto_Encoder(tszMsgBuffer, &nLen, (XBYTE*)tszCodecBuffer, lpszPasswd); |
145 | | - if (!APIClient_Http_Request(_X("POST"), lpszVerUrl, tszCodecBuffer, &nCode, &ptszVerBuffer, &nLen)) |
146 | | -#else |
147 | | - if (!APIClient_Http_Request(_X("POST"), lpszVerUrl, tszMsgBuffer, &nCode, &ptszVerBuffer, &nLen)) |
148 | | -#endif |
| 214 | + Authorize_APPLocal_Auth(lpszFileStr, lpszPasswd); |
| 215 | + |
| 216 | + if (!Authorize_APPLocal_Auth(lpszFileStr, lpszPasswd, tszSerialStr)) |
149 | 217 | { |
150 | | - printf("发送投递失败!\n"); |
151 | | - return 0; |
| 218 | + return -1; |
152 | 219 | } |
153 | | -#ifdef XENGINE_AUTHORIZE_CDKEY_CRYPTO |
154 | | - //解密 |
155 | | - memset(tszCodecBuffer, '\0', sizeof(tszCodecBuffer)); |
156 | 220 |
|
157 | | - OPenSsl_XCrypto_Decoder(ptszVerBuffer, &nLen, tszCodecBuffer, lpszPasswd); |
158 | | - printf("接受到数据,大小:%d,内容:\n%s\n", nLen, tszCodecBuffer); |
159 | | - Authorize_CDKey_ReadMemory(tszCodecBuffer, nLen, &st_Authorize); |
160 | | -#else |
161 | | - printf("接受到数据,大小:%d,内容:\n%s\n", nLen, ptszVerBuffer); |
162 | | - Authorize_CDKey_ReadMemory(ptszVerBuffer, nLen, &st_Authorize); |
163 | | -#endif |
164 | | - BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszVerBuffer); |
165 | | - |
166 | | - //4. 也可以本地验证 |
167 | | - if (Authorize_CDKey_GetLeftTimer(&st_Authorize)) |
| 221 | + for (int i = 0; i < 10; i++) |
168 | 222 | { |
| 223 | + if (!Authorize_APPLocal_Auth(lpszFileStr, lpszPasswd)) |
| 224 | + { |
| 225 | + break; |
| 226 | + } |
169 | 227 | printf("ok\n"); |
170 | 228 | } |
171 | | - else |
172 | | - { |
173 | | - printf("timeout\n"); |
174 | | - } |
175 | 229 | #ifdef _MSC_BUILD |
176 | 230 | WSACleanup(); |
177 | 231 | #endif |
|
0 commit comments