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