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_PROPERTY_API_H 177777dab0Sopenharmony_ci#define TEE_PROPERTY_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_property_api.h 327777dab0Sopenharmony_ci * 337777dab0Sopenharmony_ci * @brief Reference of TEE object api definitions. 347777dab0Sopenharmony_ci * 357777dab0Sopenharmony_ci * @library NA 367777dab0Sopenharmony_ci * @kit TEEKit 377777dab0Sopenharmony_ci * @syscap SystemCapability.Tee.TeeClient 387777dab0Sopenharmony_ci * @since 12 397777dab0Sopenharmony_ci * @version 1.0 407777dab0Sopenharmony_ci */ 417777dab0Sopenharmony_ci 427777dab0Sopenharmony_ci#include "tee_defines.h" 437777dab0Sopenharmony_ci 447777dab0Sopenharmony_ci#ifdef __cplusplus 457777dab0Sopenharmony_ciextern "C" { 467777dab0Sopenharmony_ci#endif 477777dab0Sopenharmony_ci/** 487777dab0Sopenharmony_ci * The definitions below are defined by Global Platform or Platform SDK released previously 497777dab0Sopenharmony_ci * for compatibility. 507777dab0Sopenharmony_ci * Do not make any change to the content below. 517777dab0Sopenharmony_ci */ 527777dab0Sopenharmony_ci 537777dab0Sopenharmony_ci/** 547777dab0Sopenharmony_ci * @brief Enumerates the types of the property set. 557777dab0Sopenharmony_ci * 567777dab0Sopenharmony_ci * @since 12 577777dab0Sopenharmony_ci */ 587777dab0Sopenharmony_citypedef enum { 597777dab0Sopenharmony_ci TEE_PROPSET_UNKNOW = 0, 607777dab0Sopenharmony_ci TEE_PROPSET_TEE_IMPLEMENTATION = 0xFFFFFFFD, 617777dab0Sopenharmony_ci TEE_PROPSET_CURRENT_CLIENT = 0xFFFFFFFE, 627777dab0Sopenharmony_ci TEE_PROPSET_CURRENT_TA = 0xFFFFFFFF, 637777dab0Sopenharmony_ci} Pseudo_PropSetHandle; 647777dab0Sopenharmony_ci 657777dab0Sopenharmony_citypedef uint32_t TEE_PropSetHandle; 667777dab0Sopenharmony_ci 677777dab0Sopenharmony_ci/** 687777dab0Sopenharmony_ci * @brief Obtains a property from a property set and converts its value into a printable string. 697777dab0Sopenharmony_ci * 707777dab0Sopenharmony_ci * 717777dab0Sopenharmony_ci * @param propsetOrEnumerator Indicates one of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator. 727777dab0Sopenharmony_ci * @param name Indicates the pointer to the zero-terminated string containing the name of the property to obtain. 737777dab0Sopenharmony_ci * @param valueBuffer Indicates the pointer to the buffer for holding the property value obtained. 747777dab0Sopenharmony_ci * @param valueBufferLen Indicates the pointer to the buffer length. 757777dab0Sopenharmony_ci * 767777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 777777dab0Sopenharmony_ci * @return Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the target property cannot be obtained. 787777dab0Sopenharmony_ci * @return Returns <b>TEE_ERROR_SHORT_BUFFER</b> if the value buffer is too small to hold the property value obtained. 797777dab0Sopenharmony_ci * 807777dab0Sopenharmony_ci * @since 12 817777dab0Sopenharmony_ci * @version 1.0 827777dab0Sopenharmony_ci */ 837777dab0Sopenharmony_ciTEE_Result TEE_GetPropertyAsString(TEE_PropSetHandle propsetOrEnumerator, const char *name, char *valueBuffer, 847777dab0Sopenharmony_ci size_t *valueBufferLen); 857777dab0Sopenharmony_ci 867777dab0Sopenharmony_ci/** 877777dab0Sopenharmony_ci * @brief Obtains a property from a property set and converts its value into a Boolean value. 887777dab0Sopenharmony_ci * 897777dab0Sopenharmony_ci * @param propsetOrEnumerator Indicates one of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator. 907777dab0Sopenharmony_ci * @param name Indicates the pointer to the zero-terminated string containing the name of the property to obtain. 917777dab0Sopenharmony_ci * @param value Indicates the pointer to the variable that holds the property value obtained. 927777dab0Sopenharmony_ci * 937777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 947777dab0Sopenharmony_ci * @return Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the target property cannot be obtained. 957777dab0Sopenharmony_ci * 967777dab0Sopenharmony_ci * @since 12 977777dab0Sopenharmony_ci * @version 1.0 987777dab0Sopenharmony_ci */ 997777dab0Sopenharmony_ciTEE_Result TEE_GetPropertyAsBool(TEE_PropSetHandle propsetOrEnumerator, const char *name, bool *value); 1007777dab0Sopenharmony_ci 1017777dab0Sopenharmony_ci/** 1027777dab0Sopenharmony_ci * @brief Obtains a property from a property set and converts its value into a 32-bit unsigned integer. 1037777dab0Sopenharmony_ci * 1047777dab0Sopenharmony_ci * @param propsetOrEnumerator Indicates one of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator. 1057777dab0Sopenharmony_ci * @param name Indicates the pointer to the zero-terminated string containing the name of the property to obtain. 1067777dab0Sopenharmony_ci * @param value Indicates the pointer to the variable that holds the property value obtained. 1077777dab0Sopenharmony_ci * 1087777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 1097777dab0Sopenharmony_ci * @return Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the target property cannot be obtained. 1107777dab0Sopenharmony_ci * 1117777dab0Sopenharmony_ci * @since 12 1127777dab0Sopenharmony_ci * @version 1.0 1137777dab0Sopenharmony_ci */ 1147777dab0Sopenharmony_ciTEE_Result TEE_GetPropertyAsU32(TEE_PropSetHandle propsetOrEnumerator, const char *name, uint32_t *value); 1157777dab0Sopenharmony_ci 1167777dab0Sopenharmony_ci#if defined(API_LEVEL) && (API_LEVEL >= API_LEVEL1_2) 1177777dab0Sopenharmony_ci/** 1187777dab0Sopenharmony_ci * @brief Obtains a property from a property set and converts its value into a 64-bit unsigned integer. 1197777dab0Sopenharmony_ci * 1207777dab0Sopenharmony_ci * @param propsetOrEnumerator Indicates one of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator. 1217777dab0Sopenharmony_ci * @param name Indicates the pointer to the zero-terminated string containing the name of the property to obtain. 1227777dab0Sopenharmony_ci * @param value Indicates the pointer to the variable that holds the property value obtained. 1237777dab0Sopenharmony_ci * 1247777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 1257777dab0Sopenharmony_ci * @return Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the target property cannot be obtained. 1267777dab0Sopenharmony_ci * 1277777dab0Sopenharmony_ci * @since 12 1287777dab0Sopenharmony_ci * @version 1.0 1297777dab0Sopenharmony_ci */ 1307777dab0Sopenharmony_ciTEE_Result TEE_GetPropertyAsU64(TEE_PropSetHandle propsetOrEnumerator, const char *name, uint64_t *value); 1317777dab0Sopenharmony_ci#endif // API_LEVEL 1327777dab0Sopenharmony_ci 1337777dab0Sopenharmony_ci/** 1347777dab0Sopenharmony_ci * @brief Obtains a property from a property set and converts its value into a binary block. 1357777dab0Sopenharmony_ci * 1367777dab0Sopenharmony_ci * @param propsetOrEnumerator Indicates one of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator. 1377777dab0Sopenharmony_ci * @param name Indicates the pointer to the zero-terminated string containing the name of the property to obtain. 1387777dab0Sopenharmony_ci * @param valueBuffer Indicates the pointer to the buffer for holding the property value obtained. 1397777dab0Sopenharmony_ci * @param valueBufferLen Indicates the pointer to the buffer length. 1407777dab0Sopenharmony_ci * 1417777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 1427777dab0Sopenharmony_ci * @return Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the target property cannot be obtained. 1437777dab0Sopenharmony_ci * @return TEE_ERROR_SHORT_BUFFER the value buffer is not large enough to hold the whole property value 1447777dab0Sopenharmony_ci * 1457777dab0Sopenharmony_ci * @since 12 1467777dab0Sopenharmony_ci * @version 1.0 1477777dab0Sopenharmony_ci */ 1487777dab0Sopenharmony_ciTEE_Result TEE_GetPropertyAsBinaryBlock(TEE_PropSetHandle propsetOrEnumerator, const char *name, void *valueBuffer, 1497777dab0Sopenharmony_ci size_t *valueBufferLen); 1507777dab0Sopenharmony_ci 1517777dab0Sopenharmony_ci/** 1527777dab0Sopenharmony_ci * @brief Obtains a property from a property set and converts its value to the <b>TEE_UUID</b> struct. 1537777dab0Sopenharmony_ci * 1547777dab0Sopenharmony_ci * @param propsetOrEnumerator Indicates one of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator. 1557777dab0Sopenharmony_ci * @param name Indicates the pointer to the zero-terminated string containing the name of the property to obtain. 1567777dab0Sopenharmony_ci * @param value Indicates the pointer to the variable that holds the property value obtained. 1577777dab0Sopenharmony_ci * 1587777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 1597777dab0Sopenharmony_ci * @return Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the target property cannot be obtained. 1607777dab0Sopenharmony_ci * 1617777dab0Sopenharmony_ci * @since 12 1627777dab0Sopenharmony_ci * @version 1.0 1637777dab0Sopenharmony_ci */ 1647777dab0Sopenharmony_ciTEE_Result TEE_GetPropertyAsUUID(TEE_PropSetHandle propsetOrEnumerator, const char *name, TEE_UUID *value); 1657777dab0Sopenharmony_ci 1667777dab0Sopenharmony_ci/** 1677777dab0Sopenharmony_ci * @brief Obtains a property from a property set and converts its value to the <b>TEE_Identity</b> struct. 1687777dab0Sopenharmony_ci * 1697777dab0Sopenharmony_ci * @param propsetOrEnumerator Indicates one of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator. 1707777dab0Sopenharmony_ci * @param name Indicates the pointer to the zero-terminated string containing the name of the property to obtain. 1717777dab0Sopenharmony_ci * @param value Indicates the pointer to the variable that holds the property value obtained. 1727777dab0Sopenharmony_ci * 1737777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 1747777dab0Sopenharmony_ci * @return Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the target property cannot be obtained. 1757777dab0Sopenharmony_ci * 1767777dab0Sopenharmony_ci * @since 12 1777777dab0Sopenharmony_ci * @version 1.0 1787777dab0Sopenharmony_ci */ 1797777dab0Sopenharmony_ciTEE_Result TEE_GetPropertyAsIdentity(TEE_PropSetHandle propsetOrEnumerator, const char *name, TEE_Identity *value); 1807777dab0Sopenharmony_ci 1817777dab0Sopenharmony_ci/** 1827777dab0Sopenharmony_ci * @brief Allocates a property enumerator object. 1837777dab0Sopenharmony_ci * 1847777dab0Sopenharmony_ci * @param enumerator Indicates the pointer to the property enumerator filled with an opaque handle. 1857777dab0Sopenharmony_ci * 1867777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 1877777dab0Sopenharmony_ci * @return Returns <b>TEE_ERROR_OUT_OF_MEMORY</b> if there is no enough resources to allocate the property enumerator. 1887777dab0Sopenharmony_ci * 1897777dab0Sopenharmony_ci * @since 12 1907777dab0Sopenharmony_ci * @version 1.0 1917777dab0Sopenharmony_ci */ 1927777dab0Sopenharmony_ciTEE_Result TEE_AllocatePropertyEnumerator(TEE_PropSetHandle *enumerator); 1937777dab0Sopenharmony_ci 1947777dab0Sopenharmony_ci/** 1957777dab0Sopenharmony_ci * @brief Releases a property enumerator object. 1967777dab0Sopenharmony_ci * 1977777dab0Sopenharmony_ci * @param enumerator Indicates the handle on the property enumerator to release. 1987777dab0Sopenharmony_ci * 1997777dab0Sopenharmony_ci * @return void 2007777dab0Sopenharmony_ci * 2017777dab0Sopenharmony_ci * @since 12 2027777dab0Sopenharmony_ci * @version 1.0 2037777dab0Sopenharmony_ci */ 2047777dab0Sopenharmony_civoid TEE_FreePropertyEnumerator(TEE_PropSetHandle enumerator); 2057777dab0Sopenharmony_ci 2067777dab0Sopenharmony_ci/** 2077777dab0Sopenharmony_ci * @brief Starts to enumerate the properties in an enumerator. 2087777dab0Sopenharmony_ci * 2097777dab0Sopenharmony_ci * @param enumerator Indicates the handle on the enumerator. 2107777dab0Sopenharmony_ci * @param propSet Indicates the pseudo-handle on the property set to enumerate. 2117777dab0Sopenharmony_ci * 2127777dab0Sopenharmony_ci * @return void 2137777dab0Sopenharmony_ci * 2147777dab0Sopenharmony_ci * @since 12 2157777dab0Sopenharmony_ci * @version 1.0 2167777dab0Sopenharmony_ci */ 2177777dab0Sopenharmony_civoid TEE_StartPropertyEnumerator(TEE_PropSetHandle enumerator, TEE_PropSetHandle propSet); 2187777dab0Sopenharmony_ci 2197777dab0Sopenharmony_ci/** 2207777dab0Sopenharmony_ci * @brief Resets a property enumerator immediately after allocation. 2217777dab0Sopenharmony_ci * 2227777dab0Sopenharmony_ci * @param enumerator Indicates the handle on the enumerator to reset. 2237777dab0Sopenharmony_ci * 2247777dab0Sopenharmony_ci * @return void 2257777dab0Sopenharmony_ci * 2267777dab0Sopenharmony_ci * @since 12 2277777dab0Sopenharmony_ci * @version 1.0 2287777dab0Sopenharmony_ci */ 2297777dab0Sopenharmony_civoid TEE_ResetPropertyEnumerator(TEE_PropSetHandle enumerator); 2307777dab0Sopenharmony_ci 2317777dab0Sopenharmony_ci/** 2327777dab0Sopenharmony_ci * @brief Obtains the name of this property in an enumerator. 2337777dab0Sopenharmony_ci * 2347777dab0Sopenharmony_ci * @param enumerator Indicates the handle on the enumerator. 2357777dab0Sopenharmony_ci * @param nameBuffer Indicates the pointer to the buffer that stores the property name obtained. 2367777dab0Sopenharmony_ci * @param nameBufferLen Indicates the pointer to the buffer length. 2377777dab0Sopenharmony_ci * 2387777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 2397777dab0Sopenharmony_ci * @return Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the property is not found because the enumerator has not started 2407777dab0Sopenharmony_ci * or has reached the end of the property set. 2417777dab0Sopenharmony_ci * @return Returns <b>TEE_ERROR_SHORT_BUFFER</b> if the buffer is too small to hold the property name. 2427777dab0Sopenharmony_ci * 2437777dab0Sopenharmony_ci * @since 12 2447777dab0Sopenharmony_ci * @version 1.0 2457777dab0Sopenharmony_ci */ 2467777dab0Sopenharmony_ciTEE_Result TEE_GetPropertyName(TEE_PropSetHandle enumerator, void *nameBuffer, size_t *nameBufferLen); 2477777dab0Sopenharmony_ci 2487777dab0Sopenharmony_ci/** 2497777dab0Sopenharmony_ci * @brief Obtains the next property in an enumerator. 2507777dab0Sopenharmony_ci * 2517777dab0Sopenharmony_ci * @param enumerator Indicates the handle on the enumerator. 2527777dab0Sopenharmony_ci * 2537777dab0Sopenharmony_ci * @return Returns <b>TEE_SUCCESS</b> if the operation is successful. 2547777dab0Sopenharmony_ci * @return Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the property is not found because the enumerator 2557777dab0Sopenharmony_ci * has not started or has reached the end of the property set. 2567777dab0Sopenharmony_ci * 2577777dab0Sopenharmony_ci * @since 12 2587777dab0Sopenharmony_ci * @version 1.0 2597777dab0Sopenharmony_ci */ 2607777dab0Sopenharmony_ciTEE_Result TEE_GetNextProperty(TEE_PropSetHandle enumerator); 2617777dab0Sopenharmony_ci 2627777dab0Sopenharmony_ci#ifdef __cplusplus 2637777dab0Sopenharmony_ci} 2647777dab0Sopenharmony_ci#endif 2657777dab0Sopenharmony_ci/** @} */ 2667777dab0Sopenharmony_ci#endif