From 60a7065b3b74c7f3f0f51608ac6fb2e38bdf1ae5 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Wed, 8 Feb 2023 14:13:34 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../reference/apis/js-apis-huks.md | 211 ++++++++---------- 1 file changed, 88 insertions(+), 123 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-huks.md b/en/application-dev/reference/apis/js-apis-huks.md index f5eaa37329..865fc233b0 100644 --- a/en/application-dev/reference/apis/js-apis-huks.md +++ b/en/application-dev/reference/apis/js-apis-huks.md @@ -1,4 +1,4 @@ -# HUKS +# @ohos.security.huks (HUKS) The **HUKS** module provides KeyStore (KS) capabilities for applications, including key management and key cryptography operations. The keys managed by OpenHarmony Universal KeyStore (HUKS) can be imported by applications or generated by calling the HUKS APIs. @@ -44,7 +44,7 @@ Defines the HUKS handle structure. | Name | Type | Mandatory| Description | | --------- | ---------- | ---- | ---------------------------------------------------- | | handle | number | Yes | Value of the handle. | -| challenge | Uint8Array | No | Challenge obtained after the [init](#huksinit) operation.| +| challenge | Uint8Array | No | Challenge obtained after the [initSession](#huksinitsession9) operation.| ## HuksReturnResult9+ @@ -74,7 +74,7 @@ Generates a key. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | --------------------------------------------- | | keyAlias | string | Yes | Alias of the key. | -| options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key. | +| options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key. The algorithm, key purpose, and key length are mandatory.| | callback | AsyncCallback\ | Yes | Callback that returns no value.| **Example** @@ -130,7 +130,7 @@ Generates a key. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ------------------------ | | keyAlias | string | Yes | Alias of the key. | -| options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key.| +| options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key. The algorithm, key purpose, and key length are mandatory.| **Example** @@ -288,7 +288,7 @@ Imports a key in plaintext. This API uses an asynchronous callback to return the | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | --------------------------------------------- | | keyAlias | string | Yes | Alias of the key. | -| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key to import. | +| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key to import. The algorithm, key purpose, and key length are mandatory.| | callback | AsyncCallback\ | Yes | Callback that returns no value.| **Example** @@ -356,7 +356,7 @@ Imports a key in plaintext. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ----------------------------------- | | keyAlias | string | Yes | Alias of the key. | -| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key to import.| +| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key to import. The algorithm, key purpose, and key length are mandatory.| **Example** @@ -426,7 +426,7 @@ Obtains the certificate used to verify a key. This API uses an asynchronous call | -------- | ---------------------------------------------------- | ---- | --------------------------------------------- | | keyAlias | string | Yes | Alias of the key. The certificate to be obtained stores the key. | | options | [HuksOptions](#huksoptions) | Yes | Parameters and data required for obtaining the certificate. | -| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | Yes | Callback invoked to return the result. If the operation is successful, no **err** value is returned; otherwise, an error code is returned.| +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | Yes | Callback invoked to return the result. If the operation is successful, no **err** value is returned; otherwise, an error code is returned.| **Example** @@ -553,7 +553,7 @@ Obtains the certificate used to verify a key. This API uses a promise to return | Type | Description | | ---------------------------------------------- | --------------------------------------------- | -| Promise<[HuksReturnResult](#huksreturnresult)> | Promise used to return the result. If the operation is successful, no **err** value is returned; otherwise, an error code is returned.| +| Promise<[HuksReturnResult](#huksreturnresult9)> | Promise used to return the result. If the operation is successful, no **err** value is returned; otherwise, an error code is returned.| **Example** @@ -675,7 +675,7 @@ Imports a wrapped key. This API uses an asynchronous callback to return the resu | ---------------- | --------------------------- | ---- | --------------------------------------------- | | keyAlias | string | Yes | Alias of the wrapped key to import. | | wrappingKeyAlias | string | Yes | Alias of the data used to unwrap the key imported. | -| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and the wrapped key to import.| +| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and the wrapped key to import. The algorithm, key purpose, and key length are mandatory.| | callback | AsyncCallback\ | Yes | Callback that returns no value.| **Example** @@ -891,7 +891,7 @@ Imports a wrapped key. This API uses a promise to return the result. | ---------------- | --------------------------- | ---- | --------------------------------------------- | | keyAlias | string | Yes | Alias of the wrapped key to import. | | wrappingKeyAlias | string | Yes | Alias of the data used to unwrap the key imported. | -| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and the wrapped key to import.| +| options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and the wrapped key to import. The algorithm, key purpose, and key length are mandatory.| **Example** @@ -926,7 +926,7 @@ Exports a key. This API uses an asynchronous callback to return the result. | -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned and **outData** contains the public key exported. If the operation fails, an error code is returned. | +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned and **outData** contains the public key exported. If the operation fails, an error code is returned.| **Example** @@ -968,7 +968,7 @@ Exports a key. This API uses a promise to return the result. | Type | Description | | ---------------------------------------------- | ------------------------------------------------------------ | -| Promise<[HuksReturnResult](#huksreturnresult)> | Promise used to return the result. If the operation is successful, no **err** value is returned and **outData** contains the public key exported. If the operation fails, an error code is returned. | +| Promise<[HuksReturnResult](#huksreturnresult9)> | Promise used to return the result. If the operation is successful, no **err** value is returned and **outData** contains the public key exported. If the operation fails, an error code is returned. | **Example** @@ -1005,7 +1005,7 @@ Obtains key properties. This API uses an asynchronous callback to return the res | -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | Yes | Callback invoked to return the result. If the operation is successful, **errorCode** is **HUKS_SUCCESS**; otherwise, an error code is returned.| +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | Yes | Callback invoked to return the result. If the operation is successful, **errorCode** is **HUKS_SUCCESS**; otherwise, an error code is returned.| **Example** @@ -1047,7 +1047,7 @@ Obtains key properties. This API uses a promise to return the result. | Type | Description | | ----------------------------------------------- | ------------------------------------------------------------ | -| Promise\<[HuksReturnResult](#huksreturnresult)> | Promise used to return the result. If the operation is successful, no **err** value is returned and **properties** contains the parameters required for generating the key. If the operation fails, an error code is returned. | +| Promise\<[HuksReturnResult](#huksreturnresult9)> | Promise used to return the result. If the operation is successful, no **err** value is returned and **properties** contains the parameters required for generating the key. If the operation fails, an error code is returned. | **Example** @@ -1126,7 +1126,7 @@ Checks whether a key exists. This API uses a promise to return the result. | Type | Description | | ----------------- | --------------------------------------- | -| Promise\ | Promise used to return the result. **TRUE** means that the key exists; **FALSE** means the opposite.| +| Promise\ | Promise used to return the result. The value **TRUE** means that the key exists; **FALSE** means the opposite.| **Example** @@ -1163,8 +1163,7 @@ Initializes the data for a key operation. This API uses an asynchronous callback | -------- | ------------------------------------------------------- | ---- | ---------------------------------------------------- | | keyAlias | string | Yes | Alias of the target key. | | options | [HuksOptions](#huksoptions) | Yes | Parameters used for initialization. | -| callback | AsyncCallback\<[HuksSessionHandle](#hukssessionhandle)> | Yes | Callback invoked to return the key operation handle.| - +| callback | AsyncCallback\<[HuksSessionHandle](#hukssessionhandle9)> | Yes | Callback invoked to return the handle obtained through the initialization operation.| ## huks.initSession9+ @@ -1185,7 +1184,7 @@ Initializes the data for a key operation. This API uses a promise to return the | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksSessionHandle](#hukssessionhandle)> | Promise used to return the key operation handle.| +| Promise\<[HuksSessionHandle](#hukssessionhandle9)> | Promise used to return the handle obtained through the initialization operation.| ## huks.updateSession9+ @@ -1201,7 +1200,7 @@ Updates the key operation by segment. This API uses an asynchronous callback to | -------- | ---------------------------------------------------- | ---- | -------------------------------------------- | | handle | number | Yes | Handle of the **Update** operation. | | options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Update** operation. | -| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | Yes | Callback invoked to return the result.| +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | Yes | Callback invoked to return the result.| ## huks.updateSession9+ @@ -1219,7 +1218,7 @@ Updates the key operation by segment. This API uses an asynchronous callback to | handle | number | Yes | Handle of the **Update** operation. | | options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Update** operation. | | token | Uint8Array | Yes | Token of the **Update** operation. | -| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | Yes | Callback invoked to return the result.| +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | Yes | Callback invoked to return the result.| ## huks.updateSession9+ @@ -1241,7 +1240,7 @@ Updates the key operation data by segment. This API uses a promise to return the | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise<[HuksReturnResult](#huksreturnresult)> | Promise used to return the result.| +| Promise<[HuksReturnResult](#huksreturnresult9)> | Promise used to return the result.| ## huks.finishSession9+ @@ -1258,7 +1257,7 @@ Completes the key operation and releases resources. This API uses an asynchronou | handle | number | Yes | Handle of the **Finish** operation. | | options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Finish** operation. | | token | Uint8Array | Yes | Token for the **Finish** operation. | -| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult)> | Yes | Callback invoked to return the result.| +| callback | AsyncCallback<[HuksReturnResult](#huksreturnresult9)> | Yes | Callback invoked to return the result.| ## huks.finishSession9+ @@ -1275,8 +1274,7 @@ Completes the key operation and releases resources. This API uses an asynchronou | handle | number | Yes | Handle of the **Finish** operation. | | options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Finish** operation. | | token | Uint8Array | Yes | Token for the **Finish** operation. | -| callback | AsyncCallback\<[HuksReturnResult](#huksreturnresult)> | Yes | Callback invoked to return the result.| - +| callback | AsyncCallback\<[HuksReturnResult](#huksreturnresult9)> | Yes | Callback invoked to return the result.| ## huks.finishSession9+ @@ -1298,8 +1296,7 @@ Completes the key operation and releases resources. This API uses a promise to r | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksReturnResult](#huksreturnresult)> | Promise used to return the result.| - +| Promise\<[HuksReturnResult](#huksreturnresult9)> | Promise used to return the result.| ## huks.abortSession9+ @@ -1322,7 +1319,7 @@ Aborts the use of the key. This API uses an asynchronous callback to return the ```js /* huks.initSession, huks.updateSession, and huks.finishSession must be used together. * If an error occurs in any of huks.initSession, huks.updateSession, - * and huks.finishSession operation, + * and huks.finishSession operations, * huks.abortSession must be called to terminate the use of the key. * * The following uses the callback of an RSA1024 key as an example. @@ -1472,7 +1469,7 @@ Aborts the use of the key. This API uses a promise to return the result. ```js /* huks.initSession, huks.updateSession, and huks.finishSession must be used together. * If an error occurs in any of huks.initSession, huks.updateSession, - * and huks.finishSession operation, + * and huks.finishSession operations, * huks.abortSession must be called to terminate the use of the key. * * The following uses the callback of an RSA1024 key as an example. @@ -1583,7 +1580,7 @@ async function huksFinish() { async function huksAbort() { console.log('enter huksAbort'); try { - await huks.abortSession(keyAlias, options) + await huks.abortSession(handle, options) .then ((data) => { console.info(`promise: abortSession success`); }) @@ -1605,26 +1602,26 @@ For details about the error codes, see [KUKS Error Codes](../errorcodes/errorcod **System capability**: SystemCapability.Security.Huks -| Name | Description | Error Code | -| ---------------------------------------------- | --------------------------- | -------- | -| HUKS_ERR_CODE_PERMISSION_FAIL | Permission verification failed. | 201 | -| HUKS_ERR_CODE_ILLEGAL_ARGUMENT | Invalid parameters are detected. | 401 | -| HUKS_ERR_CODE_NOT_SUPPORTED_API | The API is not supported. | 801 | -| HUKS_ERR_CODE_FEATURE_NOT_SUPPORTED | The feature is not supported. | 12000001 | -| HUKS_ERR_CODE_MISSING_CRYPTO_ALG_ARGUMENT | Key algorithm parameters are missing. | 12000002 | -| HUKS_ERR_CODE_INVALID_CRYPTO_ALG_ARGUMENT | Invalid key algorithm parameters are detected. | 12000003 | -| HUKS_ERR_CODE_FILE_OPERATION_FAIL | The file operation failed. | 12000004 | -| HUKS_ERR_CODE_COMMUNICATION_FAIL | The communication failed. | 12000005 | -| HUKS_ERR_CODE_CRYPTO_FAIL | Failed to operate the algorithm library. | 12000006 | -| HUKS_ERR_CODE_KEY_AUTH_PERMANENTLY_INVALIDATED | Failed to access the key because the key has expired.| 12000007 | -| HUKS_ERR_CODE_KEY_AUTH_VERIFY_FAILED | Failed to access the key because the authentication has failed.| 12000008 | -| HUKS_ERR_CODE_KEY_AUTH_TIME_OUT | Key access timed out.| 12000009 | -| HUKS_ERR_CODE_SESSION_LIMIT | The number of key operation sessions has reached the limit. | 12000010 | -| HUKS_ERR_CODE_ITEM_NOT_EXIST | The target object does not exist. | 12000011 | -| HUKS_ERR_CODE_EXTERNAL_ERROR | An external error occurs. | 12000012 | -| HUKS_ERR_CODE_CREDENTIAL_NOT_EXIST | The credential does not exist. | 12000013 | -| HUKS_ERR_CODE_INSUFFICIENT_MEMORY | The memory is insufficient. | 12000014 | -| HUKS_ERR_CODE_CALL_SERVICE_FAILED | Failed to call other system services. | 12000015 | +| Name | Value| Description | +| ---------------------------------------------- | -------- |--------------------------- | +| HUKS_ERR_CODE_PERMISSION_FAIL | 201 | Permission verification failed. | +| HUKS_ERR_CODE_ILLEGAL_ARGUMENT | 401 | Invalid parameters are detected. | +| HUKS_ERR_CODE_NOT_SUPPORTED_API | 801 | The API is not supported. | +| HUKS_ERR_CODE_FEATURE_NOT_SUPPORTED | 12000001 | The feature is not supported. | +| HUKS_ERR_CODE_MISSING_CRYPTO_ALG_ARGUMENT | 12000002 | Key algorithm parameters are missing. | +| HUKS_ERR_CODE_INVALID_CRYPTO_ALG_ARGUMENT | 12000003 | Invalid key algorithm parameters are detected. | +| HUKS_ERR_CODE_FILE_OPERATION_FAIL | 12000004 | The file operation failed. | +| HUKS_ERR_CODE_COMMUNICATION_FAIL | 12000005 | The communication failed. | +| HUKS_ERR_CODE_CRYPTO_FAIL | 12000006 | Failed to operate the algorithm library. | +| HUKS_ERR_CODE_KEY_AUTH_PERMANENTLY_INVALIDATED | 12000007 | Failed to access the key because the key has expired.| +| HUKS_ERR_CODE_KEY_AUTH_VERIFY_FAILED | 12000008 | Failed to access the key because the authentication has failed.| +| HUKS_ERR_CODE_KEY_AUTH_TIME_OUT | 12000009 | Key access timed out.| +| HUKS_ERR_CODE_SESSION_LIMIT | 12000010 | The number of key operation sessions has reached the limit. | +| HUKS_ERR_CODE_ITEM_NOT_EXIST | 12000011 | The target object does not exist. | +| HUKS_ERR_CODE_EXTERNAL_ERROR | 12000012 | An external error occurs. | +| HUKS_ERR_CODE_CREDENTIAL_NOT_EXIST | 12000013 | The credential does not exist. | +| HUKS_ERR_CODE_INSUFFICIENT_MEMORY | 12000014 | The memory is insufficient. | +| HUKS_ERR_CODE_CALL_SERVICE_FAILED | 12000015 | Failed to call other system services. | ## HuksKeyPurpose @@ -1710,7 +1707,7 @@ Enumerates the key sizes. | HUKS_ECC_KEY_SIZE_384 | 384 | ECC key of 384 bits | | HUKS_ECC_KEY_SIZE_521 | 521 | ECC key of 521 bits | | HUKS_AES_KEY_SIZE_128 | 128 | Advanced Encryption Standard (AES) key of 128 bits | -| HUKS_AES_KEY_SIZE_192 | 196 | AES key of 196 bits | +| HUKS_AES_KEY_SIZE_192 | 192 | AES key of 192 bits | | HUKS_AES_KEY_SIZE_256 | 256 | AES key of 256 bits | | HUKS_AES_KEY_SIZE_512 | 512 | AES key of 512 bits | | HUKS_CURVE25519_KEY_SIZE_256 | 256 | Curve25519 key of 256 bits| @@ -1983,7 +1980,7 @@ generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\ **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.generateKeyItem9+](#huksgeneratekeyitem9). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.generateKeyItem9+](#huksgeneratekeyitem9). **System capability**: SystemCapability.Security.Huks @@ -1993,7 +1990,7 @@ Generates a key. This API uses an asynchronous callback to return the result. | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Alias of the key. | | options | [HuksOptions](#huksoptions) | Yes | Tags required for generating the key. | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code defined in **HuksResult** is returned.| +| callback | AsyncCallback\<[HuksResult](#huksresultdeprecated)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code defined in **HuksResult** is returned.| **Example** @@ -2035,7 +2032,7 @@ generateKey(keyAlias: string, options: HuksOptions) : Promise\ Generates a key. This API uses a promise to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.generateKeyItem9+](#huksgeneratekeyitem9-1). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.generateKeyItem9+](#huksgeneratekeyitem9-1). **System capability**: SystemCapability.Security.Huks @@ -2050,7 +2047,7 @@ Generates a key. This API uses a promise to return the result. | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| +| Promise\<[HuksResult](#huksresultdeprecated)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| **Example** @@ -2082,14 +2079,13 @@ let options = { let result = huks.generateKey(keyAlias, options); ``` - ## huks.deleteKey(deprecated) deleteKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void Deletes a key. This API uses an asynchronous callback to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.deleteKeyItem9+](#huksdeletekeyitem9). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.deleteKeyItem9+](#huksdeletekeyitem9). **System capability**: SystemCapability.Security.Huks @@ -2099,7 +2095,7 @@ Deletes a key. This API uses an asynchronous callback to return the result. | -------- | ----------------------------------------- | ---- | -------------------------------------------------- | | keyAlias | string | Yes | Key alias passed in when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| +| callback | AsyncCallback\<[HuksResult](#huksresultdeprecated)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| **Example** @@ -2118,7 +2114,7 @@ deleteKey(keyAlias: string, options: HuksOptions) : Promise\ Deletes a key. This API uses a promise to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.deleteKeyItem9+](#huksdeletekeyitem9-1). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.deleteKeyItem9+](#huksdeletekeyitem9-1). **System capability**: SystemCapability.Security.Huks @@ -2133,7 +2129,7 @@ Deletes a key. This API uses a promise to return the result. | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| +| Promise\<[HuksResult](#huksresultdeprecated)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| **Example** @@ -2146,14 +2142,13 @@ let emptyOptions = { let result = huks.deleteKey(keyAlias, emptyOptions); ``` - ## huks.importKey(deprecated) importKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void Imports a key in plaintext. This API uses an asynchronous callback to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.importKeyItem9+](#huksimportkeyitem9). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.importKeyItem9+](#huksimportkeyitem9). **System capability**: SystemCapability.Security.Huks @@ -2163,7 +2158,7 @@ Imports a key in plaintext. This API uses an asynchronous callback to return the | -------- | ------------------------ | ---- | ------------------------------------------------- | | keyAlias | string | Yes | Alias of the key.| | options | [HuksOptions](#huksoptions) | Yes | Tags required for the import and key to import.| -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| +| callback | AsyncCallback\<[HuksResult](#huksresultdeprecated)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| **Example** @@ -2213,7 +2208,7 @@ importKey(keyAlias: string, options: HuksOptions) : Promise\ Imports a key in plaintext. This API uses a promise to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.importKeyItem9+](#huksimportkeyitem9-1). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.importKeyItem9+](#huksimportkeyitem9-1). **System capability**: SystemCapability.Security.Huks @@ -2228,7 +2223,7 @@ Imports a key in plaintext. This API uses a promise to return the result. | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| +| Promise\<[HuksResult](#huksresultdeprecated)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** is returned; otherwise, an error code is returned.| **Example** @@ -2274,14 +2269,13 @@ let huksoptions = { let result = huks.importKey(keyAlias, huksoptions); ``` - ## huks.exportKey(deprecated) exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void Exports a key. This API uses an asynchronous callback to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.exportKeyItem9+](#huksexportkeyitem9). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.exportKeyItem9+](#huksexportkeyitem9). **System capability**: SystemCapability.Security.Huks @@ -2291,7 +2285,7 @@ Exports a key. This API uses an asynchronous callback to return the result. | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned and **outData** contains the public key exported. If the operation fails, an error code is returned.| +| callback | AsyncCallback\<[HuksResult](#huksresultdeprecated)> | Yes | Callback invoked to return the result. If the operation is successful, **HUKS_SUCCESS** is returned and **outData** contains the public key exported. If the operation fails, an error code is returned.| **Example** @@ -2310,7 +2304,7 @@ exportKey(keyAlias: string, options: HuksOptions) : Promise\ Exports a key. This API uses a promise to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.exportKeyItem9+](#huksexportkeyitem9-1). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.exportKeyItem9+](#huksexportkeyitem9-1). **System capability**: SystemCapability.Security.Huks @@ -2325,7 +2319,7 @@ Exports a key. This API uses a promise to return the result. | Type | Description | | ----------------------------------- | ------------------------------------------------------------ | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** is returned and **outData** contains the public key exported. If the operation fails, an error code is returned. | +| Promise\<[HuksResult](#huksresultdeprecated)> | Promise used to return the result. If the operation is successful, **HUKS_SUCCESS** is returned and **outData** contains the public key exported. If the operation fails, an error code is returned. | **Example** @@ -2338,14 +2332,13 @@ let emptyOptions = { let result = huks.exportKey(keyAlias, emptyOptions); ``` - ## huks.getKeyProperties(deprecated) getKeyProperties(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void Obtains key properties. This API uses an asynchronous callback to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.getKeyItemProperties9+](#huksgetkeyitemproperties9). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.getKeyItemProperties9+](#huksgetkeyitemproperties9). **System capability**: SystemCapability.Security.Huks @@ -2355,7 +2348,7 @@ Obtains key properties. This API uses an asynchronous callback to return the res | -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | | keyAlias | string | Yes | Key alias, which must be the same as the alias used when the key was generated. | | options | [HuksOptions](#huksoptions) | Yes | Empty object (leave this parameter empty). | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result. If the operation is successful, **errorCode** is **HUKS_SUCCESS**; otherwise, an error code is returned.| +| callback | AsyncCallback\<[HuksResult](#huksresultdeprecated)> | Yes | Callback invoked to return the result. If the operation is successful, **errorCode** is **HUKS_SUCCESS**; otherwise, an error code is returned.| **Example** @@ -2374,7 +2367,7 @@ getKeyProperties(keyAlias: string, options: HuksOptions) : Promise\ Obtains key properties. This API uses a promise to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.getKeyItemProperties9+](#huksgetkeyitemproperties9-1). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.getKeyItemProperties9+](#huksgetkeyitemproperties9-1). **System capability**: SystemCapability.Security.Huks @@ -2402,14 +2395,13 @@ let emptyOptions = { let result = huks.getKeyProperties(keyAlias, emptyOptions); ``` - ## huks.isKeyExist(deprecated) isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback\) : void Checks whether a key exists. This API uses an asynchronous callback to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.isKeyItemExist9+](#huksiskeyitemexist9). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.isKeyItemExist9+](#huksiskeyitemexist9). **System capability**: SystemCapability.Security.Huks @@ -2438,7 +2430,7 @@ isKeyExist(keyAlias: string, options: HuksOptions) : Promise\ Checks whether a key exists. This API uses a promise to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.isKeyItemExist9+](#huksiskeyitemexist9-1). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.isKeyItemExist9+](#huksiskeyitemexist9-1). **System capability**: SystemCapability.Security.Huks @@ -2453,7 +2445,7 @@ Checks whether a key exists. This API uses a promise to return the result. | Type | Description | | ----------------- | --------------------------------------- | -| Promise\ | Promise used to return the result. **TRUE** means that the key exists; **FALSE** means the opposite.| +| Promise\ | Promise used to return the result. The value **TRUE** means that the key exists; **FALSE** means the opposite.| **Example** @@ -2472,7 +2464,7 @@ init(keyAlias: string, options: HuksOptions, callback: AsyncCallback\ **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.initSession9+](#huksinitsession9-1). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.initSession9+](#huksinitsession9-1). **System capability**: SystemCapability.Security.Huks @@ -2482,8 +2474,7 @@ Initializes the data for a key operation. This API uses an asynchronous callback | -------- | ---------------------- | ---- | ------------------------------------- | | keyAlias | string | Yes | Alias of the target key.| | options | [HuksOptions](#huksoptions) | Yes | Parameters used for initialization.| -| callback | AsyncCallback\<[HuksHandle](#hukshandle)> | Yes | Callback invoked to return the key operation handle.| - +| callback | AsyncCallback\<[HuksHandle](#hukshandledeprecated)> | Yes | Callback invoked to return the handle obtained through the initialization operation.| ## huks.init(deprecated) @@ -2491,7 +2482,7 @@ init(keyAlias: string, options: HuksOptions) : Promise\ Initializes the data for a key operation. This API uses a promise to return the result. **huks.init**, **huks.update**, and **huks.finish** must be used together. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.initSession9+](#huksinitsession9-1). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.initSession9+](#huksinitsession9-1). **System capability**: SystemCapability.Security.Huks @@ -2506,34 +2497,15 @@ Initializes the data for a key operation. This API uses a promise to return the | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksHandle](#hukshandle)> | Promise used to return the key operation handle.| - +| Promise\<[HuksHandle](#hukshandledeprecated)> | Promise used to return the handle obtained through the initialization operation.| ## huks.update(deprecated) -update(handle: number, options: HuksOptions, callback: AsyncCallback\) : void +update(handle: number, token?: Uint8Array, options: HuksOptions, callback: AsyncCallback\) : void Updates the key operation by segment. This API uses an asynchronous callback to return the result. **huks.init**, **huks.update**, and **huks.finish** must be used together. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.updateSession9+](#huksupdatesession9). - -**System capability**: SystemCapability.Security.Huks - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------------- | ---- | -------------------------------------------- | -| handle | number | Yes | Handle of the **Update** operation. | -| options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Update** operation. | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result.| - -## huks.update(deprecated) - -update(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\) : void - -Updates the key operation by segment. This API uses an asynchronous callback to return the result. **huks.init**, **huks.update**, and **huks.finish** must be used together. - -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.updateSession9+](#huksupdatesession9-1). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.updateSession9+](#huksupdatesession9-1). **System capability**: SystemCapability.Security.Huks @@ -2544,15 +2516,15 @@ Updates the key operation by segment. This API uses an asynchronous callback to | handle | number | Yes | Handle of the **Update** operation. | | token | Uint8Array | No | Token of the **Update** operation. | | options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Update** operation. | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes | Callback invoked to return the result.| +| callback | AsyncCallback\<[HuksResult](#huksresultdeprecated)> | Yes | Callback invoked to return the result.| ## huks.update(deprecated) -update(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\ +update(handle: number, token?: Uint8Array, options: HuksOptions) : Promise\; Updates the key operation by segment. This API uses a promise to return the result. **huks.init**, **huks.update**, and **huks.finish** must be used together. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.updateSession9+](#huksupdatesession9-2). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.updateSession9+](#huksupdatesession9-2). **System capability**: SystemCapability.Security.Huks @@ -2568,8 +2540,7 @@ Updates the key operation by segment. This API uses a promise to return the resu | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result.| - +| Promise\<[HuksResult](#huksresultdeprecated)> | Promise used to return the result.| ## huks.finish(deprecated) @@ -2577,7 +2548,7 @@ finish(handle: number, options: HuksOptions, callback: AsyncCallback\ **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.finishSession9+](#huksfinishsession9). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.finishSession9+](#huksfinishsession9). **System capability**: SystemCapability.Security.Huks @@ -2587,8 +2558,7 @@ Completes the key operation and releases resources. This API uses an asynchronou | -------- | ---------------------- | ---- | ------------------------------------- | | handle | number | Yes | Handle of the **Finish** operation.| | options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Finish** operation.| -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback invoked to return the result.| - +| callback | AsyncCallback\<[HuksResult](#huksresultdeprecated)> | Yes| Callback invoked to return the result.| ## huks.finish(deprecated) @@ -2596,7 +2566,7 @@ finish(handle: number, options: HuksOptions) : Promise\ Completes the key operation and releases resources. This API uses a promise to return the result. **huks.init**, **huks.update**, and **huks.finish** must be used together. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.finishSession9+](#huksfinishsession9-1). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.finishSession9+](#huksfinishsession9-1). **System capability**: SystemCapability.Security.Huks @@ -2611,8 +2581,7 @@ Completes the key operation and releases resources. This API uses a promise to r | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result.| - +| Promise\<[HuksResult](#huksresultdeprecated)> | Promise used to return the result.| ## huks.abort(deprecated) @@ -2620,7 +2589,7 @@ abort(handle: number, options: HuksOptions, callback: AsyncCallback\ Aborts the use of the key. This API uses an asynchronous callback to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.abortSession9+](#huksabortsession9). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.abortSession9+](#huksabortsession9). **System capability**: SystemCapability.Security.Huks @@ -2630,7 +2599,7 @@ Aborts the use of the key. This API uses an asynchronous callback to return the | -------- | ---------------------- | ---- | ------------------------------------- | | handle | number | Yes | Handle of the **Abort** operation.| | options | [HuksOptions](#huksoptions) | Yes | Parameters of the **Abort** operation.| -| callback | AsyncCallback\<[HuksResult](#huksresult)> | Yes| Callback invoked to return the result.| +| callback | AsyncCallback\<[HuksResult](#huksresultdeprecated)> | Yes| Callback invoked to return the result.| **Example** @@ -2731,7 +2700,7 @@ abort(handle: number, options: HuksOptions) : Promise\; Aborts the use of the key. This API uses a promise to return the result. -> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.abortSession9+](#huksabortsession9-1). +> **NOTE**
This API is deprecated since API version 9. You are advised to use [huks.abortSession9+](#huksabortsession9-1). **System capability**: SystemCapability.Security.Huks @@ -2746,7 +2715,7 @@ Aborts the use of the key. This API uses a promise to return the result. | Type | Description | | ----------------------------------- | -------------------------------------------------- | -| Promise\<[HuksResult](#huksresult)> | Promise used to return the result.| +| Promise\<[HuksResult](#huksresultdeprecated)> | Promise used to return the result.| **Example** @@ -2847,7 +2816,6 @@ function huksAbort() { } ``` - ## HuksHandle(deprecated) Defines the HUKS handle structure. @@ -2858,8 +2826,7 @@ Defines the HUKS handle structure. | ---------- | ---------------- | ---- | -------- | | errorCode | number | Yes | Error code.| | handle | number | Yes| Value of the handle.| -| token | Uint8Array | No| Challenge obtained after the [init](#huksinit) operation.| - +| token | Uint8Array | No| Challenge obtained after the [init](#huksinitdeprecated) operation.| ## HuksResult(deprecated) @@ -2867,8 +2834,6 @@ Defines the **HuksResult** structure. **System capability**: SystemCapability.Security.Huks - - | Name | Type | Mandatory| Description | | ---------- | ------------------------------- | ---- | ---------------- | | errorCode | number | Yes | Error code. | -- GitLab