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 CERT_MANGAGER_API_H
17 #define CERT_MANGAGER_API_H
18 
19 #include "cm_type.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 CM_API_EXPORT int32_t CmGetCertList(uint32_t store, struct CertList *certificateList);
26 
27 CM_API_EXPORT int32_t CmGetCertInfo(const struct CmBlob *certUri, uint32_t store,
28     struct CertInfo *certificateInfo);
29 
30 CM_API_EXPORT int32_t CmSetCertStatus(const struct CmBlob *certUri, const uint32_t store,
31     const bool status);
32 
33 CM_API_EXPORT int32_t CmInstallAppCert(const struct CmBlob *appCert, const struct CmBlob *appCertPwd,
34     const struct CmBlob *certAlias, const uint32_t store, struct CmBlob *keyUri);
35 
36 CM_API_EXPORT int32_t CmUninstallAppCert(const struct CmBlob *keyUri, const uint32_t store);
37 
38 CM_API_EXPORT int32_t CmUninstallAllAppCert(void);
39 
40 CM_API_EXPORT int32_t CmGetAppCertList(const uint32_t store, struct CredentialList *certificateList);
41 
42 CM_API_EXPORT int32_t CmCallingGetAppCertList(const uint32_t store, struct CredentialList *certificateList);
43 
44 CM_API_EXPORT int32_t CmGetAppCert(const struct CmBlob *keyUri, const uint32_t store, struct Credential *certificate);
45 
46 CM_API_EXPORT int32_t CmGrantAppCertificate(const struct CmBlob *keyUri, uint32_t appUid, struct CmBlob *authUri);
47 
48 CM_API_EXPORT int32_t CmGetAuthorizedAppList(const struct CmBlob *keyUri, struct CmAppUidList *appUidList);
49 
50 CM_API_EXPORT int32_t CmIsAuthorizedApp(const struct CmBlob *authUri);
51 
52 CM_API_EXPORT int32_t CmRemoveGrantedApp(const struct CmBlob *keyUri, uint32_t appUid);
53 
54 CM_API_EXPORT int32_t CmInit(const struct CmBlob *authUri, const struct CmSignatureSpec *spec, struct CmBlob *handle);
55 
56 CM_API_EXPORT int32_t CmUpdate(const struct CmBlob *handle, const struct CmBlob *inData);
57 
58 CM_API_EXPORT int32_t CmFinish(const struct CmBlob *handle, const struct CmBlob *inData, struct CmBlob *outData);
59 
60 CM_API_EXPORT int32_t CmAbort(const struct CmBlob *handle);
61 
62 CM_API_EXPORT int32_t CmGetUserCertList(uint32_t store, struct CertList *certificateList);
63 
64 CM_API_EXPORT int32_t CmGetUserCertInfo(const struct CmBlob *certUri, uint32_t store,
65     struct CertInfo *certificateInfo);
66 
67 CM_API_EXPORT int32_t CmSetUserCertStatus(const struct CmBlob *certUri, uint32_t store,
68     const bool status);
69 
70 CM_API_EXPORT int32_t CmInstallUserTrustedCert(const struct CmBlob *userCert,
71     const struct CmBlob *certAlias, struct CmBlob *certUri);
72 
73 CM_API_EXPORT int32_t CmUninstallUserTrustedCert(const struct CmBlob *certUri);
74 
75 CM_API_EXPORT int32_t CmUninstallAllUserTrustedCert(void);
76 
77 CM_API_EXPORT int32_t CmInstallSystemAppCert(const struct CmAppCertParam *certParam, struct CmBlob *keyUri);
78 
79 CM_API_EXPORT int32_t CmInstallUserCACert(const struct CmBlob *userCert,
80     const struct CmBlob *certAlias, const uint32_t userId, const bool status, struct CmBlob *certUri);
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 
86 #endif /* CERT_MANGAGER_API_H */