1 /* 2 * Copyright (C) 2022 Huawei Technologies Co., Ltd. 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 13 #ifndef __TEE_EXT_TRUSTED_STORAGE_API_H 14 #define __TEE_EXT_TRUSTED_STORAGE_API_H 15 16 #include "tee_defines.h" 17 #include "tee_ext_trusted_storage_api_legacy.h" 18 /* 19 * Create a new persist object for target TA by SDTA and store it in the perso partition. 20 * The data flow and TEE_Attribute can be initialized. 21 * Users can use the returned handle to access the TEE_Attribute and data flow of the object. 22 * 23 * @param target[IN]: uuid of the target TA, which is managed by SDTA. The file to be created belongs to target TA. 24 * @param storageID[IN]: Storage space of each application. Only TEE_OBJECT_STORAGE_PERSO is supported. 25 * @param objectID[IN]: Name of the object to be created. 26 * @param objectIDLen[IN]: Length of the name of the object to be created. 27 * @param flags[IN]: flags after object creation. The value can be one or more of Data_Flag_Constants 28 * or Handle_Flag_Constants. 29 * @param attributes[IN]:TEE_ObjectHandle of the temporary object, which is used to initialize 30 * the TEE_Attribute of the object. 31 * @param initialData[IN]:Initial data, which is used to initialize data flow data. 32 * @param initialDataLen[IN]: Initial data length(byte) 33 * @param object[OUT]: TEE_ObjectHandle returned after the function is successfully executed 34 * 35 * @return TEE_SUCCESS: In case of success 36 * @return TEE_ERROR_ITEM_NOT_FOUND: The storageID does not exist 37 * @return TEE_ERROR_ACCESS_CONFLICT: Access permission conflict 38 * @return TEE_ERROR_OUT_OF_MEMORY: There are not enough resources to complete the operation 39 * @return TEE_ERROR_STORAGE_NO_SPACE: The disk does not have sufficient space to create objects 40 * @return TEE_ERROR_ACCESS_DENIED: Permission verification error. e.g. a non-SDTA invokes this interface 41 * @return TEE_ERROR_GENERIC: Generic error 42 */ 43 TEE_Result tee_ext_create_persistent_object(TEE_UUID target, uint32_t storageID, const void *objectID, 44 size_t objectIDLen, uint32_t flags, TEE_ObjectHandle attributes, const void *initialData, 45 size_t initialDataLen, TEE_ObjectHandle *object); 46 47 /* 48 * Open a persist object by SDTA. 49 * Users can use the returned handle to access the TEE_Attribute and data flow of the object. 50 * 51 * @param target[IN]: uuid of the target TA, which is managed by SDTA. The file to be opened belongs to target TA. 52 * @param storageID[IN]: Storage space of each application. Only TEE_OBJECT_STORAGE_PERSO is supported. 53 * @param objectID[IN]: Name of the object to be opened. 54 * @param objectIDLen[IN]: Length of the name of the object to be opened. 55 * @param flags[IN]: flags after object open. The value can be one or more of Data_Flag_Constants 56 * or Handle_Flag_Constants. 57 * @param object[OUT]: TEE_ObjectHandle returned after the function is successfully executed 58 * 59 * @return TEE_SUCCESS: In case of success. 60 * @return TEE_ERROR_ITEM_NOT_FOUND: The storageID or object does not exist. 61 * @return TEE_ERROR_ACCESS_CONFLICT: Access permission conflict. 62 * @return TEE_ERROR_OUT_OF_MEMORY: There are not enough resources to complete the operation. 63 * @return TEE_ERROR_STORAGE_NO_SPACE: The disk does not have sufficient space to create objects. 64 * @return TEE_ERROR_STORAGE_EMFILE: For the process, the number of open files has reached the maximum. 65 * @return TEE_ERROR_GENERIC: Generic error. 66 */ 67 TEE_Result tee_ext_open_persistent_object(TEE_UUID target, uint32_t storageID, const void *objectID, 68 size_t objectIDLen, uint32_t flags, TEE_ObjectHandle *object); 69 70 /* 71 * Delete the files of the managed TA, including the perso partition and private partition. 72 * 73 * @param target[IN]: uuid of the managed TA. The uuid specifies the TA of the file to be deleted. 74 * 75 * @return TEE_SUCCESS: In case of success. 76 */ 77 TEE_Result tee_ext_delete_all_objects(TEE_UUID target); 78 79 #endif 80