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 constexpr uint32_t TEST_USERID = 100; 40 41 namespace CertmanagerTest { 42 void FreeCMBlobData(struct CmBlob *blob); 43 44 void FreeCertList(struct CertList *certList); 45 46 bool CompareCertInfo(const struct CertInfo *firstCert, const struct CertInfo *secondCert); 47 48 bool CompareCertData(const struct CmBlob *firstData, const struct CmBlob *secondData); 49 50 bool CompareCredential(const struct Credential *firstCredential, const struct Credential *secondCredential); 51 52 bool CompareCredentialList(const struct CredentialAbstract *firstCert, const struct CredentialAbstract *secondCert); 53 54 int32_t TestGenerateAppCert(const struct CmBlob *alias, uint32_t alg, uint32_t store); 55 56 std::string DumpCertAbstractInfo(const struct CertAbstract *certAbstract); 57 std::string DumpCertInfo(const struct CertInfo* certInfo); 58 std::string DumpCertList(struct CertList *certList); 59 60 void SetATPermission(void); 61 62 int32_t InitCertList(struct CertList **cList); 63 64 int32_t InitUserCertInfo(struct CertInfo **cInfo); 65 66 int32_t InitCertInfo(struct CertInfo *certInfo); 67 68 bool FindCertAbstract(const struct CertAbstract *abstract, const struct CertList *cList); 69 70 void FreeCertInfo(struct CertInfo *cInfo); 71 } 72 #endif /* CM_TEST_COMMON_H */ 73