• 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 "huks_mem.h"
23 #include "native_huks_api.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 {
44 #define SEC_INFO_DATA "hi_security_level_info"
45 #define CHALLENGE_DATA "hi_challenge_data"
46 #define VERSION_DATA "hi_os_version_data"
47 #define ALIAS "testKey"
48 #define UDID_DATA "hi_udid_data"
49 #define SN_DATA "hi_sn_data"
50 #define DEVICE_ID "test_device_id"
51 
52 void FreeCertChain(struct OH_Huks_CertChain **certChain, const uint32_t pos);
53 
54 OH_Huks_Result TestGenerateKey(const struct OH_Huks_Blob *keyAlias);
55 
56 int32_t ConstructDataToCertChain(struct OH_Huks_CertChain **certChain, const struct HksTestCertChain *certChainParam);
57 
58 OH_Huks_Result GenerateParamSet(struct OH_Huks_ParamSet **paramSet, const struct OH_Huks_Param tmpParams[],
59                                 uint32_t paramCount);
60 
61 OH_Huks_Result ValidateCertChainTest(const struct OH_Huks_CertChain *certChain, const struct OH_Huks_Param tmpParam[],
62                                      ParamType type);
63 }  // namespace Unittest::AttestKey
64 
65 #endif
66