1e41f4b71Sopenharmony_ci# HuksKeyApi
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## Overview
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciDefines the OpenHarmony Universal KeyStore (HUKS) capabilities, including key management and cryptography operations, provided for applications. Applications can call the HUKS functions to import or generate keys.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Security.Huks
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci**Since**: 9
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci## Summary
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci### File
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci| Name| Description|
19e41f4b71Sopenharmony_ci| -------- | -------- |
20e41f4b71Sopenharmony_ci| [native_huks_api.h](native__huks__api_8h.md) | Declares the functions used to access HUKS.<br>**File to include**: <huks/native_huks_api.h><br>**Library**: libhuks_ndk.z.so |
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci### Functions
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci| Name| Description|
26e41f4b71Sopenharmony_ci| -------- | -------- |
27e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_GetSdkVersion](#oh_huks_getsdkversion) (struct [OH_Huks_Blob](_o_h___huks___blob.md) \*sdkVersion) | Obtains the current HUKS SDK version. |
28e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_GenerateKeyItem](#oh_huks_generatekeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetIn, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetOut) | Generates a key. |
29e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_ImportKeyItem](#oh_huks_importkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*key) | Imports a key in plaintext. |
30e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_ImportWrappedKeyItem](#oh_huks_importwrappedkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*wrappingKeyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*wrappedKeyData) | Imports a key in ciphertext. |
31e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_ExportPublicKeyItem](#oh_huks_exportpublickeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*key) | Exports the public key. |
32e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_DeleteKeyItem](#oh_huks_deletekeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Deletes a key. |
33e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_GetKeyItemParamSet](#oh_huks_getkeyitemparamset) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetIn, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetOut) | Obtains the properties of a key. |
34e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_IsKeyItemExist](#oh_huks_iskeyitemexist) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Checks whether a key exists. |
35e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_AttestKeyItem](#oh_huks_attestkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_CertChain](_o_h___huks___cert_chain.md) \*certChain) | Obtains the certificate chain of a key. |
36e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_AnonAttestKeyItem](#oh_huks_anonattestkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_CertChain](_o_h___huks___cert_chain.md) \*certChain) | Obtains the certificate chain of a key. |
37e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_InitSession](#oh_huks_initsession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*token) | Initializes a key session. This function returns a session handle (mandatory) and a challenge value (optional). |
38e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_UpdateSession](#oh_huks_updatesession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*inData, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*outData) | Adds and processes data by segment for a key operation, and outputs the processed data. |
39e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_FinishSession](#oh_huks_finishsession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*inData, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*outData) | Finishes a key session. |
40e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_AbortSession](#oh_huks_abortsession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Aborts a key session. |
41e41f4b71Sopenharmony_ci| struct [OH_Huks_Result](_o_h___huks___result.md) [OH_Huks_ListAliases](#oh_huks_listaliases) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_KeyAliasSet](_o_h___huks___key_alias_set.md) \*\*outData) | Lists key aliases. |
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci## Function Description
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci### OH_Huks_AbortSession()
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci```
50e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_AbortSession (const struct OH_Huks_Blob * handle, const struct OH_Huks_ParamSet * paramSet )
51e41f4b71Sopenharmony_ci```
52e41f4b71Sopenharmony_ci**Description**
53e41f4b71Sopenharmony_ciAborts a key session.
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci**Since**: 9
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci**Parameters**
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci| Name| Description|
60e41f4b71Sopenharmony_ci| -------- | -------- |
61e41f4b71Sopenharmony_ci| handle | Pointer to the key session handle, which is returned by [OH_Huks_InitSession](#oh_huks_initsession). |
62e41f4b71Sopenharmony_ci| paramSet | Pointer to the parameters for aborting the key session. By default, this parameter is a null pointer. |
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci**Returns**
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci**See**
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci[OH_Huks_InitSession](#oh_huks_initsession)
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci[OH_Huks_UpdateSession](#oh_huks_updatesession)
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci[OH_Huks_FinishSession](#oh_huks_finishsession)
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci### OH_Huks_AnonAttestKeyItem()
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci```
80e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_AnonAttestKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, struct OH_Huks_CertChain * certChain )
81e41f4b71Sopenharmony_ci```
82e41f4b71Sopenharmony_ci**Description**
83e41f4b71Sopenharmony_ciObtains the certificate chain of a key.
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci**Since**: 11
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci**Parameters**
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci| Name| Description|
90e41f4b71Sopenharmony_ci| -------- | -------- |
91e41f4b71Sopenharmony_ci| keyAlias | Pointer to the alias of the target key. |
92e41f4b71Sopenharmony_ci| paramSet | Pointer to the parameters for obtaining the certificate chain. |
93e41f4b71Sopenharmony_ci| certChain | Pointer to the certificate chain obtained. |
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci**Returns**
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci**NOTE**
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ciThis function involves time-consuming network operation. The caller can obtain the certificate chain through an asynchronous thread.
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci### OH_Huks_AttestKeyItem()
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci```
107e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_AttestKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, struct OH_Huks_CertChain * certChain )
108e41f4b71Sopenharmony_ci```
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci**Description**
111e41f4b71Sopenharmony_ciObtains the certificate chain of a key.
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci**Required permissions**
114e41f4b71Sopenharmony_ciohos.permission.ATTEST_KEY (for system applications only)
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci**Since**: 9
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci**Parameters**
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci| Name| Description|
121e41f4b71Sopenharmony_ci| -------- | -------- |
122e41f4b71Sopenharmony_ci| keyAlias | Pointer to the alias of the target key. |
123e41f4b71Sopenharmony_ci| paramSet | Pointer to the parameters for obtaining the certificate chain. |
124e41f4b71Sopenharmony_ci| certChain | Pointer to the certificate chain obtained. |
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci**Returns**
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci### OH_Huks_DeleteKeyItem()
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci```
134e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_DeleteKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet )
135e41f4b71Sopenharmony_ci```
136e41f4b71Sopenharmony_ci**Description**
137e41f4b71Sopenharmony_ciDeletes a key.
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci**Since**: 9
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci**Parameters**
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci| Name| Description|
144e41f4b71Sopenharmony_ci| -------- | -------- |
145e41f4b71Sopenharmony_ci| keyAlias | Pointer to the alias of the key to delete. It must be the same as the alias used for generating the key. |
146e41f4b71Sopenharmony_ci| paramSet | Pointer to the parameters for deleting the key. By default, this parameter is a null pointer. |
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci**Returns**
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci### OH_Huks_ExportPublicKeyItem()
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci```
156e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_ExportPublicKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, struct OH_Huks_Blob * key )
157e41f4b71Sopenharmony_ci```
158e41f4b71Sopenharmony_ci**Description**
159e41f4b71Sopenharmony_ciExports a public key.
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci**Since**: 9
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci**Parameters**
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci| Name| Description|
166e41f4b71Sopenharmony_ci| -------- | -------- |
167e41f4b71Sopenharmony_ci| keyAlias | Pointer to the alias of the public key to export. It must be the same as the alias used for generating the key. |
168e41f4b71Sopenharmony_ci| paramSet | Pointer to the parameters for exporting the public key. |
169e41f4b71Sopenharmony_ci| key | Pointer to the public key exported. |
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci**Returns**
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci### OH_Huks_FinishSession()
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci```
179e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_FinishSession (const struct OH_Huks_Blob * handle, const struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Blob * inData, struct OH_Huks_Blob * outData )
180e41f4b71Sopenharmony_ci```
181e41f4b71Sopenharmony_ci**Description**
182e41f4b71Sopenharmony_ciFinishes a key session.
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci**Since**: 9
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci**Parameters**
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci| Name| Description|
189e41f4b71Sopenharmony_ci| -------- | -------- |
190e41f4b71Sopenharmony_ci| handle | Pointer to the key session handle, which is returned by [OH_Huks_InitSession](#oh_huks_initsession). |
191e41f4b71Sopenharmony_ci| paramSet | Pointer to the parameters required for the key operation. |
192e41f4b71Sopenharmony_ci| inData | Pointer to the data to be passed in. |
193e41f4b71Sopenharmony_ci| outData | Pointer to the output data. |
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci**Returns**
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci**See**
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci[OH_Huks_InitSession](#oh_huks_initsession)
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci[OH_Huks_UpdateSession](#oh_huks_updatesession)
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci[OH_Huks_AbortSession](#oh_huks_abortsession)
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci### OH_Huks_GenerateKeyItem()
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci```
211e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_GenerateKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSetIn, struct OH_Huks_ParamSet * paramSetOut )
212e41f4b71Sopenharmony_ci```
213e41f4b71Sopenharmony_ci**Description**
214e41f4b71Sopenharmony_ciGenerates a key.
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci**Since**: 9
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci**Parameters**
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci| Name| Description|
221e41f4b71Sopenharmony_ci| -------- | -------- |
222e41f4b71Sopenharmony_ci| keyAlias | Pointer to the alias of the key to generate. The alias must be unique in the process of the service. |
223e41f4b71Sopenharmony_ci| paramSetIn | Pointer to the parameters for generating the key. |
224e41f4b71Sopenharmony_ci| paramSetOut | Pointer to a temporary key generated. If the generated key is not a temporary key, this parameter is a null pointer. |
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci**Returns**
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci### OH_Huks_GetKeyItemParamSet()
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci```
234e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_GetKeyItemParamSet (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSetIn, struct OH_Huks_ParamSet * paramSetOut )
235e41f4b71Sopenharmony_ci```
236e41f4b71Sopenharmony_ci**Description**
237e41f4b71Sopenharmony_ciObtains the properties of a key.
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci**Since**: 9
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci**Parameters**
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci| Name| Description|
244e41f4b71Sopenharmony_ci| -------- | -------- |
245e41f4b71Sopenharmony_ci| keyAlias | Pointer to the alias of the target key. |
246e41f4b71Sopenharmony_ci| paramSetIn | Pointer to the tag required for obtaining the properties. By default, this parameter is a null pointer. |
247e41f4b71Sopenharmony_ci| paramSetOut | Pointer to the key properties obtained. |
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ci**Returns**
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci### OH_Huks_GetSdkVersion()
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci```
257e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_GetSdkVersion (struct OH_Huks_Blob * sdkVersion)
258e41f4b71Sopenharmony_ci```
259e41f4b71Sopenharmony_ci**Description**
260e41f4b71Sopenharmony_ciObtains the current HUKS SDK version.
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci**Since**: 9
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci**Parameters**
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ci| Name| Description|
267e41f4b71Sopenharmony_ci| -------- | -------- |
268e41f4b71Sopenharmony_ci| sdkVersion | Pointer to the SDK version (string) obtained. |
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci**Returns**
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci### OH_Huks_ImportKeyItem()
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci```
278e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_ImportKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Blob * key )
279e41f4b71Sopenharmony_ci```
280e41f4b71Sopenharmony_ci**Description**
281e41f4b71Sopenharmony_ciImports a key in plaintext.
282e41f4b71Sopenharmony_ci
283e41f4b71Sopenharmony_ci**Since**: 9
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci**Parameters**
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci| Name| Description|
288e41f4b71Sopenharmony_ci| -------- | -------- |
289e41f4b71Sopenharmony_ci| keyAlias | Pointer to the alias of the key to import. The alias must be unique in the process of the service. |
290e41f4b71Sopenharmony_ci| paramSet | Pointer to the properties of the key to import. |
291e41f4b71Sopenharmony_ci| key | Pointer to the key to import. The key data must be of the [HuksTypeApi](_huks_type_api.md) type. |
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ci**Returns**
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci### OH_Huks_ImportWrappedKeyItem()
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ci```
301e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_ImportWrappedKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_Blob * wrappingKeyAlias, const struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Blob * wrappedKeyData )
302e41f4b71Sopenharmony_ci```
303e41f4b71Sopenharmony_ci**Description**
304e41f4b71Sopenharmony_ciImports a key in ciphertext.
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci**Since**: 9
307e41f4b71Sopenharmony_ci
308e41f4b71Sopenharmony_ci**Parameters**
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci| Name| Description|
311e41f4b71Sopenharmony_ci| -------- | -------- |
312e41f4b71Sopenharmony_ci| keyAlias | Pointer to the alias of the key to import. The alias must be unique in the process of the service. |
313e41f4b71Sopenharmony_ci| wrappingKeyAlias | Pointer to the alias of the key used for key agreement, which generates a shared secret to decrypt the key to import. |
314e41f4b71Sopenharmony_ci| paramSet | Pointer to the parameters for importing the key in ciphertext. |
315e41f4b71Sopenharmony_ci| wrappedKeyData | Pointer to the encrypted key to import. The data must be of the [OH_Huks_AlgSuite](_huks_type_api.md#oh_huks_algsuite) type.|
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci**Returns**
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ci
322e41f4b71Sopenharmony_ci### OH_Huks_InitSession()
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci```
325e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_InitSession (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, struct OH_Huks_Blob * handle, struct OH_Huks_Blob * token )
326e41f4b71Sopenharmony_ci```
327e41f4b71Sopenharmony_ci**Description**
328e41f4b71Sopenharmony_ciInitializes a key session. This function returns a handle (mandatory) and a challenge value (optional).
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_ci**Since**: 9
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ci**Parameters**
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_ci| Name| Description|
335e41f4b71Sopenharmony_ci| -------- | -------- |
336e41f4b71Sopenharmony_ci| keyAlias | Pointer to the alias of the target key. |
337e41f4b71Sopenharmony_ci| paramSet | Pointer to the parameters for the initialization operation. |
338e41f4b71Sopenharmony_ci| handle | Pointer to the handle of the key session. This handle is required for subsequent operations of the same key, including [OH_Huks_UpdateSession](#oh_huks_updatesession), [OH_Huks_FinishSession](#oh_huks_finishsession), and [OH_Huks_AbortSession](#oh_huks_abortsession). |
339e41f4b71Sopenharmony_ci| token | Pointer to the token used for key access control. |
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci**Returns**
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci**See**
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci[OH_Huks_UpdateSession](#oh_huks_updatesession)
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci[OH_Huks_FinishSession](#oh_huks_finishsession)
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ci[OH_Huks_AbortSession](#oh_huks_abortsession)
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci### OH_Huks_IsKeyItemExist()
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci```
357e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_IsKeyItemExist (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet )
358e41f4b71Sopenharmony_ci```
359e41f4b71Sopenharmony_ci**Description**
360e41f4b71Sopenharmony_ciChecks whether a key exists.
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_ci**Since**: 9
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ci**Parameters**
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci| Name| Description|
367e41f4b71Sopenharmony_ci| -------- | -------- |
368e41f4b71Sopenharmony_ci| keyAlias | Pointer to the alias of the key to check. |
369e41f4b71Sopenharmony_ci| paramSet | Pointer to the parameters for checking the key. By default, this parameter is a null pointer. |
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_ci**Returns**
372e41f4b71Sopenharmony_ci
373e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the key exists.
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_ERR_CODE_ITEM_NOT_EXIST](_huks_type_api.md#oh_huks_errcode) if the key does not exist. 
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_ciReturns other errors in other cases.
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci### OH_Huks_ListAliases()
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci```
383e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_ListAliases (const struct OH_Huks_ParamSet * paramSet, struct OH_Huks_KeyAliasSet ** outData )
384e41f4b71Sopenharmony_ci```
385e41f4b71Sopenharmony_ci**Description**
386e41f4b71Sopenharmony_ciLists key aliases.
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ci**Since**: 12
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci**Parameters**
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_ci| Name| Description|
393e41f4b71Sopenharmony_ci| -------- | -------- |
394e41f4b71Sopenharmony_ci| paramSet | Pointer to the parameters for listing the key aliases. By default, this parameter is a null pointer. |
395e41f4b71Sopenharmony_ci| outData | pointer to the key aliases obtained. |
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ci**Returns**
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci
402e41f4b71Sopenharmony_ci### OH_Huks_UpdateSession()
403e41f4b71Sopenharmony_ci
404e41f4b71Sopenharmony_ci```
405e41f4b71Sopenharmony_cistruct OH_Huks_Result OH_Huks_UpdateSession (const struct OH_Huks_Blob * handle, const struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Blob * inData, struct OH_Huks_Blob * outData )
406e41f4b71Sopenharmony_ci```
407e41f4b71Sopenharmony_ci**Description**
408e41f4b71Sopenharmony_ciAdds and processes data by segment for a key operation, and outputs the processed data.
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ci**Since**: 9
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ci**Parameters**
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci| Name| Description|
415e41f4b71Sopenharmony_ci| -------- | -------- |
416e41f4b71Sopenharmony_ci| handle | Pointer to the key session handle, which is returned by [OH_Huks_InitSession](#oh_huks_initsession). |
417e41f4b71Sopenharmony_ci| paramSet | Pointer to the parameters required for the key operation. |
418e41f4b71Sopenharmony_ci| inData | Pointer to the data to be processed. If there is a large amount of data to be processed, you can call this function multiple times to process data by segment. |
419e41f4b71Sopenharmony_ci| outData | Pointer to the output data. |
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_ci**Returns**
422e41f4b71Sopenharmony_ci
423e41f4b71Sopenharmony_ciReturns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md#oh_huks_errcode) if the operation is successful; returns an error code otherwise.
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci**See**
426e41f4b71Sopenharmony_ci
427e41f4b71Sopenharmony_ci[OH_Huks_InitSession](#oh_huks_initsession)
428e41f4b71Sopenharmony_ci
429e41f4b71Sopenharmony_ci[OH_Huks_FinishSession](#oh_huks_finishsession)
430e41f4b71Sopenharmony_ci
431e41f4b71Sopenharmony_ci[OH_Huks_AbortSession](#oh_huks_abortsession)
432