17777dab0Sopenharmony_ci/* 27777dab0Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License. 57777dab0Sopenharmony_ci * You may obtain a copy of the License at 67777dab0Sopenharmony_ci * 77777dab0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87777dab0Sopenharmony_ci * 97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and 137777dab0Sopenharmony_ci * limitations under the License. 147777dab0Sopenharmony_ci */ 157777dab0Sopenharmony_ci 167777dab0Sopenharmony_ci#ifndef __TEE_TRUSTED_STORAGE_API_H 177777dab0Sopenharmony_ci#define __TEE_TRUSTED_STORAGE_API_H 187777dab0Sopenharmony_ci 197777dab0Sopenharmony_ci/** 207777dab0Sopenharmony_ci * @addtogroup TeeTrusted 217777dab0Sopenharmony_ci * @{ 227777dab0Sopenharmony_ci * 237777dab0Sopenharmony_ci * @brief TEE(Trusted Excution Environment) API. 247777dab0Sopenharmony_ci * Provides security capability APIs such as trusted storage, encryption and decryption, 257777dab0Sopenharmony_ci * and trusted time for trusted application development. 267777dab0Sopenharmony_ci * 277777dab0Sopenharmony_ci * @since 12 287777dab0Sopenharmony_ci */ 297777dab0Sopenharmony_ci 307777dab0Sopenharmony_ci/** 317777dab0Sopenharmony_ci * @file tee_trusted_storage_api.h 327777dab0Sopenharmony_ci * 337777dab0Sopenharmony_ci * @brief Provides trusted storage APIs. 347777dab0Sopenharmony_ci * 357777dab0Sopenharmony_ci * You can use these APIs to implement trusted storage features. 367777dab0Sopenharmony_ci * 377777dab0Sopenharmony_ci * @library NA 387777dab0Sopenharmony_ci * @kit TEEKit 397777dab0Sopenharmony_ci * @syscap SystemCapability.Tee.TeeClient 407777dab0Sopenharmony_ci * @since 12 417777dab0Sopenharmony_ci * @version 1.0 427777dab0Sopenharmony_ci */ 437777dab0Sopenharmony_ci 447777dab0Sopenharmony_ci#include "tee_defines.h" 457777dab0Sopenharmony_ci#include "tee_object_api.h" 467777dab0Sopenharmony_ci 477777dab0Sopenharmony_ci#ifdef __cplusplus 487777dab0Sopenharmony_ciextern "C" { 497777dab0Sopenharmony_ci#endif 507777dab0Sopenharmony_ci 517777dab0Sopenharmony_ci/** 527777dab0Sopenharmony_ci * @brief Defines the start position in the data stream associated with an object. 537777dab0Sopenharmony_ci * It is used in the <b>TEE_SeekObjectData</b> function. 547777dab0Sopenharmony_ci * 557777dab0Sopenharmony_ci * @since 12 567777dab0Sopenharmony_ci */ 577777dab0Sopenharmony_cienum __TEE_Whence { 587777dab0Sopenharmony_ci /* Set the start position to the beginning of the data stream. */ 597777dab0Sopenharmony_ci TEE_DATA_SEEK_SET = 0, 607777dab0Sopenharmony_ci /* Set the start position to the current data stream position. */ 617777dab0Sopenharmony_ci TEE_DATA_SEEK_CUR, 627777dab0Sopenharmony_ci /* Set the start position to the end of the data stream. */ 637777dab0Sopenharmony_ci TEE_DATA_SEEK_END 647777dab0Sopenharmony_ci}; 657777dab0Sopenharmony_ci 667777dab0Sopenharmony_cistruct __TEE_ObjectEnumHandle; 677777dab0Sopenharmony_ci 687777dab0Sopenharmony_ci/** 697777dab0Sopenharmony_ci * @brief Defines the pointer to <b>TEE_ObjectEnumHandle</b>. 707777dab0Sopenharmony_ci * 717777dab0Sopenharmony_ci * @see __TEE_ObjectEnumHandle 727777dab0Sopenharmony_ci * 737777dab0Sopenharmony_ci * @since 12 747777dab0Sopenharmony_ci */ 757777dab0Sopenharmony_citypedef struct __TEE_ObjectEnumHandle *TEE_ObjectEnumHandle; 767777dab0Sopenharmony_ci 777777dab0Sopenharmony_citypedef uint32_t TEE_Whence; 787777dab0Sopenharmony_ci 797777dab0Sopenharmony_ci/** 807777dab0Sopenharmony_ci * @brief Defines the storage ID, which identifies the storage space of the application. 817777dab0Sopenharmony_ci * 827777dab0Sopenharmony_ci * @since 12 837777dab0Sopenharmony_ci */ 847777dab0Sopenharmony_cienum Object_Storage_Constants { 857777dab0Sopenharmony_ci /* Separate private storage space for each application. */ 867777dab0Sopenharmony_ci TEE_OBJECT_STORAGE_PRIVATE = 0x00000001, 877777dab0Sopenharmony_ci /* Separate personal storage space for application. */ 887777dab0Sopenharmony_ci TEE_OBJECT_STORAGE_PERSO = 0x00000002, 897777dab0Sopenharmony_ci /* Space for secure flash storage. */ 907777dab0Sopenharmony_ci TEE_OBJECT_SEC_FLASH = 0x80000000, 917777dab0Sopenharmony_ci /* Credential encrypted storage space. */ 927777dab0Sopenharmony_ci TEE_OBJECT_STORAGE_CE = 0x80000002, 937777dab0Sopenharmony_ci}; 947777dab0Sopenharmony_ci 957777dab0Sopenharmony_ci/** 967777dab0Sopenharmony_ci * @brief Defines the system resource constraints, such as the maximum value for the data stream position indicator. 977777dab0Sopenharmony_ci * 987777dab0Sopenharmony_ci * @since 12 997777dab0Sopenharmony_ci */ 1007777dab0Sopenharmony_cienum Miscellaneous_Constants { 1017777dab0Sopenharmony_ci /* Maximum length that the position indicator of the data stream can take. */ 1027777dab0Sopenharmony_ci TEE_DATA_MAX_POSITION = 0xFFFFFFFF, 1037777dab0Sopenharmony_ci /* Maximum length of the object ID, which can extend to 128 bytes. */ 1047777dab0Sopenharmony_ci TEE_OBJECT_ID_MAX_LEN = 64, 1057777dab0Sopenharmony_ci}; 1067777dab0Sopenharmony_ci 1077777dab0Sopenharmony_ci/** 1087777dab0Sopenharmony_ci * @brief Defines the maximum number of bytes that can be held in a data stream. 1097777dab0Sopenharmony_ci * 1107777dab0Sopenharmony_ci * @since 12 1117777dab0Sopenharmony_ci */ 1127777dab0Sopenharmony_cienum TEE_DATA_Size { 1137777dab0Sopenharmony_ci TEE_DATA_OBJECT_MAX_SIZE = 0xFFFFFFFF 1147777dab0Sopenharmony_ci}; 1157777dab0Sopenharmony_ci 1167777dab0Sopenharmony_ci/** 1177777dab0Sopenharmony_ci * @brief Defines the <b>handleFlags</b> of a <b>TEE_ObjectHandle</b>. 1187777dab0Sopenharmony_ci * The <b>handleFlags</b> determines the access permissions to the data stream associated with the object. 1197777dab0Sopenharmony_ci * 1207777dab0Sopenharmony_ci * @since 12 1217777dab0Sopenharmony_ci */ 1227777dab0Sopenharmony_cienum Data_Flag_Constants { 1237777dab0Sopenharmony_ci /** The data stream can be read. */ 1247777dab0Sopenharmony_ci TEE_DATA_FLAG_ACCESS_READ = 0x00000001, 1257777dab0Sopenharmony_ci /** The data stream can be written or truncated. */ 1267777dab0Sopenharmony_ci TEE_DATA_FLAG_ACCESS_WRITE = 0x00000002, 1277777dab0Sopenharmony_ci /** The data stream can be deleted or renamed. */ 1287777dab0Sopenharmony_ci TEE_DATA_FLAG_ACCESS_WRITE_META = 0x00000004, 1297777dab0Sopenharmony_ci /** Multiple TEE_ObjectHandles can be opened for concurrent read. */ 1307777dab0Sopenharmony_ci TEE_DATA_FLAG_SHARE_READ = 0x00000010, 1317777dab0Sopenharmony_ci /** Multiple TEE_ObjectHandles can be opened for concurrent write. */ 1327777dab0Sopenharmony_ci TEE_DATA_FLAG_SHARE_WRITE = 0x00000020, 1337777dab0Sopenharmony_ci /** Reserved. */ 1347777dab0Sopenharmony_ci TEE_DATA_FLAG_CREATE = 0x00000200, 1357777dab0Sopenharmony_ci /** 1367777dab0Sopenharmony_ci * Protect the existing file with the same name. Throw an error if the file with the same name exists; 1377777dab0Sopenharmony_ci * create a data file otherwise. 1387777dab0Sopenharmony_ci */ 1397777dab0Sopenharmony_ci TEE_DATA_FLAG_EXCLUSIVE = 0x00000400, 1407777dab0Sopenharmony_ci /** 1417777dab0Sopenharmony_ci * Protect the existing file with the same name. Throw an error if the file with the same name exists; 1427777dab0Sopenharmony_ci * create a data file otherwise. 1437777dab0Sopenharmony_ci */ 1447777dab0Sopenharmony_ci TEE_DATA_FLAG_OVERWRITE = 0x00000400, 1457777dab0Sopenharmony_ci /** Use AES256 if bit 28 is 1; use AES128 if bit 28 is 0. */ 1467777dab0Sopenharmony_ci TEE_DATA_FLAG_AES256 = 0x10000000, 1477777dab0Sopenharmony_ci /** If bit 29 is set to 1, open the earlier version preferentially. */ 1487777dab0Sopenharmony_ci TEE_DATA_FLAG_OPEN_AESC = 0x20000000, 1497777dab0Sopenharmony_ci}; 1507777dab0Sopenharmony_ci 1517777dab0Sopenharmony_ci/** 1527777dab0Sopenharmony_ci * @brief Creates a persistent object. 1537777dab0Sopenharmony_ci * 1547777dab0Sopenharmony_ci * This function creates a persistent object with initialized <b>TEE_Attribute</b> and data stream. 1557777dab0Sopenharmony_ci * You can use the returned handle to access the <b>TEE_Attribute</b> and data stream of the object. 1567777dab0Sopenharmony_ci * 1577777dab0Sopenharmony_ci * @param storageID Indicates the storage to use. The value is specified by <b>Object_Storage_Constants</b>. 1587777dab0Sopenharmony_ci * @param ojbectID Indicates the pointer to the object identifier, that is, the name of the object to create. 1597777dab0Sopenharmony_ci * @param objectIDLen Indicates the length of the object identifier, in bytes. It cannot exceed 128 bytes. 1607777dab0Sopenharmony_ci * @param flags Indicates the flags of the object created. The value can be 1617777dab0Sopenharmony_ci * one or more of <b>Data_Flag_Constants</b> or <b>Handle_Flag_Constants</b>. 1627777dab0Sopenharmony_ci * @param attributes Indicates the <b>TEE_ObjectHandle</b> of a transient object from which to take 1637777dab0Sopenharmony_ci * <b>TEE_Attribute</b>. It can be <b>TEE_HANDLE_NULL</b> if the persistent object contains no attribute. 1647777dab0Sopenharmony_ci * @param initialData Indicates the pointer to the initial data used to initialize the data stream data. 1657777dab0Sopenharmony_ci * @param initialDataLen Indicates the length of the initial data, in bytes. 1667777dab0Sopenharmony_ci * @param object Indicates the pointer to the <b>TEE_ObjectHandle</b> returned 1677777dab0Sopenharmony_ci * after the function is successfully executed. 1687777dab0Sopenharmony_ci * 1697777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 1707777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the storage specified by <b>storageID</b> does not exist. 1717777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_ACCESS_CONFLICT</b> if an access conflict occurs. 1727777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if the memory is not sufficient to complete the operation. 1737777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_STORAGE_NO_SPACE</b> if there is no enough space to create the object. 1747777dab0Sopenharmony_ci * 1757777dab0Sopenharmony_ci * @since 12 1767777dab0Sopenharmony_ci * @version 1.0 1777777dab0Sopenharmony_ci */ 1787777dab0Sopenharmony_ciTEE_Result TEE_CreatePersistentObject(uint32_t storageID, const void *ojbectID, size_t objectIDLen, uint32_t flags, 1797777dab0Sopenharmony_ci TEE_ObjectHandle attributes, const void *initialData, size_t initialDataLen, 1807777dab0Sopenharmony_ci TEE_ObjectHandle *object); 1817777dab0Sopenharmony_ci 1827777dab0Sopenharmony_ci/** 1837777dab0Sopenharmony_ci * @brief Opens an existing persistent object. 1847777dab0Sopenharmony_ci * 1857777dab0Sopenharmony_ci * The handle returned can be used to access the <b>TEE_Attribute</b> and data stream of the object. 1867777dab0Sopenharmony_ci * 1877777dab0Sopenharmony_ci * @param storageID Indicates the storage to use. The value is specified by <b>Object_Storage_Constants</b>. 1887777dab0Sopenharmony_ci * @param ojbectID Indicates the pointer to the object identifier, that is, the name of the object to open. 1897777dab0Sopenharmony_ci * @param objectIDLen Indicates the length of the object identifier, in bytes. It cannot exceed 128 bytes. 1907777dab0Sopenharmony_ci * @param flags Indicates the flags of the object opened. 1917777dab0Sopenharmony_ci * The value can be one or more of <b>Data_Flag_Constants</b> or <b>Handle_Flag_Constants</b>. 1927777dab0Sopenharmony_ci * @param object Indicates the pointer to the <b>TEE_ObjectHandle</b> returned 1937777dab0Sopenharmony_ci * after the function is successfully executed. 1947777dab0Sopenharmony_ci * 1957777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 1967777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the storage specified by <b>storageID</b> does not exist 1977777dab0Sopenharmony_ci * or the object identifier cannot be found in the storage. 1987777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_ACCESS_CONFLICT</b> if an access conflict occurs. 1997777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if the memory is not sufficient to complete the operation. 2007777dab0Sopenharmony_ci * 2017777dab0Sopenharmony_ci * @since 12 2027777dab0Sopenharmony_ci * @version 1.0 2037777dab0Sopenharmony_ci */ 2047777dab0Sopenharmony_ciTEE_Result TEE_OpenPersistentObject(uint32_t storageID, const void *ojbectID, size_t objectIDLen, uint32_t flags, 2057777dab0Sopenharmony_ci TEE_ObjectHandle *object); 2067777dab0Sopenharmony_ci 2077777dab0Sopenharmony_ci/** 2087777dab0Sopenharmony_ci * @brief Reads data from the data stream associated with an object into the buffer. 2097777dab0Sopenharmony_ci * 2107777dab0Sopenharmony_ci * The <b>TEE_ObjectHandle</b> of the object must have been opened with the <b>TEE_DATA_FLAG_ACCESS_READ</b> permission. 2117777dab0Sopenharmony_ci * 2127777dab0Sopenharmony_ci * @param ojbect Indicates the <b>TEE_ObjectHandle</b> of the object to read. 2137777dab0Sopenharmony_ci * @param buffer Indicates the pointer to the buffer used to store the data read. 2147777dab0Sopenharmony_ci * @param size Indicates the number of bytes to read. 2157777dab0Sopenharmony_ci * @param count Indicates the pointer to the variable that contains the number of bytes read. 2167777dab0Sopenharmony_ci * 2177777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 2187777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if the memory is not sufficient to complete the operation. 2197777dab0Sopenharmony_ci * 2207777dab0Sopenharmony_ci * @since 12 2217777dab0Sopenharmony_ci * @version 1.0 2227777dab0Sopenharmony_ci */ 2237777dab0Sopenharmony_ciTEE_Result TEE_ReadObjectData(TEE_ObjectHandle ojbect, void *buffer, size_t size, uint32_t *count); 2247777dab0Sopenharmony_ci 2257777dab0Sopenharmony_ci/** 2267777dab0Sopenharmony_ci * @brief Writes bytes from the buffer to the data stream associated with an object. 2277777dab0Sopenharmony_ci * 2287777dab0Sopenharmony_ci * The <b>TEE_ObjectHandle</b> must have been opened with the <b>TEE_DATA_FLAG_ACCESS_WRITE</b> permission. 2297777dab0Sopenharmony_ci * 2307777dab0Sopenharmony_ci * @param ojbect Indicates the <b>TEE_ObjectHandle</b> of the object. 2317777dab0Sopenharmony_ci * @param buffer Indicates the pointer to the buffer that stores the data to be written. 2327777dab0Sopenharmony_ci * @param size Indicates the number of bytes to be written. It cannot exceed 4096 bytes. 2337777dab0Sopenharmony_ci * 2347777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 2357777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if the memory is not sufficient to complete the operation. 2367777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_STORAGE_NO_SPACE</b> if the storage space is not sufficient to complete the operation. 2377777dab0Sopenharmony_ci * 2387777dab0Sopenharmony_ci * @since 12 2397777dab0Sopenharmony_ci * @version 1.0 2407777dab0Sopenharmony_ci */ 2417777dab0Sopenharmony_ciTEE_Result TEE_WriteObjectData(TEE_ObjectHandle ojbect, const void *buffer, size_t size); 2427777dab0Sopenharmony_ci 2437777dab0Sopenharmony_ci/** 2447777dab0Sopenharmony_ci * @brief Changes the size of a data stream. 2457777dab0Sopenharmony_ci * 2467777dab0Sopenharmony_ci * If the size is less than the current size of the data stream, all bytes beyond <b>size</b> are deleted. If the size 2477777dab0Sopenharmony_ci * is greater than the current size of the data stream, add 0s at the end of the stream to extend the stream. 2487777dab0Sopenharmony_ci * The object handle must be opened with the <b>TEE_DATA_FLAG_ACCESS_WRITE</b> permission. 2497777dab0Sopenharmony_ci * 2507777dab0Sopenharmony_ci * @param object Indicates the <b>TEE_ObjectHandle</b> of the object. 2517777dab0Sopenharmony_ci * @param size Indicates the new size of the data stream. It cannot exceed 4096 bytes. 2527777dab0Sopenharmony_ci * 2537777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 2547777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_STORAGE_NO_SPACE</b> if the storage space is not sufficient to complete the operation. 2557777dab0Sopenharmony_ci * 2567777dab0Sopenharmony_ci * @since 12 2577777dab0Sopenharmony_ci * @version 1.0 2587777dab0Sopenharmony_ci */ 2597777dab0Sopenharmony_ciTEE_Result TEE_TruncateObjectData(TEE_ObjectHandle object, size_t size); 2607777dab0Sopenharmony_ci 2617777dab0Sopenharmony_ci/** 2627777dab0Sopenharmony_ci * @brief Sets the position of the data stream to which <b>TEE_ObjectHandle</b> points. 2637777dab0Sopenharmony_ci * 2647777dab0Sopenharmony_ci * The data position indicator is determined by the start position and an offset together. 2657777dab0Sopenharmony_ci * The <b>whence</b> parameter determines the start position. Its value is set in <b>TEE_Whence</b> as follows: 2667777dab0Sopenharmony_ci * <b>TEE_DATA_SEEK_SET = 0</b>: The start position is the beginning of the data stream. 2677777dab0Sopenharmony_ci * <b>TEE_DATA_SEEK_CUR</b>: The start position is the current position of the data stream. 2687777dab0Sopenharmony_ci * <b>TEE_DATA_SEEK_END</b>: The start position is the end of the data stream. 2697777dab0Sopenharmony_ci * If the parameter <b>offset</b> is a positive number, the data position is moved forward. 2707777dab0Sopenharmony_ci * If <b>offset</b> is a negative number, the data position is moved backward. 2717777dab0Sopenharmony_ci * 2727777dab0Sopenharmony_ci * @param object Indicates the <b>TEE_ObjectHandle</b> of the object. 2737777dab0Sopenharmony_ci * @param offset Indicates the number of bytes to move the data position. It cannot exceed 4096 bytes. 2747777dab0Sopenharmony_ci * @param whence Indicates the start position in the data stream to calculate the new position. 2757777dab0Sopenharmony_ci * 2767777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 2777777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_OVERFLOW</b> if the position indicator resulting from this operation 2787777dab0Sopenharmony_ci * is greater than <b>TEE_DATA_MAX_POSIT</b>. 2797777dab0Sopenharmony_ci * 2807777dab0Sopenharmony_ci * @since 12 2817777dab0Sopenharmony_ci * @version 1.0 2827777dab0Sopenharmony_ci */ 2837777dab0Sopenharmony_ciTEE_Result TEE_SeekObjectData(TEE_ObjectHandle object, int32_t offset, TEE_Whence whence); 2847777dab0Sopenharmony_ci 2857777dab0Sopenharmony_ci/** 2867777dab0Sopenharmony_ci * @brief Synchronizes the opened <b>TEE_ObjectHandle</b> and the corresponding security attribute file to the disk. 2877777dab0Sopenharmony_ci * 2887777dab0Sopenharmony_ci * @param object Indicates the <b>TEE_ObjectHandle</b> of the object. 2897777dab0Sopenharmony_ci * 2907777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 2917777dab0Sopenharmony_ci * 2927777dab0Sopenharmony_ci * @since 12 2937777dab0Sopenharmony_ci * @version 1.0 2947777dab0Sopenharmony_ci */ 2957777dab0Sopenharmony_ciTEE_Result TEE_SyncPersistentObject(TEE_ObjectHandle object); 2967777dab0Sopenharmony_ci 2977777dab0Sopenharmony_ci/** 2987777dab0Sopenharmony_ci * @brief Changes the object identifier. 2997777dab0Sopenharmony_ci * 3007777dab0Sopenharmony_ci * The <b>TEE_ObjectHandle</b> must have been opened with the <b>TEE_DATA_FLAG_ACCESS_WRITE_META</b> permission. 3017777dab0Sopenharmony_ci * 3027777dab0Sopenharmony_ci * @param object Indicates the handle of the target object. 3037777dab0Sopenharmony_ci * @param newObjectID Indicates the pointer to the new object identifier. 3047777dab0Sopenharmony_ci * @param newObjectIDLen Indicates the length of the new object identifier. 3057777dab0Sopenharmony_ci * 3067777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 3077777dab0Sopenharmony_ci * 3087777dab0Sopenharmony_ci * @since 12 3097777dab0Sopenharmony_ci * @version 1.0 3107777dab0Sopenharmony_ci */ 3117777dab0Sopenharmony_ciTEE_Result TEE_RenamePersistentObject(TEE_ObjectHandle object, void *newObjectID, size_t newObjectIDLen); 3127777dab0Sopenharmony_ci 3137777dab0Sopenharmony_ci/** 3147777dab0Sopenharmony_ci * @brief Allocates a handle on an uninitialized object enumerator. 3157777dab0Sopenharmony_ci * 3167777dab0Sopenharmony_ci * @param obj_enumerator Indicates the pointer to the handle of the newly created object enumerator. 3177777dab0Sopenharmony_ci * 3187777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 3197777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if the memory is not sufficient to complete the operation. 3207777dab0Sopenharmony_ci * 3217777dab0Sopenharmony_ci * @since 12 3227777dab0Sopenharmony_ci * @version 1.0 3237777dab0Sopenharmony_ci */ 3247777dab0Sopenharmony_ciTEE_Result TEE_AllocatePersistentObjectEnumerator(TEE_ObjectEnumHandle *obj_enumerator); 3257777dab0Sopenharmony_ci 3267777dab0Sopenharmony_ci/** 3277777dab0Sopenharmony_ci * @brief Releases all resources associated with an object enumerator handle. 3287777dab0Sopenharmony_ci * 3297777dab0Sopenharmony_ci * After this function is called, the object handle is no longer valid and all resources associated with 3307777dab0Sopenharmony_ci * the object enumerator handle will be reclaimed. 3317777dab0Sopenharmony_ci * <b>TEE_FreePersistentObjectEnumerator</b> and <b>TEE_AllocatePersistentObjectEnumerator</b>are used in pairs. 3327777dab0Sopenharmony_ci * 3337777dab0Sopenharmony_ci * @param obj_enumerator Indicates the <b>TEE_ObjectEnumHandle</b> to release. 3347777dab0Sopenharmony_ci * 3357777dab0Sopenharmony_ci * @since 12 3367777dab0Sopenharmony_ci * @version 1.0 3377777dab0Sopenharmony_ci */ 3387777dab0Sopenharmony_civoid TEE_FreePersistentObjectEnumerator(TEE_ObjectEnumHandle obj_enumerator); 3397777dab0Sopenharmony_ci 3407777dab0Sopenharmony_ci/** 3417777dab0Sopenharmony_ci * @brief Resets an object enumerator handle to its initial state after allocation. 3427777dab0Sopenharmony_ci * 3437777dab0Sopenharmony_ci * @param obj_enumerator Indicates the <b>TEE_ObjectEnumHandle</b> of the object enumerator to reset. 3447777dab0Sopenharmony_ci * 3457777dab0Sopenharmony_ci * @since 12 3467777dab0Sopenharmony_ci * @version 1.0 3477777dab0Sopenharmony_ci */ 3487777dab0Sopenharmony_civoid TEE_ResetPersistentObjectEnumerator(TEE_ObjectEnumHandle obj_enumerator); 3497777dab0Sopenharmony_ci 3507777dab0Sopenharmony_ci/** 3517777dab0Sopenharmony_ci * @brief Starts the enumeration of all the objects in the given trusted storage. 3527777dab0Sopenharmony_ci * 3537777dab0Sopenharmony_ci * The object information can be obtained by using <b>TEE_GetNextPersistentObject</b>. 3547777dab0Sopenharmony_ci * 3557777dab0Sopenharmony_ci * @param obj_enumerator Indicates the <b>TEE_ObjectEnumHandle</b> of the object enumerator. 3567777dab0Sopenharmony_ci * @param storage_id Indicates the storage, in which the objects are enumerated. 3577777dab0Sopenharmony_ci * The value is specified by <b>Object_Storage_Constants</b>. 3587777dab0Sopenharmony_ci * Currently, only <b>TEE_STORAGE_PRIVATE</b> is supported. 3597777dab0Sopenharmony_ci * 3607777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 3617777dab0Sopenharmony_ci * Returns <b>TEE_ITEM_NOT_FOUND</b> if <b>storageID</b> is not <b>TEE_STORAGE_PRIVATE</b> 3627777dab0Sopenharmony_ci * or there is no object in the specified storage. 3637777dab0Sopenharmony_ci * 3647777dab0Sopenharmony_ci * @since 12 3657777dab0Sopenharmony_ci * @version 1.0 3667777dab0Sopenharmony_ci */ 3677777dab0Sopenharmony_ciTEE_Result TEE_StartPersistentObjectEnumerator(TEE_ObjectEnumHandle obj_enumerator, uint32_t storage_id); 3687777dab0Sopenharmony_ci 3697777dab0Sopenharmony_ci/** 3707777dab0Sopenharmony_ci * @brief Obtains the next object in the object enumerator. 3717777dab0Sopenharmony_ci * 3727777dab0Sopenharmony_ci * Information such as <b>TEE_ObjectInfo</b>, <b>objectID</b>, and <b>objectIDLen</b> will be obtained. 3737777dab0Sopenharmony_ci * 3747777dab0Sopenharmony_ci * @param obj_enumerator Indicates the <b>TEE_ObjectEnumHandle</b> of the object enumerator. 3757777dab0Sopenharmony_ci * @param object_info Indicates the pointer to the obtained<b>TEE_ObjectInfo</b>. 3767777dab0Sopenharmony_ci * @param object_id Indicates the pointer to the buffer used to store the obtained <b>objectID</b>. 3777777dab0Sopenharmony_ci * @param object_id_len Indicates the pointer to the <b>objectIDLen</b>. 3787777dab0Sopenharmony_ci * 3797777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 3807777dab0Sopenharmony_ci * Returns <b>TEE_ITEM_NOT_FOUND</b> if the object enumerator has no element 3817777dab0Sopenharmony_ci * or the enumerator has not been initialized. 3827777dab0Sopenharmony_ci * 3837777dab0Sopenharmony_ci * @since 12 3847777dab0Sopenharmony_ci * @version 1.0 3857777dab0Sopenharmony_ci */ 3867777dab0Sopenharmony_ciTEE_Result TEE_GetNextPersistentObject(TEE_ObjectEnumHandle obj_enumerator, 3877777dab0Sopenharmony_ci TEE_ObjectInfo *object_info, void *object_id, size_t *object_id_len); 3887777dab0Sopenharmony_ci 3897777dab0Sopenharmony_ci/** 3907777dab0Sopenharmony_ci * @brief Closes a <b>TEE_ObjectHandle</b> and deletes the object. 3917777dab0Sopenharmony_ci * 3927777dab0Sopenharmony_ci * The object must be a persistent object, and the object handle must have been opened with 3937777dab0Sopenharmony_ci * the <b>TEE_DATA_FLAG_ACCESS_WRITE_META</b> permission. 3947777dab0Sopenharmony_ci * 3957777dab0Sopenharmony_ci * @param object Indicates the object handle to close. 3967777dab0Sopenharmony_ci * 3977777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 3987777dab0Sopenharmony_ci * Returns <b>TEE_ERROR_STORAGE_NOT_AVAILABLE</b> if the object is stored 3997777dab0Sopenharmony_ci * in a storage area that is inaccessible currently. 4007777dab0Sopenharmony_ci * 4017777dab0Sopenharmony_ci * @since 12 4027777dab0Sopenharmony_ci * @version 1.0 4037777dab0Sopenharmony_ci */ 4047777dab0Sopenharmony_ciTEE_Result TEE_CloseAndDeletePersistentObject1(TEE_ObjectHandle object); 4057777dab0Sopenharmony_ci 4067777dab0Sopenharmony_ci#ifdef __cplusplus 4077777dab0Sopenharmony_ci} 4087777dab0Sopenharmony_ci#endif 4097777dab0Sopenharmony_ci/** @} */ 4107777dab0Sopenharmony_ci#endif 411