1 /*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <string.h>
17 #include <securec.h>
18 #include <math.h>
19 #include "pthread.h"
20 #include "time.h"
21 #include "attest_type.h"
22 #include "attest_utils.h"
23 #include "attest_utils_memleak.h"
24 #include "attest_utils_log.h"
25 #include "attest_security_token.h"
26 #include "attest_security_ticket.h"
27 #include "attest_adapter.h"
28 #include "attest_adapter_mock.h"
29 #include "attest_service_auth.h"
30 #include "attest_service_reset.h"
31 #include "attest_service_active.h"
32 #include "attest_service_device.h"
33 #include "attest_service_challenge.h"
34 #include "attest_network.h"
35 #include "attest_service.h"
36 #include "cJSON.h"
37 #include "attest_utils_json.h"
38
39 pthread_mutex_t g_mtxAttest = PTHREAD_MUTEX_INITIALIZER;
40 pthread_mutex_t g_authStatusMutex;
41 static uint8_t g_authResultCode = 2;
42
GetAuthResultCode(void)43 static int32_t GetAuthResultCode(void)
44 {
45 int32_t ret;
46 pthread_mutex_lock(&g_authStatusMutex);
47 AttestReadAuthResultCode((char*)&g_authResultCode, 1);
48 ret = g_authResultCode;
49 pthread_mutex_unlock(&g_authStatusMutex);
50 return ret;
51 }
52
UpdateAuthResultCode(uint8_t authResultCode)53 static void UpdateAuthResultCode(uint8_t authResultCode)
54 {
55 pthread_mutex_lock(&g_authStatusMutex);
56 AttestWriteAuthResultCode((char*)&authResultCode, 1);
57 g_authResultCode = authResultCode;
58 pthread_mutex_unlock(&g_authStatusMutex);
59 }
60
RecordFullLoadStatus(bool isCreate,double curHour,double number)61 static int32_t RecordFullLoadStatus(bool isCreate, double curHour, double number)
62 {
63 double curNumber = number;
64 if (isCreate) {
65 curNumber = 1;
66 }
67
68 cJSON *root = cJSON_CreateObject();
69 if (cJSON_AddNumberToObject(root, "Hour", curHour) == NULL ||\
70 cJSON_AddNumberToObject(root, "Number", curNumber) == NULL) {
71 ATTEST_LOG_ERROR("[RecordFullLoadStatus] Failed to add");
72 cJSON_Delete(root);
73 return ATTEST_ERR;
74 }
75
76 char *data = cJSON_PrintUnformatted(root);
77 cJSON_Delete(root);
78 int32_t ret = AttestWriteFullLoadStatus(data, strlen(data));
79 ATTEST_MEM_FREE(data);
80 return ret;
81 }
82
IsFullLoad(void)83 static int32_t IsFullLoad(void)
84 {
85 time_t timet;
86 (void)time(&timet);
87 struct tm* timePacket = gmtime(&timet);
88 if (timePacket == NULL) {
89 ATTEST_LOG_ERROR("[IsFullLoad] Failed to get time");
90 return ATTEST_ERR;
91 }
92 int32_t curHour = timePacket->tm_mday * 24 + timePacket->tm_hour;
93
94 char data[MAX_ATTEST_FULL_LOAD_STATUS_LEN + 1] = {0};
95 int32_t ret = AttestReadFullLoadStatus(data, MAX_ATTEST_FULL_LOAD_STATUS_LEN);
96 if (ret != ATTEST_OK) {
97 return RecordFullLoadStatus(true, curHour, ATTEST_OK);
98 }
99
100 double recordHour = GetObjectItemValueNumber(data, "Hour");
101 if (isnan(recordHour)) {
102 ATTEST_LOG_ERROR("[IsFullLoad] recordHour is nan.");
103 return ATTEST_ERR;
104 }
105 double recordNumber = GetObjectItemValueNumber(data, "Number");
106 if (isnan(recordNumber)) {
107 ATTEST_LOG_ERROR("[IsFullLoad] recordNumber is nan.");
108 return ATTEST_ERR;
109 }
110 if ((recordHour == (double)curHour) && (recordNumber >= MAX_ATTEST_FULL_LOAD_STATUS_TIMES)) {
111 ATTEST_LOG_ERROR("[IsFullLoad] Full load limit");
112 return ATTEST_ERR;
113 } else if (recordHour == (double)curHour) {
114 ret = RecordFullLoadStatus(false, curHour, recordNumber + 1);
115 } else {
116 ret = RecordFullLoadStatus(false, curHour, 1);
117 }
118 return ret;
119 }
120
ResetDevice(void)121 static int32_t ResetDevice(void)
122 {
123 ATTEST_LOG_DEBUG("[ResetDevice] Begin.");
124 int32_t ret = ATTEST_OK;
125 ChallengeResult* challenge = NULL;
126 DevicePacket* reqMsg = NULL;
127 char* respMsg = NULL;
128 do {
129 ATTEST_LOG_DEBUG("[ResetDevice] Get challenge begin.");
130 ret = GetChallenge(&challenge, ATTEST_ACTION_RESET);
131 if (ret != ATTEST_OK) {
132 ATTEST_LOG_ERROR("[ResetDevice] Get challenge failed, ret = %d.", ret);
133 break;
134 }
135 ATTEST_LOG_DEBUG("[ResetDevice] Generate challenge begin.");
136 ret = GenResetMsg(challenge, &reqMsg);
137 if (ret != ATTEST_OK) {
138 ATTEST_LOG_ERROR("[ResetDevice] Generate reset request message failed, ret = %d.", ret);
139 break;
140 }
141 ATTEST_LOG_DEBUG("[ResetDevice] Send reset msg begin.");
142 ret = SendResetMsg(reqMsg, &respMsg);
143 if (ret != ATTEST_OK) {
144 ATTEST_LOG_ERROR("[ResetDevice] Send reset request message failed, ret = %d.", ret);
145 break;
146 }
147 ATTEST_LOG_DEBUG("[ResetDevice] Parse reset msg begin.");
148 ret = ParseResetResult((const char*)respMsg);
149 if (ret != ATTEST_OK) {
150 ATTEST_LOG_ERROR("[ResetDevice] Parse reset result message failed, ret = %d.", ret);
151 break;
152 }
153 }while (0);
154 FREE_CHALLENGE_RESULT(challenge);
155 FREE_DEVICE_PACKET(reqMsg);
156 ATTEST_MEM_FREE(respMsg);
157 ATTEST_LOG_DEBUG("[ResetDevice] End.");
158 return ret;
159 }
160
AuthDevice(AuthResult * authResult)161 static int32_t AuthDevice(AuthResult* authResult)
162 {
163 ATTEST_LOG_DEBUG("[AuthDevice] Begin.");
164 if (authResult == NULL) {
165 ATTEST_LOG_ERROR("[AuthDevice] Invalid parameter");
166 return ATTEST_ERR;
167 }
168
169 int32_t ret;
170 ChallengeResult* challenge = NULL;
171 DevicePacket* reqMsg = NULL;
172 char* respMsg = NULL;
173 do {
174 ATTEST_LOG_DEBUG("[AuthDevice] Get challenge begin.");
175 ret = GetChallenge(&challenge, ATTEST_ACTION_AUTHORIZE);
176 if (ret != ATTEST_OK) {
177 ATTEST_LOG_ERROR("[AuthDevice] Get challenge ret = %d.", ret);
178 break;
179 }
180 ATTEST_LOG_DEBUG("[AuthDevice] Generate challenge begin.");
181 ret = GenAuthMsg(challenge, &reqMsg);
182 if (ret != ATTEST_OK) {
183 ATTEST_LOG_ERROR("[AuthDevice] Generate auth request message failed, ret = %d.", ret);
184 break;
185 }
186 ATTEST_LOG_DEBUG("[AuthDevice] Send auth msg begin.");
187 ret = SendAuthMsg(reqMsg, &respMsg);
188 if (ret != ATTEST_OK) {
189 ATTEST_LOG_ERROR("[AuthDevice] Send auth request message failed, ret = %d.", ret);
190 break;
191 }
192 ATTEST_LOG_DEBUG("[AuthDevice] Parse auth msg begin.");
193 ret = ParseAuthResultResp(respMsg, authResult);
194 if (ret != ATTEST_OK) {
195 ATTEST_LOG_ERROR("[AuthDevice] Parse auth result message failed, ret = %d.", ret);
196 break;
197 }
198 }while (0);
199 FREE_CHALLENGE_RESULT(challenge);
200 FREE_DEVICE_PACKET(reqMsg);
201 ATTEST_MEM_FREE(respMsg);
202 ATTEST_LOG_DEBUG("[AuthDevice] End.");
203 return ret;
204 }
205
ActiveToken(AuthResult * authResult)206 static int32_t ActiveToken(AuthResult* authResult)
207 {
208 ATTEST_LOG_DEBUG("[ActiveToken] Begin.");
209 if (authResult == NULL) {
210 ATTEST_LOG_ERROR("[ActiveToken] Invalid parameter");
211 return ATTEST_ERR;
212 }
213
214 int32_t ret = FlushToken(authResult);
215 if (ret != ATTEST_OK) {
216 ATTEST_LOG_ERROR("[ActiveToken] Flush Token failed, ret = %d.", ret);
217 return ATTEST_ERR;
218 }
219
220 ChallengeResult* challenge = NULL;
221 DevicePacket* reqMsg = NULL;
222 char* respMsg = NULL;
223 do {
224 ATTEST_LOG_DEBUG("[ActiveToken] Get challenge begin.");
225 ret = GetChallenge(&challenge, ATTEST_ACTION_ACTIVATE);
226 if (ret != ATTEST_OK) {
227 ATTEST_LOG_ERROR("[ActiveToken] Get challenge ret = %d.", ret);
228 break;
229 }
230 ATTEST_LOG_DEBUG("[ActiveToken] Generate active request message begin.");
231 ret = GenActiveMsg(authResult, (const ChallengeResult*)challenge, &reqMsg);
232 if (ret != ATTEST_OK) {
233 ATTEST_LOG_ERROR("[ActiveToken] Generate active request message failed, ret = %d.", ret);
234 break;
235 }
236 ATTEST_LOG_DEBUG("[ActiveToken] Send active request message begin.");
237 ret = SendActiveMsg(reqMsg, &respMsg);
238 if (ret != ATTEST_OK) {
239 ATTEST_LOG_ERROR("[ActiveToken] Send active request message failed, ret = %d.", ret);
240 break;
241 }
242 ATTEST_LOG_DEBUG("[ActiveToken] Parse active request message begin.");
243 ret = ParseActiveResult(respMsg);
244 if (ret != ATTEST_OK) {
245 ATTEST_LOG_ERROR("[ActiveToken] Parse active result message failed, ret = %d.", ret);
246 break;
247 }
248 }while (0);
249 FREE_CHALLENGE_RESULT(challenge);
250 FREE_DEVICE_PACKET(reqMsg);
251 ATTEST_MEM_FREE(respMsg);
252 ATTEST_LOG_DEBUG("[ActiveToken] End.");
253 return ret;
254 }
255
FlushAttestData(const char * ticket,const char * authStatus)256 static void FlushAttestData(const char* ticket, const char* authStatus)
257 {
258 // ticket is not always need to write, and we don't care about writing it succeed or not.
259 if (authStatus == NULL) {
260 ATTEST_LOG_ERROR("[FlushAttestData] Invalid parameter");
261 return;
262 }
263
264 // 结果保存到本地
265 if (FlushAuthResult(ticket, authStatus) != ATTEST_OK) {
266 ATTEST_LOG_WARN("[FlushAttestData] Flush auth result failed");
267 }
268 // 结果保存到启动子系统parameter,方便展示
269 if (FlushAttestStatusPara(authStatus) != ATTEST_OK) {
270 ATTEST_LOG_WARN("[FlushAttestData] Flush attest para failed");
271 }
272 }
273
AttestStartup(AuthResult * authResult)274 static int32_t AttestStartup(AuthResult *authResult)
275 {
276 if (authResult == NULL) {
277 ATTEST_LOG_ERROR("[AttestStartup] Invalid parameter");
278 return ATTEST_ERR;
279 }
280 int32_t ret = ATTEST_OK;
281 // 重置设备
282 ATTEST_LOG_INFO("[AttestStartup] Reset device.");
283 if (!AttestIsResetFlagExist()) {
284 for (int32_t i = 0; i <= WISE_RETRY_CNT; i++) {
285 ret = ResetDevice();
286 if (!IS_WISE_RETRY(-ret)) {
287 break;
288 }
289 }
290 if (ret == ATTEST_OK) {
291 AttestCreateResetFlag();
292 }
293 }
294 // token认证
295 ATTEST_LOG_INFO("[AttestStartup] Auth device.");
296 for (int32_t i = 0; i <= WISE_RETRY_CNT; i++) {
297 ret = AuthDevice(authResult);
298 if (!IS_WISE_RETRY(-ret)) {
299 break;
300 }
301 }
302 if (ret != ATTEST_OK) {
303 UpdateAuthResultCode(AUTH_FAILED);
304 AttestSetParameter(STARTSUP_PARA_ATTEST_KEY, STARTSUP_PARA_ATTEST_ERROR);
305 ATTEST_LOG_ERROR("[AttestStartup] Auth token failed, ret = %d.", ret);
306 return ATTEST_ERR;
307 }
308 // 保存结果
309 ATTEST_LOG_INFO("[AttestStartup] Flush auth result.");
310 FlushAttestData(authResult->ticket, authResult->authStatus);
311 UpdateAuthResultCode(AUTH_SUCCESS);
312 AttestCreateResetFlag();
313 // token激活
314 ATTEST_LOG_INFO("[AttestStartup] Active token.");
315 for (int32_t i = 0; i <= WISE_RETRY_CNT; i++) {
316 ret = ActiveToken(authResult);
317 if (!IS_WISE_RETRY(-ret)) {
318 break;
319 }
320 }
321 if (ret != ATTEST_OK) {
322 ATTEST_LOG_ERROR("[AttestStartup] Active token failed, ret = %d.", ret);
323 return ATTEST_ERR;
324 }
325 return ATTEST_OK;
326 }
327
ProcAttestImpl(void)328 static int32_t ProcAttestImpl(void)
329 {
330 // 初始化系统参数
331 int32_t ret = InitSysData();
332 if (ret != ATTEST_OK) {
333 ATTEST_LOG_ERROR("[ProcAttestImpl] Init system device param failed, ret = %d.", ret);
334 DestroySysData();
335 return ATTEST_ERR;
336 }
337 // 检查本地数据是否修改或过期,进行重新验证
338 if (!IsAuthStatusChg()) {
339 ATTEST_LOG_WARN("[ProcAttestImpl] There is no change on auth status.");
340 UpdateAuthResultCode(AUTH_SUCCESS);
341 DestroySysData();
342 return ATTEST_OK;
343 }
344 AuthResult *authResult = CreateAuthResult();
345 if (authResult == NULL) {
346 ATTEST_LOG_ERROR("[ProcAttestImpl] Create auth result failed");
347 DestroySysData();
348 return ATTEST_ERR;
349 }
350 // 走授权验证流程
351 ret = AttestStartup(authResult);
352 DestroySysData();
353 DestroyAuthResult(&authResult);
354 return ret;
355 }
356
ProcAttest(void)357 int32_t ProcAttest(void)
358 {
359 pthread_mutex_lock(&g_mtxAttest);
360 PrintCurrentTime();
361 int32_t ret = 0;
362 int32_t retValue;
363 if (ATTEST_DEBUG_MEMORY_LEAK) {
364 retValue = InitMemNodeList();
365 ATTEST_LOG_INFO("[ProcAttest] Init mem node list, retValue = %d.", retValue);
366 }
367 do {
368 if (ret == 0) {
369 break;
370 }
371 ret = IsFullLoad();
372 if (ret != ATTEST_OK) {
373 ATTEST_LOG_ERROR("[ProcAttest] Process stopped, ret = %d.", ret);
374 break;
375 }
376
377 // init network server info
378 ret = InitNetworkServerInfo();
379 if (ret != ATTEST_OK) {
380 ATTEST_LOG_ERROR("[ProcAttest] InitNetworkServerInfo failed, ret = %d.", ret);
381 }
382
383 // 主流程
384 ret = ProcAttestImpl();
385 if (ret != ATTEST_OK) {
386 ATTEST_LOG_ERROR("[ProcAttest] Proc Attest failed, ret = %d.", ret);
387 }
388 } while (0);
389 if (ATTEST_DEBUG_MEMORY_LEAK) {
390 PrintMemNodeList();
391 retValue = DestroyMemNodeList();
392 ATTEST_LOG_INFO("[ProcAttest] Destroy mem node list, retValue = %d.", retValue);
393 }
394 PrintCurrentTime();
395 pthread_mutex_unlock(&g_mtxAttest);
396 return ret;
397 }
398
AttestStatusTrans(int32_t attestStatus)399 static int32_t AttestStatusTrans(int32_t attestStatus)
400 {
401 if (attestStatus == DEVICE_ATTEST_INIT) {
402 return DEVICE_ATTEST_INIT;
403 }
404 return (attestStatus == DEVICE_ATTEST_PASS) ? DEVICE_ATTEST_PASS : DEVICE_ATTEST_FAIL;
405 }
406
CopyResultArray(AuthStatus * authStatus,int32_t ** resultArray)407 static int32_t CopyResultArray(AuthStatus* authStatus, int32_t** resultArray)
408 {
409 if (authStatus == NULL || resultArray == NULL) {
410 return ATTEST_ERR;
411 }
412 int32_t *head = *resultArray;
413 head[ATTEST_RESULT_AUTH] = AttestStatusTrans(authStatus->hardwareResult);
414 head[ATTEST_RESULT_SOFTWARE] = AttestStatusTrans(authStatus->softwareResult);
415 SoftwareResultDetail *softwareResultDetail = (SoftwareResultDetail *)authStatus->softwareResultDetail;
416 if (softwareResultDetail == NULL) {
417 ATTEST_LOG_ERROR("[CopyResultArray] failed to get softwareResultDetail");
418 return ATTEST_ERR;
419 }
420 head[ATTEST_RESULT_VERSIONID] = AttestStatusTrans(softwareResultDetail->versionIdResult);
421 head[ATTEST_RESULT_PATCHLEVEL] = AttestStatusTrans(softwareResultDetail->patchLevelResult);
422 head[ATTEST_RESULT_ROOTHASH] = AttestStatusTrans(softwareResultDetail->rootHashResult);
423 head[ATTEST_RESULT_PCID] = AttestStatusTrans(softwareResultDetail->pcidResult);
424 head[ATTEST_RESULT_RESERVE] = DEVICE_ATTEST_INIT; // Always equal to DEVICE_ATTEST_INIT
425 return ATTEST_OK;
426 }
427
SetAttestResultArray(int32_t ** resultArray,int32_t value)428 static int32_t SetAttestResultArray(int32_t** resultArray, int32_t value)
429 {
430 if (resultArray == NULL) {
431 return ATTEST_ERR;
432 }
433 int32_t *head = *resultArray;
434 for (int32_t i = 0; i < ATTEST_RESULT_MAX; i++) {
435 head[i] = value;
436 }
437 head[ATTEST_RESULT_RESERVE] = DEVICE_ATTEST_INIT; // Always equal to DEVICE_ATTEST_INIT
438 return ATTEST_OK;
439 }
440
SetAttestStatusDefault(int32_t ** resultArray,char ** ticket,int32_t * ticketLength)441 static int32_t SetAttestStatusDefault(int32_t** resultArray, char** ticket, int32_t* ticketLength)
442 {
443 int32_t ret = SetAttestResultArray(resultArray, DEVICE_ATTEST_INIT);
444 *ticket = "";
445 *ticketLength = 0;
446 return ret;
447 }
448
SetAttestStatusFailed(int32_t ** resultArray,char ** ticket,int32_t * ticketLength)449 static int32_t SetAttestStatusFailed(int32_t** resultArray, char** ticket, int32_t* ticketLength)
450 {
451 int32_t ret = SetAttestResultArray(resultArray, DEVICE_ATTEST_FAIL);
452 *ticket = "";
453 *ticketLength = 0;
454 return ret;
455 }
456
SetAttestStatusSucc(int32_t ** resultArray,char ** ticket,int32_t * ticketLength)457 static int32_t SetAttestStatusSucc(int32_t** resultArray, char** ticket, int32_t* ticketLength)
458 {
459 char* authStatusBase64 = NULL;
460 AuthStatus* authStatus = CreateAuthStatus();
461 int32_t ret = ATTEST_OK;
462 do {
463 *ticket = "";
464 *ticketLength = 0;
465 // 获取认证结果
466 if (GetAuthStatus(&authStatusBase64) != ATTEST_OK) {
467 ATTEST_LOG_ERROR("[SetAttestStatusSucc] Load Auth Status failed, auth file not exist");
468 ret = ATTEST_ERR;
469 break;
470 }
471 if (DecodeAuthStatus((const char*)authStatusBase64, authStatus) != ATTEST_OK) {
472 ATTEST_LOG_ERROR("[SetAttestStatusSucc] Decode Auth Status failed");
473 ret = ATTEST_ERR;
474 break;
475 }
476 if (authStatus->hardwareResult != 0) {
477 break;
478 }
479 // 获取token
480 char* decryptedTicket = (char *)ATTEST_MEM_MALLOC(MAX_TICKET_LEN + 1);
481 if (decryptedTicket == NULL) {
482 ATTEST_LOG_ERROR("[SetAttestStatusSucc] buff malloc memory failed");
483 ret = ATTEST_ERR;
484 break;
485 }
486 if (ReadTicketFromDevice(decryptedTicket, MAX_TICKET_LEN) != ATTEST_OK) {
487 ATTEST_LOG_ERROR("[SetAttestStatusSucc] read ticket from device failed");
488 ATTEST_MEM_FREE(decryptedTicket);
489 ret = ATTEST_ERR;
490 break;
491 }
492 *ticket = decryptedTicket;
493 *ticketLength = strlen(*ticket);
494 } while (0);
495 ATTEST_MEM_FREE(authStatusBase64);
496 if (ret != ATTEST_OK) {
497 DestroyAuthStatus(&authStatus);
498 return ret;
499 }
500 ret = CopyResultArray(authStatus, resultArray);
501 DestroyAuthStatus(&authStatus);
502 return ret;
503 }
504
QueryAttestStatusSwitch(int32_t ** resultArray,int32_t arraySize,char ** ticket,int32_t * ticketLength)505 static int32_t QueryAttestStatusSwitch(int32_t** resultArray, int32_t arraySize, char** ticket, int32_t* ticketLength)
506 {
507 if (resultArray == NULL || arraySize != ATTEST_RESULT_MAX || ticket == NULL) {
508 ATTEST_LOG_ERROR("[QueryAttestStatusSwitch] parameter wrong");
509 return ATTEST_ERR;
510 }
511
512 int32_t ret = ATTEST_ERR;
513 int32_t authResultCode = GetAuthResultCode();
514 switch (authResultCode) {
515 case (AUTH_UNKNOWN):
516 ret = SetAttestStatusDefault(resultArray, ticket, ticketLength);
517 ATTEST_LOG_INFO("[QueryAttestStatusSwitch] authResultCode is 2, ret = %d", ret);
518 break;
519 case (AUTH_FAILED):
520 ret = SetAttestStatusFailed(resultArray, ticket, ticketLength);
521 ATTEST_LOG_INFO("[QueryAttestStatusSwitch] authResultCode is 1, ret = %d", ret);
522 break;
523 case (AUTH_SUCCESS):
524 ret = SetAttestStatusSucc(resultArray, ticket, ticketLength);
525 ATTEST_LOG_INFO("[QueryAttestStatusSwitch] authResultCode is 0, ret = %d", ret);
526 break;
527 default:
528 ATTEST_LOG_WARN("[QueryAttestStatusSwitch] authResultCode is invalid");
529 break;
530 }
531 return ret;
532 }
533
QueryAttestStatus(int32_t ** resultArray,int32_t arraySize,char ** ticket,int32_t * ticketLength)534 int32_t QueryAttestStatus(int32_t** resultArray, int32_t arraySize, char** ticket, int32_t* ticketLength)
535 {
536 pthread_mutex_lock(&g_mtxAttest);
537 int32_t ret = QueryAttestStatusSwitch(resultArray, arraySize, ticket, ticketLength);
538 if (ret != ATTEST_OK) {
539 ATTEST_LOG_ERROR("[QueryAttestStatus] failed ret = %d.", ret);
540 }
541 pthread_mutex_unlock(&g_mtxAttest);
542 return ret;
543 }
544
AttestWaitTaskOverImpl(void)545 int32_t AttestWaitTaskOverImpl(void)
546 {
547 pthread_mutex_lock(&g_mtxAttest);
548 int32_t ret = ATTEST_OK;
549 pthread_mutex_unlock(&g_mtxAttest);
550 return ret;
551 }