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 "executor_message.h"
17
18 #include "securec.h"
19 #include "adaptor_algorithm.h"
20 #include "adaptor_log.h"
21 #include "coauth.h"
22 #include "tlv_wrapper.h"
23 #include "adaptor_memory.h"
24 #include "adaptor_time.h"
25 #include "ed25519_key.h"
26 #include "idm_database.h"
27
28 static bool IsExecutorInfoValid(const ExecutorResultInfo *executorResultInfo, const Buffer *data, const Buffer *sign);
29 static Buffer *CreateExecutorMsg(uint32_t authType, uint32_t authPropertyMode, const TemplateIdArrays *templateIds);
30
ParseExecutorResultRemainTime(ExecutorResultInfo * result,TlvListNode * body)31 static ResultCode ParseExecutorResultRemainTime(ExecutorResultInfo *result, TlvListNode *body)
32 {
33 int32_t ret = GetInt32Para(body, AUTH_REMAIN_COUNT, &result->remainTimes);
34 if (ret != OPERA_SUCC) {
35 LOG_ERROR("parse remainTimes failed, ret is %{public}d", ret);
36 return RESULT_GENERAL_ERROR;
37 }
38 return RESULT_SUCCESS;
39 }
40
ParseExecutorResultFreezingTime(ExecutorResultInfo * result,TlvListNode * body)41 static ResultCode ParseExecutorResultFreezingTime(ExecutorResultInfo *result, TlvListNode *body)
42 {
43 int32_t ret = GetInt32Para(body, AUTH_REMAIN_TIME, &result->freezingTime);
44 if (ret != OPERA_SUCC) {
45 LOG_ERROR("parse freezingTime failed, ret is %{public}d", ret);
46 return RESULT_GENERAL_ERROR;
47 }
48 return RESULT_SUCCESS;
49 }
50
ParseExecutorResultAcl(ExecutorResultInfo * result,TlvListNode * body)51 static ResultCode ParseExecutorResultAcl(ExecutorResultInfo *result, TlvListNode *body)
52 {
53 int32_t ret = GetUint32Para(body, AUTH_CAPABILITY_LEVEL, &result->capabilityLevel);
54 if (ret != OPERA_SUCC) {
55 LOG_ERROR("parse capabilityLevel failed, ret is %{public}d", ret);
56 return RESULT_GENERAL_ERROR;
57 }
58 return RESULT_SUCCESS;
59 }
60
ParseExecutorResultTemplateId(ExecutorResultInfo * result,TlvListNode * body)61 static ResultCode ParseExecutorResultTemplateId(ExecutorResultInfo *result, TlvListNode *body)
62 {
63 int32_t ret = GetUint64Para(body, AUTH_TEMPLATE_ID, &result->templateId);
64 if (ret != OPERA_SUCC) {
65 LOG_ERROR("parse templateId failed, ret is %{public}d", ret);
66 return RESULT_GENERAL_ERROR;
67 }
68 return RESULT_SUCCESS;
69 }
70
ParseExecutorResultScheduleId(ExecutorResultInfo * result,TlvListNode * body)71 static ResultCode ParseExecutorResultScheduleId(ExecutorResultInfo *result, TlvListNode *body)
72 {
73 int32_t ret = GetUint64Para(body, AUTH_SCHEDULE_ID, &result->scheduleId);
74 if (ret != OPERA_SUCC) {
75 LOG_ERROR("parse scheduleId failed, ret is %{public}d", ret);
76 return RESULT_GENERAL_ERROR;
77 }
78 return RESULT_SUCCESS;
79 }
80
ParseExecutorResultCode(ExecutorResultInfo * result,TlvListNode * body)81 static ResultCode ParseExecutorResultCode(ExecutorResultInfo *result, TlvListNode *body)
82 {
83 int32_t ret = GetInt32Para(body, AUTH_RESULT_CODE, &result->result);
84 if (ret != OPERA_SUCC) {
85 LOG_ERROR("parse resultCode failed, ret is %{public}d", ret);
86 return RESULT_GENERAL_ERROR;
87 }
88 return RESULT_SUCCESS;
89 }
90
ParseExecutorResultAuthSubType(ExecutorResultInfo * result,TlvListNode * body)91 static ResultCode ParseExecutorResultAuthSubType(ExecutorResultInfo *result, TlvListNode *body)
92 {
93 int32_t ret = GetUint64Para(body, AUTH_SUBTYPE, &result->authSubType);
94 if (ret != OPERA_SUCC) {
95 LOG_ERROR("parse authSubType failed, ret is %{public}d", ret);
96 return RESULT_GENERAL_ERROR;
97 }
98 return RESULT_SUCCESS;
99 }
100
ParseExecutorResultInfo(const Buffer * data,ExecutorResultInfo * result)101 static ResultCode ParseExecutorResultInfo(const Buffer *data, ExecutorResultInfo *result)
102 {
103 TlvListNode *parseBody = CreateTlvList();
104 if (parseBody == NULL) {
105 LOG_ERROR("parseBody is null");
106 return false;
107 }
108 int ret = ParseTlvWrapper(data->buf, data->contentSize, parseBody);
109 if (ret != RESULT_SUCCESS) {
110 LOG_ERROR("ParseTlvWrapper failed");
111 goto EXIT;
112 }
113 ret = ParseExecutorResultAcl(result, parseBody->next);
114 if (ret != RESULT_SUCCESS) {
115 goto EXIT;
116 }
117 ret = ParseExecutorResultTemplateId(result, parseBody->next);
118 if (ret != RESULT_SUCCESS) {
119 goto EXIT;
120 }
121 ret = ParseExecutorResultAuthSubType(result, parseBody->next);
122 if (ret != RESULT_SUCCESS) {
123 goto EXIT;
124 }
125 ret = ParseExecutorResultCode(result, parseBody->next);
126 if (ret != RESULT_SUCCESS) {
127 goto EXIT;
128 }
129 ret = ParseExecutorResultScheduleId(result, parseBody->next);
130 if (ret != RESULT_SUCCESS) {
131 goto EXIT;
132 }
133 ret = ParseExecutorResultRemainTime(result, parseBody->next);
134 if (ret != RESULT_SUCCESS) {
135 goto EXIT;
136 }
137 ret = ParseExecutorResultFreezingTime(result, parseBody->next);
138 if (ret != RESULT_SUCCESS) {
139 goto EXIT;
140 }
141
142 // Only pin auth can have rootsecret
143 result->rootSecret = GetBuffPara(parseBody->next, AUTH_ROOT_SECRET);
144
145 EXIT:
146 DestroyTlvList(parseBody);
147 return ret;
148 }
149
ParseExecutorResultData(TlvListNode * body)150 static Buffer *ParseExecutorResultData(TlvListNode *body)
151 {
152 Buffer *data = GetBuffPara(body, AUTH_DATA);
153 if (!IsBufferValid(data)) {
154 LOG_ERROR("ParseCoAuthPara data failed");
155 return NULL;
156 }
157 return data;
158 }
159
ParseExecutorResultSign(TlvListNode * body)160 static Buffer *ParseExecutorResultSign(TlvListNode *body)
161 {
162 Buffer *sign = GetBuffPara(body, AUTH_SIGNATURE);
163 if (!IsBufferValid(sign)) {
164 LOG_ERROR("ParseCoAuthPara sign failed");
165 return NULL;
166 }
167 return sign;
168 }
169
ParseRoot(ExecutorResultInfo * result,TlvListNode * body)170 static ResultCode ParseRoot(ExecutorResultInfo *result, TlvListNode *body)
171 {
172 Buffer *msg = GetBuffPara(body, AUTH_ROOT);
173 if (!IsBufferValid(msg)) {
174 LOG_ERROR("parse msg failed");
175 return RESULT_BAD_PARAM;
176 }
177 Buffer *data = NULL;
178 Buffer *sign = NULL;
179 TlvListNode *parseBody = CreateTlvList();
180 if (parseBody == NULL) {
181 LOG_ERROR("parseBody is null");
182 DestoryBuffer(msg);
183 return RESULT_NO_MEMORY;
184 }
185 int32_t ret = ParseTlvWrapper(msg->buf, msg->contentSize, parseBody);
186 if (ret != RESULT_SUCCESS) {
187 LOG_ERROR("parse failed");
188 goto EXIT;
189 }
190 data = ParseExecutorResultData(parseBody->next);
191 if (!IsBufferValid(data)) {
192 LOG_ERROR("parse data failed");
193 ret = RESULT_GENERAL_ERROR;
194 goto EXIT;
195 }
196 ret = ParseExecutorResultInfo(data, result);
197 if (ret != RESULT_SUCCESS) {
198 LOG_ERROR("parse info failed");
199 goto EXIT;
200 }
201 sign = ParseExecutorResultSign(parseBody->next);
202 if (!IsBufferValid(sign)) {
203 LOG_ERROR("parse sign failed");
204 ret = RESULT_GENERAL_ERROR;
205 goto EXIT;
206 }
207 if (!IsExecutorInfoValid(result, data, sign)) {
208 LOG_ERROR("executor info is invalid");
209 ret = RESULT_GENERAL_ERROR;
210 }
211 EXIT:
212 DestoryBuffer(data);
213 DestoryBuffer(sign);
214 DestoryBuffer(msg);
215 DestroyTlvList(parseBody);
216 return ret;
217 }
218
CreateExecutorResultInfo(const Buffer * tlv)219 ExecutorResultInfo *CreateExecutorResultInfo(const Buffer *tlv)
220 {
221 if (!IsBufferValid(tlv)) {
222 LOG_ERROR("param is invalid");
223 return NULL;
224 }
225 TlvListNode *parseBody = CreateTlvList();
226 if (parseBody == NULL) {
227 LOG_ERROR("parseBody is null");
228 return NULL;
229 }
230
231 int ret = ParseTlvWrapper(tlv->buf, tlv->contentSize, parseBody);
232 if (ret != RESULT_SUCCESS) {
233 LOG_ERROR("ParseTlvWrapper failed");
234 DestroyTlvList(parseBody);
235 return NULL;
236 }
237
238 ExecutorResultInfo *result = Malloc(sizeof(ExecutorResultInfo));
239 if (result == NULL) {
240 LOG_ERROR("malloc failed");
241 goto FAIL;
242 }
243 if (memset_s(result, sizeof(ExecutorResultInfo), 0, sizeof(ExecutorResultInfo)) != EOK) {
244 LOG_ERROR("set result failed");
245 goto FAIL;
246 }
247 ret = ParseRoot(result, parseBody->next);
248 if (ret != RESULT_SUCCESS) {
249 LOG_ERROR("ParseExecutorResult failed");
250 goto FAIL;
251 }
252 DestroyTlvList(parseBody);
253 return result;
254
255 FAIL:
256 DestroyTlvList(parseBody);
257 DestoryExecutorResultInfo(result);
258 return NULL;
259 }
260
DestoryExecutorResultInfo(ExecutorResultInfo * result)261 void DestoryExecutorResultInfo(ExecutorResultInfo *result)
262 {
263 if (result == NULL) {
264 return;
265 }
266 if (result->rootSecret != NULL) {
267 DestoryBuffer(result->rootSecret);
268 }
269 Free(result);
270 }
271
IsExecutorInfoValid(const ExecutorResultInfo * executorResultInfo,const Buffer * data,const Buffer * sign)272 static bool IsExecutorInfoValid(const ExecutorResultInfo *executorResultInfo, const Buffer *data, const Buffer *sign)
273 {
274 if (executorResultInfo == NULL) {
275 LOG_ERROR("there is a problem with the data content");
276 return false;
277 }
278 const CoAuthSchedule *currentSchedule = GetCoAuthSchedule(executorResultInfo->scheduleId);
279 if (currentSchedule == NULL) {
280 LOG_ERROR("get schedule info failed");
281 return false;
282 }
283 Buffer *publicKey = NULL;
284 for (uint32_t index = 0; index < currentSchedule->executorSize; ++index) {
285 const ExecutorInfoHal *executor = &((currentSchedule->executors)[index]);
286 if (executor->executorRole == VERIFIER || executor->executorRole == ALL_IN_ONE) {
287 publicKey = CreateBufferByData(executor->pubKey, PUBLIC_KEY_LEN);
288 break;
289 }
290 }
291 if (!IsBufferValid(publicKey)) {
292 LOG_ERROR("get publicKey failed");
293 return false;
294 }
295 ResultCode ret = Ed25519Verify(publicKey, data, sign);
296 if (ret != RESULT_SUCCESS) {
297 LOG_ERROR("verify sign failed");
298 DestoryBuffer(publicKey);
299 return false;
300 }
301 DestoryBuffer(publicKey);
302 return true;
303 }
304
SerializeExecutorMsgData(uint32_t authType,uint32_t propertyMode,const TemplateIdArrays * templateIds)305 static Buffer *SerializeExecutorMsgData(uint32_t authType, uint32_t propertyMode, const TemplateIdArrays *templateIds)
306 {
307 if ((propertyMode != PROPERMODE_UNLOCK && propertyMode != PROPERMODE_LOCK) ||
308 templateIds->num > MAX_TEMPLATE_OF_SCHEDULE) {
309 LOG_ERROR("param is invalid");
310 return NULL;
311 }
312 TlvListNode *parseBody = CreateTlvList();
313 if (parseBody == NULL) {
314 LOG_ERROR("parseBody is null");
315 return NULL;
316 }
317 int32_t ret = TlvAppendObject(parseBody, AUTH_PROPERTY_MODE, (uint8_t *)&propertyMode, sizeof(uint32_t));
318 if (ret != OPERA_SUCC) {
319 LOG_ERROR("append propertyMode failed");
320 goto FAIL;
321 }
322 ret = TlvAppendObject(parseBody, AUTH_TYPE, (uint8_t *)&authType, sizeof(authType));
323 if (ret != OPERA_SUCC) {
324 LOG_ERROR("append authType failed");
325 goto FAIL;
326 }
327 ret = TlvAppendObject(parseBody, AUTH_TEMPLATE_ID_LIST,
328 (uint8_t *)templateIds->value, templateIds->num * sizeof(uint64_t));
329 if (ret != OPERA_SUCC) {
330 LOG_ERROR("append template list failed");
331 goto FAIL;
332 }
333 uint64_t time = GetSystemTime();
334 ret = TlvAppendObject(parseBody, AUTH_TIME_STAMP, (uint8_t *)&time, sizeof(uint64_t));
335 if (ret != OPERA_SUCC) {
336 LOG_ERROR("append time failed");
337 goto FAIL;
338 }
339 Buffer *data = CreateBufferBySize(BUFFER_SIZE);
340 if (!IsBufferValid(data)) {
341 LOG_ERROR("buf is null");
342 goto FAIL;
343 }
344 ret = SerializeTlvWrapper(parseBody, data->buf, data->maxSize, &data->contentSize);
345 if (ret != OPERA_SUCC) {
346 LOG_ERROR("serialize tlv failed");
347 DestoryBuffer(data);
348 goto FAIL;
349 }
350 DestroyTlvList(parseBody);
351 return data;
352
353 FAIL:
354 DestroyTlvList(parseBody);
355 return NULL;
356 }
357
SerializeExecutorMsg(const Buffer * data,const Buffer * signatrue)358 static Buffer *SerializeExecutorMsg(const Buffer *data, const Buffer *signatrue)
359 {
360 TlvListNode *parseBody = CreateTlvList();
361 if (parseBody == NULL) {
362 LOG_ERROR("data parseBody is null");
363 return NULL;
364 }
365 int32_t ret = TlvAppendObject(parseBody, AUTH_DATA, data->buf, data->contentSize);
366 if (ret != OPERA_SUCC) {
367 LOG_ERROR("append auth data failed");
368 goto FAIL;
369 }
370 if (signatrue != NULL) {
371 ret = TlvAppendObject(parseBody, AUTH_SIGNATURE, signatrue->buf, signatrue->contentSize);
372 if (ret != OPERA_SUCC) {
373 LOG_ERROR("append signature failed");
374 goto FAIL;
375 }
376 }
377 Buffer *msgTlvData = CreateBufferBySize(BUFFER_SIZE);
378 if (!IsBufferValid(msgTlvData)) {
379 LOG_ERROR("buf is null");
380 goto FAIL;
381 }
382 ret = SerializeTlvWrapper(parseBody, msgTlvData->buf, msgTlvData->maxSize, &msgTlvData->contentSize);
383 if (ret != OPERA_SUCC) {
384 LOG_ERROR("serialize tlv failed");
385 DestoryBuffer(msgTlvData);
386 goto FAIL;
387 }
388 return msgTlvData;
389
390 FAIL:
391 DestroyTlvList(parseBody);
392 return NULL;
393 }
394
SerializeRootMsg(const Buffer * msg)395 static Buffer *SerializeRootMsg(const Buffer *msg)
396 {
397 TlvListNode *rootParseBody = CreateTlvList();
398 if (rootParseBody == NULL) {
399 LOG_ERROR("rootParseBody is null");
400 return NULL;
401 }
402 int32_t ret = TlvAppendObject(rootParseBody, AUTH_ROOT, msg->buf, msg->contentSize);
403 if (ret != OPERA_SUCC) {
404 LOG_ERROR("append msg failed");
405 DestroyTlvList(rootParseBody);
406 return NULL;
407 }
408 Buffer *rootMsg = CreateBufferBySize(BUFFER_SIZE);
409 if (!IsBufferValid(rootMsg)) {
410 LOG_ERROR("buf is null");
411 DestroyTlvList(rootParseBody);
412 return NULL;
413 }
414 ret = SerializeTlvWrapper(rootParseBody, rootMsg->buf, rootMsg->maxSize, &rootMsg->contentSize);
415 if (ret != OPERA_SUCC) {
416 LOG_ERROR("serialize tlv failed");
417 DestroyTlvList(rootParseBody);
418 DestoryBuffer(rootMsg);
419 return NULL;
420 }
421 DestroyTlvList(rootParseBody);
422 return rootMsg;
423 }
424
CreateExecutorMsg(uint32_t authType,uint32_t authPropertyMode,const TemplateIdArrays * templateIds)425 static Buffer *CreateExecutorMsg(uint32_t authType, uint32_t authPropertyMode, const TemplateIdArrays *templateIds)
426 {
427 if (templateIds == NULL) {
428 LOG_ERROR("templateIds is null");
429 return NULL;
430 }
431
432 Buffer *data = SerializeExecutorMsgData(authType, authPropertyMode, templateIds);
433 if (!IsBufferValid(data)) {
434 LOG_ERROR("data is null");
435 return NULL;
436 }
437 Buffer *signatrue = NULL;
438 if (authPropertyMode == PROPERMODE_UNLOCK) {
439 signatrue = ExecutorMsgSign(data);
440 if (!IsBufferValid(signatrue)) {
441 LOG_ERROR("signature is invalid");
442 DestoryBuffer(data);
443 return NULL;
444 }
445 }
446
447 Buffer *msg = SerializeExecutorMsg(data, signatrue);
448 DestoryBuffer(data);
449 DestoryBuffer(signatrue);
450 if (!IsBufferValid(msg)) {
451 LOG_ERROR("msg is invalid");
452 return NULL;
453 }
454 Buffer *rootMsg = SerializeRootMsg(msg);
455 DestoryBuffer(msg);
456 return rootMsg;
457 }
458
DestoryExecutorMsg(void * data)459 static void DestoryExecutorMsg(void *data)
460 {
461 if (data == NULL) {
462 return;
463 }
464 ExecutorMsg *msg = (ExecutorMsg *)data;
465 DestoryBuffer(msg->msg);
466 Free(msg);
467 }
468
GetExecutorTemplateList(const ExecutorInfoHal * executorNode,TemplateIdArrays * templateIds)469 static ResultCode GetExecutorTemplateList(const ExecutorInfoHal *executorNode, TemplateIdArrays *templateIds)
470 {
471 CredentialCondition condition = {};
472 SetCredentialConditionAuthType(&condition, executorNode->authType);
473 SetCredentialConditionExecutorSensorHint(&condition, executorNode->executorSensorHint);
474 LinkedList *credList = QueryCredentialLimit(&condition);
475 if (credList == NULL) {
476 LOG_ERROR("query credential failed");
477 DestroyLinkedList(credList);
478 return RESULT_UNKNOWN;
479 }
480 uint32_t credListNum = credList->getSize(credList);
481 if (credListNum > MAX_CREDENTIAL) {
482 LOG_ERROR("cred num is invalid");
483 DestroyLinkedList(credList);
484 return RESULT_REACH_LIMIT;
485 }
486 if (credListNum == 0) {
487 templateIds->value = NULL;
488 templateIds->num = 0;
489 DestroyLinkedList(credList);
490 return RESULT_SUCCESS;
491 }
492 templateIds->value = (uint64_t *)Malloc(sizeof(uint64_t) * credListNum);
493 if (templateIds->value == NULL) {
494 LOG_ERROR("value malloc failed");
495 DestroyLinkedList(credList);
496 return RESULT_NO_MEMORY;
497 }
498 templateIds->num = 0;
499 LinkedListNode *temp = credList->head;
500 while (temp != NULL) {
501 if (temp->data == NULL) {
502 LOG_ERROR("link node is invalid");
503 DestroyLinkedList(credList);
504 Free(templateIds->value);
505 templateIds->value = NULL;
506 return RESULT_UNKNOWN;
507 }
508 CredentialInfoHal *credentialHal = (CredentialInfoHal *)temp->data;
509 templateIds->value[templateIds->num] = credentialHal->templateId;
510 ++(templateIds->num);
511 temp = temp->next;
512 }
513 DestroyLinkedList(credList);
514 return RESULT_SUCCESS;
515 }
516
AssemblyMessage(const ExecutorInfoHal * executorNode,uint32_t authPropertyMode,LinkedList * executorMsg)517 static ResultCode AssemblyMessage(const ExecutorInfoHal *executorNode, uint32_t authPropertyMode,
518 LinkedList *executorMsg)
519 {
520 TemplateIdArrays templateIds;
521 ResultCode ret = GetExecutorTemplateList(executorNode, &templateIds);
522 if (ret != RESULT_SUCCESS) {
523 LOG_ERROR("get template list failed");
524 return ret;
525 }
526 if (templateIds.num == 0) {
527 return RESULT_SUCCESS;
528 }
529 ExecutorMsg *msg = (ExecutorMsg *)Malloc(sizeof(ExecutorMsg));
530 if (msg == NULL) {
531 LOG_ERROR("msg is null");
532 Free(templateIds.value);
533 return RESULT_NO_MEMORY;
534 }
535 msg->executorIndex = executorNode->executorIndex;
536 msg->msg = CreateExecutorMsg(executorNode->authType, authPropertyMode, &templateIds);
537 if (msg->msg == NULL) {
538 LOG_ERROR("msg's msg is null");
539 Free(templateIds.value);
540 DestoryExecutorMsg(msg);
541 return RESULT_NO_MEMORY;
542 }
543 ret = executorMsg->insert(executorMsg, msg);
544 if (ret != RESULT_SUCCESS) {
545 LOG_ERROR("insert msg failed");
546 DestoryExecutorMsg(msg);
547 }
548 Free(templateIds.value);
549 return ret;
550 }
551
TraverseExecutor(uint32_t executorRole,uint32_t authPropertyMode,LinkedList * executorMsg)552 static ResultCode TraverseExecutor(uint32_t executorRole, uint32_t authPropertyMode, LinkedList *executorMsg)
553 {
554 ExecutorCondition condition = {};
555 SetExecutorConditionExecutorRole(&condition, executorRole);
556 LinkedList *executors = QueryExecutor(&condition);
557 if (executors == NULL) {
558 LOG_ERROR("query executor failed");
559 return RESULT_UNKNOWN;
560 }
561 LinkedListNode *temp = executors->head;
562 while (temp != NULL) {
563 if (temp->data == NULL) {
564 LOG_ERROR("list node is invalid");
565 DestroyLinkedList(executors);
566 return RESULT_UNKNOWN;
567 }
568 ExecutorInfoHal *executorNode = (ExecutorInfoHal *)temp->data;
569 if (executorNode->authType != PIN_AUTH) {
570 ResultCode ret = AssemblyMessage(executorNode, authPropertyMode, executorMsg);
571 if (ret != RESULT_SUCCESS) {
572 LOG_ERROR("assembly message failed");
573 DestroyLinkedList(executors);
574 return ret;
575 }
576 }
577 temp = temp->next;
578 }
579 DestroyLinkedList(executors);
580 return RESULT_SUCCESS;
581 }
582
GetExecutorMsgList(uint32_t authPropertyMode,LinkedList ** executorMsg)583 ResultCode GetExecutorMsgList(uint32_t authPropertyMode, LinkedList **executorMsg)
584 {
585 if (executorMsg == NULL) {
586 LOG_ERROR("executorMsg is null");
587 return RESULT_BAD_PARAM;
588 }
589 *executorMsg = CreateLinkedList(DestoryExecutorMsg);
590 if (*executorMsg == NULL) {
591 LOG_ERROR("create list failed");
592 return RESULT_NO_MEMORY;
593 }
594 ResultCode ret = TraverseExecutor(VERIFIER, authPropertyMode, *executorMsg);
595 if (ret != RESULT_SUCCESS) {
596 LOG_ERROR("traverse verifier failed");
597 DestroyLinkedList(*executorMsg);
598 *executorMsg = NULL;
599 return ret;
600 }
601 ret = TraverseExecutor(ALL_IN_ONE, authPropertyMode, *executorMsg);
602 if (ret != RESULT_SUCCESS) {
603 LOG_ERROR("traverse allInOne executor failed");
604 DestroyLinkedList(*executorMsg);
605 *executorMsg = NULL;
606 }
607 return ret;
608 }
609