• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #ifndef IAM_COMMON_IMPL_TEST_H
17 #define IAM_COMMON_IMPL_TEST_H
18 
19 #include "attribute.h"
20 #include "executor_func_common.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif // __cplusplus
25 
GetAuthFwkExtraInfo(uint64_t scheduleId,KeyPair * keyPair,uint8_t * challenge,uint8_t challengeSize)26 Buffer *GetAuthFwkExtraInfo(uint64_t scheduleId, KeyPair *keyPair, uint8_t *challenge, uint8_t challengeSize)
27 {
28     Attribute *data = GetAttributeDataBase(scheduleId, REMOTE_PIN_MSG_NONE);
29     if (data == NULL) {
30         return NULL;
31     }
32 
33     Uint8Array uint8Array = {
34         .data = challenge,
35         .len = challengeSize,
36     };
37     if (SetAttributeUint8Array(data, ATTR_CHALLENGE, uint8Array) != RESULT_SUCCESS) {
38         FreeAttribute(&data);
39         return NULL;
40     }
41 
42     Buffer *msg = CreateBufferBySize(MAX_EXECUTOR_MSG_LEN);
43     if (msg == NULL) {
44         FreeAttribute(&data);
45         return NULL;
46     }
47     msg->contentSize = msg->maxSize;
48     if (FormatTlvMsg(data, keyPair, msg->buf, &(msg->contentSize)) != RESULT_SUCCESS) {
49         FreeAttribute(&data);
50         DestroyBuffer(msg);
51         return NULL;
52     }
53 
54     FreeAttribute(&data);
55     return msg;
56 }
57 
58 #ifdef __cplusplus
59 }
60 #endif // __cplusplus
61 #endif // IAM_COMMON_IMPL_TEST_H
62