• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "huks_three_stage_test_common.h"
17 #ifndef HUKS_ATTEST_TEST_COMMON_H
18 #define HUKS_ATTEST_TEST_COMMON_H
19 
20 #include <securec.h>
21 
22 #include "native_huks_api.h"
23 #include "huks_mem.h"
24 #include "native_huks_param.h"
25 #include "native_huks_type.h"
26 
27 enum ParamType {
28     IDS_PARAM,
29     NON_IDS_PARAM,
30 };
31 
32 struct HksTestCertChain {
33     bool certChainExist;
34     bool certCountValid;
35     bool certDataExist;
36     uint32_t certDataSize;
37 };
38 
39 static uint32_t g_size = 4096;
40 static uint32_t CERT_COUNT = 4;
41 
42 namespace Unittest::AttestKey {
43 #define SEC_INFO_DATA "hi_security_level_info"
44 #define CHALLENGE_DATA "hi_challenge_data"
45 #define VERSION_DATA "hi_os_version_data"
46 #define ALIAS "testKey"
47 #define UDID_DATA "hi_udid_data"
48 #define SN_DATA "hi_sn_data"
49 #define DEVICE_ID "test_device_id"
50 
51 void FreeCertChain(struct OH_Huks_CertChain **certChain, const uint32_t pos);
52 
53 OH_Huks_Result TestGenerateKey(const struct OH_Huks_Blob *keyAlias);
54 
55 int32_t ConstructDataToCertChain(struct OH_Huks_CertChain **certChain,
56     const struct HksTestCertChain *certChainParam);
57 
58 OH_Huks_Result GenerateParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param tmpParams[], uint32_t paramCount);
59 
60 OH_Huks_Result ValidateCertChainTest(const struct OH_Huks_CertChain *certChain, const struct OH_Huks_Param tmpParam[],
61     ParamType type);
62 }
63 
64 #endif
65