1# General Process of Using a Key
2
3
4The key generated or imported can be used to perform the following operations to ensure data confidentiality and integrity:
5
6
7- [Encryption and decryption](huks-encryption-decryption-overview.md)
8
9- [Signing and signature verification](huks-signing-signature-verification-overview.md)
10
11- [Key agreement](huks-key-agreement-overview.md)
12
13- [Key derivation](huks-key-derivation-overview.md)
14
15
16The common operations provided do not include the secondary identity authentication for key access control. For details, see [HUKS Key Access Control](huks-identity-authentication-overview.md).
17
18
19## General Development Process
20
21HUKS operates data based on a key session. The general process is as follows:
22
231. (Mandatory) Initialize a key session using [huks.initSession()](../../reference/apis-universal-keystore-kit/js-apis-huks.md#huksinitsession9).
24   You need to pass in the key alias and key operation parameters. A session handle will be returned after the initialization. The key operation parameters must contain the parameters required by the cipher algorithm, including the cipher algorithm, key size, key purpose, working mode, padding mode, hash mode, IV, nonce, and AAD.
25
262. (Optional) Process data by segment using [huks.updateSession()](../../reference/apis-universal-keystore-kit/js-apis-huks.md#huksupdatesession9).
27   Process data by segment as required by the cryptographic algorithm in use or if the data to be processed exceeds 100 KB in size. Otherwise, skip this step.
28
293. (Mandatory) Finish the key session using [huks.finishSession()](../../reference/apis-universal-keystore-kit/js-apis-huks.md#huksfinishsession9).
30   If the data is processes by segment, [huks.finishSession()] processes the last data segment and finishes the key session.
31
32You can use [huks.abortSession()](../../reference/apis-universal-keystore-kit/js-apis-huks.md#huksabortsession9) to abort the session if an error occurs in any of the preceding steps or the current key operation data is not required.
33