1 /* 2 * Copyright (c) 2023 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 #ifndef CERT_MANAGER_UPDATEFLAG_H 16 #define CERT_MANAGER_UPDATEFLAG_H 17 18 #include <stdint.h> 19 #include <stdbool.h> 20 21 #include "cm_type.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /** 28 * @brief Check whether the certificate needs to backup 29 * 30 * @param[in] userId User ID 31 * @param[in] uid User identifier 32 * @param[in] certUri Certificate uri 33 * @param[out] needUpdate Returns the result of whether the backup needs to backup 34 * @return int32_t result 35 * @retval 0 success 36 * @retval <0 failure 37 */ 38 int32_t IsCertNeedBackup(uint32_t userId, uint32_t uid, const struct CmBlob *certUri, bool *needUpdate); 39 40 /** 41 * @brief Read the user certificate data 42 * 43 * @param store Storage type 44 * @param context Context information 45 * @param certUri Certificate uri 46 * @param userCertData Certificate data 47 * @return int32_t result 48 * @retval 0 success 49 * @retval <0 failure 50 */ 51 int32_t CmReadCertData(uint32_t store, const struct CmContext *context, const struct CmBlob *certUri, 52 struct CmBlob *userCertData); 53 54 /** 55 * @brief Back up the specified user certificate 56 * 57 * @param[in] context Context information 58 * @param[in] certUri Certificate uri 59 * @param[in] certData Certificate data 60 * @return int32_t result 61 * @retval 0 success 62 * @retval <0 failure 63 */ 64 int32_t CmBackupUserCert(const struct CmContext *context, const struct CmBlob *certUri, const struct CmBlob *certData); 65 66 /** 67 * @brief Back up all user certificates 68 * 69 * @return int32_t result 70 * @retval 0 success 71 * @retval <0 failure 72 */ 73 int32_t CmBackupAllSaUserCerts(void); 74 75 #ifdef __cplusplus 76 } 77 #endif 78 79 #endif