1# HuksParamSetApi 2 3 4## Overview 5 6Defines functions for parameter set lifecycle management, including initializing a parameter set, adding parameters, building a parameter set, and freeing a parameter set, as well as parameter set operations such as obtaining parameters, copying a parameter set, querying a parameter set, and checking the validity of a parameter set. 7 8**System capability**: SystemCapability.Security.Huks 9 10**Since**: 9 11 12 13## Summary 14 15 16### File 17 18| Name| Description| 19| -------- | -------- | 20| [native_huks_param.h](native__huks__param_8h.md) | Defines the functions for constructing, using, and destroying a parameter set. | 21 22 23### Functions 24 25| Name| Description| 26| -------- | -------- | 27| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_InitParamSet](#oh_huks_initparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Initializes a parameter set and pre-allocates memory to **paramSet**. | 28| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_AddParams](#oh_huks_addparams) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Param](_o_h___huks___param.md) \*params, uint32_t paramCnt) | Adds parameters to a parameter set. Before calling this API, call **OH_Huks_InitParamSet** to initialize **paramSet**. | 29| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_BuildParamSet](#oh_huks_buildparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Builds a parameter set. After adding parameters to **paramSet**, call **OH_Huks_BuildParamSet** to integrate the parameter set. | 30| void [OH_Huks_FreeParamSet](#oh_huks_freeparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Frees a parameter set. | 31| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_CopyParamSet](#oh_huks_copyparamset) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*fromParamSet, uint32_t fromParamSetSize, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Copies a parameter set (deep copy). | 32| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_GetParam](#oh_huks_getparam) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, uint32_t tag, struct [OH_Huks_Param](_o_h___huks___param.md) \*\*param) | Obtains a parameter from a parameter set. | 33| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_FreshParamSet](#oh_huks_freshparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, bool isCopy) | Updates the data of the [OH_Huks_Blob](_o_h___huks___blob.md) type in a parameter set. | 34| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_IsParamSetTagValid](#oh_huks_isparamsettagvalid) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Checks whether the parameters in a parameter set are valid. | 35| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_IsParamSetValid](#oh_huks_isparamsetvalid) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, uint32_t size) | Checks whether a parameter set is of the valid size. | 36| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_CheckParamMatch](#oh_huks_checkparammatch) (const struct [OH_Huks_Param](_o_h___huks___param.md) \*baseParam, const struct [OH_Huks_Param](_o_h___huks___param.md) \*param) | Checks whether two parameters are the same.| 37| void [OH_Huks_FreeKeyAliasSet](#oh_huks_freekeyaliasset) (struct [OH_Huks_KeyAliasSet](_o_h___huks___key_alias_set.md) \*keyAliasSet) | Frees a key alias set. | 38 39 40## Function Description 41 42 43### OH_Huks_AddParams() 44 45``` 46struct OH_Huks_Result OH_Huks_AddParams (struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Param * params, uint32_t paramCnt ) 47``` 48**Description** 49Adds parameters to a parameter set. 50 51**Since**: 9 52 53**Parameters** 54 55| Name| Description| 56| -------- | -------- | 57| paramSet | Pointer to the parameter set to which parameters are to be added. | 58| params | Pointer to an array of parameters to add. | 59| paramCnt | Number of parameters to add. | 60 61**Returns** 62 63Returns [OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise. 64 65 66### OH_Huks_BuildParamSet() 67 68``` 69struct OH_Huks_Result OH_Huks_BuildParamSet (struct OH_Huks_ParamSet ** paramSet) 70``` 71**Description** 72Builds a parameter set. 73 74**Since**: 9 75 76**Parameters** 77 78| Name| Description| 79| -------- | -------- | 80| paramSet | Double pointer to the parameter set to build. | 81 82**Returns** 83 84Returns [OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise. 85 86 87### OH_Huks_CheckParamMatch() 88 89``` 90struct OH_Huks_Result OH_Huks_CheckParamMatch (const struct OH_Huks_Param * baseParam, const struct OH_Huks_Param * param ) 91``` 92**Description** 93Checks whether two parameters are the same. 94 95**Since**: 9 96 97**Parameters** 98 99| Name| Description| 100| -------- | -------- | 101| baseParam | Pointer to the first parameter to compare. | 102| param | Pointer to the second parameter to compare. | 103 104**Returns** 105 106Returns [OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the two parameters are the same; returns an error code otherwise. 107 108 109### OH_Huks_CopyParamSet() 110 111``` 112struct OH_Huks_Result OH_Huks_CopyParamSet (const struct OH_Huks_ParamSet * fromParamSet, uint32_t fromParamSetSize, struct OH_Huks_ParamSet ** paramSet ) 113``` 114**Description** 115Copies a parameter set (deep copy). 116 117**Since**: 9 118 119**Parameters** 120 121| Name| Description| 122| -------- | -------- | 123| fromParamSet | Pointer to the parameter set to copy. | 124| fromParamSetSize | Size of the memory occupied by the copied parameter set. | 125| paramSet | Double pointer to the new parameter set generated. | 126 127**Returns** 128 129Returns [OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise. 130 131 132### OH_Huks_FreeKeyAliasSet() 133 134``` 135void OH_Huks_FreeKeyAliasSet (struct OH_Huks_KeyAliasSet * keyAliasSet) 136``` 137**Description** 138Frees a key alias set. 139 140**Since**: 12 141 142**Parameters** 143 144| Name| Description| 145| -------- | -------- | 146| keyAliasSet | Pointer to the key alias set to free. | 147 148 149### OH_Huks_FreeParamSet() 150 151``` 152void OH_Huks_FreeParamSet (struct OH_Huks_ParamSet ** paramSet) 153``` 154**Description** 155Frees a parameter set. 156 157**Since**: 9 158 159**Parameters** 160 161| Name| Description| 162| -------- | -------- | 163| paramSet | Pointer to the parameter set to free. | 164 165 166### OH_Huks_FreshParamSet() 167 168``` 169struct OH_Huks_Result OH_Huks_FreshParamSet (struct OH_Huks_ParamSet * paramSet, bool isCopy ) 170``` 171**Description** 172Updates the data of the [OH_Huks_Blob](_o_h___huks___blob.md) type in a parameter set. 173 174**Since**: 9 175 176**Parameters** 177 178| Name| Description| 179| -------- | -------- | 180| paramSet | Pointer to the parameter set to check. | 181| isCopy | Whether to copy the data. The value **true** means to update the address of the data of the [OH_Huks_Blob](_o_h___huks___blob.md) type and copy the data to the parameter set. The value **false** means only update the address of the data of the [OH_Huks_Blob](_o_h___huks___blob.md) type. | 182 183**Returns** 184 185Returns [OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise. 186 187 188### OH_Huks_GetParam() 189 190``` 191struct OH_Huks_Result OH_Huks_GetParam (const struct OH_Huks_ParamSet * paramSet, uint32_t tag, struct OH_Huks_Param ** param ) 192``` 193**Description** 194Obtains a parameter from a parameter set. 195 196**Since**: 9 197 198**Parameters** 199 200| Name| Description| 201| -------- | -------- | 202| paramSet | Pointer to the parameter set to check. | 203| tag | Name of the parameter to obtain. | 204| param | Double pointer to the obtained parameter. | 205 206**Returns** 207 208Returns [OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise. 209 210 211### OH_Huks_InitParamSet() 212 213``` 214struct OH_Huks_Result OH_Huks_InitParamSet (struct OH_Huks_ParamSet ** paramSet) 215``` 216**Description** 217Initializes a parameter set. 218 219**Since**: 9 220 221**Parameters** 222 223| Name| Description| 224| -------- | -------- | 225| paramSet | Pointer to the parameter set to initialize. | 226 227**Returns** 228 229Returns [OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise. 230 231 232### OH_Huks_IsParamSetTagValid() 233 234``` 235struct OH_Huks_Result OH_Huks_IsParamSetTagValid (const struct OH_Huks_ParamSet * paramSet) 236``` 237**Description** 238Checks whether the parameters in a parameter set are valid. 239 240**Since**: 9 241 242**Parameters** 243 244| Name| Description| 245| -------- | -------- | 246| paramSet | Pointer to the parameter set to check. | 247 248**Returns** 249 250Returns [OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the parameters are valid. Otherwise, invalid or duplicate parameters are found. 251 252 253### OH_Huks_IsParamSetValid() 254 255``` 256struct OH_Huks_Result OH_Huks_IsParamSetValid (const struct OH_Huks_ParamSet * paramSet, uint32_t size ) 257``` 258**Description** 259Checks whether a parameter set is of the valid size. 260 261**Since**: 9 262 263**Parameters** 264 265| Name| Description| 266| -------- | -------- | 267| paramSet | Pointer to the parameter set to check. | 268| size | Memory size occupied by the parameter set. | 269 270**Returns** 271 272Returns [OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the size of the parameter set is valid; returns an error code otherwise. 273