14e56987cSopenharmony_ci/*
24e56987cSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
34e56987cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
44e56987cSopenharmony_ci * you may not use this file except in compliance with the License.
54e56987cSopenharmony_ci * You may obtain a copy of the License at
64e56987cSopenharmony_ci *
74e56987cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
84e56987cSopenharmony_ci *
94e56987cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
104e56987cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
114e56987cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124e56987cSopenharmony_ci * See the License for the specific language governing permissions and
134e56987cSopenharmony_ci * limitations under the License.
144e56987cSopenharmony_ci */
154e56987cSopenharmony_ci
164e56987cSopenharmony_ci#ifndef CM_TEST_COMMON_H
174e56987cSopenharmony_ci#define CM_TEST_COMMON_H
184e56987cSopenharmony_ci
194e56987cSopenharmony_ci#include "cm_type.h"
204e56987cSopenharmony_ci#include "securec.h"
214e56987cSopenharmony_ci
224e56987cSopenharmony_ci#include  <string>
234e56987cSopenharmony_ci
244e56987cSopenharmony_ci#define PERFORMACE_COUNT 10
254e56987cSopenharmony_ci
264e56987cSopenharmony_ci#define DELIMITER "$$$"
274e56987cSopenharmony_ci#define ENDOF  "\n"
284e56987cSopenharmony_ci
294e56987cSopenharmony_ciconstexpr uint32_t CERT_KEY_ALG_RSA = 1;
304e56987cSopenharmony_ciconstexpr uint32_t CERT_KEY_ALG_ECC = 2;
314e56987cSopenharmony_ciconstexpr uint32_t CERT_KEY_ALG_RSA_512 = 3;
324e56987cSopenharmony_ciconstexpr uint32_t CERT_KEY_ALG_RSA_1024 = 4;
334e56987cSopenharmony_ciconstexpr uint32_t CERT_KEY_ALG_RSA_3072 = 5;
344e56987cSopenharmony_ciconstexpr uint32_t CERT_KEY_ALG_RSA_4096 = 6;
354e56987cSopenharmony_ciconstexpr uint32_t CERT_KEY_ALG_ECC_P224 = 7;
364e56987cSopenharmony_ciconstexpr uint32_t CERT_KEY_ALG_ECC_P384 = 8;
374e56987cSopenharmony_ciconstexpr uint32_t CERT_KEY_ALG_ECC_P521 = 9;
384e56987cSopenharmony_ciconstexpr uint32_t CERT_KEY_ALG_ED25519 = 10;
394e56987cSopenharmony_ciconstexpr uint32_t TEST_USERID = 100;
404e56987cSopenharmony_ci
414e56987cSopenharmony_cinamespace CertmanagerTest {
424e56987cSopenharmony_civoid FreeCMBlobData(struct CmBlob *blob);
434e56987cSopenharmony_ci
444e56987cSopenharmony_civoid FreeCertList(struct CertList *certList);
454e56987cSopenharmony_ci
464e56987cSopenharmony_cibool CompareCertInfo(const struct CertInfo *firstCert, const struct CertInfo *secondCert);
474e56987cSopenharmony_ci
484e56987cSopenharmony_cibool CompareCertData(const struct CmBlob *firstData, const struct CmBlob *secondData);
494e56987cSopenharmony_ci
504e56987cSopenharmony_cibool CompareCredential(const struct Credential *firstCredential, const struct Credential *secondCredential);
514e56987cSopenharmony_ci
524e56987cSopenharmony_cibool CompareCredentialList(const struct CredentialAbstract *firstCert, const struct CredentialAbstract *secondCert);
534e56987cSopenharmony_ci
544e56987cSopenharmony_ciint32_t TestGenerateAppCert(const struct CmBlob *alias, uint32_t alg, uint32_t store);
554e56987cSopenharmony_ci
564e56987cSopenharmony_cistd::string DumpCertAbstractInfo(const struct CertAbstract *certAbstract);
574e56987cSopenharmony_cistd::string DumpCertInfo(const struct CertInfo* certInfo);
584e56987cSopenharmony_cistd::string DumpCertList(struct CertList *certList);
594e56987cSopenharmony_ci
604e56987cSopenharmony_civoid SetATPermission(void);
614e56987cSopenharmony_ci
624e56987cSopenharmony_ciint32_t InitCertList(struct CertList **cList);
634e56987cSopenharmony_ci
644e56987cSopenharmony_ciint32_t InitUserCertInfo(struct CertInfo **cInfo);
654e56987cSopenharmony_ci
664e56987cSopenharmony_ciint32_t InitCertInfo(struct CertInfo *certInfo);
674e56987cSopenharmony_ci
684e56987cSopenharmony_cibool FindCertAbstract(const struct CertAbstract *abstract, const struct CertList *cList);
694e56987cSopenharmony_ci
704e56987cSopenharmony_civoid FreeCertInfo(struct CertInfo *cInfo);
714e56987cSopenharmony_ci}
724e56987cSopenharmony_ci#endif /* CM_TEST_COMMON_H */
73