• 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 #ifndef CM_TEST_COMMON_H
17 #define CM_TEST_COMMON_H
18 
19 #include "cm_type.h"
20 #include "securec.h"
21 
22 #include  <string>
23 
24 #define PERFORMACE_COUNT 10
25 
26 #define DELIMITER "$$$"
27 #define ENDOF  "\n"
28 
29 constexpr uint32_t CERT_KEY_ALG_RSA = 1;
30 constexpr uint32_t CERT_KEY_ALG_ECC = 2;
31 constexpr uint32_t CERT_KEY_ALG_RSA_512 = 3;
32 constexpr uint32_t CERT_KEY_ALG_RSA_1024 = 4;
33 constexpr uint32_t CERT_KEY_ALG_RSA_3072 = 5;
34 constexpr uint32_t CERT_KEY_ALG_RSA_4096 = 6;
35 constexpr uint32_t CERT_KEY_ALG_ECC_P224 = 7;
36 constexpr uint32_t CERT_KEY_ALG_ECC_P384 = 8;
37 constexpr uint32_t CERT_KEY_ALG_ECC_P521 = 9;
38 constexpr uint32_t CERT_KEY_ALG_ED25519 = 10;
39 
40 namespace CertmanagerTest {
41 void FreeCMBlobData(struct CmBlob *blob);
42 
43 void FreeCertList(struct CertList *certList);
44 
45 bool CompareCertInfo(const struct CertInfo *firstCert, const struct CertInfo *secondCert);
46 
47 bool CompareCertData(const struct CmBlob *firstData, const struct CmBlob *secondData);
48 
49 bool CompareCredential(const struct Credential *firstCredential, const struct Credential *secondCredential);
50 
51 bool CompareCredentialList(const struct CredentialAbstract *firstCert, const struct CredentialAbstract *secondCert);
52 
53 int32_t TestGenerateAppCert(const struct CmBlob *alias, uint32_t alg, uint32_t store);
54 
55 std::string DumpCertAbstractInfo(const struct CertAbstract *certAbstract);
56 std::string DumpCertInfo(const struct CertInfo* certInfo);
57 std::string DumpCertList(struct CertList *certList);
58 
59 void SetATPermission(void);
60 
61 int32_t InitCertList(struct CertList **cList);
62 
63 int32_t InitUserCertInfo(struct CertInfo **cInfo);
64 
65 int32_t InitCertInfo(struct CertInfo *certInfo);
66 
67 bool FindCertAbstract(const struct CertAbstract *abstract, const struct CertList *cList);
68 
69 void FreeCertInfo(struct CertInfo *cInfo);
70 }
71 #endif /* CM_TEST_COMMON_H */
72