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_PROPERTY_API_H 14 #define TEE_PROPERTY_API_H 15 16 #include "tee_defines.h" 17 18 /* 19 * below definitions are defined by Global Platform or Platform SDK released previously 20 * for compatibility: 21 * don't make any change to the content below 22 */ 23 typedef enum { 24 TEE_PROPSET_UNKNOW = 0, 25 TEE_PROPSET_TEE_IMPLEMENTATION = 0xFFFFFFFD, 26 TEE_PROPSET_CURRENT_CLIENT = 0xFFFFFFFE, 27 TEE_PROPSET_CURRENT_TA = 0xFFFFFFFF, 28 } Pseudo_PropSetHandle; 29 30 typedef uint32_t TEE_PropSetHandle; 31 32 /* 33 * performs a lookup in a property set to retrieve an individual 34 * property and convert its value into a printable string 35 * 36 * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator 37 * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve 38 * @param valueBuffer [OUT] Output buffer for the property value 39 * @param valueBufferLen [IN/OUT] Output buffer length 40 * 41 * @return TEE_SUCCESS operation success 42 * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property 43 * @return TEE_ERROR_SHORT_BUFFER the value buffer is not large enough to hold the whole property value 44 */ 45 TEE_Result TEE_GetPropertyAsString(TEE_PropSetHandle propsetOrEnumerator, const char *name, char *valueBuffer, 46 size_t *valueBufferLen); 47 48 /* 49 * retrieves a single property in a property set and converts its value to a Boolean 50 * 51 * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator 52 * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve 53 * @param value [OUT] A pointer to the variable that will contain the value of the property 54 * 55 * @return TEE_SUCCESS operation success 56 * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property 57 */ 58 TEE_Result TEE_GetPropertyAsBool(TEE_PropSetHandle propsetOrEnumerator, const char *name, bool *value); 59 60 /* 61 * retrieves a single property in a property set and converts its value to a 32-bit unsigned integer 62 * 63 * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator 64 * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve 65 * @param value [OUT] A pointer to the variable that will contain the value of the property 66 * 67 * @return TEE_SUCCESS operation success 68 * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property 69 */ 70 TEE_Result TEE_GetPropertyAsU32(TEE_PropSetHandle propsetOrEnumerator, const char *name, uint32_t *value); 71 72 #if defined(API_LEVEL) && (API_LEVEL >= API_LEVEL1_2) 73 /* 74 * retrieves a single property in a property set and converts its value to a 64-bit unsigned integer 75 * 76 * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator 77 * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve 78 * @param value [IN/OUT] A pointer to the variable that will contain the value of the property 79 * 80 * @return TEE_SUCCESS operation success 81 * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property 82 */ 83 TEE_Result TEE_GetPropertyAsU64(TEE_PropSetHandle propsetOrEnumerator, const char *name, uint64_t *value); 84 #endif // API_LEVEL 85 86 /* 87 * retrieves an individual property and converts its value into a binary block 88 * 89 * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator 90 * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve 91 * @param valueBuffer [OUT] Output buffer for the property value 92 * @param valueBufferLen [IN/OUT] Output buffer length 93 * 94 * @return TEE_SUCCESS operation success 95 * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property 96 * @return TEE_ERROR_SHORT_BUFFER the value buffer is not large enough to hold the whole property value 97 */ 98 TEE_Result TEE_GetPropertyAsBinaryBlock(TEE_PropSetHandle propsetOrEnumerator, const char *name, void *valueBuffer, 99 size_t *valueBufferLen); 100 101 /* 102 * retrieves a single property in a property set and converts its value to TEE_UUID struct 103 * 104 * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator 105 * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve 106 * @param value [OUT] A pointer to the variable that will contain the value of the property 107 * 108 * @return TEE_SUCCESS operation success 109 * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property 110 */ 111 TEE_Result TEE_GetPropertyAsUUID(TEE_PropSetHandle propsetOrEnumerator, const char *name, TEE_UUID *value); 112 113 /* 114 * retrieves a single property in a property set and converts its value to TEE_Identity struct 115 * 116 * @param propsetOrEnumerator [IN] One of the TEE_PROPSET_XXX pseudo-handles or a handle on a property enumerator 117 * @param name [IN] Pointer to the zero-terminated string containing name of the property to retrieve 118 * @param value [OUT] A pointer to the variable that will contain the value of the property 119 * 120 * @return TEE_SUCCESS operation success 121 * @return TEE_ERROR_ITEM_NOT_FOUND cannot find target property 122 */ 123 TEE_Result TEE_GetPropertyAsIdentity(TEE_PropSetHandle propsetOrEnumerator, const char *name, TEE_Identity *value); 124 125 /* 126 * allocates a property enumerator object 127 * 128 * @param enumerator [OUT] A pointer filled with an opaque handle on the property enumerator 129 * 130 * @return TEE_SUCCESS operation success 131 * @return TEE_ERROR_OUT_OF_MEMORY not enough resources to allocate the property enumerator 132 */ 133 TEE_Result TEE_AllocatePropertyEnumerator(TEE_PropSetHandle *enumerator); 134 135 /* 136 * deallocates a property enumerator object 137 * 138 * @param enumerator [IN] A handle on the enumerator to free 139 * 140 * @return void 141 */ 142 void TEE_FreePropertyEnumerator(TEE_PropSetHandle enumerator); 143 144 /* 145 * starts to enumerate the properties in an enumerator 146 * 147 * @param enumerator [IN] A handle on the enumerator 148 * @param propSet [IN] A pseudo-handle on the property set to enumerate 149 * 150 * @return void 151 */ 152 void TEE_StartPropertyEnumerator(TEE_PropSetHandle enumerator, TEE_PropSetHandle propSet); 153 154 /* 155 * resets a property enumerator to its state immediately after allocation 156 * 157 * @param enumerator A handle on the enumerator to reset 158 * 159 * @return void 160 */ 161 void TEE_ResetPropertyEnumerator(TEE_PropSetHandle enumerator); 162 163 /* 164 * gets the name of the current property in an enumerator 165 * 166 * @param enumerator [IN] A handle on the enumerator 167 * @param nameBuffer [OUT] The buffer to be filled with the name 168 * @param nameBufferLen [IN/OUT] The length of buffer to be filled 169 * 170 * @return TEE_SUCCESS operation success 171 * @return TEE_ERROR_ITEM_NOT_FOUND no current property either because the enumerator has not started 172 * or because it has reached the end of the property set 173 * @return TEE_ERROR_SHORT_BUFFER If the name buffer is not large enough to contain the property name 174 */ 175 TEE_Result TEE_GetPropertyName(TEE_PropSetHandle enumerator, void *nameBuffer, size_t *nameBufferLen); 176 177 /* 178 * advances the enumerator to the next property 179 * 180 * @param enumerator [IN] A handle on the enumerator 181 * 182 * @return TEE_SUCCESS operation success 183 * @return TEE_ERROR_ITEM_NOT_FOUND enumerator has reached the end of the property set or if it has not started 184 */ 185 TEE_Result TEE_GetNextProperty(TEE_PropSetHandle enumerator); 186 #endif 187