1# HuksParamSetApi 2 3 4## Overview 5 6Defines the capabilities of OpenHarmony Universal KeyStore (HUKS) parameter sets. The HUKS APIs can be used to perform parameter set lifecycle management, including initializing a parameter set, adding parameters to a parameter set, constructing a parameter set, and destroying a parameter set. They can also be used to obtain parameters, copy parameter sets, and check parameter validity. 7 8\@syscap SystemCapability.Security.Huks 9 10**Since:** 119 12 13 14## Summary 15 16 17### Files 18 19| Name | Description | 20| -------- | -------- | 21| [native_huks_param.h](native__huks__param_8h.md) | Provides APIs for constructing, using, and destroying parameter sets. <br>File to Include: <huks/native_huks/native_huks_param.h> | 22 23 24### Functions 25 26| Name | Description | 27| -------- | -------- | 28| [OH_Huks_InitParamSet](#oh_huks_initparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Initializes a parameter set. | 29| [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. | 30| [OH_Huks_BuildParamSet](#oh_huks_buildparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Constructs a parameter set. | 31| [OH_Huks_FreeParamSet](#oh_huks_freeparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Destroys a parameter set. | 32| [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). | 33| [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 parameters from a parameter set. | 34| [OH_Huks_FreshParamSet](#oh_huks_freshparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, bool isCopy) | Refreshes data of the **Blob** type in a parameter set. | 35| [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. | 36| [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. | 37| [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. | 38 39 40## Function Description 41 42 43### OH_Huks_AddParams() 44 45 46``` 47int32_t OH_Huks_AddParams (struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Param * params, uint32_t paramCnt ) 48``` 49**Description**<br> 50Adds parameters to a parameter set. 51 52 **Parameters** 53 54| Name | Description | 55| -------- | -------- | 56| paramSet | Indicates the pointer to the parameter set to which parameters are to be added. | 57| params | Indicates the pointer to the array of parameters to add. | 58| paramCnt | Indicates the number of parameters to add. | 59 60**Returns** 61 62Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. 63 64 65### OH_Huks_BuildParamSet() 66 67 68``` 69int32_t OH_Huks_BuildParamSet (struct OH_Huks_ParamSet ** paramSet) 70``` 71**Description**<br> 72Constructs a parameter set. 73 74 **Parameters** 75 76| Name | Description | 77| -------- | -------- | 78| paramSet | Indicates the double pointer to the parameter set to construct. | 79 80**Returns** 81 82Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. 83 84 85### OH_Huks_CheckParamMatch() 86 87 88``` 89int32_t OH_Huks_CheckParamMatch (const struct OH_Huks_Param * baseParam, const struct OH_Huks_Param * param ) 90``` 91**Description**<br> 92Checks whether two parameters are the same. 93 94 **Parameters** 95 96| Name | Description | 97| -------- | -------- | 98| baseParam | Indicates the pointer to the first parameter. | 99| param | Indicates the pointer to the second parameter. | 100 101**Returns** 102 103Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the two parameters are the same; returns an error code otherwise. 104 105 106### OH_Huks_CopyParamSet() 107 108 109``` 110int32_t OH_Huks_CopyParamSet (const struct OH_Huks_ParamSet * fromParamSet, uint32_t fromParamSetSize, struct OH_Huks_ParamSet ** paramSet ) 111``` 112**Description**<br> 113Copies a parameter set (deep copy). 114 115 **Parameters** 116 117| Name | Description | 118| -------- | -------- | 119| fromParamSet | Indicates the pointer to the parameter set to copy. | 120| fromParamSetSize | Indicates the memory size occupied by the source parameter set. | 121| paramSet | Indicates the double pointer to the new parameter set generated. | 122 123**Returns** 124 125Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. 126 127 128### OH_Huks_FreeParamSet() 129 130 131``` 132void OH_Huks_FreeParamSet (struct OH_Huks_ParamSet ** paramSet) 133``` 134**Description**<br> 135Destroys a parameter set. 136 137 **Parameters** 138 139| Name | Description | 140| -------- | -------- | 141| paramSet | Indicates the double pointer to the parameter set to destroy. | 142 143 144### OH_Huks_FreshParamSet() 145 146 147``` 148int32_t OH_Huks_FreshParamSet (struct OH_Huks_ParamSet * paramSet, bool isCopy ) 149``` 150**Description**<br> 151Refreshes data of the **Blob** type in a parameter set. 152 153 **Parameters** 154 155| Name | Description | 156| -------- | -------- | 157| paramSet | Indicates the pointer to the target parameter set. | 158| isCopy | Specifies whether to copy the data of the **Blob** type to the parameter set. If yes, the data of the **Blob** type will be copied to the parameter set. Otherwise, only the address of the **Blob** data will be refreshed. | 159 160**Returns** 161 162Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if operation is successful; returns an error code otherwise. 163 164 165### OH_Huks_GetParam() 166 167 168``` 169int32_t OH_Huks_GetParam (const struct OH_Huks_ParamSet * paramSet, uint32_t tag, struct OH_Huks_Param ** param ) 170``` 171**Description**<br> 172Obtains parameters from a parameter set. 173 174 **Parameters** 175 176| Name | Description | 177| -------- | -------- | 178| paramSet | Indicates the pointer to the target parameter set. | 179| tag | Indicates the value of the parameter to be obtained. | 180| param | Indicates the double pointer to the parameter obtained. | 181 182**Returns** 183 184Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful, returns an error code otherwise. 185 186 187### OH_Huks_InitParamSet() 188 189 190``` 191int32_t OH_Huks_InitParamSet (struct OH_Huks_ParamSet ** paramSet) 192``` 193**Description**<br> 194Initializes a parameter set. 195 196 **Parameters** 197 198| Name | Description | 199| -------- | -------- | 200| paramSet | Indicates the double pointer to the parameter set to initialize. | 201 202**Returns** 203 204Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the initialization is successful; returns an error code otherwise. 205 206 207### OH_Huks_isParamSetTagValid() 208 209 210``` 211int32_t OH_Huks_isParamSetTagValid (const struct OH_Huks_ParamSet * paramSet) 212``` 213**Description**<br> 214Checks whether the parameters in a parameter set are valid. 215 216 **Parameters** 217 218| Name | Description | 219| -------- | -------- | 220| paramSet | Indicates the pointer to the parameter set to check. | 221 222**Returns** 223 224Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the parameters in the parameter set are valid; returns other values if the parameter set has invalid, duplicate, or incorrect parameters. 225 226 227### OH_Huks_isParamSetValid() 228 229 230``` 231int32_t OH_Huks_isParamSetValid (const struct OH_Huks_ParamSet * paramSet, uint32_t size ) 232``` 233**Description**<br> 234Checks whether a parameter set is of the valid size. 235 236 **Parameters** 237 238| Name | Description | 239| -------- | -------- | 240| paramSet | Indicates the pointer to the parameter set to check. | 241| size | Indicates the memory size occupied by the parameter set. | 242 243**Returns** 244 245Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the parameter set is of the valid size; returns an error code otherwise. 246